Andrew Fenn : xinput1_3: Added test for XInputGetBatteryInformation.

Alexandre Julliard julliard at winehq.org
Thu Jan 8 08:31:15 CST 2009


Module: wine
Branch: master
Commit: 37a7ca59b32062d5538edb3cf685fee840a3c5e9
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=37a7ca59b32062d5538edb3cf685fee840a3c5e9

Author: Andrew Fenn <andrewfenn at gmail.com>
Date:   Thu Jan  8 01:48:25 2009 +0700

xinput1_3: Added test for XInputGetBatteryInformation.

---

 dlls/xinput1_3/tests/xinput.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/dlls/xinput1_3/tests/xinput.c b/dlls/xinput1_3/tests/xinput.c
index f597ed0..29f075f 100644
--- a/dlls/xinput1_3/tests/xinput.c
+++ b/dlls/xinput1_3/tests/xinput.c
@@ -29,6 +29,7 @@ static DWORD (WINAPI *pXInputSetState)(DWORD, XINPUT_VIBRATION*);
 static void  (WINAPI *pXInputEnable)(BOOL);
 static DWORD (WINAPI *pXInputGetKeystroke)(DWORD, DWORD, PXINPUT_KEYSTROKE);
 static DWORD (WINAPI *pXInputGetDSoundAudioDeviceGuids)(DWORD, GUID*, GUID*);
+static DWORD (WINAPI *pXInputGetBatteryInformation)(DWORD, BYTE, XINPUT_BATTERY_INFORMATION*);
 
 static void test_set_state(void)
 {
@@ -168,6 +169,30 @@ static void test_get_dsoundaudiodevice(void)
     ok(result == ERROR_BAD_ARGUMENTS, "XInputGetDSoundAudioDeviceGuids returned (%d)\n", result);
 }
 
+static void test_get_batteryinformation(void)
+{
+    DWORD controllerNum;
+    DWORD result;
+    XINPUT_BATTERY_INFORMATION batteryInfo;
+
+    for(controllerNum=0; controllerNum < XUSER_MAX_COUNT; controllerNum++)
+    {
+        ZeroMemory(&batteryInfo, sizeof(XINPUT_BATTERY_INFORMATION));
+
+        result = pXInputGetBatteryInformation(controllerNum, BATTERY_DEVTYPE_GAMEPAD, &batteryInfo);
+        ok(result == ERROR_SUCCESS || result == ERROR_DEVICE_NOT_CONNECTED, "XInputGetBatteryInformation failed with (%d)\n", result);
+
+        if (ERROR_DEVICE_NOT_CONNECTED == result)
+        {
+            ok(batteryInfo.BatteryLevel == BATTERY_TYPE_DISCONNECTED, "Failed to report device as being disconnected.");
+            skip("Controller %d is not connected\n", controllerNum);
+        }
+    }
+
+    result = pXInputGetBatteryInformation(XUSER_MAX_COUNT+1, BATTERY_DEVTYPE_GAMEPAD, &batteryInfo);
+    ok(result == ERROR_BAD_ARGUMENTS, "XInputGetBatteryInformation returned (%d)\n", result);
+}
+
 START_TEST(xinput)
 {
     HMODULE hXinput;
@@ -185,12 +210,14 @@ START_TEST(xinput)
     pXInputGetKeystroke = (void*)GetProcAddress(hXinput, "XInputGetKeystroke");
     pXInputGetCapabilities = (void*)GetProcAddress(hXinput, "XInputGetCapabilities");
     pXInputGetDSoundAudioDeviceGuids = (void*)GetProcAddress(hXinput, "XInputGetDSoundAudioDeviceGuids");
+    pXInputGetBatteryInformation = (void*)GetProcAddress(hXinput, "XInputGetBatteryInformation");
 
     test_set_state();
     test_get_state();
     test_get_keystroke();
     test_get_capabilities();
     test_get_dsoundaudiodevice();
+    test_get_batteryinformation();
 
     FreeLibrary(hXinput);
 }




More information about the wine-cvs mailing list