Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: TestManager.cpp
- Revision:
- 32:8ff0b67bb58c
- Parent:
- 30:dd2beda340c6
- Child:
- 33:16126e029d58
--- a/TestManager.cpp Wed Sep 12 10:18:28 2012 +0000 +++ b/TestManager.cpp Thu Sep 13 08:21:25 2012 +0000 @@ -1,33 +1,35 @@ #include "TestManager.h" #include "Tests.h" -TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { - // using direct array indexing instead of searching each time, so need to put in dummy tests - for(int i=0; i<10; i++) { _tests.push_back(NULL); } - - _tests.push_back((VodafoneTestCase*)new Test10(_modem,10)); - - for(int i=11; i<12; i++) { _tests.push_back(NULL); } - _tests.push_back((VodafoneTestCase*)new Test12(_modem,12)); - _tests.push_back((VodafoneTestCase*)new Test13(_modem,13)); - - for(int i=14; i<16; i++) { _tests.push_back(NULL); } - _tests.push_back((VodafoneTestCase*)new Test16(_modem,16)); - for(int i=17; i<21; i++) { _tests.push_back(NULL); } - - _tests.push_back((VodafoneTestCase*)new Test21(_modem,21)); - _tests.push_back((VodafoneTestCase*)new Test22(_modem,22)); - _tests.push_back((VodafoneTestCase*)new Test23(_modem,23)); - - for(int i=24; i<25; i++) { _tests.push_back(NULL); } - - _tests.push_back((VodafoneTestCase*)new Test25(_modem,25)); - _tests.push_back((VodafoneTestCase*)new Test26(_modem,26)); - - for(int i=27; i<50; i++) { _tests.push_back(NULL); } - - _tests.push_back((VodafoneTestCase*)new Test50(_modem,50)); - _tests.push_back((VodafoneTestCase*)new Test56(_modem,45)); +// adds a test into the master test index +void TestManager::addTest(VodafoneTestCase* testCase) { + int index = testCase->_testCaseNumber; + // make space for test + int currentSize = _tests.size(); + if(index>=currentSize) { + int pushCount = (index-currentSize)+1; + while(pushCount--) + _tests.push_back(NULL); + } + if(_tests[index]==NULL) { + _tests[index] = testCase; + } +} + +TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { + // using direct array indexing instead of searching each time + // dummy tests are inserted by the addTest function + addTest((VodafoneTestCase*)new Test10(_modem,10)); + addTest((VodafoneTestCase*)new Test12(_modem,12)); + addTest((VodafoneTestCase*)new Test13(_modem,13)); + addTest((VodafoneTestCase*)new Test16(_modem,16)); + addTest((VodafoneTestCase*)new Test21(_modem,21)); + addTest((VodafoneTestCase*)new Test22(_modem,22)); + addTest((VodafoneTestCase*)new Test23(_modem,23)); + addTest((VodafoneTestCase*)new Test25(_modem,25)); + addTest((VodafoneTestCase*)new Test26(_modem,26)); + addTest((VodafoneTestCase*)new Test50(_modem,50)); + addTest((VodafoneTestCase*)new Test56(_modem,56)); } int TestManager::getTestProfileLength(TestProfile profile) { @@ -40,11 +42,9 @@ } int TestManager::executeTestProfile(TestProfile profile) { - int numPassed = 0; - if(profile <TESTS_END) { // no test for >= 0 since TestProfile is unsigned + if(profile<TESTS_END) { // no test for >= 0 since TestProfile is unsigned numPassed = executeTestList(gTestProfiles[profile], gTestProfileLengths[profile]); - } else { LOG("Test profile out of bounds. Must be between 0 and %d",TESTS_END-1); return 0; @@ -65,7 +65,7 @@ continue; } - VodafoneTestCase* test = _tests[list[i]]; + VodafoneTestCase* test = _tests[testIndex]; if(test->_lastRunOutcome==false) { LOG("Test %d:",list[i]); LOG(gTestDescriptions[list[i]]); @@ -73,6 +73,14 @@ } } +VodafoneTestCase* TestManager::getTest(int index) { + for(int i=0; i<_tests.size(); i++) { + if(index==_tests[i]->_testCaseNumber) + return _tests[i]; + } + return NULL; +} + int TestManager::executeTestList(const int *list, const int listLen) { LOG("The executeTestList is: %d", list); LOG("The executeTestListLength is: %d", listLen); @@ -86,7 +94,7 @@ continue; } - VodafoneTestCase* test = _tests[list[i]]; + VodafoneTestCase* test = _tests[testIndex]; if(test==NULL) { LOG("NULL test! This will be counted as a failure."); continue;