winex11.drv: Map coordinates before calling send_mouse_input.
[wine/zf.git] / dlls / kernel32 / tests / power.c
blobaf488849e211092c8b1d8ff48450ee09cd9afc73
1 /*
2 * Unit tests for power management functions
4 * Copyright (c) 2019 Alex Henrie
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "wine/test.h"
23 void test_GetSystemPowerStatus(void)
25 SYSTEM_POWER_STATUS ps;
26 BOOL ret;
27 BYTE capacity_flags, expected_capacity_flags;
29 if (0) /* crashes */
30 GetSystemPowerStatus(NULL);
32 memset(&ps, 0x23, sizeof(ps));
33 ret = GetSystemPowerStatus(&ps);
34 ok(ret == TRUE, "expected TRUE\n");
36 if (ps.BatteryFlag == BATTERY_FLAG_UNKNOWN)
38 skip("GetSystemPowerStatus not implemented or not working\n");
39 return;
41 else if (ps.BatteryFlag != BATTERY_FLAG_NO_BATTERY)
43 trace("battery detected\n");
44 expected_capacity_flags = 0;
45 if (ps.BatteryLifePercent > 66)
46 expected_capacity_flags |= BATTERY_FLAG_HIGH;
47 if (ps.BatteryLifePercent < 33)
48 expected_capacity_flags |= BATTERY_FLAG_LOW;
49 if (ps.BatteryLifePercent < 5)
50 expected_capacity_flags |= BATTERY_FLAG_CRITICAL;
51 capacity_flags = (ps.BatteryFlag & ~BATTERY_FLAG_CHARGING);
52 ok(capacity_flags == expected_capacity_flags,
53 "expected %u%%-charged battery to have capacity flags 0x%02x, got 0x%02x\n",
54 ps.BatteryLifePercent, expected_capacity_flags, capacity_flags);
55 ok(ps.BatteryLifeTime <= ps.BatteryFullLifeTime,
56 "expected BatteryLifeTime %u to be less than or equal to BatteryFullLifeTime %u\n",
57 ps.BatteryLifeTime, ps.BatteryFullLifeTime);
58 if (ps.BatteryFlag & BATTERY_FLAG_CHARGING)
60 ok(ps.BatteryLifeTime == BATTERY_LIFE_UNKNOWN,
61 "expected BatteryLifeTime to be -1 when charging, got %u\n", ps.BatteryLifeTime);
62 ok(ps.BatteryFullLifeTime == BATTERY_LIFE_UNKNOWN,
63 "expected BatteryFullLifeTime to be -1 when charging, got %u\n", ps.BatteryFullLifeTime);
66 else
68 trace("no battery detected\n");
69 ok(ps.ACLineStatus == AC_LINE_ONLINE,
70 "expected ACLineStatus to be 1, got %u\n", ps.ACLineStatus);
71 ok(ps.BatteryLifePercent == BATTERY_PERCENTAGE_UNKNOWN,
72 "expected BatteryLifePercent to be -1, got %u\n", ps.BatteryLifePercent);
73 ok(ps.BatteryLifeTime == BATTERY_LIFE_UNKNOWN,
74 "expected BatteryLifeTime to be -1, got %u\n", ps.BatteryLifeTime);
75 ok(ps.BatteryFullLifeTime == BATTERY_LIFE_UNKNOWN,
76 "expected BatteryFullLifeTime to be -1, got %u\n", ps.BatteryFullLifeTime);
80 START_TEST(power)
82 test_GetSystemPowerStatus();