wlanutilities/wlanwizard/tsrc/ut/main.cpp
changeset 62 b47b808de481
parent 56 de27cc8389dd
equal deleted inserted replaced
58:301aeb18ae47 62:b47b808de481
    26 #include "testwlanwizardeap.h"
    26 #include "testwlanwizardeap.h"
    27 #include "testwlanwizardconnect.h"
    27 #include "testwlanwizardconnect.h"
    28 #include "testwlanwizardmanual.h"
    28 #include "testwlanwizardmanual.h"
    29 #include "testwlanwizardwps.h"
    29 #include "testwlanwizardwps.h"
    30 
    30 
       
    31 static bool match(int argc, char *argv[], const QString &tc);
       
    32 
    31 // ======== LOCAL FUNCTIONS ========
    33 // ======== LOCAL FUNCTIONS ========
    32 int main(int argc, char *argv[])
    34 int main(int argc, char *argv[])
    33 {
    35 {
    34     qDebug("TestWlanWizard main start");
       
    35     HbApplication app(argc, argv);
    36     HbApplication app(argc, argv);
    36     int res = 0;
    37     int res = 0;
    37     char *pass[3];
    38     char *pass[3];
    38     pass[0] = argv[0];
    39     pass[0] = argv[0];
    39     pass[1] = "-o";
    40     pass[1] = "-o";
    40     
    41     
    41     // log folder: \epoc32\winscw\c\data
    42     // log folder: 
       
    43     // - emulator: \epoc32\winscw\c\data
       
    44     // - device:   c:\data
    42     
    45     
    43     app.setApplicationName("TestWlanWizardUtilities");
    46     // By default all test cases are executed.
    44     pass[2] = "c:\\data\\TestWlanWizardUtilities.txt";
    47     // Use following to limit the testcases as your needs:
    45     TestWlanWizard *tcUtilities = new TestWlanWizard();
    48     // t_wlanwizard -t <testcases>
    46     res |= QTest::qExec(tcUtilities, 3, pass);
    49     //     testcases    utils connect manual eap wps
    47     delete tcUtilities;
    50     // e.g. t_wlanwizard -t connect wps 
    48     tcUtilities = NULL;
    51     // runs only "connect" and "wps" test cases
       
    52     
       
    53     if (match(argc, argv, "utils")) {
       
    54         app.setApplicationName("TestWlanWizardUtilities");
       
    55         pass[2] = "c:\\data\\TestWlanWizardUtilities.txt";
       
    56         TestWlanWizard *tcUtilities = new TestWlanWizard();
       
    57         res |= QTest::qExec(tcUtilities, 3, pass);
       
    58         delete tcUtilities;
       
    59         tcUtilities = NULL;
       
    60     }
       
    61     
       
    62     if (match(argc, argv, "connect")) {
       
    63         app.setApplicationName("TestWlanWizardConnect");
       
    64         pass[2] = "c:\\data\\TestWlanWizardConnect.txt";
       
    65         TestWlanWizardConnect *tcConnect = new TestWlanWizardConnect();
       
    66         res |= QTest::qExec(tcConnect, 3, pass);
       
    67         delete tcConnect;
       
    68         tcConnect = NULL;
       
    69     }
       
    70     
       
    71     if (match(argc, argv, "manual")) {
       
    72         app.setApplicationName("TestWlanWizardManual");
       
    73         pass[2] = "c:\\data\\TestWlanWizardManual.txt";
       
    74         TestWlanWizardManual *tcManual = new TestWlanWizardManual();
       
    75         res |= QTest::qExec(tcManual, 3, pass);
       
    76         delete tcManual;
       
    77         tcManual = NULL;
       
    78     }
       
    79     
       
    80     if (match(argc, argv, "eap")) {
       
    81         app.setApplicationName("TestWlanWizardEap");
       
    82         pass[2] = "c:\\data\\TestWlanWizardEap.txt";
       
    83         TestWlanWizardEap *tcEap = new TestWlanWizardEap();
       
    84         res |= QTest::qExec(tcEap, 3, pass);
       
    85         delete tcEap;
       
    86         tcEap = NULL;
       
    87     }
    49 
    88 
    50     app.setApplicationName("TestWlanWizardConnect");
    89     if (match(argc, argv, "wps")) {
    51     pass[2] = "c:\\data\\TestWlanWizardConnect.txt";
    90         app.setApplicationName("TestWlanWizardWps");
    52     TestWlanWizardConnect *tcConnect = new TestWlanWizardConnect();
    91         pass[2] = "c:\\data\\TestWlanWizardWps.txt";
    53     res |= QTest::qExec(tcConnect, 3, pass);
    92         TestWlanWizardWps *tcWps = new TestWlanWizardWps();
    54     delete tcConnect;
    93         res |= QTest::qExec(tcWps, 3, pass);
    55     tcConnect = NULL;
    94         delete tcWps;
       
    95         tcWps = NULL;
       
    96     }
    56     
    97     
    57     app.setApplicationName("TestWlanWizardManual");
       
    58     pass[2] = "c:\\data\\TestWlanWizardManual.txt";
       
    59     TestWlanWizardManual *tcManual = new TestWlanWizardManual();
       
    60     res |= QTest::qExec(tcManual, 3, pass);
       
    61     delete tcManual;
       
    62     tcManual = NULL;
       
    63 
       
    64     app.setApplicationName("TestWlanWizardEap");
       
    65     pass[2] = "c:\\data\\TestWlanWizardEap.txt";
       
    66     TestWlanWizardEap *tcEap = new TestWlanWizardEap();
       
    67     res |= QTest::qExec(tcEap, 3, pass);
       
    68     delete tcEap;
       
    69     tcEap = NULL;
       
    70 
       
    71     app.setApplicationName("TestWlanWizardWps");
       
    72     pass[2] = "c:\\data\\TestWlanWizardWps.txt";
       
    73     TestWlanWizardWps *tcWps = new TestWlanWizardWps();
       
    74     res |= QTest::qExec(tcWps, 3, pass);
       
    75     delete tcWps;
       
    76     tcWps = NULL;
       
    77     
       
    78     qDebug("TestWlanWizard main exit");
       
    79     return res;
    98     return res;
    80 }
    99 }
       
   100 
       
   101 bool match(int argc, char *argv[], const QString &tc)
       
   102 {
       
   103     bool testArgument = false;
       
   104     bool testCase = false;
       
   105     bool ret = true;
       
   106     
       
   107     int i = argc;
       
   108     while( --i > 0) {
       
   109         if (QString(argv[i]) == QString("-t")) {
       
   110             testArgument = true;
       
   111             break;
       
   112         }
       
   113     }
       
   114     
       
   115     i = argc;
       
   116     while( --i > 0) {
       
   117         if (QString(argv[i]) == tc) {
       
   118             testCase = true;
       
   119             break;
       
   120         }
       
   121     }
       
   122     
       
   123     if (testArgument && !testCase) {
       
   124         ret = false;
       
   125     }
       
   126     
       
   127     return ret;
       
   128 }