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