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

TestCaseDummyPunctualAction_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseDummyPunctualAction_1.cpp 00005 // 00006 // Version 1.3 00007 // Date 11.04.03 (Version 1.2) 00008 // 30.09.03 (Version 1.3) 00009 // Author A. Pasetti (P&P Software), R. Totaro 00010 // 00011 // Change Record: 00012 // Version 1.3: Added a test of the action's activation counter 00013 00014 #include "../GeneralInclude/CompilerSwitches.h" 00015 #include "../GeneralInclude/ClassId.h" 00016 #include "../GeneralInclude/Constants.h" 00017 #include "../Base/DC_DummyPunctualAction.h" 00018 #include "TestCaseDummyPunctualAction_1.h" 00019 00020 TestCaseDummyPunctualAction_1::TestCaseDummyPunctualAction_1(void) : 00021 TestCaseWithEvtCheck(ID_DUMMYPUNCTUALACTION*10+1,"TestCaseDummyPunctualAction_1") { 00022 return; 00023 } 00024 00025 void TestCaseDummyPunctualAction_1::runTestCase(void) { 00026 const unsigned int nEvt =getNumberOfEvents(); 00027 DC_DummyPunctualAction *pAct=new DC_DummyPunctualAction; 00028 00029 // Verify correctness of the class identifier 00030 if (pAct->getClassId()!=ID_DUMMYPUNCTUALACTION) { 00031 setTestResult(TEST_FAILURE,"Wrong class identifier"); 00032 return; 00033 } 00034 00035 // Dummy punctual actions should be enabled at creation 00036 if (!pAct->isEnabled()) { 00037 setTestResult(TEST_FAILURE,"Wrong enable status at creation"); 00038 return; 00039 } 00040 00041 // The activation counter shall be equal to zero 00042 if (pAct->getActivationCounter()) { 00043 setTestResult(TEST_FAILURE,"Wrong activation counter at creation"); 00044 return; 00045 } 00046 00047 // The outcome should be set to ACTION_RESET 00048 if (pAct->getLastOutcome()!=ACTION_RESET) { 00049 setTestResult(TEST_FAILURE,"Wrong action outcome at creation"); 00050 return; 00051 } 00052 00053 // Send an execute request to the punctual action and check that the 00054 // correct event is recorded. 00055 if (pAct->execute()!=ACTION_SUCCESS) { 00056 setTestResult(TEST_FAILURE,"Wrong punctual action outcome"); 00057 return; 00058 } 00059 00060 if (!verifyLatestEvent(nEvt+1,EVT_PUNCTUAL_ACTION_EXEC)) 00061 return; 00062 00063 // Verify that the activation counter was incremented 00064 if (pAct->getActivationCounter()!=1) { 00065 setTestResult(TEST_FAILURE,"Activation counter was not incremented"); 00066 return; 00067 } 00068 00069 // Disable the punctual action and verify correct enable status 00070 pAct->setEnabled(DISABLED); 00071 if (pAct->isEnabled()) { 00072 setTestResult(TEST_FAILURE, "Punctual action was not disabled"); 00073 return; 00074 } 00075 00076 // Send an execute request to the punctual action and check that the 00077 // correct event is recorded. 00078 if (pAct->execute()!=ACTION_DISABLED) { 00079 setTestResult(TEST_FAILURE,"Wrong punctual action outcome"); 00080 return; 00081 } 00082 00083 if (!verifyLatestEvent(nEvt+2,EVT_PUNCTUAL_ACTION_DIS)) 00084 return; 00085 00086 // Verify the the latest outcome is properly reported 00087 if (pAct->getLastOutcome()!=ACTION_DISABLED ) { 00088 setTestResult(TEST_FAILURE,"Wrong puctual action outcome"); 00089 return; 00090 } 00091 00092 // Reset the latest outcome and verify that it is now ACTION_RESET 00093 pAct->resetLastOutcome(); 00094 if (pAct->getLastOutcome()!=ACTION_RESET) { 00095 setTestResult(TEST_FAILURE,"getLastOutcome() failed"); 00096 return; 00097 } 00098 00099 setTestResult(TEST_SUCCESS,"Test Successful"); 00100 return; 00101 }
Copyright 2003 P&P Software GmbH - All Rights Reserved