[SDK][NDK] Move SYSTEM_POWER_INFORMATION to ntpoapi.h (#869)
[reactos.git] / modules / rostests / apitests / powrprof / power.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Tests for powrprof.dll
5 * PROGRAMMER: Alex Wurzinger
6 * Johannes Anderwald
7 * Martin Rottensteiner
8 */
9
10 #include <apitest.h>
11
12 #include <stdio.h>
13 #include <stdarg.h>
14 #include <ntstatus.h>
15 #define WIN32_NO_STATUS
16 #include <winreg.h>
17 #include <ndk/potypes.h>
18 #include <powrprof.h>
19
20 unsigned int g_NumPwrSchemes = 0;
21 unsigned int g_NumPwrSchemesEnumerated = 0;
22 unsigned int g_ActivePwrScheme = 3;
23 unsigned int g_TempPwrScheme = 99;
24
25 POWER_POLICY g_PowerPolicy;
26
27 static const WCHAR szMachPowerPoliciesSubKey[] = { 'S', 'O', 'F', 'T', 'W', 'A', 'R',
28 'E', '\\', 'M', 'i', 'c', 'r', 'o', 's', 'o', 'f', 't', '\\', 'W', 'i', 'n', 'd',
29 'o', 'w', 's', '\\', 'C', 'u', 'r', 'r', 'e', 'n', 't', 'V', 'e', 'r', 's', 'i',
30 'o', 'n', '\\', 'C', 'o', 'n', 't', 'r', 'o', 'l', 's', ' ', 'F', 'o', 'l', 'd',
31 'e', 'r', '\\', 'P', 'o', 'w', 'e', 'r', 'C', 'f', 'g', '\\', 'P', 'o', 'w', 'e',
32 'r', 'P', 'o', 'l', 'i', 'c', 'i', 'e', 's', 0};
33
34 static const WCHAR szTempPwrScheme[] = { '9', '9', 0 };
35
36 void test_ValidatePowerPolicies_Next(PGLOBAL_POWER_POLICY pGPP_original,PPOWER_POLICY pPP_original);
37
38 void test_CallNtPowerInformation(void)
39 {
40 DWORD retval;
41 ADMINISTRATOR_POWER_POLICY apolicy;
42 ULONGLONG atime, ctime;
43 PROCESSOR_POWER_INFORMATION ppi, *pppi;
44 PROCESSOR_POWER_POLICY ppp;
45 SYSTEM_BATTERY_STATE sbs;
46 SYSTEM_POWER_CAPABILITIES spc;
47 SYSTEM_POWER_INFORMATION spi;
48 SYSTEM_POWER_POLICY spp;
49 HANDLE x=NULL;
50
51 /* AdministratorPowerPolicy tests */
52 retval = CallNtPowerInformation(AdministratorPowerPolicy, 0, 0, 0, 0);
53 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
54 retval = CallNtPowerInformation(AdministratorPowerPolicy, 0, 0, &apolicy, sizeof(ADMINISTRATOR_POWER_POLICY));
55 ok(retval == STATUS_SUCCESS, "function expected STATUS_SUCCESS but got %d\n", (UINT)retval);
56 retval = CallNtPowerInformation(AdministratorPowerPolicy, &apolicy, sizeof(ADMINISTRATOR_POWER_POLICY), 0, 0);
57 ok(retval != STATUS_PRIVILEGE_NOT_HELD, "Privileg not held!!!! more errors to expect\n");
58 ok(retval == STATUS_SUCCESS, "function expected STATUS_SUCCESS but got %d\n", (UINT)retval);
59
60 /* LastSleepTime tests */
61 retval = CallNtPowerInformation(LastSleepTime, 0, 0, 0, 0);
62 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
63 retval = CallNtPowerInformation(LastSleepTime, &atime, sizeof(sizeof(ULONGLONG)), 0, 0);
64 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
65 retval = CallNtPowerInformation(LastSleepTime, &atime, sizeof(ULONGLONG), &ctime, sizeof(ULONGLONG));
66 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
67 retval = CallNtPowerInformation(LastSleepTime, 0, 0, &atime, sizeof(ULONGLONG));
68 ok(retval == STATUS_SUCCESS, "function expected STATUS_SUCCESS but got %d\n",(UINT)retval);
69
70 /* LastWakeTime tests */
71 retval = CallNtPowerInformation(LastWakeTime, 0, 0, 0, 0);
72 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
73 retval = CallNtPowerInformation(LastWakeTime, &atime, sizeof(sizeof(ULONGLONG)), 0, 0);
74 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
75 retval = CallNtPowerInformation(LastWakeTime, &atime, sizeof(ULONGLONG), &ctime, sizeof(ULONGLONG));
76 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
77 retval = CallNtPowerInformation(LastWakeTime, 0, 0, &atime, sizeof(ULONGLONG));
78 ok(retval == STATUS_SUCCESS, "function expected STATUS_SUCCESS but got %d\n",(UINT)retval);
79
80 /* ProcessorInformation tests */
81 retval = CallNtPowerInformation(ProcessorInformation, 0, 0, 0, 0);
82 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
83 retval = CallNtPowerInformation(ProcessorInformation, 0, 0, &ppi, sizeof(PROCESSOR_POWER_INFORMATION));
84 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
85 retval = CallNtPowerInformation(ProcessorInformation, &ppi, sizeof(PROCESSOR_POWER_INFORMATION), 0, 0);
86 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
87 retval = CallNtPowerInformation(ProcessorInformation, &ppi, sizeof(PROCESSOR_POWER_INFORMATION), &ppi, sizeof(PROCESSOR_POWER_INFORMATION));
88
89 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
90 retval = CallNtPowerInformation(ProcessorInformation, 0, 0, &pppi, sizeof(PPROCESSOR_POWER_INFORMATION));
91 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
92 retval = CallNtPowerInformation(ProcessorInformation, &pppi, sizeof(PPROCESSOR_POWER_INFORMATION), 0, 0);
93 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
94 retval = CallNtPowerInformation(ProcessorInformation, &pppi, sizeof(PPROCESSOR_POWER_INFORMATION), &pppi, sizeof(PPROCESSOR_POWER_INFORMATION));
95 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
96
97 /* ProcessorPowerPolicyAc tests */
98 retval = CallNtPowerInformation(ProcessorPowerPolicyAc, 0, 0, 0, 0);
99 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
100 retval = CallNtPowerInformation(ProcessorPowerPolicyAc, 0, 0, &ppp, sizeof(PROCESSOR_POWER_POLICY));
101 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
102 retval = CallNtPowerInformation(ProcessorPowerPolicyAc, &ppp, sizeof(PROCESSOR_POWER_POLICY), 0, 0);
103 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
104 retval = CallNtPowerInformation(ProcessorPowerPolicyAc, &ppp, sizeof(PROCESSOR_POWER_POLICY), &ppp, sizeof(PROCESSOR_POWER_POLICY));
105 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
106
107 /* ProcessorPowerPolicyCurrent tests */
108 retval = CallNtPowerInformation(ProcessorPowerPolicyCurrent, 0, 0, 0, 0);
109 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
110 retval = CallNtPowerInformation(ProcessorPowerPolicyCurrent, 0, 0, &ppp, sizeof(PROCESSOR_POWER_POLICY));
111 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
112 retval = CallNtPowerInformation(ProcessorPowerPolicyCurrent, &ppp, sizeof(PROCESSOR_POWER_POLICY), 0, 0);
113 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
114 retval = CallNtPowerInformation(ProcessorPowerPolicyCurrent, &ppp, sizeof(PROCESSOR_POWER_POLICY), &ppp, sizeof(PROCESSOR_POWER_POLICY));
115 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
116
117 /* ProcessorPowerPolicyDc tests */
118 retval = CallNtPowerInformation(ProcessorPowerPolicyDc, 0, 0, 0, 0);
119 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
120 retval = CallNtPowerInformation(ProcessorPowerPolicyDc, 0, 0, &ppp, sizeof(PROCESSOR_POWER_POLICY));
121 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
122 retval = CallNtPowerInformation(ProcessorPowerPolicyDc, &ppp, sizeof(PROCESSOR_POWER_POLICY), 0, 0);
123 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
124 retval = CallNtPowerInformation(ProcessorPowerPolicyDc, &ppp, sizeof(PROCESSOR_POWER_POLICY), &ppp, sizeof(PROCESSOR_POWER_POLICY));
125 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
126
127 /* SystemBatteryState tests */
128 retval = CallNtPowerInformation(SystemBatteryState, 0, 0, 0, 0);
129 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
130 retval = CallNtPowerInformation(SystemBatteryState, 0, 0, &sbs, sizeof(SYSTEM_BATTERY_STATE));
131 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
132 retval = CallNtPowerInformation(SystemBatteryState, &sbs, sizeof(SYSTEM_BATTERY_STATE), 0, 0);
133 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
134 retval = CallNtPowerInformation(SystemBatteryState, &sbs, sizeof(SYSTEM_BATTERY_STATE), &sbs, sizeof(SYSTEM_BATTERY_STATE));
135 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
136
137 /* SystemExecutionState tests */
138 retval = CallNtPowerInformation(SystemExecutionState, 0, 0, 0, 0);
139 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
140
141 /* SystemPowerCapabilities tests */
142 retval = CallNtPowerInformation(SystemPowerCapabilities, 0, 0, 0, 0);
143 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
144 retval = CallNtPowerInformation(SystemPowerCapabilities, 0, 0, &spc, sizeof(SYSTEM_POWER_CAPABILITIES));
145 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
146 retval = CallNtPowerInformation(SystemPowerCapabilities, &spc, sizeof(SYSTEM_POWER_CAPABILITIES), 0, 0);
147 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
148 retval = CallNtPowerInformation(SystemPowerCapabilities, &spc, sizeof(SYSTEM_POWER_CAPABILITIES), &spc, sizeof(SYSTEM_POWER_CAPABILITIES));
149 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
150
151 /* SystemPowerInformation tests */
152 retval = CallNtPowerInformation(SystemPowerInformation, 0, 0, 0, 0);
153 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
154 retval = CallNtPowerInformation(SystemPowerInformation, 0, 0, &spi, sizeof(SYSTEM_POWER_INFORMATION));
155 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
156 retval = CallNtPowerInformation(SystemPowerInformation, &spi, sizeof(SYSTEM_POWER_INFORMATION), 0, 0);
157 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
158 retval = CallNtPowerInformation(SystemPowerInformation, &spi, sizeof(SYSTEM_POWER_INFORMATION), &spi, sizeof(SYSTEM_POWER_INFORMATION));
159 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
160 retval = CallNtPowerInformation(SystemPowerInformation, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
161 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
162 retval = CallNtPowerInformation(SystemPowerInformation, &spp, sizeof(SYSTEM_POWER_POLICY), &spi, sizeof(SYSTEM_POWER_INFORMATION));
163 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
164
165 /* SystemPowerPolicyAc tests */
166 retval = CallNtPowerInformation(SystemPowerPolicyAc, 0, 0, 0, 0);
167 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
168 retval = CallNtPowerInformation(SystemPowerPolicyAc, 0, 0, &spp, sizeof(SYSTEM_POWER_POLICY));
169 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
170 retval = CallNtPowerInformation(SystemPowerPolicyAc, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
171 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
172 retval = CallNtPowerInformation(SystemPowerPolicyAc, &spp, sizeof(SYSTEM_POWER_POLICY), &spp, sizeof(SYSTEM_POWER_POLICY));
173 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
174
175 /* SystemPowerPolicyCurrent tests */
176 retval = CallNtPowerInformation(SystemPowerPolicyCurrent, 0, 0, 0, 0);
177 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
178 retval = CallNtPowerInformation(SystemPowerPolicyCurrent, 0, 0, &spp, sizeof(SYSTEM_POWER_POLICY));
179 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
180 retval = CallNtPowerInformation(SystemPowerPolicyCurrent, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
181 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
182 retval = CallNtPowerInformation(SystemPowerPolicyCurrent, &spp, sizeof(SYSTEM_POWER_POLICY), &spp, sizeof(SYSTEM_POWER_POLICY));
183 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
184
185 /* SystemPowerPolicyDc tests */
186 retval = CallNtPowerInformation(SystemPowerPolicyDc, 0, 0, 0, 0);
187 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
188 retval = CallNtPowerInformation(SystemPowerPolicyDc, 0, 0, &spp, sizeof(SYSTEM_POWER_POLICY));
189 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
190 retval = CallNtPowerInformation(SystemPowerPolicyDc, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
191 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
192 retval = CallNtPowerInformation(SystemPowerPolicyDc, &spp, sizeof(SYSTEM_POWER_POLICY), &spp, sizeof(SYSTEM_POWER_POLICY));
193 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
194
195 /* SystemReserveHiberFile tests */
196 /*
197 retval = CallNtPowerInformation(SystemReserveHiberFile, 0, 0, 0, 0);
198 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %ld\n", retval);
199 bln=TRUE;
200 retval = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), 0, 0);
201 ok(retval == STATUS_DISK_FULL, "function result wrong expected STATUS_DISK_FULL but got %ld\n", nret);
202 bln=FALSE;
203 retval = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), 0, 0);
204 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %ld\n", nret);
205
206 bln2=TRUE;
207 nret = CallNtPowerInformation(SystemReserveHiberFile, 0, 0, &bln2, sizeof(bln2));
208 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
209 bln2=FALSE;
210 nret = CallNtPowerInformation(SystemReserveHiberFile, 0, 0, &bln2, sizeof(bln2));
211 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
212
213 bln=TRUE;
214 bln2=TRUE;
215 nret = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), &bln2, sizeof(bln2));
216 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
217 bln2=FALSE;
218 nret = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), &bln2, sizeof(bln2));
219 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
220 bln=FALSE;
221 bln2=TRUE;
222 nret = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), &bln2, sizeof(bln2));
223 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
224 bln2=FALSE;
225 nret = CallNtPowerInformation(SystemReserveHiberFile, &bln, sizeof(bln), &bln2, sizeof(bln2));
226 ok(nret == STATUS_DATATYPE_MISALIGNMENT, "function result wrong expected STATUS_DATATYPE_MISALIGNMENT but got %ld\n", nret);
227 */
228
229 /* VerifyProcessorPowerPolicyAc tests */
230 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyAc, 0, 0, 0, 0);
231 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
232 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyAc, 0, 0, &ppp, sizeof(PROCESSOR_POWER_POLICY));
233 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
234 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyAc, &ppp, sizeof(PROCESSOR_POWER_POLICY), 0, 0);
235 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
236 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyAc, &ppp, sizeof(PROCESSOR_POWER_POLICY), &ppp, sizeof(PROCESSOR_POWER_POLICY));
237 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
238
239 /* VerifyProcessorPowerPolicyDc tests */
240 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyDc, 0, 0, 0, 0);
241 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
242 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyDc, 0, 0, &ppp, sizeof(PROCESSOR_POWER_POLICY));
243 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
244 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyDc, &ppp, sizeof(PROCESSOR_POWER_POLICY), 0, 0);
245 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
246 retval = CallNtPowerInformation(VerifyProcessorPowerPolicyDc, &ppp, sizeof(PROCESSOR_POWER_POLICY), &ppp, sizeof(PROCESSOR_POWER_POLICY));
247 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
248
249 /* VerifySystemPolicyAc tests */
250 retval = CallNtPowerInformation(VerifySystemPolicyAc, 0, 0, 0, 0);
251 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
252 retval = CallNtPowerInformation(VerifySystemPolicyAc, 0, 0, &spp, sizeof(SYSTEM_POWER_POLICY));
253 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
254 retval = CallNtPowerInformation(VerifySystemPolicyAc, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
255 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
256 retval = CallNtPowerInformation(VerifySystemPolicyAc, &spp, sizeof(SYSTEM_POWER_POLICY), &spp, sizeof(SYSTEM_POWER_POLICY));
257 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
258
259 /* VerifySystemPolicyDc tests */
260 retval = CallNtPowerInformation(VerifySystemPolicyDc, 0, 0, 0, 0);
261 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
262 retval = CallNtPowerInformation(VerifySystemPolicyDc, 0, 0, &spp, sizeof(SYSTEM_POWER_POLICY));
263 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
264 retval = CallNtPowerInformation(VerifySystemPolicyDc, &spp, sizeof(SYSTEM_POWER_POLICY), 0, 0);
265 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
266 retval = CallNtPowerInformation(VerifySystemPolicyDc, &spp, sizeof(SYSTEM_POWER_POLICY), &spp, sizeof(SYSTEM_POWER_POLICY));
267 ok(retval == STATUS_SUCCESS, "function result wrong expected STATUS_SUCCESS but got %d\n", (UINT)retval);
268
269 /* SystemPowerStateHandler tests */
270 retval = CallNtPowerInformation(SystemPowerStateHandler, 0, 0, 0, 0);
271 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
272 retval = CallNtPowerInformation(SystemPowerStateHandler, 0, 0, x, sizeof(HANDLE));
273 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
274
275 /* ProcessorStateHandler tests */
276 retval = CallNtPowerInformation(ProcessorStateHandler, 0, 0, 0, 0);
277 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
278 retval = CallNtPowerInformation(ProcessorStateHandler, 0, 0, x, sizeof(HANDLE));
279 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
280
281 /* ProcessorStateHandler2 tests */
282 retval = CallNtPowerInformation(ProcessorStateHandler2, 0, 0, 0, 0);
283 ok(retval == STATUS_ACCESS_DENIED, "function result wrong expected STATUS_ACCESS_DENIED but got %d\n", (UINT)retval);
284 retval = CallNtPowerInformation(ProcessorStateHandler2, 0, 0, x, sizeof(HANDLE));
285 ok(retval == STATUS_ACCESS_DENIED, "function result wrong expected STATUS_ACCESS_DENIED but got %d\n", (UINT)retval);
286
287 /* SystemPowerStateNotifyHandler tests */
288 retval = CallNtPowerInformation(SystemPowerStateNotifyHandler, 0, 0, 0, 0);
289 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
290 retval = CallNtPowerInformation(SystemPowerStateNotifyHandler, 0, 0, x, sizeof(HANDLE));
291 ok(retval == STATUS_INVALID_PARAMETER, "function result wrong expected STATUS_INVALID_PARAMETER but got %d\n", (UINT)retval);
292
293 }
294
295 /*
296 @implemented
297 */
298 void test_CanUserWritePwrScheme(void)
299 {
300 DWORD error, retval;
301
302 retval = CanUserWritePwrScheme();
303
304 error = GetLastError();
305
306 if (retval)
307 ok(retval, "function failed?");
308 else
309 ok(error == ERROR_ACCESS_DENIED, "function last error wrong expected ERROR_ACCESS_DENIED but got %d\n", (UINT)error);
310
311 }
312 BOOLEAN CALLBACK test_callback_EnumPwrScheme(UINT uiIndex, DWORD dwName, LPWSTR sName, DWORD dwDesc,
313 LPWSTR sDesc, PPOWER_POLICY pp,LPARAM lParam )
314 {
315 ok(uiIndex == g_NumPwrSchemes, "expected power scheme index of %d but got %d\n", g_NumPwrSchemes, uiIndex);
316 g_NumPwrSchemes++;
317
318 ok(lParam == 0xDEADBEEF, "expected function lParam to be 0xDEADBEEF but got %d\n", (UINT)lParam);
319
320 return TRUE;
321 }
322
323 BOOLEAN CALLBACK test_callback_stop_EnumPwrScheme(UINT uiIndex, DWORD dwName, LPWSTR sName, DWORD dwDesc,
324 LPWSTR sDesc, PPOWER_POLICY pp,LPARAM lParam )
325 {
326 ok((!uiIndex || g_NumPwrSchemesEnumerated + 1 == uiIndex), "expected power scheme %d but got %d\n",g_NumPwrSchemesEnumerated+1, uiIndex);
327 g_NumPwrSchemesEnumerated = uiIndex;
328
329 ok(uiIndex <= (UINT)lParam, "enumeration should have already been stopped at index %d current index %d\n", (UINT)lParam, uiIndex);
330 if (uiIndex == (UINT)lParam)
331 return FALSE;
332 else
333 return TRUE;
334 }
335
336 void test_DeletePwrScheme(void)
337 {
338 DWORD retval;
339 HKEY hSubKey = NULL;
340
341
342 /*
343 * try inexistant profile number, should fail
344 */
345
346 retval = DeletePwrScheme(0xFFFFFFFF);
347 ok(!retval, "function should have failed error %x\n",(UINT)GetLastError());
348
349 /*
350 * delete active power scheme, should fail
351 */
352
353 retval = GetActivePwrScheme(&g_ActivePwrScheme);
354 ok(retval, "function was expected to succeed, error %x\n",(UINT)GetLastError());
355
356 retval = DeletePwrScheme(g_ActivePwrScheme);
357 ok(!retval, "function should have failed\n");
358 ok(GetLastError() == ERROR_ACCESS_DENIED, "function should have failed with ERROR_ACCESS_DENIED but got %x\n", (UINT)GetLastError());
359
360 /*
361 * delete a temporarly created power scheme
362 */
363 retval = DeletePwrScheme(g_TempPwrScheme);
364 ok(retval, "function should have succeeded\n");
365
366 /*
367 * clean up, delete illegal entry, witch was created for this test
368 */
369
370 if (RegOpenKeyW(HKEY_LOCAL_MACHINE, szMachPowerPoliciesSubKey, &hSubKey) == ERROR_SUCCESS)
371 {
372 if (RegDeleteKeyW(hSubKey, szTempPwrScheme) != STATUS_SUCCESS)
373 printf("#1 failed to delete subkey %i (testentry)\n", g_TempPwrScheme);
374 RegCloseKey(hSubKey);
375 }
376
377 }
378
379 void test_EnumPwrSchemes(void)
380 {
381 BOOLEAN retval;
382
383 /*
384 * test EnumPwrScheme with null pointer callback
385 */
386
387 retval = EnumPwrSchemes(0, 0);
388 ok(!retval, "function was expected to fail\n");
389 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER but got %x\n",(UINT)GetLastError());
390
391 /*
392 * enumerate power schemes, should succeed
393 */
394
395 retval = EnumPwrSchemes(test_callback_EnumPwrScheme, 0xDEADBEEF);
396 ok(retval, "function was expected to succeed %d\n",retval);
397 ok(g_NumPwrSchemes, "Warning: no power schemes available\n");
398
399 /*
400 * stop enumeration after first power scheme
401 */
402
403 retval = EnumPwrSchemes(test_callback_stop_EnumPwrScheme, (LPARAM)0);
404 ok(!retval, "function was expected to false\n");
405
406 /*
407 * enumerate half of all avalailble profiles
408 */
409
410 g_NumPwrSchemesEnumerated = 0;
411 retval = EnumPwrSchemes(test_callback_stop_EnumPwrScheme, (LPARAM)g_NumPwrSchemes / 2);
412 ok(retval, "function was expected to succeed but got %i\n", (UINT)retval);
413 ok(g_NumPwrSchemesEnumerated == g_NumPwrSchemes / 2, "function did not enumerate requested num of profiles %d enumerated %d\n", g_NumPwrSchemes / 2, g_NumPwrSchemesEnumerated);
414
415
416 }
417
418 void test_GetSetActivePwrScheme(void)
419 {
420 DWORD retval;
421 UINT current_scheme = 2;
422 UINT temp_scheme = 0;
423
424 /*
425 * read active power scheme
426 */
427
428 retval = GetActivePwrScheme(&g_ActivePwrScheme);
429
430 ok(retval, "function was expected to succeed, error %x\n",(UINT)GetLastError());
431 ok(retval <= g_NumPwrSchemes, "expected index lower as power scheme count %d but got %d\n", g_NumPwrSchemes, g_ActivePwrScheme);
432
433 /*
434 * sets active power scheme to inexistant profile
435 * -> corrupts power scheme enumeration on Windows XP SP2
436 */
437 //corrupts registry
438 //retval = SetActivePwrScheme(0xFFFFFFFF, 0, 0);
439 //ok(!retval, "function was expected to fail");
440 //current_scheme = min(active_scheme+1, g_NumPwrSchemes-1);
441
442 /*
443 * sets the active power scheme to profile with index 0
444 */
445
446 retval = SetActivePwrScheme(current_scheme, 0, 0);
447 ok(retval, "function was expected to succeed, error %x\n",(UINT)GetLastError());
448
449 /*
450 * read back the active power scheme
451 */
452
453 retval = GetActivePwrScheme(&temp_scheme);
454 ok(retval, "function was expected to succeed, error %x\n",(UINT)GetLastError());
455 ok(temp_scheme == current_scheme, "expected %d but got %d\n", (UINT)current_scheme, (UINT)temp_scheme);
456
457 /*
458 * restore previous active power scheme
459 */
460
461 retval = SetActivePwrScheme(g_ActivePwrScheme, 0, 0);
462 ok(retval, "Warning: failed to restore old active power scheme %d\n", (UINT)g_ActivePwrScheme);
463 }
464
465 void test_GetCurrentPowerPolicies(void)
466 {
467 GLOBAL_POWER_POLICY gpp;
468 POWER_POLICY pp;
469 BOOLEAN ret;
470 UINT current_scheme = 2;
471
472 g_ActivePwrScheme=3;
473 ret = GetActivePwrScheme(&g_ActivePwrScheme);
474
475 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
476 ret = SetActivePwrScheme(0, &gpp, 0);
477
478 ok(!ret, "function was expected to fail\n");
479
480 ret = SetActivePwrScheme(0, 0, &pp);
481 ok(!ret, "function was expected to fail\n");
482
483 ret = SetActivePwrScheme(0, &gpp, &pp);
484 ok(!ret, "function was expected to fail\n");
485
486 ret = SetActivePwrScheme(current_scheme, &gpp, 0);
487 ok(!ret, "function was expected to fail\n");
488
489 ret = SetActivePwrScheme(current_scheme, 0, &pp);
490 ok(!ret, "function was expected to fail\n");
491
492 ret = SetActivePwrScheme(current_scheme, &gpp, &pp);
493 ok(!ret, "function was expected to fail\n");
494
495 ret = SetActivePwrScheme(g_ActivePwrScheme, 0, 0);
496 ok(ret, "Warning: failed to restore old active power scheme %d\n", (UINT)g_ActivePwrScheme);
497
498 ret = GetCurrentPowerPolicies(0,0);
499 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
500
501 ret = GetCurrentPowerPolicies(&gpp,0);
502 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
503
504 ret = GetCurrentPowerPolicies(0,&pp);
505 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
506
507 ret = GetCurrentPowerPolicies(&gpp,&pp);
508 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
509 ok(gpp.mach.Revision == 1,"Global Mach Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
510 ok(gpp.user.Revision == 1,"Global User Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
511 ok(pp.mach.Revision == 1,"Mach Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
512 ok(pp.user.Revision == 1,"User Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
513
514
515 ret = GetActivePwrScheme(&g_ActivePwrScheme);
516 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
517
518 ret = SetActivePwrScheme(0, &gpp, 0);
519 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
520
521 ret = SetActivePwrScheme(0, 0, &pp);
522 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
523
524 ret = SetActivePwrScheme(0, &gpp, &pp);
525 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
526
527 ret = SetActivePwrScheme(current_scheme, &gpp, 0);
528 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
529
530 ret = SetActivePwrScheme(current_scheme, 0, &pp);
531 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
532
533 ret = SetActivePwrScheme(current_scheme, &gpp, &pp);
534 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
535
536 ret = SetActivePwrScheme(g_ActivePwrScheme, 0, 0);
537 ok(ret, "Warning: failed to restore old active power scheme %d\n", (UINT)g_ActivePwrScheme);
538
539 }
540
541 void test_GetPwrCapabilities(void)
542 {
543 SYSTEM_POWER_CAPABILITIES spc;
544 BOOLEAN ret;
545
546 ret = GetPwrCapabilities(0);
547 ok(!ret, "function was expected to fail\n");
548 if (!ret)
549 {
550 ok(GetLastError() == ERROR_INVALID_PARAMETER,"function was expectet to return ERROR_INVALID_PARAMETER, but returns: %x\n",(UINT)GetLastError());
551 }
552 ret = GetPwrCapabilities(&spc);
553 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
554 }
555
556 void test_GetPwrDiskSpindownRange(void)
557 {
558 DWORD retval;
559 UINT min = 0;
560 UINT max = 0;
561
562 /*
563 * invalid parameter checks
564 */
565
566 retval = GetPwrDiskSpindownRange(NULL, NULL);
567 ok(!retval, "function was expected to fail\n");
568 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());
569
570 retval = GetPwrDiskSpindownRange(&max, NULL);
571 ok(!retval, "function was expected to fail\n");
572 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());
573
574 retval = GetPwrDiskSpindownRange(NULL, &min);
575 ok(!retval, "function was expected to fail\n");
576 ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected error ERROR_INVALID_PARAMETER but got %x\n", (UINT)GetLastError());
577
578 /*
579 * read disk spindown range
580 */
581
582 retval = GetPwrDiskSpindownRange(&max, &min);
583 ok(retval, "function was expected to succeed error %x\n",(UINT)GetLastError());
584 ok(min <= max, "range mismatch min %d max %d\n",min, max);
585 }
586
587 void test_IsAdminOverrideActive(void)
588 {
589 ADMINISTRATOR_POWER_POLICY app;
590 BOOLEAN ret;
591
592 ret = IsAdminOverrideActive(0);
593 ok(!ret, "function was expected to fail\n");
594
595 ret = IsAdminOverrideActive(&app);
596 ok(!ret, "function was expected to fail\n");
597
598 app.MinSleep = 0;
599 app.MaxSleep = 0;
600 app.MinVideoTimeout = 0;
601 app.MaxVideoTimeout = 0;
602 app.MinSpindownTimeout = 0;
603 app.MaxSpindownTimeout = 0;
604
605 ret = IsAdminOverrideActive(&app);
606 ok(!ret, "function was expected to fail\n");
607
608 app.MinSleep = 1;
609 app.MaxSleep = 2;
610 app.MinVideoTimeout = 3;
611 app.MaxVideoTimeout = 4;
612 app.MinSpindownTimeout = 5;
613 app.MaxSpindownTimeout = 6;
614
615 ret = IsAdminOverrideActive(&app);
616 ok(!ret, "function was expected to fail\n");
617
618 }
619
620 void test_IsPwrHibernateAllowed(void)
621 {
622 /*
623 BOOLEAN ret;
624
625 ret = IsPwrHibernateAllowed();
626 ok(!ret, "function was expected to fail\n");
627 */
628 }
629
630 void test_IsPwrShutdownAllowed(void)
631 {
632 /*
633 BOOLEAN ret;
634
635 ret = IsPwrShutdownAllowed();
636 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
637 */
638 }
639
640 void test_IsPwrSuspendAllowed(void)
641 {
642 /*
643 BOOLEAN ret;
644
645 ret = IsPwrSuspendAllowed();
646 ok(ret, "function was expected to succed, error %x\n",(UINT)GetLastError());
647 */
648 }
649
650 void test_ReadGlobalPwrPolicy(void)
651 {
652 GLOBAL_POWER_POLICY gpp;
653 BOOLEAN ret;
654
655 ret = ReadGlobalPwrPolicy(&gpp);
656 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
657 ok(gpp.mach.Revision == 1,"Global Mach Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
658 ok(gpp.user.Revision == 1,"Global User Revision was expected to be 1 got %i\n",(UINT)gpp.mach.Revision);
659
660
661
662 }
663
664 void test_ReadProcessorPwrScheme(void)
665 {
666 MACHINE_PROCESSOR_POWER_POLICY mppp;
667 BOOLEAN ret;
668 UINT i = 0;
669 DWORD err;
670
671 do
672 {
673 RtlZeroMemory(&mppp, sizeof(MACHINE_PROCESSOR_POWER_POLICY));
674 ret = ReadProcessorPwrScheme(i,&mppp);
675 if (ret)
676 {
677 ok(mppp.Revision == 1,"Main Revision was expected to be 1 got %i\n",(UINT)mppp.Revision);
678 ok(mppp.ProcessorPolicyAc.Revision == 1,"PowerAC Revision was expected to be 1 got %i\n",(UINT)mppp.ProcessorPolicyAc.Revision);
679 ok(mppp.ProcessorPolicyDc.Revision == 1,"PowerDC Revision was expected to be 1 got %i\n",(UINT)mppp.ProcessorPolicyDc.Revision);
680 }
681 else
682 {
683 err = GetLastError();
684 ok(err == 0,"Failed Error %x\n",(UINT)err);
685 return;
686 }
687 i++;
688 if (i == g_NumPwrSchemes)
689 return;
690 } while (TRUE);
691
692 }
693
694 void test_ReadPwrScheme(void)
695 {
696 DWORD retval;
697
698 /*
699 * read power scheme with null pointer -> crashs on Windows XP SP2
700 */
701 //retval = ReadPwrScheme(0, NULL);
702 //ok(!retval, "function was expected to fail\n");
703 //ok(GetLastError() == STATUS_INVALID_PARAMETER, "expected error ... but got %x\n", GetLastError());
704
705 /*
706 * read a power scheme with an invalid index, leads to the creation of the key
707 * -> corrupts power scheme enumeration
708 */
709 //retval = ReadPwrScheme(0xFFFFFFFF, &powerPolicy);
710 //ok(!retval, "function was expected to fail\n");
711 //ok(GetLastError() == ERROR_ACCESS_DENIED, "expected error ERROR_ACCESS_DENIED but got %x\n", GetLastError());
712
713 /*
714 * read current active power scheme
715 */
716
717 retval = ReadPwrScheme(g_ActivePwrScheme, &g_PowerPolicy);
718 ok(retval, "function was expected to succeed error %x\n",(UINT)GetLastError());
719
720 }
721
722 void test_SetSuspendState(void)
723 {
724 // SetSuspendState(FALSE,FALSE,FALSE)
725 }
726
727
728 BOOLEAN globalcompare(GLOBAL_POWER_POLICY gpp, GLOBAL_POWER_POLICY gpp_compare)
729 {
730 //return TRUE;
731 int i,j;
732 BOOLEAN ret;
733
734 ret = TRUE;
735 if (gpp.mach.BroadcastCapacityResolution != gpp_compare.mach.BroadcastCapacityResolution)
736 {
737 printf("mach.BroadcastCapacityResolution failed %lu != %lu\n",gpp.mach.BroadcastCapacityResolution,gpp_compare.mach.BroadcastCapacityResolution);
738 ret = FALSE;
739 }
740 if (gpp.mach.LidOpenWakeAc != gpp_compare.mach.LidOpenWakeAc)
741 {
742 printf("mach.LidOpenWakeAc failed %i != %i\n",gpp.mach.LidOpenWakeAc,gpp_compare.mach.LidOpenWakeAc);
743 ret = FALSE;
744 }
745 if (gpp.mach.LidOpenWakeDc != gpp_compare.mach.LidOpenWakeDc)
746 {
747 printf("mach.LidOpenWakeDc failed %i != %i\n",gpp.mach.LidOpenWakeDc,gpp_compare.mach.LidOpenWakeDc);
748 ret = FALSE;
749 }
750 if (gpp.mach.Revision != gpp_compare.mach.Revision)
751 {
752 printf("mach.Revision failed %lu != %lu\n",gpp.mach.Revision,gpp_compare.mach.Revision);
753 ret = FALSE;
754 }
755
756 if (gpp.user.PowerButtonAc.Action != gpp_compare.user.PowerButtonAc.Action)
757 {
758 printf("user.PowerButtonAc.Action failed %i != %i\n",gpp.user.PowerButtonAc.Action,gpp_compare.user.PowerButtonAc.Action);
759 ret = FALSE;
760 }
761 if (gpp.user.PowerButtonAc.EventCode != gpp_compare.user.PowerButtonAc.EventCode)
762 {
763 printf("user.PowerButtonAc.EventCode failed %lu != %lu\n",gpp.user.PowerButtonAc.EventCode,gpp_compare.user.PowerButtonAc.EventCode);
764 ret = FALSE;
765 }
766 if (gpp.user.PowerButtonAc.Flags != gpp_compare.user.PowerButtonAc.Flags)
767 {
768 printf("user.PowerButtonAc.Flags failed %lu != %lu\n",gpp.user.PowerButtonAc.Flags,gpp_compare.user.PowerButtonAc.Flags);
769 ret = FALSE;
770 }
771 if (gpp.user.PowerButtonDc.Action != gpp_compare.user.PowerButtonDc.Action)
772 {
773 printf("user.PowerButtonDc.Action failed %i != %i\n",gpp.user.PowerButtonDc.Action,gpp_compare.user.PowerButtonDc.Action);
774 ret = FALSE;
775 }
776 if (gpp.user.PowerButtonDc.EventCode != gpp_compare.user.PowerButtonDc.EventCode)
777 {
778 printf("user.PowerButtonDc.EventCode failed %lu != %lu\n",gpp.user.PowerButtonDc.EventCode,gpp_compare.user.PowerButtonDc.EventCode);
779 ret = FALSE;
780 }
781 if (gpp.user.PowerButtonDc.Flags != gpp_compare.user.PowerButtonDc.Flags)
782 {
783 printf("user.PowerButtonDc.Flags failed %lu != %lu\n",gpp.user.PowerButtonDc.Flags,gpp_compare.user.PowerButtonDc.Flags);
784 ret = FALSE;
785 }
786 if (gpp.user.SleepButtonAc.Action != gpp_compare.user.SleepButtonAc.Action)
787 {
788 printf("user.SleepButtonAc.Action failed %i != %i\n",gpp.user.SleepButtonAc.Action,gpp_compare.user.SleepButtonAc.Action);
789 ret = FALSE;
790 }
791 if (gpp.user.SleepButtonAc.EventCode != gpp_compare.user.SleepButtonAc.EventCode)
792 {
793 printf("user.SleepButtonAc.EventCode failed %lu != %lu\n",gpp.user.SleepButtonAc.EventCode,gpp_compare.user.SleepButtonAc.EventCode);
794 ret = FALSE;
795 }
796 if (gpp.user.SleepButtonAc.Flags != gpp_compare.user.SleepButtonAc.Flags)
797 {
798 printf("user.SleepButtonAc.Flags failed %lu != %lu\n",gpp.user.SleepButtonAc.Flags,gpp_compare.user.SleepButtonAc.Flags);
799 ret = FALSE;
800 }
801 if (gpp.user.SleepButtonDc.Action != gpp_compare.user.SleepButtonDc.Action)
802 {
803 printf("user.SleepButtonDc.Action failed %i != %i\n",gpp.user.SleepButtonDc.Action,gpp_compare.user.SleepButtonDc.Action);
804 ret = FALSE;
805 }
806 if (gpp.user.SleepButtonDc.EventCode != gpp_compare.user.SleepButtonDc.EventCode)
807 {
808 printf("user.SleepButtonDc.EventCode failed %lu != %lu\n",gpp.user.SleepButtonDc.EventCode,gpp_compare.user.SleepButtonDc.EventCode);
809 ret = FALSE;
810 }
811 if (gpp.user.SleepButtonDc.Flags != gpp_compare.user.SleepButtonDc.Flags)
812 {
813 printf("user.SleepButtonDc.Flags failed %lu != %lu\n",gpp.user.SleepButtonDc.Flags,gpp_compare.user.SleepButtonDc.Flags);
814 ret = FALSE;
815 }
816 if (gpp.user.LidCloseAc.Action != gpp_compare.user.LidCloseAc.Action)
817 {
818 printf("user.LidCloseAc.Action failed %i != %i\n",gpp.user.LidCloseAc.Action,gpp_compare.user.LidCloseAc.Action);
819 ret = FALSE;
820 }
821 if (gpp.user.LidCloseAc.EventCode != gpp_compare.user.LidCloseAc.EventCode)
822 {
823 printf("user.LidCloseAc.EventCode failed %lu != %lu\n",gpp.user.LidCloseAc.EventCode,gpp_compare.user.LidCloseAc.EventCode);
824 ret = FALSE;
825 }
826 if (gpp.user.LidCloseAc.Flags != gpp_compare.user.LidCloseAc.Flags)
827 {
828 printf("user.LidCloseAc.Flags failed %lu != %lu\n",gpp.user.LidCloseAc.Flags,gpp_compare.user.LidCloseAc.Flags);
829 ret = FALSE;
830 }
831 if (gpp.user.LidCloseDc.Action != gpp_compare.user.LidCloseDc.Action)
832 {
833 printf("user.LidCloseDc.Action failed %i != %i\n",gpp.user.LidCloseDc.Action,gpp_compare.user.LidCloseDc.Action);
834 ret = FALSE;
835 }
836 if (gpp.user.LidCloseDc.EventCode != gpp_compare.user.LidCloseDc.EventCode)
837 {
838 printf("user.LidCloseDc.EventCode failed %lu != %lu\n",gpp.user.LidCloseDc.EventCode,gpp_compare.user.LidCloseDc.EventCode);
839 ret = FALSE;
840 }
841 if (gpp.user.LidCloseDc.Flags != gpp_compare.user.LidCloseDc.Flags)
842 {
843 printf("user.LidCloseDc.Flags failed %lu != %lu\n",gpp.user.LidCloseDc.Flags,gpp_compare.user.LidCloseDc.Flags);
844 ret = FALSE;
845 }
846
847 for(i=0;i<NUM_DISCHARGE_POLICIES;i++)
848 {
849 if (gpp.user.DischargePolicy[i].Enable != gpp_compare.user.DischargePolicy[i].Enable)
850 {
851 printf("user.DischargePolicy(%i).Enable failed %i != %i\n",i, gpp.user.DischargePolicy[i].Enable,gpp_compare.user.DischargePolicy[i].Enable);
852 ret = FALSE;
853 }
854 for (j=0;j<3;j++)
855 {
856 if (gpp.user.DischargePolicy[i].Spare[j] != gpp_compare.user.DischargePolicy[i].Spare[j])
857 {
858 printf("user.DischargePolicy(%i).Spare[j] failed %i != %i\n",i, gpp.user.DischargePolicy[i].Spare[j],gpp_compare.user.DischargePolicy[i].Spare[j]);
859 ret = FALSE;
860 }
861 }
862 if (gpp.user.DischargePolicy[i].BatteryLevel != gpp_compare.user.DischargePolicy[i].BatteryLevel)
863 {
864 printf("user.DischargePolicy(%i).BatteryLevel failed %lu != %lu\n",i, gpp.user.DischargePolicy[i].BatteryLevel,gpp_compare.user.DischargePolicy[i].BatteryLevel);
865 ret = FALSE;
866 }
867 if (gpp.user.DischargePolicy[i].PowerPolicy.Action != gpp_compare.user.DischargePolicy[i].PowerPolicy.Action)
868 {
869 printf("user.DischargePolicy(%i).PowerPolicy.Action failed %i != %i\n",i, gpp.user.DischargePolicy[i].PowerPolicy.Action,gpp_compare.user.DischargePolicy[i].PowerPolicy.Action);
870 ret = FALSE;
871 }
872 if (gpp.user.DischargePolicy[i].PowerPolicy.Flags != gpp_compare.user.DischargePolicy[i].PowerPolicy.Flags)
873 {
874 printf("user.DischargePolicy(%i).PowerPolicy.Flags failed %lu != %lu\n",i, gpp.user.DischargePolicy[i].PowerPolicy.Flags,gpp_compare.user.DischargePolicy[i].PowerPolicy.Flags);
875 ret = FALSE;
876 }
877 if (gpp.user.DischargePolicy[i].PowerPolicy.EventCode != gpp_compare.user.DischargePolicy[i].PowerPolicy.EventCode)
878 {
879 printf("user.DischargePolicy(%i).PowerPolicy.EventCode failed %lu != %lu\n",i, gpp.user.DischargePolicy[i].PowerPolicy.EventCode,gpp_compare.user.DischargePolicy[i].PowerPolicy.EventCode);
880 ret = FALSE;
881 }
882 if (gpp.user.DischargePolicy[i].MinSystemState != gpp_compare.user.DischargePolicy[i].MinSystemState)
883 {
884 printf("user.DischargePolicy(%i).MinSystemState failed %i != %i\n",i, gpp.user.DischargePolicy[i].MinSystemState,gpp_compare.user.DischargePolicy[i].MinSystemState);
885 ret = FALSE;
886 }
887 }
888 if (gpp.user.GlobalFlags != gpp_compare.user.GlobalFlags)
889 {
890 printf("user.GlobalFlags failed %lu != %lu\n",gpp.user.GlobalFlags,gpp_compare.user.GlobalFlags);
891 ret = FALSE;
892 }
893 if (gpp.user.Revision != gpp_compare.user.Revision)
894 {
895 printf("user.Revision failed %lu != %lu\n",gpp.user.Revision,gpp_compare.user.Revision);
896 ret = FALSE;
897 }
898 return ret;
899 }
900 BOOLEAN compare(POWER_POLICY pp, POWER_POLICY pp_compare)
901 {
902 //return TRUE;
903 BOOLEAN ret=TRUE;
904
905 if (pp.mach.DozeS4TimeoutAc != pp_compare.mach.DozeS4TimeoutAc)
906 {
907 printf("mach.DozeS4TimeoutAc failed %lu != %lu\n",pp.mach.DozeS4TimeoutAc,pp_compare.mach.DozeS4TimeoutAc);
908 ret = FALSE;
909 }
910 if (pp.mach.DozeS4TimeoutDc != pp_compare.mach.DozeS4TimeoutDc)
911 {
912 printf("mach.DozeS4TimeoutDc failed %lu != %lu\n",pp.mach.DozeS4TimeoutDc,pp_compare.mach.DozeS4TimeoutDc);
913 ret = FALSE;
914 }
915 if (pp.mach.MinSleepAc != pp_compare.mach.MinSleepAc)
916 {
917 printf("mach.MinSleepAc failed %i != %i\n",pp.mach.MinSleepAc,pp_compare.mach.MinSleepAc);
918 ret = FALSE;
919 }
920 if (pp.mach.MinSleepDc != pp_compare.mach.MinSleepDc)
921 {
922 printf("mach.MinSleepDc failed %i != %i\n",pp.mach.MinSleepDc,pp_compare.mach.MinSleepDc);
923 ret = FALSE;
924 }
925 if (pp.mach.DozeTimeoutAc != pp_compare.mach.DozeTimeoutAc)
926 {
927 printf("mach.DozeTimeoutAc failed %lu != %lu\n",pp.mach.DozeTimeoutAc,pp_compare.mach.DozeTimeoutAc);
928 ret = FALSE;
929 }
930 if (pp.mach.DozeTimeoutDc != pp_compare.mach.DozeTimeoutDc)
931 {
932 printf("mach.DozeTimeoutDc failed %lu != %lu\n",pp.mach.DozeTimeoutDc,pp_compare.mach.DozeTimeoutDc);
933 ret = FALSE;
934 }
935 if (pp.mach.ReducedLatencySleepAc != pp_compare.mach.ReducedLatencySleepAc)
936 {
937 printf("mach.ReducedLatencySleepAc failed %i != %i\n",pp.mach.ReducedLatencySleepAc,pp_compare.mach.ReducedLatencySleepAc);
938 ret = FALSE;
939 }
940 if (pp.mach.ReducedLatencySleepDc != pp_compare.mach.ReducedLatencySleepDc)
941 {
942 printf("mach.ReducedLatencySleepDc failed %i != %i\n",pp.mach.ReducedLatencySleepDc,pp_compare.mach.ReducedLatencySleepDc);
943 ret = FALSE;
944 }
945 if (pp.mach.MinThrottleAc != pp_compare.mach.MinThrottleAc)
946 {
947 printf("mach.MinThrottleAc failed %i != %i\n",pp.mach.MinThrottleAc,pp_compare.mach.MinThrottleAc);
948 ret = FALSE;
949 }
950 if (pp.mach.MinThrottleDc != pp_compare.mach.MinThrottleDc)
951 {
952 printf("mach.MinThrottleDc failed %i != %i\n",pp.mach.MinThrottleDc,pp_compare.mach.MinThrottleDc);
953 ret = FALSE;
954 }
955
956 if (pp.mach.OverThrottledAc.Action != pp_compare.mach.OverThrottledAc.Action)
957 {
958 printf("mach.OverThrottledAc.Action failed %i != %i\n",pp.mach.OverThrottledAc.Action,pp_compare.mach.OverThrottledAc.Action);
959 ret = FALSE;
960 }
961 if (pp.mach.OverThrottledAc.Flags != pp_compare.mach.OverThrottledAc.Flags)
962 {
963 printf("mach.OverThrottledAc.Flags failed %lu != %lu\n",pp.mach.OverThrottledAc.Flags,pp_compare.mach.OverThrottledAc.Flags);
964 ret = FALSE;
965 }
966 if (pp.mach.OverThrottledAc.EventCode != pp_compare.mach.OverThrottledAc.EventCode)
967 {
968 printf("mach.OverThrottledAc.EventCode failed %lu != %lu\n",pp.mach.OverThrottledAc.EventCode,pp_compare.mach.OverThrottledAc.EventCode);
969 ret = FALSE;
970 }
971 if (pp.mach.OverThrottledDc.Action != pp_compare.mach.OverThrottledDc.Action)
972 {
973 printf("mach.OverThrottledDc.Action failed %i != %i\n",pp.mach.OverThrottledDc.Action,pp_compare.mach.OverThrottledDc.Action);
974 ret = FALSE;
975 }
976 if (pp.mach.OverThrottledDc.Flags != pp_compare.mach.OverThrottledDc.Flags)
977 {
978 printf("mach.OverThrottledDc.Flags failed %lu != %lu\n",pp.mach.OverThrottledDc.Flags,pp_compare.mach.OverThrottledDc.Flags);
979 ret = FALSE;
980 }
981 if (pp.mach.OverThrottledDc.EventCode != pp_compare.mach.OverThrottledDc.EventCode)
982 {
983 printf("mach.OverThrottledDc.EventCode failed %lu != %lu\n",pp.mach.OverThrottledDc.EventCode,pp_compare.mach.OverThrottledDc.EventCode);
984 ret = FALSE;
985 }
986
987 if (pp.mach.pad1[0] != pp_compare.mach.pad1[0])
988 {
989 printf("mach.pad1[0] failed %i != %i\n",pp.mach.pad1[0],pp_compare.mach.pad1[0]);
990 ret = FALSE;
991 }
992 if (pp.mach.pad1[1] != pp_compare.mach.pad1[1])
993 {
994 printf("mach.pad1[1] failed %i != %i\n",pp.mach.pad1[1],pp_compare.mach.pad1[1]);
995 ret = FALSE;
996 }
997 if (pp.mach.Revision != pp_compare.mach.Revision)
998 {
999 printf("mach.Revision failed %lu != %lu\n",pp.mach.Revision,pp_compare.mach.Revision);
1000 ret = FALSE;
1001 }
1002
1003 if (pp.user.IdleAc.Action != pp_compare.user.IdleAc.Action)
1004 {
1005 printf("user.IdleAc.Action failed %i != %i\n",pp.user.IdleAc.Action,pp_compare.user.IdleAc.Action);
1006 ret = FALSE;
1007 }
1008 if (pp.user.IdleAc.Flags != pp_compare.user.IdleAc.Flags)
1009 {
1010 printf("user.IdleAc.Flags failed %lu != %lu\n",pp.user.IdleAc.Flags,pp_compare.user.IdleAc.Flags);
1011 ret = FALSE;
1012 }
1013 if (pp.user.IdleAc.EventCode != pp_compare.user.IdleAc.EventCode)
1014 {
1015 printf("user.IdleAc.EventCode failed %lu != %lu\n",pp.user.IdleAc.EventCode,pp_compare.user.IdleAc.EventCode);
1016 ret = FALSE;
1017 }
1018 if (pp.user.IdleDc.Action != pp_compare.user.IdleDc.Action)
1019 {
1020 printf("user.IdleDc.Action failed %i != %i\n",pp.user.IdleDc.Action,pp_compare.user.IdleDc.Action);
1021 ret = FALSE;
1022 }
1023 if (pp.user.IdleDc.Flags != pp_compare.user.IdleDc.Flags)
1024 {
1025 printf("user.IdleDc.Flags failed %lu != %lu\n",pp.user.IdleDc.Flags,pp_compare.user.IdleDc.Flags);
1026 ret = FALSE;
1027 }
1028 if (pp.user.IdleDc.EventCode != pp_compare.user.IdleDc.EventCode)
1029 {
1030 printf("user.IdleDc.EventCode failed %lu != %lu\n",pp.user.IdleDc.EventCode,pp_compare.user.IdleDc.EventCode);
1031 ret = FALSE;
1032 }
1033 if (pp.user.IdleTimeoutAc != pp_compare.user.IdleTimeoutAc)
1034 {
1035 printf("user.IdleTimeoutAc failed %lu != %lu\n",pp.user.IdleTimeoutAc,pp_compare.user.IdleTimeoutAc);
1036 ret = FALSE;
1037 }
1038 if (pp.user.IdleTimeoutDc != pp_compare.user.IdleTimeoutDc)
1039 {
1040 printf("user.IdleTimeoutDc failed %lu != %lu\n",pp.user.IdleTimeoutDc,pp_compare.user.IdleTimeoutDc);
1041 ret = FALSE;
1042 }
1043 if (pp.user.IdleSensitivityAc != pp_compare.user.IdleSensitivityAc)
1044 {
1045 printf("user.IdleSensitivityAc failed %i != %i\n",pp.user.IdleSensitivityAc,pp_compare.user.IdleSensitivityAc);
1046 ret = FALSE;
1047 }
1048 if (pp.user.IdleSensitivityDc != pp_compare.user.IdleSensitivityDc)
1049 {
1050 printf("user.IdleSensitivityDc failed %i != %i\n",pp.user.IdleSensitivityDc,pp_compare.user.IdleSensitivityDc);
1051 ret = FALSE;
1052 }
1053 if (pp.user.ThrottlePolicyAc != pp_compare.user.ThrottlePolicyAc)
1054 {
1055 printf("user.ThrottlePolicyAc failed %i != %i\n",pp.user.ThrottlePolicyAc,pp_compare.user.ThrottlePolicyAc);
1056 ret = FALSE;
1057 }
1058 if (pp.user.ThrottlePolicyDc != pp_compare.user.ThrottlePolicyDc)
1059 {
1060 printf("user.ThrottlePolicyDc failed %i != %i\n",pp.user.ThrottlePolicyDc,pp_compare.user.ThrottlePolicyDc);
1061 ret = FALSE;
1062 }
1063 if (pp.user.MaxSleepAc != pp_compare.user.MaxSleepAc)
1064 {
1065 printf("user.MaxSleepAc failed %i != %i\n",pp.user.MaxSleepAc,pp_compare.user.MaxSleepAc);
1066 ret = FALSE;
1067 }
1068 if (pp.user.MaxSleepDc != pp_compare.user.MaxSleepDc)
1069 {
1070 printf("user.MaxSleepDc failed %i != %i\n",pp.user.MaxSleepDc,pp_compare.user.MaxSleepDc);
1071 ret = FALSE;
1072 }
1073 if (pp.user.Reserved[0] != pp_compare.user.Reserved[0])
1074 {
1075 printf("user.Reserved[0] failed %lu != %lu\n",pp.user.Reserved[0],pp_compare.user.Reserved[0]);
1076 ret = FALSE;
1077 }
1078 if (pp.user.Reserved[1] != pp_compare.user.Reserved[1])
1079 {
1080 printf("user.Reserved[1] failed %lu != %lu\n",pp.user.Reserved[1],pp_compare.user.Reserved[1]);
1081 ret = FALSE;
1082 }
1083 if (pp.user.Reserved[2] != pp_compare.user.Reserved[2])
1084 {
1085 printf("user.Reserved[2] failed %lu != %lu\n",pp.user.Reserved[2],pp_compare.user.Reserved[2]);
1086 ret = FALSE;
1087 }
1088 if (pp.user.VideoTimeoutAc != pp_compare.user.VideoTimeoutAc)
1089 {
1090 printf("user.VideoTimeoutAc failed %lu != %lu\n",pp.user.VideoTimeoutAc,pp_compare.user.VideoTimeoutAc);
1091 ret = FALSE;
1092 }
1093 if (pp.user.VideoTimeoutDc != pp_compare.user.VideoTimeoutDc)
1094 {
1095 printf("user.VideoTimeoutDc failed %lu != %lu\n",pp.user.VideoTimeoutDc,pp_compare.user.VideoTimeoutDc);
1096 ret = FALSE;
1097 }
1098
1099 if (pp.user.SpindownTimeoutAc != pp_compare.user.SpindownTimeoutAc)
1100 {
1101 printf("user.SpindownTimeoutAc failed %lu != %lu\n",pp.user.SpindownTimeoutAc,pp_compare.user.SpindownTimeoutAc);
1102 ret = FALSE;
1103 }
1104 if (pp.user.SpindownTimeoutDc != pp_compare.user.SpindownTimeoutDc)
1105 {
1106 printf("user.SpindownTimeoutDc failed %lu != %lu\n",pp.user.SpindownTimeoutDc,pp_compare.user.SpindownTimeoutDc);
1107 ret = FALSE;
1108 }
1109 if (pp.user.OptimizeForPowerAc != pp_compare.user.OptimizeForPowerAc)
1110 {
1111 printf("user.OptimizeForPowerAc failed %i != %i\n",pp.user.OptimizeForPowerAc,pp_compare.user.OptimizeForPowerAc);
1112 ret = FALSE;
1113 }
1114 if (pp.user.OptimizeForPowerDc != pp_compare.user.OptimizeForPowerDc)
1115 {
1116 printf("user.OptimizeForPowerDc failed %i != %i\n",pp.user.OptimizeForPowerDc,pp_compare.user.OptimizeForPowerDc);
1117 ret = FALSE;
1118 }
1119 if (pp.user.FanThrottleToleranceAc != pp_compare.user.FanThrottleToleranceAc)
1120 {
1121 printf("user.FanThrottleToleranceAc failed %i != %i\n",pp.user.FanThrottleToleranceAc,pp_compare.user.FanThrottleToleranceAc);
1122 ret = FALSE;
1123 }
1124 if (pp.user.FanThrottleToleranceDc != pp_compare.user.FanThrottleToleranceDc)
1125 {
1126 printf("user.FanThrottleToleranceDc failed %i != %i\n",pp.user.FanThrottleToleranceDc,pp_compare.user.FanThrottleToleranceDc);
1127 ret = FALSE;
1128 }
1129 if (pp.user.ForcedThrottleAc != pp_compare.user.ForcedThrottleAc)
1130 {
1131 printf("user.ForcedThrottleAc failed %i != %i\n",pp.user.ForcedThrottleAc,pp_compare.user.ForcedThrottleAc);
1132 ret = FALSE;
1133 }
1134 if (pp.user.ForcedThrottleDc != pp_compare.user.ForcedThrottleDc)
1135 {
1136 printf("user.ForcedThrottleDc failed %i != %i\n",pp.user.ForcedThrottleDc,pp_compare.user.ForcedThrottleDc);
1137 ret = FALSE;
1138 }
1139 if (pp.user.Revision != pp_compare.user.Revision)
1140 {
1141 printf("user.Revision failed %lu != %lu\n",pp.user.Revision,pp_compare.user.Revision);
1142 ret = FALSE;
1143 }
1144
1145 return ret;
1146 }
1147
1148 void test_ValidatePowerPolicies_Old(void)
1149 {
1150 GLOBAL_POWER_POLICY gpp;
1151 POWER_POLICY pp;
1152 BOOLEAN ret;
1153
1154 RtlZeroMemory(&gpp, sizeof(GLOBAL_POWER_POLICY));
1155 RtlZeroMemory(&pp, sizeof(POWER_POLICY));
1156
1157 SetLastError(0);
1158 ret = ValidatePowerPolicies(0,0);
1159 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1160
1161 ret = ValidatePowerPolicies(&gpp,0);
1162 ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
1163 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH(%i,%i), but error :%i\n",(UINT)gpp.user.Revision,(UINT)gpp.mach.Revision,(UINT)GetLastError());
1164
1165 ret = ValidatePowerPolicies(0,&pp);
1166 ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
1167 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1168
1169 ret = ValidatePowerPolicies(&gpp,&pp);
1170 ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
1171 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1172
1173 gpp.user.Revision = 1;
1174 gpp.mach.Revision = 1;
1175
1176 ret = ValidatePowerPolicies(&gpp,0);
1177 ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
1178 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1179
1180 gpp.mach.LidOpenWakeAc = PowerSystemWorking;
1181 gpp.mach.LidOpenWakeDc = PowerSystemWorking;
1182
1183 ret = ValidatePowerPolicies(&gpp,0);
1184 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1185
1186 gpp.user.PowerButtonAc.Action = PowerActionNone;
1187 gpp.user.PowerButtonDc.Action = PowerActionNone;
1188 gpp.user.SleepButtonAc.Action = PowerActionNone;
1189 gpp.user.SleepButtonDc.Action = PowerActionNone;
1190 gpp.user.LidCloseAc.Action = PowerActionNone;
1191 gpp.user.LidCloseDc.Action = PowerActionNone;
1192
1193 gpp.user.DischargePolicy[0].Enable=FALSE;
1194 gpp.user.DischargePolicy[1].Enable=FALSE;
1195 gpp.user.DischargePolicy[2].Enable=FALSE;
1196 gpp.user.DischargePolicy[3].Enable=FALSE;
1197 ret = ValidatePowerPolicies(&gpp,0);
1198 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1199 if (!ret)
1200 {
1201 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1202 }
1203
1204 pp.user.Revision = 1;
1205 pp.mach.Revision = 1;
1206
1207 ret = ValidatePowerPolicies(0,&pp);
1208 ok(!ret, "function was expected to fail return %i\n",(UINT)ret);
1209 ok(GetLastError() == ERROR_INVALID_DATA || GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE or ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1210
1211 pp.mach.MinSleepAc = PowerSystemWorking;
1212 pp.mach.MinSleepDc = PowerSystemWorking;
1213 pp.mach.ReducedLatencySleepAc = PowerSystemWorking;
1214 pp.mach.ReducedLatencySleepDc = PowerSystemWorking;
1215 pp.mach.OverThrottledAc.Action = PowerActionNone;
1216 pp.mach.OverThrottledDc.Action = PowerActionNone;
1217
1218 pp.user.IdleAc.Action = PowerActionWarmEject+1;
1219 pp.user.IdleDc.Action = PowerActionNone-1;
1220 pp.user.MaxSleepAc = PowerSystemMaximum+1;
1221 pp.user.MaxSleepDc = PowerSystemUnspecified;
1222
1223 ret = ValidatePowerPolicies(0,&pp);
1224 ok(!ret, "function was expected to fail return %i\n",(UINT)GetLastError());
1225 if (!ret)
1226 {
1227 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1228 }
1229
1230 pp.user.IdleAc.Action = PowerActionNone;
1231 pp.user.IdleDc.Action = PowerActionNone;
1232 pp.user.MaxSleepAc = PowerSystemWorking;
1233 pp.user.MaxSleepDc = PowerSystemWorking;
1234
1235 ret = ValidatePowerPolicies(0,&pp);
1236 ok(ret, "function was expected to succeed, error %i\n",(UINT)GetLastError());
1237 if (!ret)
1238 {
1239 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1240 }
1241
1242 ret = ValidatePowerPolicies(&gpp,&pp);
1243 ok(ret, "function was expected to succeed, error %i\n",(UINT)GetLastError());
1244 if (!ret)
1245 {
1246 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1247 }
1248
1249
1250 ret = GetCurrentPowerPolicies(&gpp,&pp);
1251 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1252
1253 ret = ValidatePowerPolicies(&gpp,0);
1254 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1255
1256 ret = ValidatePowerPolicies(0,&pp);
1257 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1258
1259 ret = ValidatePowerPolicies(&gpp,&pp);
1260 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1261
1262 }
1263
1264 void test_ValidatePowerPolicies(void)
1265 {
1266 GLOBAL_POWER_POLICY gpp, gpp_compare, gpp_original;
1267 POWER_POLICY pp, pp_compare, pp_original;
1268 BOOLEAN ret;
1269
1270 RtlZeroMemory(&gpp_original, sizeof(GLOBAL_POWER_POLICY));
1271 RtlZeroMemory(&pp_original, sizeof(POWER_POLICY));
1272
1273 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1274 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1275 ok(compare(pp,pp_compare),"Difference Found\n");
1276
1277 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1278 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1279 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1280
1281 SetLastError(0);
1282 ret = ValidatePowerPolicies(0,0);
1283 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1284
1285 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1286 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1287 ret = ValidatePowerPolicies(&gpp,0);
1288 ok(!ret, "function was expected to fail\n");
1289 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH(%i,%i), but error :%i\n",(UINT)gpp.user.Revision,(UINT)gpp.mach.Revision,(UINT)GetLastError());
1290 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1291
1292 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1293 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1294 ret = ValidatePowerPolicies(0,&pp);
1295 ok(!ret, "function was expected to fail\n");
1296 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1297 ok(compare(pp,pp_compare),"Difference Found\n");
1298
1299 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1300 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1301 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1302 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1303 ret = ValidatePowerPolicies(&gpp,&pp);
1304 ok(!ret, "function was expected to fail\n");
1305 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1306 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1307 ok(compare(pp,pp_compare),"Difference Found\n");
1308
1309 gpp_original.user.Revision = 1;
1310 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1311 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1312 ret = ValidatePowerPolicies(&gpp,0);
1313 ok(!ret, "function was expected to fail\n");
1314 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1315 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1316
1317 gpp_original.mach.Revision = 1;
1318 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1319 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1320 ret = ValidatePowerPolicies(&gpp,0);
1321 ok(!ret, "function was expected to fail\n");
1322 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1323 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1324
1325 gpp_original.mach.LidOpenWakeAc = PowerSystemWorking;
1326 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1327 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1328 ret = ValidatePowerPolicies(&gpp,0);
1329 ok(!ret, "function was expected to fail\n");
1330 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1331 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1332
1333 gpp_original.mach.LidOpenWakeDc = PowerSystemWorking;
1334 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1335 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1336 ret = ValidatePowerPolicies(&gpp,0);
1337 ok(ret, "function was expected to succeed, error %x\n",(UINT)GetLastError());
1338 gpp_compare.mach.BroadcastCapacityResolution=100;
1339 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1340 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1341 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1342 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1343
1344 gpp_original.user.PowerButtonAc.Action = PowerActionNone;
1345 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1346 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1347 ret = ValidatePowerPolicies(&gpp,0);
1348 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1349 gpp_compare.mach.BroadcastCapacityResolution=100;
1350 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1351 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1352 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1353 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1354
1355 gpp_original.user.PowerButtonDc.Action = PowerActionNone;
1356 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1357 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1358 ret = ValidatePowerPolicies(&gpp,0);
1359 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1360 gpp_compare.mach.BroadcastCapacityResolution=100;
1361 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1362 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1363 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1364 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1365
1366 gpp_original.user.SleepButtonAc.Action = PowerActionNone;
1367 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1368 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1369 ret = ValidatePowerPolicies(&gpp,0);
1370 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1371 gpp_compare.mach.BroadcastCapacityResolution=100;
1372 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1373 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1374 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1375 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1376
1377 gpp_original.user.SleepButtonDc.Action = PowerActionNone;
1378 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1379 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1380 ret = ValidatePowerPolicies(&gpp,0);
1381 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1382 gpp_compare.mach.BroadcastCapacityResolution=100;
1383 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1384 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1385 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1386 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1387
1388 gpp_original.user.LidCloseAc.Action = PowerActionNone;
1389 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1390 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1391 ret = ValidatePowerPolicies(&gpp,0);
1392 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1393 gpp_compare.mach.BroadcastCapacityResolution=100;
1394 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1395 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1396 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1397 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1398
1399 gpp_original.user.LidCloseDc.Action = PowerActionNone;
1400 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1401 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1402 ret = ValidatePowerPolicies(&gpp,0);
1403 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1404 gpp_compare.mach.BroadcastCapacityResolution=100;
1405 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1406 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1407 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1408 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1409
1410 gpp_original.user.DischargePolicy[0].Enable=FALSE;
1411 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1412 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1413 ret = ValidatePowerPolicies(&gpp,0);
1414 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1415 gpp_compare.mach.BroadcastCapacityResolution=100;
1416 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1417 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1418 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1419 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1420
1421 gpp_original.user.DischargePolicy[1].Enable=FALSE;
1422 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1423 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1424 ret = ValidatePowerPolicies(&gpp,0);
1425 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1426 gpp_compare.mach.BroadcastCapacityResolution=100;
1427 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1428 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1429 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1430 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1431
1432 gpp_original.user.DischargePolicy[2].Enable=FALSE;
1433 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1434 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1435 ret = ValidatePowerPolicies(&gpp,0);
1436 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1437 gpp_compare.mach.BroadcastCapacityResolution=100;
1438 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1439 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1440 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1441 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1442
1443 gpp_original.user.DischargePolicy[3].Enable=FALSE;
1444 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1445 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1446 ret = ValidatePowerPolicies(&gpp,0);
1447 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1448 gpp_compare.mach.BroadcastCapacityResolution=100;
1449 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1450 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1451 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1452 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1453
1454 pp_original.user.Revision = 1;
1455 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1456 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1457 ret = ValidatePowerPolicies(0,&pp);
1458 ok(!ret, "function was expected to fail\n");
1459 ok(GetLastError() == ERROR_REVISION_MISMATCH,"function was expected to fail with ERROR_REVISION_MISMATCH, but error :%i\n",(UINT)GetLastError());
1460 ok(compare(pp,pp_compare),"Difference Found\n");
1461
1462 pp_original.mach.Revision = 1;
1463 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1464 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1465 ret = ValidatePowerPolicies(0,&pp);
1466 ok(!ret, "function was expected to fail\n");
1467 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1468 ok(compare(pp,pp_compare),"Difference Found\n");
1469
1470 pp_original.mach.MinSleepAc = PowerSystemWorking;
1471 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1472 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1473 ret = ValidatePowerPolicies(0,&pp);
1474 ok(!ret, "function was expected to fail\n");
1475 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1476 ok(compare(pp,pp_compare),"Difference Found\n");
1477
1478 pp_original.mach.MinSleepDc = PowerSystemWorking;
1479 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1480 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1481 ret = ValidatePowerPolicies(0,&pp);
1482 ok(!ret, "function was expected to fail\n");
1483 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1484 ok(compare(pp,pp_compare),"Difference Found\n");
1485
1486 pp_original.mach.ReducedLatencySleepAc = PowerSystemWorking;
1487 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1488 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1489 ret = ValidatePowerPolicies(0,&pp);
1490 ok(!ret, "function was expected to fail\n");
1491 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1492 ok(compare(pp,pp_compare),"Difference Found\n");
1493
1494 pp_original.mach.ReducedLatencySleepDc = PowerSystemWorking;
1495 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1496 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1497 ret = ValidatePowerPolicies(0,&pp);
1498 ok(!ret, "function was expected to fail\n");
1499 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1500 ok(compare(pp,pp_compare),"Difference Found\n");
1501
1502 pp_original.mach.OverThrottledAc.Action = PowerActionNone;
1503 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1504 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1505 ret = ValidatePowerPolicies(0,&pp);
1506 ok(!ret, "function was expected to fail\n");
1507 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1508 ok(compare(pp,pp_compare),"Difference Found\n");
1509
1510 pp_original.mach.OverThrottledDc.Action = PowerActionNone;
1511 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1512 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1513 ret = ValidatePowerPolicies(0,&pp);
1514 ok(!ret, "function was expected to fail\n");
1515 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1516 ok(compare(pp,pp_compare),"Difference Found\n");
1517
1518 pp_original.user.IdleAc.Action = PowerActionWarmEject+1;
1519 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1520 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1521 ret = ValidatePowerPolicies(0,&pp);
1522 ok(!ret, "function was expected to fail\n");
1523 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1524 ok(compare(pp,pp_compare),"Difference Found\n");
1525
1526 pp_original.user.IdleDc.Action = PowerActionNone-1;
1527 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1528 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1529 ret = ValidatePowerPolicies(0,&pp);
1530 ok(!ret, "function was expected to fail\n");
1531 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1532 ok(compare(pp,pp_compare),"Difference Found\n");
1533
1534 pp_original.user.MaxSleepAc = PowerSystemMaximum+1;
1535 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1536 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1537 ret = ValidatePowerPolicies(0,&pp);
1538 ok(!ret, "function was expected to fail\n");
1539 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1540 ok(compare(pp,pp_compare),"Difference Found\n");
1541
1542 pp_original.user.MaxSleepDc = PowerSystemUnspecified;
1543 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1544 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1545 ret = ValidatePowerPolicies(0,&pp);
1546 ok(!ret, "function was expected to fail\n");
1547 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1548 ok(compare(pp,pp_compare),"Difference Found\n");
1549
1550 pp_original.user.IdleAc.Action = PowerActionNone;
1551 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1552 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1553 ret = ValidatePowerPolicies(0,&pp);
1554 ok(!ret, "function was expected to fail\n");
1555 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1556 ok(compare(pp,pp_compare),"Difference Found\n");
1557
1558 pp_original.user.IdleDc.Action = PowerActionNone;
1559 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1560 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1561 ret = ValidatePowerPolicies(0,&pp);
1562 ok(!ret, "function was expected to fail\n");
1563 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1564 ok(compare(pp,pp_compare),"Difference Found\n");
1565
1566 pp_original.user.MaxSleepAc = PowerSystemWorking;
1567 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1568 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1569 ret = ValidatePowerPolicies(0,&pp);
1570 ok(!ret, "function was expected to fail\n");
1571 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1572 ok(compare(pp,pp_compare),"Difference Found\n");
1573
1574 pp_original.user.MaxSleepDc = PowerSystemWorking;
1575 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1576 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1577 ret = ValidatePowerPolicies(0,&pp);
1578 ok(ret, "function was expected to succeed, error %i\n",(UINT)GetLastError());
1579 pp_compare.mach.MinSleepAc=4;
1580 pp_compare.mach.MinSleepDc=4;
1581 pp_compare.user.MaxSleepAc=4;
1582 pp_compare.user.MaxSleepDc=4;
1583 pp_compare.user.OptimizeForPowerAc=1;
1584 pp_compare.user.OptimizeForPowerDc=1;
1585 ok(compare(pp,pp_compare),"Difference Found\n");
1586
1587 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1588 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1589 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1590 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1591 ret = ValidatePowerPolicies(&gpp,&pp);
1592 ok(ret, "function was expected to succeed, error %i\n",(UINT)GetLastError());
1593 gpp_compare.mach.BroadcastCapacityResolution=100;
1594 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1595 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1596 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1597 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1598 pp_compare.mach.MinSleepAc=4;
1599 pp_compare.mach.MinSleepDc=4;
1600 pp_compare.user.MaxSleepAc=4;
1601 pp_compare.user.MaxSleepDc=4;
1602 pp_compare.user.OptimizeForPowerAc=1;
1603 pp_compare.user.OptimizeForPowerDc=1;
1604 ok(compare(pp,pp_compare),"Difference Found\n");
1605
1606
1607 gpp_original.mach.BroadcastCapacityResolution=95;
1608 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1609 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1610 ret = ValidatePowerPolicies(&gpp,0);
1611 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1612 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
1613 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1614 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1615 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1616
1617 gpp_original.user.DischargePolicy[1].PowerPolicy.EventCode = 256;
1618 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1619 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1620 ret = ValidatePowerPolicies(&gpp,0);
1621 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1622 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65792;
1623 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
1624 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1625 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1626
1627 gpp_original.user.DischargePolicy[2].PowerPolicy.EventCode = 256;
1628 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1629 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1630 ret = ValidatePowerPolicies(&gpp,0);
1631 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1632 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65792;
1633 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131328;
1634 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
1635 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1636
1637 gpp_original.user.DischargePolicy[3].PowerPolicy.EventCode = 256;
1638 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1639 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1640 ret = ValidatePowerPolicies(&gpp,0);
1641 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1642 gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65792;
1643 gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131328;
1644 gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196864;
1645 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1646
1647
1648 gpp_original.user.DischargePolicy[1].PowerPolicy.EventCode = 65792;
1649 gpp_original.user.DischargePolicy[2].PowerPolicy.EventCode = 131328;
1650 gpp_original.user.DischargePolicy[3].PowerPolicy.EventCode = 196864;
1651 gpp_original.mach.LidOpenWakeAc=PowerSystemUnspecified;
1652 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1653 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1654 ret = ValidatePowerPolicies(&gpp,0);
1655 ok(!ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1656 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1657 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1658
1659 gpp_original.mach.LidOpenWakeAc=PowerSystemWorking;
1660 gpp_original.mach.LidOpenWakeDc=PowerSystemUnspecified;
1661 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1662 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1663 ret = ValidatePowerPolicies(&gpp,0);
1664 ok(!ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1665 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1666 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1667
1668 gpp_original.mach.LidOpenWakeDc=PowerSystemWorking;
1669 gpp_original.user.LidCloseAc.Action = PowerActionWarmEject+1;
1670 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1671 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1672 ret = ValidatePowerPolicies(&gpp,0);
1673 ok(!ret, "function was expected to fail\n");
1674 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1675 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1676
1677 gpp_original.user.LidCloseAc.Action = PowerActionWarmEject;
1678 gpp_original.user.LidCloseDc.Action = PowerActionNone;
1679 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1680 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1681 ret = ValidatePowerPolicies(&gpp,0);
1682 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1683 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1684
1685 gpp_original.user.LidCloseDc.Action = PowerActionWarmEject;
1686 gpp_original.user.PowerButtonAc.Action = PowerActionNone-1;
1687 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1688 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1689 ret = ValidatePowerPolicies(&gpp,0);
1690 ok(!ret, "function was expected to fail\n");
1691 ok(GetLastError() == ERROR_INVALID_DATA,"function was expected to fail with ERROR_INVALID_DATA, but error :%i\n",(UINT)GetLastError());
1692 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1693
1694 gpp_original.user.PowerButtonAc.Action = PowerActionNone;
1695 gpp_original.user.PowerButtonDc.Action = PowerActionWarmEject;
1696 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1697 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1698 ret = ValidatePowerPolicies(&gpp,0);
1699 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1700 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1701
1702 gpp_original.user.SleepButtonAc.Action = PowerActionWarmEject;
1703 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1704 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1705 ret = ValidatePowerPolicies(&gpp,0);
1706 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1707 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1708
1709 gpp_original.user.SleepButtonDc.Action = PowerActionWarmEject;
1710 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1711 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1712 ret = ValidatePowerPolicies(&gpp,0);
1713 ok(ret, "function was expected to succeed return %i\n",(UINT)GetLastError());
1714 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
1715
1716
1717 pp_original.mach.MinSleepAc=PowerSystemUnspecified-1;
1718 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1719 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1720 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1721 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1722 ret = ValidatePowerPolicies(0,&pp);
1723 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1724 pp_compare.mach.MinSleepAc=4;
1725 pp_compare.mach.MinSleepDc=4;
1726 pp_compare.user.MaxSleepAc=4;
1727 pp_compare.user.MaxSleepDc=4;
1728 pp_compare.user.OptimizeForPowerAc=1;
1729 pp_compare.user.OptimizeForPowerDc=1;
1730 ok(compare(pp,pp_compare),"Difference Found\n");
1731
1732 pp_original.mach.MinSleepDc=PowerSystemUnspecified-1;
1733 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1734 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1735 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1736 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1737 ret = ValidatePowerPolicies(0,&pp);
1738 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1739 pp_compare.mach.MinSleepAc=4;
1740 pp_compare.mach.MinSleepDc=4;
1741 pp_compare.user.MaxSleepAc=4;
1742 pp_compare.user.MaxSleepDc=4;
1743 pp_compare.user.OptimizeForPowerAc=1;
1744 pp_compare.user.OptimizeForPowerDc=1;
1745 ok(compare(pp,pp_compare),"Difference Found\n");
1746
1747 pp_original.user.MaxSleepAc=PowerSystemUnspecified-1;
1748 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1749 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1750 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1751 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1752 ret = ValidatePowerPolicies(0,&pp);
1753 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1754 pp_compare.mach.MinSleepAc=4;
1755 pp_compare.mach.MinSleepDc=4;
1756 pp_compare.user.MaxSleepAc=4;
1757 pp_compare.user.MaxSleepDc=4;
1758 pp_compare.user.OptimizeForPowerAc=1;
1759 pp_compare.user.OptimizeForPowerDc=1;
1760 ok(compare(pp,pp_compare),"Difference Found\n");
1761
1762 pp_original.user.MaxSleepDc=PowerSystemUnspecified-1;
1763 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1764 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1765 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1766 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1767 ret = ValidatePowerPolicies(0,&pp);
1768 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1769 pp_compare.mach.MinSleepAc=4;
1770 pp_compare.mach.MinSleepDc=4;
1771 pp_compare.user.MaxSleepAc=4;
1772 pp_compare.user.MaxSleepDc=4;
1773 pp_compare.user.OptimizeForPowerAc=1;
1774 pp_compare.user.OptimizeForPowerDc=1;
1775 ok(compare(pp,pp_compare),"Difference Found\n");
1776
1777 pp_original.mach.MinSleepAc=PowerSystemUnspecified;
1778 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1779 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1780 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1781 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1782 ret = ValidatePowerPolicies(0,&pp);
1783 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1784 pp_compare.mach.MinSleepAc=4;
1785 pp_compare.mach.MinSleepDc=4;
1786 pp_compare.user.MaxSleepAc=4;
1787 pp_compare.user.MaxSleepDc=4;
1788 pp_compare.user.OptimizeForPowerAc=1;
1789 pp_compare.user.OptimizeForPowerDc=1;
1790 ok(compare(pp,pp_compare),"Difference Found\n");
1791
1792 pp_original.mach.MinSleepDc=PowerSystemUnspecified;
1793 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1794 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1795 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1796 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1797 ret = ValidatePowerPolicies(0,&pp);
1798 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1799 pp_compare.mach.MinSleepAc=4;
1800 pp_compare.mach.MinSleepDc=4;
1801 pp_compare.user.MaxSleepAc=4;
1802 pp_compare.user.MaxSleepDc=4;
1803 pp_compare.user.OptimizeForPowerAc=1;
1804 pp_compare.user.OptimizeForPowerDc=1;
1805 ok(compare(pp,pp_compare),"Difference Found\n");
1806
1807 pp_original.user.MaxSleepAc=PowerSystemUnspecified;
1808 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1809 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1810 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1811 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1812 ret = ValidatePowerPolicies(0,&pp);
1813 ok(!ret, "function was expected to fail\n");
1814 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1815 ok(compare(pp,pp_compare),"Difference Found\n");
1816
1817 pp_original.user.MaxSleepDc=PowerSystemUnspecified;
1818 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1819 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1820 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1821 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1822 ret = ValidatePowerPolicies(0,&pp);
1823 ok(!ret, "function was expected to fail\n");
1824 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1825 ok(compare(pp,pp_compare),"Difference Found\n");
1826
1827 pp_original.mach.MinSleepAc=PowerSystemWorking;
1828 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1829 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1830 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1831 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1832 ret = ValidatePowerPolicies(0,&pp);
1833 ok(!ret, "function was expected to fail\n");
1834 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1835 //pp_compare.mach.MinSleepAc=4;
1836 //pp_compare.mach.MinSleepDc=4;
1837 //pp_compare.user.MaxSleepAc=4;
1838 //pp_compare.user.MaxSleepDc=4;
1839 ok(compare(pp,pp_compare),"Difference Found\n");
1840
1841 pp_original.mach.MinSleepDc=PowerSystemWorking;
1842 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1843 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1844 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1845 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1846 ret = ValidatePowerPolicies(0,&pp);
1847 ok(!ret, "function was expected to fail\n");
1848 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1849 //pp_compare.mach.MinSleepAc=4;
1850 //pp_compare.mach.MinSleepDc=4;
1851 //pp_compare.user.MaxSleepAc=4;
1852 //pp_compare.user.MaxSleepDc=4;
1853 ok(compare(pp,pp_compare),"Difference Found\n");
1854
1855 pp_original.user.MaxSleepAc=PowerSystemWorking;
1856 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1857 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1858 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1859 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1860 ret = ValidatePowerPolicies(0,&pp);
1861 ok(!ret, "function was expected to fail\n");
1862 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
1863 //pp_compare.mach.MinSleepAc=4;
1864 //pp_compare.mach.MinSleepDc=4;
1865 //pp_compare.user.MaxSleepAc=4;
1866 //pp_compare.user.MaxSleepDc=4;
1867 //pp_compare.user.OptimizeForPowerAc=1;
1868 //pp_compare.user.OptimizeForPowerDc=1;
1869 ok(compare(pp,pp_compare),"Difference Found\n");
1870
1871 pp_original.user.MaxSleepDc=PowerSystemWorking;
1872 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1873 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1874 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1875 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1876 ret = ValidatePowerPolicies(0,&pp);
1877 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1878 pp_compare.mach.MinSleepAc=4;
1879 pp_compare.mach.MinSleepDc=4;
1880 pp_compare.user.MaxSleepAc=4;
1881 pp_compare.user.MaxSleepDc=4;
1882 pp_compare.user.OptimizeForPowerAc=1;
1883 pp_compare.user.OptimizeForPowerDc=1;
1884 ok(compare(pp,pp_compare),"Difference Found\n");
1885
1886 pp_original.mach.MinSleepAc=PowerSystemSleeping1;
1887 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1888 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1889 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1890 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1891 ret = ValidatePowerPolicies(0,&pp);
1892 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1893 pp_compare.mach.MinSleepAc=4;
1894 pp_compare.mach.MinSleepDc=4;
1895 pp_compare.user.MaxSleepAc=4;
1896 pp_compare.user.MaxSleepDc=4;
1897 pp_compare.user.OptimizeForPowerAc=1;
1898 pp_compare.user.OptimizeForPowerDc=1;
1899 ok(compare(pp,pp_compare),"Difference Found\n");
1900
1901 pp_original.mach.MinSleepDc=PowerSystemSleeping1;
1902 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1903 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1904 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1905 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1906 ret = ValidatePowerPolicies(0,&pp);
1907 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1908 pp_compare.mach.MinSleepAc=4;
1909 pp_compare.mach.MinSleepDc=4;
1910 pp_compare.user.MaxSleepAc=4;
1911 pp_compare.user.MaxSleepDc=4;
1912 pp_compare.user.OptimizeForPowerAc=1;
1913 pp_compare.user.OptimizeForPowerDc=1;
1914 ok(compare(pp,pp_compare),"Difference Found\n");
1915
1916 pp_original.user.MaxSleepAc=PowerSystemSleeping1;
1917 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1918 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1919 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1920 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1921 ret = ValidatePowerPolicies(0,&pp);
1922 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1923 pp_compare.mach.MinSleepAc=4;
1924 pp_compare.mach.MinSleepDc=4;
1925 pp_compare.user.MaxSleepAc=4;
1926 pp_compare.user.MaxSleepDc=4;
1927 pp_compare.user.OptimizeForPowerAc=1;
1928 pp_compare.user.OptimizeForPowerDc=1;
1929 ok(compare(pp,pp_compare),"Difference Found\n");
1930
1931 pp_original.user.MaxSleepDc=PowerSystemSleeping1;
1932 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1933 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1934 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1935 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1936 ret = ValidatePowerPolicies(0,&pp);
1937 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1938 pp_compare.mach.MinSleepAc=4;
1939 pp_compare.mach.MinSleepDc=4;
1940 pp_compare.user.MaxSleepAc=4;
1941 pp_compare.user.MaxSleepDc=4;
1942 pp_compare.user.OptimizeForPowerAc=1;
1943 pp_compare.user.OptimizeForPowerDc=1;
1944 ok(compare(pp,pp_compare),"Difference Found\n");
1945
1946 pp_original.mach.MinSleepAc=PowerSystemSleeping2;
1947 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1948 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1949 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1950 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1951 ret = ValidatePowerPolicies(0,&pp);
1952 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1953 pp_compare.mach.MinSleepAc=4;
1954 pp_compare.mach.MinSleepDc=4;
1955 pp_compare.user.MaxSleepAc=4;
1956 pp_compare.user.MaxSleepDc=4;
1957 pp_compare.user.OptimizeForPowerAc=1;
1958 pp_compare.user.OptimizeForPowerDc=1;
1959 ok(compare(pp,pp_compare),"Difference Found\n");
1960
1961 pp_original.mach.MinSleepDc=PowerSystemSleeping2;
1962 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1963 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1964 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1965 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1966 ret = ValidatePowerPolicies(0,&pp);
1967 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1968 pp_compare.mach.MinSleepAc=4;
1969 pp_compare.mach.MinSleepDc=4;
1970 pp_compare.user.MaxSleepAc=4;
1971 pp_compare.user.MaxSleepDc=4;
1972 pp_compare.user.OptimizeForPowerAc=1;
1973 pp_compare.user.OptimizeForPowerDc=1;
1974 ok(compare(pp,pp_compare),"Difference Found\n");
1975
1976 pp_original.user.MaxSleepAc=PowerSystemSleeping2;
1977 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1978 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1979 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1980 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1981 ret = ValidatePowerPolicies(0,&pp);
1982 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1983 pp_compare.mach.MinSleepAc=4;
1984 pp_compare.mach.MinSleepDc=4;
1985 pp_compare.user.MaxSleepAc=4;
1986 pp_compare.user.MaxSleepDc=4;
1987 pp_compare.user.OptimizeForPowerAc=1;
1988 pp_compare.user.OptimizeForPowerDc=1;
1989 ok(compare(pp,pp_compare),"Difference Found\n");
1990
1991 pp_original.user.MaxSleepDc=PowerSystemSleeping2;
1992 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1993 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
1994 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
1995 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
1996 ret = ValidatePowerPolicies(0,&pp);
1997 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
1998 pp_compare.mach.MinSleepAc=4;
1999 pp_compare.mach.MinSleepDc=4;
2000 pp_compare.user.MaxSleepAc=4;
2001 pp_compare.user.MaxSleepDc=4;
2002 pp_compare.user.OptimizeForPowerAc=1;
2003 pp_compare.user.OptimizeForPowerDc=1;
2004 ok(compare(pp,pp_compare),"Difference Found\n");
2005
2006 pp_original.mach.MinSleepAc=PowerSystemSleeping3;
2007 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2008 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2009 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2010 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2011 ret = ValidatePowerPolicies(0,&pp);
2012 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2013 pp_compare.mach.MinSleepDc=4;
2014 pp_compare.user.MaxSleepAc=4;
2015 pp_compare.user.MaxSleepDc=4;
2016 pp_compare.user.OptimizeForPowerAc=1;
2017 pp_compare.user.OptimizeForPowerDc=1;
2018 ok(compare(pp,pp_compare),"Difference Found\n");
2019
2020 pp_original.mach.MinSleepDc=PowerSystemSleeping3;
2021 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2022 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2023 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2024 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2025 ret = ValidatePowerPolicies(0,&pp);
2026 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2027 pp_compare.user.MaxSleepAc=4;
2028 pp_compare.user.MaxSleepDc=4;
2029 pp_compare.user.OptimizeForPowerAc=1;
2030 pp_compare.user.OptimizeForPowerDc=1;
2031 ok(compare(pp,pp_compare),"Difference Found\n");
2032
2033 pp_original.user.MaxSleepAc=PowerSystemSleeping3;
2034 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2035 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2036 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2037 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2038 ret = ValidatePowerPolicies(0,&pp);
2039 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2040 pp_compare.user.MaxSleepDc=4;
2041 pp_compare.user.OptimizeForPowerAc=1;
2042 pp_compare.user.OptimizeForPowerDc=1;
2043 ok(compare(pp,pp_compare),"Difference Found\n");
2044
2045 pp_original.user.MaxSleepDc=PowerSystemSleeping3;
2046 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2047 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2048 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2049 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2050 ret = ValidatePowerPolicies(0,&pp);
2051 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2052 pp_compare.user.OptimizeForPowerAc=1;
2053 pp_compare.user.OptimizeForPowerDc=1;
2054 ok(compare(pp,pp_compare),"Difference Found\n");
2055
2056 pp_original.mach.MinSleepAc=PowerSystemHibernate;
2057 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2058 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2059 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2060 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2061 ret = ValidatePowerPolicies(0,&pp);
2062 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2063 pp_compare.mach.MinSleepAc=4;
2064 pp_compare.mach.MinSleepDc=4;
2065 pp_compare.user.MaxSleepAc=4;
2066 pp_compare.user.MaxSleepDc=4;
2067 pp_compare.user.OptimizeForPowerAc=1;
2068 pp_compare.user.OptimizeForPowerDc=1;
2069 ok(compare(pp,pp_compare),"Difference Found\n");
2070
2071 pp_original.mach.MinSleepDc=PowerSystemHibernate;
2072 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2073 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2074 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2075 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2076 ret = ValidatePowerPolicies(0,&pp);
2077 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2078 pp_compare.mach.MinSleepAc=4;
2079 pp_compare.mach.MinSleepDc=4;
2080 pp_compare.user.MaxSleepAc=4;
2081 pp_compare.user.MaxSleepDc=4;
2082 pp_compare.user.OptimizeForPowerAc=1;
2083 pp_compare.user.OptimizeForPowerDc=1;
2084 ok(compare(pp,pp_compare),"Difference Found\n");
2085
2086 pp_original.user.MaxSleepAc=PowerSystemHibernate;
2087 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2088 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2089 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2090 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2091 ret = ValidatePowerPolicies(0,&pp);
2092 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2093 pp_compare.mach.MinSleepAc=4;
2094 pp_compare.mach.MinSleepDc=4;
2095 pp_compare.user.MaxSleepAc=4;
2096 pp_compare.user.MaxSleepDc=4;
2097 pp_compare.user.OptimizeForPowerAc=1;
2098 pp_compare.user.OptimizeForPowerDc=1;
2099 ok(compare(pp,pp_compare),"Difference Found\n");
2100
2101 pp_original.user.MaxSleepDc=PowerSystemHibernate;
2102 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2103 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2104 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2105 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2106 ret = ValidatePowerPolicies(0,&pp);
2107 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2108 pp_compare.mach.MinSleepAc=4;
2109 pp_compare.mach.MinSleepDc=4;
2110 pp_compare.user.MaxSleepAc=4;
2111 pp_compare.user.MaxSleepDc=4;
2112 pp_compare.user.OptimizeForPowerAc=1;
2113 pp_compare.user.OptimizeForPowerDc=1;
2114 ok(compare(pp,pp_compare),"Difference Found\n");
2115
2116 pp_original.mach.MinSleepAc=PowerSystemShutdown;
2117 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2118 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2119 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2120 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2121 ret = ValidatePowerPolicies(0,&pp);
2122 ok(!ret, "function was expected to fail\n");
2123 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2124 ok(compare(pp,pp_compare),"Difference Found\n");
2125
2126 pp_original.mach.MinSleepDc=PowerSystemShutdown;
2127 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2128 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2129 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2130 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2131 ret = ValidatePowerPolicies(0,&pp);
2132 ok(!ret, "function was expected to fail\n");
2133 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2134 ok(compare(pp,pp_compare),"Difference Found\n");
2135
2136 pp_original.user.MaxSleepAc=PowerSystemShutdown;
2137 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2138 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2139 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2140 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2141 ret = ValidatePowerPolicies(0,&pp);
2142 ok(!ret, "function was expected to fail\n");
2143 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2144 ok(compare(pp,pp_compare),"Difference Found\n");
2145
2146 pp_original.user.MaxSleepDc=PowerSystemShutdown;
2147 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2148 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2149 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2150 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2151 ret = ValidatePowerPolicies(0,&pp);
2152 ok(!ret, "function was expected to fail\n");
2153 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2154 ok(compare(pp,pp_compare),"Difference Found\n");
2155
2156 pp_original.mach.MinSleepAc=PowerSystemMaximum;
2157 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2158 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2159 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2160 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2161 ret = ValidatePowerPolicies(0,&pp);
2162 ok(!ret, "function was expected to fail\n");
2163 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2164 ok(compare(pp,pp_compare),"Difference Found\n");
2165
2166 pp_original.mach.MinSleepDc=PowerSystemMaximum;
2167 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2168 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2169 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2170 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2171 ret = ValidatePowerPolicies(0,&pp);
2172 ok(!ret, "function was expected to fail\n");
2173 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2174 ok(compare(pp,pp_compare),"Difference Found\n");
2175
2176 pp_original.user.MaxSleepAc=PowerSystemMaximum;
2177 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2178 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2179 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2180 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2181 ret = ValidatePowerPolicies(0,&pp);
2182 ok(!ret, "function was expected to fail\n");
2183 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2184 ok(compare(pp,pp_compare),"Difference Found\n");
2185
2186 pp_original.user.MaxSleepDc=PowerSystemMaximum;
2187 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2188 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2189 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2190 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2191 ret = ValidatePowerPolicies(0,&pp);
2192 ok(!ret, "function was expected to fail\n");
2193 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2194 ok(compare(pp,pp_compare),"Difference Found\n");
2195
2196 pp_original.mach.MinSleepAc=PowerSystemMaximum+1;
2197 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2198 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2199 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2200 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2201 ret = ValidatePowerPolicies(0,&pp);
2202 ok(!ret, "function was expected to fail\n");
2203 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2204 ok(compare(pp,pp_compare),"Difference Found\n");
2205
2206 pp_original.mach.MinSleepDc=PowerSystemMaximum+1;
2207 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2208 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2209 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2210 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2211 ret = ValidatePowerPolicies(0,&pp);
2212 ok(!ret, "function was expected to fail\n");
2213 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2214 ok(compare(pp,pp_compare),"Difference Found\n");
2215
2216 pp_original.user.MaxSleepAc=PowerSystemMaximum+1;
2217 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2218 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2219 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2220 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2221 ret = ValidatePowerPolicies(0,&pp);
2222 ok(!ret, "function was expected to fail\n");
2223 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2224 ok(compare(pp,pp_compare),"Difference Found\n");
2225
2226 pp_original.user.MaxSleepDc=PowerSystemMaximum+1;
2227 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2228 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2229 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2230 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2231 ret = ValidatePowerPolicies(0,&pp);
2232 ok(!ret, "function was expected to fail\n");
2233 ok(GetLastError() == ERROR_GEN_FAILURE,"function was expected to fail with ERROR_GEN_FAILURE, but error :%i\n",(UINT)GetLastError());
2234 ok(compare(pp,pp_compare),"Difference Found\n");
2235
2236 pp_original.mach.MinSleepAc=PowerSystemWorking;
2237 pp_original.mach.MinSleepDc=PowerSystemWorking;
2238 pp_original.user.MaxSleepAc=PowerSystemWorking;
2239 pp_original.user.MaxSleepDc=PowerSystemWorking;
2240
2241
2242 test_ValidatePowerPolicies_Next(&gpp_original,&pp_original);
2243
2244
2245 // memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2246 // memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2247 //memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2248 // memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2249 ret = GetCurrentPowerPolicies(&gpp_original,&pp_original);
2250 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2251 //gpp_compare.mach.BroadcastCapacityResolution = 3;
2252 //gpp_compare.user.PowerButtonAc.Action = 2;
2253 //gpp_compare.user.PowerButtonAc.Flags=3;
2254 //gpp_compare.user.PowerButtonDc.EventCode=16;
2255 //gpp_compare.user.PowerButtonDc.Flags=3;
2256 //gpp_compare.user.SleepButtonAc.Action=2;
2257 //gpp_compare.user.SleepButtonAc.Flags=3;
2258 //gpp_compare.user.SleepButtonDc.Action=2;
2259 //gpp_compare.user.SleepButtonDc.Flags=3;
2260 //gpp_compare.user.LidCloseAc.EventCode=-2147483648;
2261 //gpp_compare.user.LidCloseAc.Flags=1;
2262 //gpp_compare.user.LidCloseDc.EventCode=-2147483648;
2263 //gpp_compare.user.LidCloseDc.Flags=1;
2264
2265 //gpp_compare.user.DischargePolicy[0].Enable=1;
2266 ////gpp_compare.user.DischargePolicy[0].Spare[0]=3;
2267 //gpp_compare.user.DischargePolicy[0].Spare[3]=3;
2268 //gpp_compare.user.DischargePolicy[0].BatteryLevel=3;
2269 //gpp_compare.user.DischargePolicy[0].PowerPolicy.Action=2;
2270 //gpp_compare.user.DischargePolicy[0].PowerPolicy.Flags=-1073741820;
2271 //gpp_compare.user.DischargePolicy[0].PowerPolicy.EventCode=1;
2272 //gpp_compare.user.DischargePolicy[0].MinSystemState=4;
2273
2274 //gpp_compare.user.DischargePolicy[1].Enable=1;
2275 ////gpp_compare.user.DischargePolicy[1].Spare[0]=3;
2276 //gpp_compare.user.DischargePolicy[1].Spare[3]=10;
2277 //gpp_compare.user.DischargePolicy[1].BatteryLevel=10;
2278 ////gpp_compare.user.DischargePolicy[1].PowerPolicy.Action=3;
2279 //gpp_compare.user.DischargePolicy[1].PowerPolicy.Flags=3;
2280 //gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode=65537;
2281 //gpp_compare.user.DischargePolicy[1].MinSystemState=1;
2282 //
2283 //gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode=131072;
2284 //gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode=196608;
2285 //gpp_compare.user.GlobalFlags=20;
2286
2287 //ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
2288 //pp_compare.mach.MinSleepAc=4;
2289 //pp_compare.mach.MinSleepDc=4;
2290 //pp_compare.mach.ReducedLatencySleepAc=4;
2291 //pp_compare.mach.ReducedLatencySleepDc=4;
2292 //pp_compare.mach.OverThrottledAc.Action=2;
2293 //pp_compare.mach.OverThrottledAc.Flags=-1073741820;
2294 //pp_compare.mach.OverThrottledDc.Action=2;
2295 //pp_compare.mach.OverThrottledDc.Flags=-1073741820;
2296 //pp_compare.mach.pad1[2]=2;
2297 //pp_compare.user.IdleAc.Flags=1;
2298 //pp_compare.user.IdleDc.Flags=1;
2299 //pp_compare.user.IdleSensitivityAc=50;
2300 //pp_compare.user.IdleSensitivityDc=50;
2301 //pp_compare.user.ThrottlePolicyAc=3;
2302 //pp_compare.user.ThrottlePolicyDc=3;
2303 //pp_compare.user.Reserved[2]=1200;
2304 //pp_compare.user.VideoTimeoutAc=1200;
2305 //pp_compare.user.VideoTimeoutDc=600;
2306 //pp_compare.user.SpindownTimeoutAc=2700;
2307 //pp_compare.user.SpindownTimeoutDc=600;
2308 //pp_compare.user.FanThrottleToleranceAc=100;
2309 //pp_compare.user.FanThrottleToleranceDc=80;
2310 //pp_compare.user.ForcedThrottleAc=100;
2311 //pp_compare.user.ForcedThrottleDc=100;
2312 //pp_compare.user.MaxSleepAc=4;
2313 //pp_compare.user.MaxSleepDc=4;
2314 //pp_compare.user.OptimizeForPowerAc=1;
2315 //pp_compare.user.OptimizeForPowerDc=1;
2316 //ok(compare(pp,pp_compare),"Difference Found\n");
2317
2318 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2319 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2320 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2321 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2322 ret = ValidatePowerPolicies(&gpp,0);
2323 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2324 //gpp_compare.mach.BroadcastCapacityResolution=100;
2325 //gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
2326 //gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
2327 //gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
2328 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
2329
2330 memcpy(&gpp, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2331 memcpy(&gpp_compare, &gpp_original, sizeof(GLOBAL_POWER_POLICY));
2332 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2333 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2334 ret = ValidatePowerPolicies(0,&pp);
2335 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2336 //pp_compare.mach.MinSleepAc=4;
2337 //pp_compare.mach.MinSleepDc=4;
2338 //pp_compare.user.MaxSleepAc=4;
2339 //pp_compare.user.MaxSleepDc=4;
2340 //pp_compare.user.OptimizeForPowerAc=1;
2341 //pp_compare.user.OptimizeForPowerDc=1;
2342 ok(compare(pp,pp_compare),"Difference Found\n");
2343
2344 memcpy(&pp, &pp_original, sizeof(POWER_POLICY));
2345 memcpy(&pp_compare, &pp_original, sizeof(POWER_POLICY));
2346 ret = ValidatePowerPolicies(&gpp,&pp);
2347 ok(ret, "function was expected to succeed error %i\n",(UINT)GetLastError());
2348 //gpp_compare.mach.BroadcastCapacityResolution=100;
2349 //gpp_compare.user.DischargePolicy[1].PowerPolicy.EventCode = 65536;
2350 //gpp_compare.user.DischargePolicy[2].PowerPolicy.EventCode = 131072;
2351 //gpp_compare.user.DischargePolicy[3].PowerPolicy.EventCode = 196608;
2352 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
2353 pp_compare.mach.MinSleepAc=4;
2354 pp_compare.mach.MinSleepDc=4;
2355 pp_compare.user.MaxSleepAc=4;
2356 pp_compare.user.MaxSleepDc=4;
2357 //pp_compare.user.OptimizeForPowerAc=1;
2358 //pp_compare.user.OptimizeForPowerDc=1;
2359 ok(compare(pp,pp_compare),"Difference Found\n");
2360
2361 }
2362
2363 void test_ValidatePowerPolicies_Next(PGLOBAL_POWER_POLICY pGPP_original,PPOWER_POLICY pPP_original)
2364 {
2365 GLOBAL_POWER_POLICY gpp, gpp_compare;
2366 POWER_POLICY pp, pp_compare;
2367 BOOLEAN ret;
2368
2369 //printf("Old: %i\n",pGPP_original->mach.LidOpenWakeAc);//1
2370 //printf("Old: %i\n",pGPP_original->mach.LidOpenWakeDc);//1
2371 //printf("Old: %i,%i,%i \n",pGPP_original->user.LidCloseAc.Action,pGPP_original->user.LidCloseAc.EventCode,pGPP_original->user.LidCloseAc.Flags);//7
2372 //printf("Old: %i,%i,%i \n",pGPP_original->user.LidCloseDc.Action,pGPP_original->user.LidCloseDc.EventCode,pGPP_original->user.LidCloseDc.Flags);//7
2373 //printf("Old: %i,%i,%i \n",pGPP_original->user.PowerButtonAc.Action,pGPP_original->user.PowerButtonAc.EventCode,pGPP_original->user.PowerButtonAc.Flags);//0,0,0
2374 //printf("Old: %i,%i,%i \n",pGPP_original->user.PowerButtonDc.Action,pGPP_original->user.PowerButtonDc.EventCode,pGPP_original->user.PowerButtonDc.Flags);//7,0,0
2375 //printf("Old: %i,%i,%i \n",pGPP_original->user.SleepButtonAc.Action,pGPP_original->user.SleepButtonAc.EventCode,pGPP_original->user.SleepButtonAc.Flags);//7,0,0
2376 //printf("Old: %i,%i,%i \n",pGPP_original->user.SleepButtonDc.Action,pGPP_original->user.SleepButtonDc.EventCode,pGPP_original->user.SleepButtonDc.Flags);//7,0,0
2377 //printf("Old: %i \n",pPP_original->mach.DozeS4TimeoutAc);//0
2378 //printf("Old: %i \n",pPP_original->mach.DozeS4TimeoutDc);//0
2379 //printf("Old: %i \n",pPP_original->mach.DozeTimeoutAc);//0
2380 //printf("Old: %i \n",pPP_original->mach.DozeTimeoutDc);//0
2381 //printf("Old: %i \n",pPP_original->mach.MinSleepAc);//1
2382 //printf("Old: %i \n",pPP_original->mach.MinSleepDc);//1
2383 //printf("Old: %i \n",pPP_original->mach.MinThrottleAc);//0
2384 //printf("Old: %i \n",pPP_original->mach.MinThrottleDc);//0
2385 //printf("Old: %i,%i,%i \n",pPP_original->mach.OverThrottledAc.Action,pPP_original->mach.OverThrottledAc.EventCode,pPP_original->mach.OverThrottledAc.Flags);//0,0,0
2386 //printf("Old: %i,%i,%i \n",pPP_original->mach.OverThrottledDc.Action,pPP_original->mach.OverThrottledDc.EventCode,pPP_original->mach.OverThrottledDc.Flags);//0,0,0
2387 //printf("Old: %i \n",pPP_original->mach.ReducedLatencySleepAc);//1
2388 //printf("Old: %i \n",pPP_original->mach.ReducedLatencySleepDc);//1
2389 //printf("Old: %i \n",pPP_original->user.FanThrottleToleranceAc);//0
2390 //printf("Old: %i \n",pPP_original->user.FanThrottleToleranceDc);//0
2391 //printf("Old: %i \n",pPP_original->user.ForcedThrottleAc);//0
2392 //printf("Old: %i \n",pPP_original->user.ForcedThrottleDc);//0
2393 //printf("Old: %i,%i,%i \n",pPP_original->user.IdleAc.Action,pPP_original->user.IdleAc.EventCode,pPP_original->user.IdleAc.Flags);//0,0,0
2394 //printf("Old: %i,%i,%i \n",pPP_original->user.IdleDc.Action,pPP_original->user.IdleDc.EventCode,pPP_original->user.IdleDc.Flags);//0,0,0
2395 //printf("Old: %i \n",pPP_original->user.IdleSensitivityAc);//0
2396 //printf("Old: %i \n",pPP_original->user.IdleSensitivityDc);//0
2397 //printf("Old: %i \n",pPP_original->user.IdleTimeoutAc);//0
2398 //printf("Old: %i \n",pPP_original->user.IdleTimeoutDc);//0
2399 //printf("Old: %i \n",pPP_original->user.MaxSleepAc);//1
2400 //printf("Old: %i \n",pPP_original->user.MaxSleepDc);//1
2401 //printf("Old: %i \n",pPP_original->user.OptimizeForPowerAc);//0
2402 //printf("Old: %i \n",pPP_original->user.OptimizeForPowerDc);//0
2403 //printf("Old: %i \n",pPP_original->user.SpindownTimeoutAc);//0
2404 //printf("Old: %i \n",pPP_original->user.SpindownTimeoutDc);//0
2405 //printf("Old: %i \n",pPP_original->user.ThrottlePolicyAc);//0
2406 //printf("Old: %i \n",pPP_original->user.ThrottlePolicyDc);//0
2407 //printf("Old: %i \n",pPP_original->user.VideoTimeoutAc);//0
2408 //printf("Old: %i \n",pPP_original->user.VideoTimeoutDc);//0
2409
2410 pPP_original->mach.MinSleepAc=4;
2411 pPP_original->mach.MinSleepDc=4;
2412 pPP_original->user.MaxSleepAc=4;
2413 pPP_original->user.MaxSleepDc=4;
2414 pPP_original->user.OptimizeForPowerAc=1;
2415 pPP_original->user.OptimizeForPowerDc=1;
2416
2417 memcpy(&gpp, pGPP_original, sizeof(GLOBAL_POWER_POLICY));
2418 memcpy(&gpp_compare, pGPP_original, sizeof(GLOBAL_POWER_POLICY));
2419 ok(globalcompare(gpp,gpp_compare),"Difference Found\n");
2420
2421 memcpy(&pp, pPP_original, sizeof(POWER_POLICY));
2422 memcpy(&pp_compare, pPP_original, sizeof(POWER_POLICY));
2423 ok(compare(pp,pp_compare),"Difference Found\n");
2424