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