Vodafone Test Suite

Dependencies:   mbed-rtos mbed HTTPClient VodafoneUSBModem

Files at this revision

API Documentation at this revision

Comitter:
ashleymills
Date:
Thu Sep 13 08:21:25 2012 +0000
Parent:
30:dd2beda340c6
Child:
33:16126e029d58
Commit message:
Changing the framework slightly.

Changed in this revision

TestManager.cpp Show annotated file Show diff for this revision Revisions of this file
TestManager.h Show annotated file Show diff for this revision Revisions of this file
Tests/Test10.h Show annotated file Show diff for this revision Revisions of this file
VodafoneTestCase.h Show annotated file Show diff for this revision Revisions of this file
--- 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;
--- a/TestManager.h	Wed Sep 12 10:18:28 2012 +0000
+++ b/TestManager.h	Thu Sep 13 08:21:25 2012 +0000
@@ -20,6 +20,8 @@
       int getTestProfileLength(TestProfile profile);
       bool runTest(int id);
       bool runTest(int id, int numTimes);
+      VodafoneTestCase* getTest(int index);
+     
       
    private:
       VodafoneUSBModem *_modem;
--- a/Tests/Test10.h	Wed Sep 12 10:18:28 2012 +0000
+++ b/Tests/Test10.h	Thu Sep 13 08:21:25 2012 +0000
@@ -8,6 +8,7 @@
 class Test10 : public VodafoneTestCase {
    public: 
       Test10(VodafoneUSBModem *m, int tcNumber) : VodafoneTestCase(m, tcNumber) {
+         _description = gTest10Description;
       }
       
       virtual void setupTest() {
--- a/VodafoneTestCase.h	Wed Sep 12 10:18:28 2012 +0000
+++ b/VodafoneTestCase.h	Thu Sep 13 08:21:25 2012 +0000
@@ -15,6 +15,7 @@
 class VodafoneTestCase {
    public:
       VodafoneTestCase(VodafoneUSBModem *m, int tcNumber) : _modem(m),  _testCaseNumber(tcNumber) , _lastRunTime(0), _lastRunOutcome(false){
+         _description = "This is a dummy description.";
       }
       
       bool run() {
@@ -39,9 +40,10 @@
       
    protected:
       VodafoneUSBModem *_modem;
-      const int _testCaseNumber;
+      
    public:
       time_t _lastRunTime;
       bool _lastRunOutcome;
-
+      const int _testCaseNumber;
+      char* _description;
 };
\ No newline at end of file