Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

TestCaseNestedFsmActivator_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseNestedFsmActivator_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 24.06.03 00008 // Author R. Totaro 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/Constants.h" 00013 #include "../GeneralInclude/TestConstants.h" 00014 #include "../FSM/DC_FsmEvent.h" 00015 #include "../FSM/DC_DummyFsmState.h" 00016 #include "../FSM/DC_NestedFsmActivator.h" 00017 #include "TestCaseNestedFsmActivator_1.h" 00018 00019 TestCaseNestedFsmActivator_1::TestCaseNestedFsmActivator_1(void) : 00020 TestCaseGenericSetUp(ID_NESTEDFSMACTIVATOR*10+1,"TestCaseNestedFsmActivator_1") { 00021 return; 00022 } 00023 00024 void TestCaseNestedFsmActivator_1::runTestCase(void) { 00025 const TD_FsmStateIndex numStates=3; 00026 CC_FSM *pFSM =new CC_FSM; 00027 DC_NestedFsmActivator *pNFA =new DC_NestedFsmActivator; 00028 DC_DummyFsmState *pFS[numStates]; 00029 DC_FsmEvent *pFE[numStates]; 00030 00031 // Initialize the FSM 00032 pFSM->setNumberOfStates(numStates); 00033 00034 for (TD_FsmStateIndex i=0;i<numStates;i++) { 00035 // Create and load FSM states 00036 pFS[i]=new DC_DummyFsmState; 00037 pFSM->setState(i,pFS[i]); 00038 00039 // Create and configure FSM events 00040 pFE[i]=new DC_FsmEvent; 00041 pFE[i]->setTargetFsm(pFSM); 00042 pFE[i]->setTargetState((i+1)%numStates); 00043 } 00044 00045 pFSM->reset(); 00046 00047 // Verify the correctness of the class id 00048 if (pNFA->getClassId()!=ID_NESTEDFSMACTIVATOR) { 00049 setTestResult(TEST_FAILURE,"Wrong class id"); 00050 return; 00051 } 00052 00053 // The object shall not be configured yet 00054 if (pNFA->isObjectConfigured()) { 00055 setTestResult(TEST_FAILURE,"Newly created object is configured"); 00056 return; 00057 } 00058 00059 // Let's attach the nested FSM to the state and verify that 00060 // the FSM pointer is properly stored and the object is configured 00061 pNFA->setTargetFsm(pFSM); 00062 00063 if (pNFA->getTargetFsm()!=pFSM) { 00064 setTestResult(TEST_FAILURE,"setTargetFsm() failed"); 00065 return; 00066 } 00067 00068 if (!pNFA->isObjectConfigured()) { 00069 setTestResult(TEST_FAILURE,"Object is not configured"); 00070 return; 00071 } 00072 00073 // Force a FSM transition and verify that doInit() performs 00074 // a reset of the nested FSM 00075 pFE[0]->execute(); 00076 pFSM->activate(); 00077 00078 pNFA->doInit(); 00079 if (pFSM->getCurrentState()!=0) { 00080 setTestResult(TEST_FAILURE,"doInit() failed"); 00081 return; 00082 } 00083 00084 // Let's see if doContinue() activates the nested FSM 00085 pFE[1]->execute(); 00086 pNFA->doContinue(); 00087 if (pFSM->getCurrentState()!=pFE[1]->getTargetState()) { 00088 setTestResult(TEST_FAILURE,"doContinue() failed"); 00089 return; 00090 } 00091 00092 setTestResult(TEST_SUCCESS,"Test Successful"); 00093 return; 00094 }
Copyright 2003 P&P Software GmbH - All Rights Reserved