summaryrefslogtreecommitdiffstats
path: root/tools/qtestlib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/qtestlib')
-rw-r--r--tools/qtestlib/wince/remotelib/commands.cpp86
-rw-r--r--tools/qtestlib/wince/remotelib/commands.h3
2 files changed, 89 insertions, 0 deletions
diff --git a/tools/qtestlib/wince/remotelib/commands.cpp b/tools/qtestlib/wince/remotelib/commands.cpp
index 4244424..88bf9e6 100644
--- a/tools/qtestlib/wince/remotelib/commands.cpp
+++ b/tools/qtestlib/wince/remotelib/commands.cpp
@@ -39,6 +39,9 @@
**
****************************************************************************/
#include "commands.h"
+#include <Pm.h>
+#include <Pmpolicy.h>
+
#define CLEAN_FAIL(a) {delete appName; \
delete arguments; \
@@ -124,3 +127,86 @@ bool qRemoteExecute(const wchar_t* program, const wchar_t* arguments, int *retur
}
return true;
}
+/**
+\brief Reset the device.
+*/
+int qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{
+ //POWER_STATE_ON On state
+ //POWER_STATE_OFF Off state
+ //POWER_STATE_CRITICAL Critical state
+ //POWER_STATE_BOOT Boot state
+ //POWER_STATE_IDLE Idle state
+ //POWER_STATE_SUSPEND Suspend state
+ //POWER_STATE_RESET Reset state
+
+ DWORD returnValue = SetSystemPowerState(0, POWER_STATE_RESET, POWER_FORCE);
+ return returnValue;
+}
+
+/**
+\brief Toggle the unattended powermode of the device
+*/
+int qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{
+ if (!stream)
+ return -1;
+
+ DWORD bytesRead;
+ int toggleVal = 0;
+ int returnValue = S_OK;
+
+ if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
+ return -2;
+
+ //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0).
+ //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0).
+ //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE.
+ //PPN_SUSPENDKEYPRESSED or
+ //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0).
+ //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0).
+ //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0).
+ //PPN_OEMBASE Greater than or equal to 0x10000
+ //You can define higher values, such as 0x10001, 0x10002, and so on.
+ // Reserved. Set dwData to zero (0).
+ returnValue = PowerPolicyNotify(PPN_UNATTENDEDMODE, toggleVal);
+
+ if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
+ return -3;
+ else
+ return S_OK;
+}
+
+/**
+\brief Virtually press the power button of the device
+*/
+int qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream)
+{
+ if (!stream)
+ return -1;
+
+ DWORD bytesRead;
+ int toggleVal = 0;
+ int returnValue = S_OK;
+
+ if (S_OK != stream->Read(&toggleVal, sizeof(toggleVal), &bytesRead))
+ return -2;
+
+ //PPN_REEVALUATESTATE 0x0001 Reserved. Set dwData to zero (0).
+ //PPN_POWERCHANGE 0x0002 Reserved. Set dwData to zero (0).
+ //PPN_UNATTENDEDMODE 0x0003 Set dwData to TRUE or FALSE.
+ //PPN_SUSPENDKEYPRESSED or
+ //PPN_POWERBUTTONPRESSED 0x0004 Reserved. Set dwData to zero (0).
+ //PPN_SUSPENDKEYRELEASED 0x0005 Reserved. Set dwData to zero (0).
+ //PPN_APPBUTTONPRESSED 0x0006 Reserved. Set dwData to zero (0).
+ //PPN_OEMBASE Greater than or equal to 0x10000
+ //You can define higher values, such as 0x10001, 0x10002, and so on.
+ // Reserved. Set dwData to zero (0).
+ returnValue = PowerPolicyNotify(PPN_POWERBUTTONPRESSED, 0);
+
+ if (S_OK != stream->Write(&returnValue, sizeof(returnValue), &bytesRead))
+ return -3;
+ else
+ return S_OK;
+}
+
diff --git a/tools/qtestlib/wince/remotelib/commands.h b/tools/qtestlib/wince/remotelib/commands.h
index c5cc926..8f202c8 100644
--- a/tools/qtestlib/wince/remotelib/commands.h
+++ b/tools/qtestlib/wince/remotelib/commands.h
@@ -45,6 +45,9 @@
extern "C" {
int __declspec(dllexport) qRemoteLaunch(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream*);
+ int __declspec(dllexport) qRemoteSoftReset(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
+ int __declspec(dllexport) qRemoteToggleUnattendedPowerMode(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
+ int __declspec(dllexport) qRemotePowerButton(DWORD, BYTE*, DWORD*, BYTE**, IRAPIStream* stream);
bool __declspec(dllexport) qRemoteExecute(const wchar_t* program, const wchar_t* arguments = NULL, int *returnValue = NULL , DWORD* error = NULL, int timeout = -1);
}