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