ReactOS 0.4.16-dev-2175-g9420ab7
power.c
Go to the documentation of this file.
1/*
2 * Unit tests for power management functions
3 *
4 * Copyright (c) 2019 Alex Henrie
5 *
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.
10 *
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.
15 *
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
19 */
20
21#include "wine/test.h"
22
24{
26 BOOL ret;
27 BYTE capacity_flags, expected_capacity_flags;
28
29 if (0) /* crashes */
31
32 memset(&ps, 0x23, sizeof(ps));
34 ok(ret == TRUE, "expected TRUE\n");
35
37 {
38 skip("GetSystemPowerStatus not implemented or not working\n");
39 return;
40 }
42 {
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);
56 "expected BatteryLifeTime %lu to be less than or equal to BatteryFullLifeTime %lu\n",
59 {
61 "expected BatteryLifeTime to be -1 when charging, got %lu\n", ps.BatteryLifeTime);
63 "expected BatteryFullLifeTime to be -1 when charging, got %lu\n", ps.BatteryFullLifeTime);
64 }
65 }
66 else
67 {
68 trace("no battery detected\n");
70 "expected ACLineStatus to be 1, got %u\n", ps.ACLineStatus);
72 "expected BatteryLifePercent to be -1, got %u\n", ps.BatteryLifePercent);
74 "expected BatteryLifeTime to be -1, got %lu\n", ps.BatteryLifeTime);
76 "expected BatteryFullLifeTime to be -1, got %lu\n", ps.BatteryFullLifeTime);
77 }
78}
79
81{
83}
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
BOOL WINAPI GetSystemPowerStatus(IN LPSYSTEM_POWER_STATUS PowerStatus)
Definition: power.c:27
return ret
Definition: mutex.c:146
unsigned int BOOL
Definition: ntddk_ex.h:94
float power
Definition: d3drm.c:3372
void test_GetSystemPowerStatus(void)
Definition: power.c:23
#define memset(x, y, z)
Definition: compat.h:39
DWORD BatteryFullLifeTime
Definition: winbase.h:915
#define BATTERY_FLAG_CHARGING
Definition: winbase.h:498
#define BATTERY_LIFE_UNKNOWN
Definition: winbase.h:502
#define BATTERY_FLAG_LOW
Definition: winbase.h:496
#define BATTERY_FLAG_NO_BATTERY
Definition: winbase.h:499
#define AC_LINE_ONLINE
Definition: winbase.h:492
#define BATTERY_FLAG_CRITICAL
Definition: winbase.h:497
#define BATTERY_FLAG_UNKNOWN
Definition: winbase.h:500
#define BATTERY_FLAG_HIGH
Definition: winbase.h:495
#define BATTERY_PERCENTAGE_UNKNOWN
Definition: winbase.h:501
unsigned char BYTE
Definition: xxhash.c:193