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

TestCaseCyclingTelemetryModeManager_1.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // TestCaseCyclingTelemetryModeManager_1.cpp 00005 // 00006 // Version 1.0 00007 // Date 18.01.04 00008 // Author A. Pasetti (P&P Software) 00009 00010 #include "TestCaseCyclingTelemetryModeManager_1.h" 00011 #include "../GeneralInclude/CompilerSwitches.h" 00012 #include "../GeneralInclude/ClassId.h" 00013 #include "../GeneralInclude/Constants.h" 00014 #include "../Telemetry/DC_CyclingTelemetryModeManager.h" 00015 #include "../Telemetry/DC_DummyTelemetryPacket.h" 00016 #include "../Base/ModeManager.h" 00017 #include "../Event/DC_EventRepository.h" 00018 00019 TestCaseCyclingTelemetryModeManager_1::TestCaseCyclingTelemetryModeManager_1(void) : 00020 TestCaseWithEvtCheck(ID_CYCLINGTELEMETRYMODEMANAGER*10+1,"TestCaseCyclingTelemetryModeManager_1") { 00021 return; 00022 } 00023 00024 void TestCaseCyclingTelemetryModeManager_1::runTestCase(void) { 00025 00026 unsigned int nEvt = getNumberOfEvents(); 00027 DC_CyclingTelemetryModeManager* pMM = new DC_CyclingTelemetryModeManager(); 00028 00029 // Verify correctness of class identifier 00030 if ( pMM->getClassId() != ID_CYCLINGTELEMETRYMODEMANAGER) 00031 { setTestResult(TEST_FAILURE, "Wrong class identifier"); 00032 return; 00033 } 00034 00035 // Mode managers should not be configured at creation 00036 if ( pMM->isObjectConfigured() == CONFIGURED ) 00037 { setTestResult(TEST_FAILURE, "Wrong configuration status at creation"); 00038 return; 00039 } 00040 00041 // Create the items to be loaded in the list mode manager 00042 DC_DummyTelemetryPacket* list1 = new DC_DummyTelemetryPacket[3]; 00043 DC_DummyTelemetryPacket* list2 = new DC_DummyTelemetryPacket[2]; 00044 DC_DummyTelemetryPacket* list3 = new DC_DummyTelemetryPacket[3]; 00045 00046 // Configure the dummy mode manager 00047 TD_Mode n = 3; 00048 TD_Mode def = 1; 00049 pMM->setNumberOfModes(n); 00050 pMM->setDefaultMode(def); 00051 pMM->setListLength(0,3); 00052 pMM->setListLength(1,2); 00053 pMM->setListLength(2,3); 00054 pMM->setListItem(0,0,&list1[0]); 00055 pMM->setListItem(0,1,&list1[1]); 00056 pMM->setListItem(0,2,&list1[2]); 00057 pMM->setListItem(1,0,&list2[0]); 00058 pMM->setListItem(1,1,&list2[1]); 00059 pMM->setListItem(2,0,&list3[0]); 00060 pMM->setListItem(2,1,&list3[1]); 00061 pMM->setListItem(2,2,&list3[2]); 00062 pMM->reset(); 00063 00064 // Verify that the component is now configured 00065 if ( pMM->isObjectConfigured() != CONFIGURED ) 00066 { setTestResult(TEST_FAILURE, "Wrong configuration status"); 00067 return; 00068 } 00069 00070 // Iterate through the list items and verify correctness 00071 int i = 0; 00072 for (pMM->first(); !pMM->isIterationFinished(); pMM->next()) { 00073 TelemetryPacket* a = pMM->getIterationTelemetryPacket(); 00074 if ( (a) != &list2[i] ) 00075 { setTestResult(TEST_FAILURE, "Error during iteration"); 00076 return; 00077 } 00078 i++; 00079 } 00080 if ( i != 2 ) 00081 { setTestResult(TEST_FAILURE, "Wrong number of iteration cycles"); 00082 return; 00083 } 00084 00085 // Check effect of non-nominal call to next() 00086 pMM->next(); 00087 if ( &list2[1]!=(pMM->getIterationTelemetryPacket()) ) 00088 { setTestResult(TEST_FAILURE, "Error after non-nominal call to nextInt()"); 00089 return; 00090 } 00091 00092 // Check iterators with an intermediate call to update() 00093 pMM->update(); // active list should now be a3[] 00094 if ( pMM->getCurrentMode()!=def+1 ) 00095 { setTestResult(TEST_FAILURE, "Wrong mode"); 00096 return; 00097 } 00098 00099 pMM->first(); // iteration list should now be a3[] 00100 TelemetryPacket* item = pMM->getIterationTelemetryPacket(); 00101 if ( (item) != &list3[0] ) 00102 { setTestResult(TEST_FAILURE, "Error during iteration"); 00103 return; 00104 } 00105 00106 pMM->update(); // active list should now be a1[] but iteration list should still be a3[] 00107 if ( pMM->getCurrentMode()!=0 ) 00108 { setTestResult(TEST_FAILURE, "Wrong mode"); 00109 return; 00110 } 00111 00112 pMM->next(); 00113 item = pMM->getIterationTelemetryPacket(); 00114 if ( (item) != &list3[1] ) 00115 { setTestResult(TEST_FAILURE, "Error during iteration"); 00116 return; 00117 } 00118 00119 // Attempt illegal reconfiguration of list and check correctness of event 00120 if (isNonNominalCheckAllowed()) { 00121 pMM->setListItem(1,2,&list2[1]); 00122 if (verifyLatestEvent(nEvt+1,EVT_ILLEGAL_MM)) 00123 return; 00124 nEvt++; 00125 } 00126 00127 setTestResult(TEST_SUCCESS,"Test Successful"); 00128 return; 00129 }
Copyright 2003 P&P Software GmbH - All Rights Reserved