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

TestCaseFsmEvent_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseFsmEvent_1.cpp 00005 // 00006 // Version 1.1 00007 // Date 23.03.03 00008 // Author A. Pasetti (P&P Software) 00009 // 00010 // Change Record: 00011 // Version 1.1: added code to configure the FSM 00012 00013 #include "TestCaseFsmEvent_1.h" 00014 #include "../GeneralInclude/CompilerSwitches.h" 00015 #include "../GeneralInclude/ClassId.h" 00016 #include "../GeneralInclude/Constants.h" 00017 #include "../FSM/DC_FsmEvent.h" 00018 #include "../FSM/CC_FSM.h" 00019 #include "../FSM/DC_DummyFsmState.h" 00020 00021 TestCaseFsmEvent_1::TestCaseFsmEvent_1(void) : 00022 TestCaseGenericSetUp(ID_FSMEVENT*10+1,"TestCaseFsmEvent_1") { 00023 return; 00024 } 00025 00026 void TestCaseFsmEvent_1::runTestCase(void) { 00027 00028 DC_FsmEvent* pFsmEvt = new DC_FsmEvent(); 00029 00030 // Verify correctness of class ID 00031 if (pFsmEvt->getClassId() != ID_FSMEVENT) 00032 { setTestResult(TEST_FAILURE, "Wrong class ID"); 00033 return; 00034 } 00035 00036 // FsmEvent object should not be configured 00037 if ( (pFsmEvt->isObjectConfigured() != NOT_CONFIGURED) ) 00038 { setTestResult(TEST_FAILURE, "FsmEvent component should not be configured at creation"); 00039 return; 00040 } 00041 00042 // Load a target FsmState and check correctness 00043 TD_FsmStateIndex state = 1; 00044 pFsmEvt->setTargetState(state); 00045 if ( pFsmEvt->getTargetState() != state ) 00046 { setTestResult(TEST_FAILURE, "Incorrect loading of target state"); 00047 return; 00048 } 00049 00050 // Create and configure an FSM 00051 CC_FSM* pFsm = new CC_FSM(); 00052 pFsm->setNumberOfStates(4); 00053 00054 DC_DummyFsmState* pState[4]; 00055 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00056 pState[i] = new DC_DummyFsmState(); 00057 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00058 pFsm->setState(i,pState[i]); 00059 00060 pFsm->reset(); 00061 00062 // Load the newly created FSM as the "target FSM" and check correctness 00063 pFsmEvt->setTargetFsm(pFsm); 00064 if ( pFsmEvt->getTargetFsm() != pFsm ) 00065 { setTestResult(TEST_FAILURE, "Incorrect loading of target FSM"); 00066 return; 00067 } 00068 00069 // FsmEvent object should now be configured 00070 if ( (pFsmEvt->isObjectConfigured() != CONFIGURED) ) 00071 { setTestResult(TEST_FAILURE, "FsmEvent component should be configured"); 00072 return; 00073 } 00074 00075 setTestResult(TEST_SUCCESS,"Test Successful"); 00076 return; 00077 }
Copyright 2003 P&P Software GmbH - All Rights Reserved