Vodafone Test Suite
Dependencies: mbed-rtos mbed HTTPClient VodafoneUSBModem
Diff: TestManager.cpp
- Revision:
- 37:847f5f86e9ff
- Parent:
- 35:6867af70c51c
- Child:
- 38:83085bfd1018
--- a/TestManager.cpp Thu Sep 13 12:17:18 2012 +0000 +++ b/TestManager.cpp Thu Sep 13 15:26:49 2012 +0000 @@ -6,20 +6,89 @@ _tests.push_back(testCase); } +VodafoneTestCase* TestManager::constructTest(int testID) { + switch(testID) { + case 0: break; + case 1: break; + case 2: break; + case 3: break; + case 4: break; + case 5: break; + case 6: break; + case 7: break; + case 8: break; + case 9: break; + case 10: return (VodafoneTestCase*) new Test10(_modem); + case 11: break; + case 12: return (VodafoneTestCase*) new Test12(_modem); + case 13: return (VodafoneTestCase*) new Test13(_modem); + case 14: return (VodafoneTestCase*) new Test14(_modem); + case 15: break; + case 16: return (VodafoneTestCase*) new Test16(_modem); + case 17: break; + case 18: break; + case 19: break; + case 20: break; + case 21: return (VodafoneTestCase*) new Test21(_modem); + case 22: return (VodafoneTestCase*) new Test22(_modem); + case 23: return (VodafoneTestCase*) new Test23(_modem); + case 24: break; + case 25: return (VodafoneTestCase*) new Test25(_modem); + case 26: return (VodafoneTestCase*) new Test26(_modem); + case 27: break; + case 28: break; + case 29: break; + case 30: break; + case 31: break; + case 32: break; + case 33: break; + case 34: break; + case 35: break; + case 36: break; + case 37: break; + case 38: break; + case 39: break; + case 40: break; + case 41: break; + case 42: break; + case 43: break; + case 44: break; + case 45: break; + case 46: break; + case 47: break; + case 48: break; + case 49: break; + case 50: return (VodafoneTestCase*) new Test50(_modem); + case 51: break; + case 52: break; + case 53: break; + case 54: break; + case 55: break; + case 56: return (VodafoneTestCase*) new Test56(_modem); + case 57: break; + case 58: break; + case 59: break; + }; +} + TestManager::TestManager(VodafoneUSBModem *m) : _modem(m) { // using direct array indexing instead of searching each time // dummy tests are inserted by the addTest function - _tests.push_back((VodafoneTestCase*)new Test10(m)); - addTest((VodafoneTestCase*)new Test12(m)); - addTest((VodafoneTestCase*)new Test13(m)); - addTest((VodafoneTestCase*)new Test16(m)); - addTest((VodafoneTestCase*)new Test21(m)); - addTest((VodafoneTestCase*)new Test22(m)); - addTest((VodafoneTestCase*)new Test23(m)); + //addTest((VodafoneTestCase*)new Test10(m)); + //addTest((VodafoneTestCase*)new Test12(m)); + + //addTest((VodafoneTestCase*)new Test13(m)); + //addTest((VodafoneTestCase*)new Test16(m)); + //addTest((VodafoneTestCase*)new Test21(m)); + + //addTest((VodafoneTestCase*)new Test22(m)); + //addTest((VodafoneTestCase*)new Test23(m)); + /* addTest((VodafoneTestCase*)new Test25(m)); addTest((VodafoneTestCase*)new Test26(m)); addTest((VodafoneTestCase*)new Test50(m)); addTest((VodafoneTestCase*)new Test56(m)); + */ } int TestManager::getTestProfileLength(TestProfile profile) { @@ -75,34 +144,32 @@ LOG("Running %d tests...",listLen); for(int i=0; i<listLen; i++) { int testIndex = list[i]; - VodafoneTestCase* test = getTest(testIndex); - if(test==NULL) { - LOG("Error. Test %d is not in test list! This will be counted as a failure.",testIndex); - continue; - } - - LOG("Running test %d...",testIndex); - if(test->execute()) { - LOG("...OK"); + if(executeTest(testIndex)) { successfullTests++; - } else { - LOG("...FAIL"); } } return successfullTests; } -bool TestManager::executeTest(int id) { - VodafoneTestCase* test = getTest(id); +bool TestManager::executeTest(int testID) { + VodafoneTestCase* test = constructTest(testID);//getTest(testID); if(test==NULL) { - LOG("Error. Test %d is not in test list! This will be counted as a failure.",id); + LOG("Error. Test %d is not in test list! This will be counted as a failure.",testID); + delete test; return false; } - - return _tests[id]->execute(); + + LOG("Running test %d...",testID); + if(test->execute()) { + LOG("...OK"); + delete test; + return true; + } + LOG("...FAIL"); + delete test; + return false; } - bool TestManager::executeTest(int id, int numTimes) { for(int i=0; i<numTimes; i++) { if(!executeTest(id))