Changeset 769 for trunk/tools/qtestlib
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/tools/qtestlib/wince/cetest/activesyncconnection.cpp
r651 r769 444 444 } 445 445 446 bool ActiveSyncConnection::setDeviceAwake(bool activate, int *returnValue) 447 { 448 if (!isConnected()) { 449 qWarning("Cannot execute, connect to device first!"); 450 return false; 451 } 452 bool result = false; 453 454 // If we want to wait, we have to use CeRapiInvoke, as CeCreateProcess has no way to wait 455 // until the process ends. The lib must have been build and also deployed already. 456 if (!isConnected() && !connect()) 457 return false; 458 459 HRESULT res = S_OK; 460 461 //SYSTEM_POWER_STATUS_EX systemPowerState; 462 463 //res = CeGetSystemPowerStatusEx(&systemPowerState, true); 464 465 QString dllLocation = "\\Windows\\QtRemote.dll"; 466 QString functionName = "qRemoteToggleUnattendedPowerMode"; 467 468 DWORD outputSize; 469 BYTE* output; 470 IRAPIStream *stream; 471 int returned = 0; 472 int toggle = int(activate); 473 474 res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); 475 if (S_OK != res) { 476 DWORD ce_error = CeGetLastError(); 477 if (S_OK != ce_error) { 478 qWarning("Error invoking %s on %s: %s", qPrintable(functionName), 479 qPrintable(dllLocation), strwinerror(ce_error).constData()); 480 } else { 481 qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), 482 qPrintable(dllLocation), res); 483 } 484 } else { 485 DWORD written; 486 487 if (S_OK != stream->Write(&toggle, sizeof(toggle), &written)) { 488 qWarning(" Could not write toggle option to process"); 489 return false; 490 } 491 492 if (S_OK != stream->Read(&returned, sizeof(returned), &written)) { 493 qWarning(" Could not access return value of process"); 494 } 495 else 496 result = true; 497 } 498 499 if (returnValue) 500 *returnValue = returned; 501 502 return result; 503 } 504 505 bool ActiveSyncConnection::resetDevice() 506 { 507 if (!isConnected()) { 508 qWarning("Cannot execute, connect to device first!"); 509 return false; 510 } 511 512 bool result = false; 513 if (!isConnected() && !connect()) 514 return false; 515 516 QString dllLocation = "\\Windows\\QtRemote.dll"; 517 QString functionName = "qRemoteSoftReset"; 518 519 DWORD outputSize; 520 BYTE* output; 521 IRAPIStream *stream; 522 523 int returned = 0; 524 525 HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); 526 if (S_OK != res) { 527 DWORD ce_error = CeGetLastError(); 528 if (S_OK != ce_error) { 529 qWarning("Error invoking %s on %s: %s", qPrintable(functionName), 530 qPrintable(dllLocation), strwinerror(ce_error).constData()); 531 } else { 532 qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), 533 qPrintable(dllLocation), res); 534 } 535 } else { 536 result = true; 537 } 538 return result; 539 } 540 541 bool ActiveSyncConnection::toggleDevicePower(int *returnValue) 542 { 543 if (!isConnected()) { 544 qWarning("Cannot execute, connect to device first!"); 545 return false; 546 } 547 548 bool result = false; 549 if (!isConnected() && !connect()) 550 return false; 551 552 QString dllLocation = "\\Windows\\QtRemote.dll"; 553 QString functionName = "qRemotePowerButton"; 554 555 DWORD outputSize; 556 BYTE* output; 557 IRAPIStream *stream; 558 int returned = 0; 559 560 HRESULT res = CeRapiInvoke(dllLocation.utf16(), functionName.utf16(), 0, 0, &outputSize, &output, &stream, 0); 561 if (S_OK != res) { 562 DWORD ce_error = CeGetLastError(); 563 if (S_OK != ce_error) { 564 qWarning("Error invoking %s on %s: %s", qPrintable(functionName), 565 qPrintable(dllLocation), strwinerror(ce_error).constData()); 566 } else { 567 qWarning("Error: %s on %s unexpectedly returned %d", qPrintable(functionName), 568 qPrintable(dllLocation), res); 569 } 570 } else { 571 DWORD written; 572 if (S_OK != stream->Read(&returned, sizeof(returned), &written)) { 573 qWarning(" Could not access return value of process"); 574 } 575 else { 576 result = true; 577 } 578 } 579 580 if (returnValue) 581 *returnValue = returned; 582 return result; 583 } 584 446 585 bool ActiveSyncConnection::createDirectory(const QString &path, bool deleteBefore) 447 586 { -
trunk/tools/qtestlib/wince/cetest/activesyncconnection.h
r651 r769 80 80 81 81 bool execute(QString program, QString arguments = QString(), int timeout = -1, int *returnValue = NULL); 82 bool resetDevice(); 83 bool toggleDevicePower(int *returnValue = NULL); 84 bool setDeviceAwake(bool activate, int *returnValue = NULL); 82 85 private: 83 86 bool connected; -
trunk/tools/qtestlib/wince/cetest/cetest.pro
r561 r769 20 20 $$QT_SOURCE_TREE/qmake \ 21 21 $$QT_SOURCE_TREE/qmake/generators/symbian \ 22 $$QT_SOURCE_TREE/tools/shared \ 22 23 $$QT_BUILD_TREE/include \ 23 24 $$QT_BUILD_TREE/include/QtCore \ 24 25 $$QT_BUILD_TREE/src/corelib/global 26 27 VPATH += $$QT_SOURCE_TREE/tools/shared 25 28 26 29 DEPENDPATH += $$QT_BUILD_TREE/src/corelib/tools $$QT_BUILD_TREE/src/corelib/io … … 34 37 remoteconnection.cpp \ 35 38 deployment.cpp \ 39 symbian/epocroot.cpp \ 40 windows/registry.cpp \ 36 41 main.cpp 37 42 -
trunk/tools/qtestlib/wince/cetest/main.cpp
r651 r769 45 45 # include "activesyncconnection.h" 46 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 51 #include "deployment.h" … … 124 127 " -release : Test release version\n" 125 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 131 " -qt-delete : Delete the Qt libraries after execution\n" 127 132 " -project-delete : Delete the project file(s) after execution\n" … … 153 158 bool cleanupQt = false; 154 159 bool cleanupProject = false; 160 bool deviceReset = false; 161 bool keepAwake = false; 155 162 156 163 for (int i=1; i<arguments.size(); ++i) { … … 197 204 cleanupQt = true; 198 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 210 } else if (arguments.at(i).toLower() == QLatin1String("-conf")) { 200 211 if (++i == arguments.size()) { … … 353 364 cout << "Error: Could not copy file(s) to device" << endl; 354 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 -
trunk/tools/qtestlib/wince/cetest/qmake_include.pri
r561 r769 6 6 $$QT_SOURCE_TREE/qmake/project.cpp \ 7 7 $$QT_SOURCE_TREE/qmake/property.cpp \ 8 $$QT_SOURCE_TREE/qmake/generators/symbian/initprojectdeploy_symbian.cpp 8 $$QT_SOURCE_TREE/qmake/generators/symbian/initprojectdeploy_symbian.cpp \ 9 $$QT_SOURCE_TREE/tools/shared/symbian/epocroot.cpp \ 10 $$QT_SOURCE_TREE/tools/shared/windows/registry.cpp 9 11 -
trunk/tools/qtestlib/wince/remotelib/commands.cpp
r651 r769 40 40 ****************************************************************************/ 41 41 #include "commands.h" 42 #include <Pm.h> 43 #include <Pmpolicy.h> 44 42 45 43 46 #define CLEAN_FAIL(a) {delete appName; \ … … 125 128 return true; 126 129 } 130 /** 131 \brief Reset the device. 132 */ 133 int qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) 134 { 135 //POWER_STATE_ON On state 136 //POWER_STATE_OFF Off state 137 //POWER_STATE_CRITICAL Critical state 138 //POWER_STATE_BOOT Boot state 139 //POWER_STATE_IDLE Idle state 140 //POWER_STATE_SUSPEND Suspend state 141 //POWER_STATE_RESET Reset state 142 143 DWORD returnValue = SetSystemPowerState(0, POWER_STATE_RESET, POWER_FORCE); 144 return returnValue; 145 } 146 147 /** 148 \brief Toggle the unattended powermode of the device 149 */ 150 int qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) 151 { 152 if (!stream) 153 return -1; 154 155 DWORD bytesRead; 156 int toggleVal = 0; 157 int returnValue = S_OK; 158 159 if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead)) 160 return -2; 161 162 //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 163 //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 164 //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 165 //PPN_SUSPENDKEYPRESSED or 166 //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 167 //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 168 //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 169 //PPN_OEMBASE Greater than or equal to 0x10000 170 //You can define higher values, such as 0x10001, 0x10002, and so on. 171 // Reserved. Set dwData to zero (0). 172 returnValue = PowerPolicyNotify(PPN_UNATTENDEDMODE, toggleVal); 173 174 if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead)) 175 return -3; 176 else 177 return S_OK; 178 } 179 180 /** 181 \brief Virtually press the power button of the device 182 */ 183 int qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream) 184 { 185 if (!stream) 186 return -1; 187 188 DWORD bytesRead; 189 int toggleVal = 0; 190 int returnValue = S_OK; 191 192 if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead)) 193 return -2; 194 195 //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0). 196 //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0). 197 //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE. 198 //PPN_SUSPENDKEYPRESSED or 199 //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0). 200 //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0). 201 //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0). 202 //PPN_OEMBASE Greater than or equal to 0x10000 203 //You can define higher values, such as 0x10001, 0x10002, and so on. 204 // Reserved. Set dwData to zero (0). 205 returnValue = PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0); 206 207 if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead)) 208 return -3; 209 else 210 return S_OK; 211 } 212 -
trunk/tools/qtestlib/wince/remotelib/commands.h
r651 r769 46 46 extern "C" { 47 47 int __declspec(dllexport) qRemoteLaunch(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream*); 48 int __declspec(dllexport) qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); 49 int __declspec(dllexport) qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); 50 int __declspec(dllexport) qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream); 48 51 bool __declspec(dllexport) qRemoteExecute(const wchar_t* program, const wchar_t* arguments = NULL, int *returnValue = NULL , DWORD* error = NULL, int timeout = -1); 49 52 }
Note:
See TracChangeset
for help on using the changeset viewer.