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

TestCaseFSM_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseFSM_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 04.10.02 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "../GeneralInclude/CompilerSwitches.h" 00011 #include "../GeneralInclude/ClassId.h" 00012 #include "../GeneralInclude/BasicTypes.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../FSM/CC_FSM.h" 00015 #include "../FSM/DC_DummyFsmState.h" 00016 #include "../Utilities/TestCaseWithEvtCheck.h" 00017 #include "TestCaseFSM_1.h" 00018 00019 TestCaseFSM_1::TestCaseFSM_1(void) : 00020 TestCaseWithEvtCheck(ID_FSM*10+1,"TestCaseFSM_1") { 00021 return; 00022 } 00023 00024 void TestCaseFSM_1::runTestCase(void) { 00025 00026 CC_FSM* pFsm = new CC_FSM(); 00027 unsigned int nEvt = getNumberOfEvents(); 00028 00029 // Check the correctness of the class identifier 00030 if ( (pFsm->getClassId() != ID_FSM) ) 00031 { setTestResult(TEST_FAILURE,"Wrong class identifier for the FSM class"); 00032 return; 00033 } 00034 00035 // FSM should not be configured upon creation 00036 if ( (pFsm->isObjectConfigured() == CONFIGURED) ) 00037 { setTestResult(TEST_FAILURE,"Wrong event repository configuration status upon repository creation"); 00038 return; 00039 } 00040 00041 // Set the number of states and check correctness 00042 pFsm->setNumberOfStates(4); 00043 if ( (pFsm->getNumberOfStates() != 4 ) ) 00044 { setTestResult(TEST_FAILURE,"Wrong number of FSM states"); 00045 return; 00046 } 00047 00048 // Load dummy FsmStates and check that the load operation is correctly executed 00049 DC_DummyFsmState* pState[4]; 00050 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00051 pState[i] = new DC_DummyFsmState(); 00052 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00053 pFsm->setState(i,pState[i]); 00054 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00055 if (pFsm->getState(i) != pState[i]) 00056 { setTestResult(TEST_FAILURE,"Wrong loaded state is reported"); 00057 return; 00058 } 00059 00060 // Attempt non-nominal state load 00061 if (isNonNominalCheckAllowed()) { 00062 pFsm->setState(5,pState[0]); 00063 if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_FS) ) 00064 return; 00065 } 00066 00067 // Reset the FSM 00068 pFsm->reset(); 00069 00070 // Check correctness of default state 00071 if ( pFsm->getCurrentState() != 0) 00072 { setTestResult(TEST_FAILURE, 00073 "Wrong default state"); 00074 return; 00075 } 00076 00077 // Check that all state transitions are enabled 00078 for (TD_FsmStateIndex i=0; i<pFsm->getNumberOfStates(); i++) 00079 if ( !pFsm->isTransitionEnabled(i) ) 00080 { setTestResult(TEST_FAILURE, 00081 "All state transitions should be enabled"); 00082 return; 00083 } 00084 00085 // Unload one state and check that the object is not configured 00086 if (isNonNominalCheckAllowed()) { 00087 pFsm->setState(0,pNULL); 00088 if ( (pFsm->isObjectConfigured() == CONFIGURED) ) 00089 { setTestResult(TEST_FAILURE, 00090 "Wrong FSM configuration status"); 00091 return; 00092 } 00093 } 00094 00095 // Reload state and check that FSM object is configured 00096 pFsm->setState(0,pState[0]); 00097 if ( (pFsm->isObjectConfigured() == NOT_CONFIGURED) ) 00098 { setTestResult(TEST_FAILURE, 00099 "Wrong FSM configuration status after configuration was completed"); 00100 return; 00101 } 00102 00103 setTestResult(TEST_SUCCESS,"Test Successful"); 00104 return; 00105 }
Copyright 2003 P&P Software GmbH - All Rights Reserved