tools/qtestlib/wince/cetest/main.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
    42 #ifdef QT_CETEST_NO_ACTIVESYNC
    42 #ifdef QT_CETEST_NO_ACTIVESYNC
    43 #   include "cetcpsyncconnection.h"
    43 #   include "cetcpsyncconnection.h"
    44 #else
    44 #else
    45 #   include "activesyncconnection.h"
    45 #   include "activesyncconnection.h"
    46 #endif
    46 #endif
       
    47 
       
    48 const int SLEEP_AFTER_RESET = 60000; // sleep for 1 minute
       
    49 const int SLEEP_RECONNECT   = 2000;  // sleep for 2 seconds before trying another reconnect
    47 
    50 
    48 #include "deployment.h"
    51 #include "deployment.h"
    49 #include <option.h>
    52 #include <option.h>
    50 #include <project.h>
    53 #include <project.h>
    51 #include <property.h>
    54 #include <property.h>
   121     cout <<
   124     cout <<
   122         "cetest specific options\n"
   125         "cetest specific options\n"
   123         " -debug            : Test debug version[default]\n"
   126         " -debug            : Test debug version[default]\n"
   124         " -release          : Test release version\n"
   127         " -release          : Test release version\n"
   125         " -libpath <path>   : Remote path to deploy Qt libraries to\n"
   128         " -libpath <path>   : Remote path to deploy Qt libraries to\n"
       
   129         " -reset            : Reset device before starting a test\n"
       
   130         " -awake            : Device does not go sleep mode\n"
   126         " -qt-delete        : Delete the Qt libraries after execution\n"
   131         " -qt-delete        : Delete the Qt libraries after execution\n"
   127         " -project-delete   : Delete the project file(s) after execution\n"
   132         " -project-delete   : Delete the project file(s) after execution\n"
   128         " -delete           : Delete everything deployed after execution\n"
   133         " -delete           : Delete everything deployed after execution\n"
   129         " -conf             : Specify location of qt.conf file\n"
   134         " -conf             : Specify location of qt.conf file\n"
   130         " -f <file>         : Specify project file\n"
   135         " -f <file>         : Specify project file\n"
   150     QString proFile;
   155     QString proFile;
   151     QString cacheFile;
   156     QString cacheFile;
   152     int timeout = -1;
   157     int timeout = -1;
   153     bool cleanupQt = false;
   158     bool cleanupQt = false;
   154     bool cleanupProject = false;
   159     bool cleanupProject = false;
       
   160     bool deviceReset = false;
       
   161     bool keepAwake = false;
   155 
   162 
   156     for (int i=1; i<arguments.size(); ++i) {
   163     for (int i=1; i<arguments.size(); ++i) {
   157         if (arguments.at(i).toLower() == QLatin1String("-help")
   164         if (arguments.at(i).toLower() == QLatin1String("-help")
   158                     || arguments.at(i).toLower() == QLatin1String("--help")
   165                     || arguments.at(i).toLower() == QLatin1String("--help")
   159                     || arguments.at(i).toLower() == QLatin1String("/?")) {
   166                     || arguments.at(i).toLower() == QLatin1String("/?")) {
   194         } else if (arguments.at(i).toLower() == QLatin1String("-project-delete")) {
   201         } else if (arguments.at(i).toLower() == QLatin1String("-project-delete")) {
   195             cleanupProject = true;
   202             cleanupProject = true;
   196         } else if (arguments.at(i).toLower() == QLatin1String("-delete")) {
   203         } else if (arguments.at(i).toLower() == QLatin1String("-delete")) {
   197             cleanupQt = true;
   204             cleanupQt = true;
   198             cleanupProject = true;
   205             cleanupProject = true;
       
   206         } else if (arguments.at(i).toLower() == QLatin1String("-reset")) {
       
   207             deviceReset = true;
       
   208         } else if (arguments.at(i).toLower() == QLatin1String("-awake")) {
       
   209             keepAwake = true;
   199         } else if (arguments.at(i).toLower() == QLatin1String("-conf")) {
   210         } else if (arguments.at(i).toLower() == QLatin1String("-conf")) {
   200             if (++i == arguments.size()) {
   211             if (++i == arguments.size()) {
   201                 cout << "Error: No qt.conf file specified!" << endl;
   212                 cout << "Error: No qt.conf file specified!" << endl;
   202                 return -1;
   213                 return -1;
   203             }
   214             }
   350     }
   361     }
   351 
   362 
   352     if (!deployment.deviceDeploy(qtDeploymentList) || !deployment.deviceDeploy(projectDeploymentList)) {
   363     if (!deployment.deviceDeploy(qtDeploymentList) || !deployment.deviceDeploy(projectDeploymentList)) {
   353         cout << "Error: Could not copy file(s) to device" << endl;
   364         cout << "Error: Could not copy file(s) to device" << endl;
   354         return -1;
   365         return -1;
       
   366     }
       
   367     // device power mode
       
   368     if (keepAwake)
       
   369     {
       
   370         int retVal = 0;
       
   371         if (!connection.setDeviceAwake(true, &retVal)) {
       
   372             cout << "Error: Could not set unattended mode on device" << endl;
       
   373             return -1;
       
   374         }
       
   375     }
       
   376 
       
   377     // reset device
       
   378     if (deviceReset)
       
   379     {
       
   380         if (!connection.resetDevice()) {
       
   381         //if (!connection.toggleDevicePower( &retVal)) {
       
   382             cout << "Error: Could not reset the device" << endl;
       
   383             return -1;
       
   384         }
       
   385         cout << " Entering sleep after reset for " << SLEEP_AFTER_RESET / 1000 << " seconds ... " << endl;
       
   386         Sleep(SLEEP_AFTER_RESET);
       
   387         cout << " ... woke up. " << endl;
       
   388         connection.disconnect();
       
   389         // reconnect after reset
       
   390         int retryCount = 21;
       
   391         while (--retryCount)
       
   392         {
       
   393             if (!connection.connect()) 
       
   394                 Sleep(SLEEP_RECONNECT);
       
   395             else
       
   396                 break;
       
   397         }
       
   398         if (!connection.isConnected())
       
   399         {
       
   400             cout << "Error: Could not connect to device!" << endl;
       
   401             return -1;
       
   402         }
   355     }
   403     }
   356 
   404 
   357     // launch
   405     // launch
   358     launchArguments.append("-o");
   406     launchArguments.append("-o");
   359     launchArguments.append(TestConfiguration::remoteResultFile);
   407     launchArguments.append(TestConfiguration::remoteResultFile);