schedsvc/tests: Don't depend on folder enumeration order.
[wine.git] / dlls / schedsvc / tests / rpcapi.c
blob0220641f971a69f8f42a0af418c0f907a923a731
1 /*
2 * Copyright 2014 Dmitry Timoshkov
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdio.h>
20 #include <windows.h>
21 #include <ole2.h>
22 #include <rpcdce.h>
23 #include <taskschd.h>
24 #include "schrpc.h"
26 #include "wine/test.h"
28 extern handle_t rpc_handle;
30 static LONG CALLBACK rpc_exception_filter(EXCEPTION_POINTERS *ptrs)
32 skip("Can't connect to Scheduler service: %#x\n", ptrs->ExceptionRecord->ExceptionCode);
34 if (winetest_debug)
36 fprintf(stdout, "rpcapi: 0 tests executed (0 marked as todo, 0 failures), 1 skipped.\n");
37 fflush(stdout);
39 ExitProcess(0);
42 START_TEST(rpcapi)
44 static unsigned char ncalrpc[] = "ncalrpc";
45 static const WCHAR empty[] = { 0 };
46 static const WCHAR Wine[] = { '\\','W','i','n','e',0 };
47 static const WCHAR Wine_Folder1[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1',0 };
48 static const WCHAR Wine_Folder2[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','2',0 };
49 static const WCHAR Folder1[] = { 'F','o','l','d','e','r','1',0 };
50 static const WCHAR Folder2[] = { 'F','o','l','d','e','r','2',0 };
51 static const WCHAR Wine_Task1[] = { '\\','W','i','n','e','\\','T','a','s','k','1',0 };
52 static const WCHAR Wine_Task2[] = { '\\','W','i','n','e','\\','T','a','s','k','2',0 };
53 static const WCHAR Wine_Task3[] = { '\\','W','i','n','e','\\','T','a','s','k','3',0 };
54 static const WCHAR Wine_Folder1_Task1[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1','\\','T','a','s','k','1',0 };
55 static const WCHAR Task1[] = { 'T','a','s','k','1',0 };
56 static const WCHAR Task2[] = { 'T','a','s','k','2',0 };
57 static const WCHAR Task3[] = { 'T','a','s','k','3',0 };
58 static const char xml1[] =
59 "<?xml version=\"1.0\"?>\n"
60 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
61 " <RegistrationInfo>\n"
62 " <Description>\"Task1\"</Description>\n"
63 " </RegistrationInfo>\n"
64 " <Settings>\n"
65 " <Enabled>false</Enabled>\n"
66 " <Hidden>false</Hidden>\n"
67 " </Settings>\n"
68 " <Actions>\n"
69 " <Exec>\n"
70 " <Command>\"task1.exe\"</Command>\n"
71 " </Exec>\n"
72 " </Actions>\n"
73 "</Task>\n";
74 static const struct
76 DWORD flags, hr;
77 } create_new_task[] =
79 { 0, S_OK },
80 { TASK_CREATE, S_OK },
81 { TASK_UPDATE, 0x80070002 /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ },
82 { TASK_CREATE | TASK_UPDATE, S_OK }
84 static const struct
86 DWORD flags, hr;
87 } open_existing_task[] =
89 { 0, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
90 { TASK_CREATE, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
91 { TASK_UPDATE, S_OK },
92 { TASK_CREATE | TASK_UPDATE, S_OK }
94 WCHAR xmlW[sizeof(xml1)], *xml;
95 HRESULT hr;
96 DWORD version, start_index, count, i, enumed, enabled, state;
97 WCHAR *path;
98 TASK_XML_ERROR_INFO *info;
99 TASK_NAMES names;
100 unsigned char *binding_str;
101 PTOP_LEVEL_EXCEPTION_FILTER old_exception_filter;
102 IID iid;
104 hr = RpcStringBindingComposeA(NULL, ncalrpc, NULL, NULL, NULL, &binding_str);
105 ok(hr == RPC_S_OK, "RpcStringBindingCompose error %#x\n", hr);
106 hr = RpcBindingFromStringBindingA(binding_str, &rpc_handle);
107 ok(hr == RPC_S_OK, "RpcBindingFromStringBinding error %#x\n", hr);
108 hr = RpcStringFreeA(&binding_str);
109 ok(hr == RPC_S_OK, "RpcStringFree error %#x\n", hr);
111 /* widl generated RpcTryExcept/RpcExcept can't catch raised exceptions */
112 old_exception_filter = SetUnhandledExceptionFilter(rpc_exception_filter);
114 version = 0;
115 hr = SchRpcHighestVersion(&version);
116 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
117 ok(version == 0x10002 /* vista */ || version == 0x10003 /* win7 */ || version == 0x10004 /* win8 */,
118 "wrong version %#x\n", version);
120 SetUnhandledExceptionFilter(old_exception_filter);
122 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 1);
123 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
125 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
126 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
128 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
129 ok(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr);
131 hr = SchRpcCreateFolder(Wine_Folder2+1, empty, 0);
132 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
134 hr = SchRpcDelete(Wine+1, 0);
135 ok(hr == HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY), "expected ERROR_DIR_NOT_EMPTY, got %#x\n", hr);
137 hr = SchRpcDelete(Wine_Folder1+1, 1);
138 ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);
140 hr = SchRpcDelete(Wine_Folder1+1, 0);
141 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
143 hr = SchRpcDelete(Wine_Folder2, 0);
144 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
146 hr = SchRpcDelete(Wine, 0);
147 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
149 hr = SchRpcDelete(Wine, 0);
150 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
152 hr = SchRpcDelete(empty, 0);
153 ok(hr == E_ACCESSDENIED /* win7 */ || hr == E_INVALIDARG /* vista */, "expected E_ACCESSDENIED, got %#x\n", hr);
155 hr = SchRpcCreateFolder(Wine, NULL, 0);
156 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
158 MultiByteToWideChar(CP_ACP, 0, xml1, -1, xmlW, sizeof(xmlW)/sizeof(xmlW[0]));
160 path = NULL;
161 info = NULL;
162 hr = SchRpcRegisterTask(Wine+1, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
163 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
164 ok(!path, "expected NULL, path %p\n", path);
165 ok(!info, "expected NULL, info %p\n", info);
167 for (i = 0; i < sizeof(create_new_task)/sizeof(create_new_task[0]); i++)
169 path = NULL;
170 info = NULL;
171 hr = SchRpcRegisterTask(Wine_Task1, xmlW, create_new_task[i].flags, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
172 ok(hr == create_new_task[i].hr, "%u: expected %#x, got %#x\n", i, create_new_task[i].hr, hr);
174 if (hr == S_OK)
176 hr = SchRpcDelete(Wine_Task1, 0);
177 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
178 ok(!info, "expected NULL, info %p\n", info);
179 MIDL_user_free(path);
183 path = NULL;
184 info = NULL;
185 hr = SchRpcRegisterTask(Wine_Task1, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
186 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
187 ok(!path, "expected NULL, path %p\n", path);
188 ok(!info, "expected NULL, info %p\n", info);
190 path = NULL;
191 info = NULL;
192 hr = SchRpcRegisterTask(NULL, xmlW, TASK_VALIDATE_ONLY, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
193 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
194 ok(!path, "expected NULL, path %p\n", path);
195 ok(!info, "expected NULL, info %p\n", info);
197 path = NULL;
198 info = NULL;
199 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
200 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
201 ok(!lstrcmpW(path, Wine_Folder1_Task1) /* win7 */ || !lstrcmpW(path, Wine_Folder1_Task1+1) /* vista */,
202 "expected \\Wine\\Folder1\\Task1, task actual path %s\n", wine_dbgstr_w(path));
203 ok(!info, "expected NULL, info %p\n", info);
204 MIDL_user_free(path);
206 for (i = 0; i < sizeof(open_existing_task)/sizeof(open_existing_task[0]); i++)
208 path = NULL;
209 info = NULL;
210 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, open_existing_task[i].flags, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
211 ok(hr == open_existing_task[i].hr, "%u: expected %#x, got %#x\n", i, open_existing_task[i].hr, hr);
212 if (hr == S_OK)
214 ok(!lstrcmpW(path, Wine_Folder1_Task1) /* win7 */ || !lstrcmpW(path, Wine_Folder1_Task1+1) /* vista */,
215 "expected \\Wine\\Folder1\\Task1, task actual path %s\n", wine_dbgstr_w(path));
216 MIDL_user_free(path);
218 else
219 ok(!path, "%u: expected NULL, path %p\n", i, path);
220 ok(!info, "%u: expected NULL, info %p\n", i, info);
223 path = NULL;
224 info = NULL;
225 hr = SchRpcRegisterTask(Wine_Folder1_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
226 ok(hr == HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr);
227 ok(!path, "expected NULL, path %p\n", path);
228 ok(!info, "expected NULL, info %p\n", info);
230 count = 0;
231 xml = NULL;
232 hr = SchRpcRetrieveTask(Wine_Folder1_Task1, empty, &count, &xml);
233 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
234 if (hr == S_OK) trace("%s\n", wine_dbgstr_w(xml));
235 MIDL_user_free(xml);
237 hr = SchRpcDelete(Wine_Folder1_Task1+1, 0);
238 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
239 hr = SchRpcDelete(Wine_Folder1+1, 0);
240 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
241 hr = SchRpcDelete(Wine+1, 0);
242 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
244 start_index = 0;
245 count = 0xdeadbeef;
246 names = NULL;
247 hr = SchRpcEnumFolders(Wine, TASK_ENUM_HIDDEN, &start_index, 0, &count, &names);
248 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
249 ok(!count, "expected 0, got %u\n", count);
250 ok(!start_index, "expected 0, got %u\n", start_index);
251 ok(!names, "expected NULL, got %p\n", names);
253 hr = SchRpcCreateFolder(Wine, NULL, 0);
254 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
256 start_index = 0;
257 count = 0xdeadbeef;
258 names = NULL;
259 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
260 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
261 ok(!count, "expected 0, got %u\n", count);
262 ok(!start_index, "expected 0, got %u\n", start_index);
263 ok(!names, "expected NULL, got %p\n", names);
265 hr = SchRpcCreateFolder(Wine_Folder1, NULL, 0);
266 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
267 hr = SchRpcCreateFolder(Wine_Folder2, NULL, 0);
268 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
270 start_index = 0;
271 count = 0xdeadbeef;
272 names = NULL;
273 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
274 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
275 ok(count == 2, "expected 2, got %u\n", count);
276 ok(start_index == 2, "expected 2, got %u\n", start_index);
277 ok(names != NULL, "names should not be NULL\n");
278 enumed = 0;
279 for (i = 0; i < count; i++)
281 if (!lstrcmpW(names[i], Folder1))
282 enumed += 1;
283 else if (!lstrcmpW(names[i], Folder2))
284 enumed += 2;
285 MIDL_user_free(names[i]);
287 MIDL_user_free(names);
288 ok(enumed == 3, "expected 3, got %u\n", enumed);
290 start_index = 0;
291 count = 0xdeadbeef;
292 names = NULL;
293 hr = SchRpcEnumFolders(Wine, 0, &start_index, 1, &count, &names);
294 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
295 ok(count == 1, "expected 1, got %u\n", count);
296 ok(start_index == 1, "expected 1, got %u\n", start_index);
297 ok(names != NULL, "names should not be NULL\n");
298 ok(!lstrcmpW(names[0], Folder1) || !lstrcmpW(names[0], Folder2), "got %s\n", wine_dbgstr_w(names[0]));
299 MIDL_user_free(names[0]);
300 MIDL_user_free(names);
302 start_index = 0;
303 count = 0xdeadbeef;
304 names = NULL;
305 hr = SchRpcEnumFolders(Wine, 0, &start_index, 2, &count, &names);
306 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
307 ok(count == 2, "expected 2, got %u\n", count);
308 ok(start_index == 2, "expected 2, got %u\n", start_index);
309 ok(names != NULL, "names should not be NULL\n");
310 enumed = 0;
311 for (i = 0; i < count; i++)
313 if (!lstrcmpW(names[i], Folder1))
314 enumed += 1;
315 else if (!lstrcmpW(names[i], Folder2))
316 enumed += 2;
317 MIDL_user_free(names[i]);
319 MIDL_user_free(names);
320 ok(enumed == 3, "expected 3, got %u\n", enumed);
322 start_index = 0;
323 count = 0xdeadbeef;
324 names = NULL;
325 hr = SchRpcEnumFolders(Wine, 0, &start_index, 10, &count, &names);
326 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
327 ok(count == 2, "expected 2, got %u\n", count);
328 ok(start_index == 2, "expected 2, got %u\n", start_index);
329 ok(names != NULL, "names should not be NULL\n");
330 enumed = 0;
331 for (i = 0; i < count; i++)
333 if (!lstrcmpW(names[i], Folder1))
334 enumed += 1;
335 else if (!lstrcmpW(names[i], Folder2))
336 enumed += 2;
337 MIDL_user_free(names[i]);
339 MIDL_user_free(names);
340 ok(enumed == 3, "expected 3, got %u\n", enumed);
342 start_index = 10;
343 count = 0xdeadbeef;
344 names = NULL;
345 hr = SchRpcEnumFolders(Wine, 0, &start_index, 0, &count, &names);
346 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
347 ok(!count, "expected 0, got %u\n", count);
348 ok(start_index == 10, "expected 10, got %u\n", start_index);
349 ok(!names, "expected NULL, got %p\n", names);
351 hr = SchRpcDelete(Wine_Folder1+1, 0);
352 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
353 hr = SchRpcDelete(Wine_Folder2, 0);
354 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
356 start_index = 0;
357 count = 0xdeadbeef;
358 names = NULL;
359 hr = SchRpcEnumTasks(Wine_Folder1, TASK_ENUM_HIDDEN, &start_index, 0, &count, &names);
360 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
361 ok(!count, "expected 0, got %u\n", count);
362 ok(!start_index, "expected 0, got %u\n", start_index);
363 ok(!names, "expected NULL, got %p\n", names);
365 path = NULL;
366 info = NULL;
367 hr = SchRpcRegisterTask(Wine_Task1+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
368 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
369 ok(!lstrcmpW(path, Wine_Task1) /* win7 */ || !lstrcmpW(path, Wine_Task1+1) /* vista */,
370 "expected \\Wine\\Task1, task actual path %s\n", wine_dbgstr_w(path));
371 ok(!info, "expected NULL, info %p\n", info);
372 MIDL_user_free(path);
374 path = NULL;
375 info = NULL;
376 hr = SchRpcRegisterTask(Wine_Task2, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
377 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
378 ok(!lstrcmpW(path, Wine_Task2), "expected \\Wine\\Task2, task actual path %s\n", wine_dbgstr_w(path));
379 ok(!info, "expected NULL, info %p\n", info);
380 MIDL_user_free(path);
382 start_index = 0;
383 count = 0xdeadbeef;
384 names = NULL;
385 hr = SchRpcEnumTasks(Wine, 0, &start_index, 0, &count, &names);
386 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
387 ok(count == 2, "expected 2, got %u\n", count);
388 ok(start_index == 2, "expected 2, got %u\n", start_index);
389 ok(names != NULL, "names should not be NULL\n");
390 enumed = 0;
391 for (i = 0; i < count; i++)
393 if (!lstrcmpW(names[i], Task1))
394 enumed += 1;
395 else if (!lstrcmpW(names[i], Task2))
396 enumed += 2;
397 MIDL_user_free(names[i]);
399 MIDL_user_free(names);
400 ok(enumed == 3, "expected 3, got %u\n", enumed);
402 start_index = 0;
403 count = 0xdeadbeef;
404 names = NULL;
405 hr = SchRpcEnumTasks(Wine, 0, &start_index, 1, &count, &names);
406 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
407 ok(count == 1, "expected 1, got %u\n", count);
408 ok(start_index == 1, "expected 1, got %u\n", start_index);
409 ok(names != NULL, "names should not be NULL\n");
410 /* returned name depends whether directory randomization is on */
411 ok(!lstrcmpW(names[0], Task1) || !lstrcmpW(names[0], Task2),
412 "expected Task1, got %s\n", wine_dbgstr_w(names[0]));
413 MIDL_user_free(names[0]);
414 MIDL_user_free(names);
416 start_index = 0;
417 count = 0xdeadbeef;
418 names = NULL;
419 hr = SchRpcEnumTasks(Wine, 0, &start_index, 2, &count, &names);
420 ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
421 ok(count == 2, "expected 2, got %u\n", count);
422 ok(start_index == 2, "expected 2, got %u\n", start_index);
423 ok(names != NULL, "names should not be NULL\n");
424 enumed = 0;
425 for (i = 0; i < count; i++)
427 if (!lstrcmpW(names[i], Task1))
428 enumed += 1;
429 else if (!lstrcmpW(names[i], Task2))
430 enumed += 2;
431 MIDL_user_free(names[i]);
433 MIDL_user_free(names);
434 ok(enumed == 3, "expected 3, got %u\n", enumed);
436 start_index = 0;
437 count = 0xdeadbeef;
438 names = NULL;
439 hr = SchRpcEnumTasks(Wine, 0, &start_index, 10, &count, &names);
440 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
441 ok(count == 2, "expected 2, got %u\n", count);
442 ok(start_index == 2, "expected 2, got %u\n", start_index);
443 ok(names != NULL, "names should not be NULL\n");
444 enumed = 0;
445 for (i = 0; i < count; i++)
447 if (!lstrcmpW(names[i], Task1))
448 enumed += 1;
449 else if (!lstrcmpW(names[i], Task2))
450 enumed += 2;
451 MIDL_user_free(names[i]);
453 MIDL_user_free(names);
454 ok(enumed == 3, "expected 3, got %u\n", enumed);
456 path = NULL;
457 info = NULL;
458 hr = SchRpcRegisterTask(Wine_Task3+1, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
459 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
460 ok(!lstrcmpW(path, Wine_Task3) /* win7 */ || !lstrcmpW(path, Wine_Task3+1) /* vista */,
461 "expected \\Wine\\Task3, task actual path %s\n", wine_dbgstr_w(path));
462 ok(!info, "expected NULL, info %p\n", info);
463 MIDL_user_free(path);
465 count = 0xdeadbeef;
466 names = NULL;
467 hr = SchRpcEnumTasks(Wine+1, 0, &start_index, 10, &count, &names);
468 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
469 ok(count == 1, "expected 1, got %u\n", count);
470 ok(start_index == 3, "expected 3, got %u\n", start_index);
471 ok(names != NULL, "names should not be NULL\n");
472 /* returned name depends whether directory randomization is on */
473 ok(!lstrcmpW(names[0], Task1) || !lstrcmpW(names[0], Task2) || !lstrcmpW(names[0], Task3),
474 "expected Task3, got %s\n", wine_dbgstr_w(names[0]));
475 MIDL_user_free(names[0]);
476 MIDL_user_free(names);
478 if (0) /* crashes under win7 */
480 hr = SchRpcGetTaskInfo(NULL, 0, NULL, NULL);
481 hr = SchRpcGetTaskInfo(Task1, 0, NULL, NULL);
482 hr = SchRpcGetTaskInfo(Task1, 0, &enabled, NULL);
483 hr = SchRpcGetTaskInfo(Task1, 0, NULL, &state);
486 hr = SchRpcGetTaskInfo(Task1, 0, &enabled, &state);
487 ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr);
489 enabled = state = 0xdeadbeef;
490 hr = SchRpcGetTaskInfo(Wine_Task1, 0, &enabled, &state);
491 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
492 ok(enabled == 0, "expected 0, got %u\n", enabled);
493 ok(state == TASK_STATE_UNKNOWN, "expected TASK_STATE_UNKNOWN, got %u\n", state);
495 enabled = state = 0xdeadbeef;
496 hr = SchRpcGetTaskInfo(Wine_Task1, SCH_FLAG_STATE, &enabled, &state);
497 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
498 ok(enabled == 0, "expected 0, got %u\n", enabled);
499 ok(state == TASK_STATE_DISABLED, "expected TASK_STATE_DISABLED, got %u\n", state);
501 hr = SchRpcEnableTask(Wine_Task1, 0xdeadbeef);
502 todo_wine
503 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
505 enabled = state = 0xdeadbeef;
506 hr = SchRpcGetTaskInfo(Wine_Task1, SCH_FLAG_STATE, &enabled, &state);
507 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
508 todo_wine
509 ok(enabled == 1, "expected 1, got %u\n", enabled);
510 todo_wine
511 ok(state == TASK_STATE_READY, "expected TASK_STATE_READY, got %u\n", state);
513 hr = SchRpcDelete(Wine_Task1+1, 0);
514 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
515 hr = SchRpcDelete(Wine_Task2+1, 0);
516 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
517 hr = SchRpcDelete(Wine_Task3+1, 0);
518 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
519 hr = SchRpcDelete(Wine, 0);
520 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
522 path = NULL;
523 info = NULL;
524 hr = SchRpcRegisterTask(NULL, xmlW, TASK_CREATE, NULL, TASK_LOGON_NONE, 0, NULL, &path, &info);
525 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
526 ok(!info, "expected NULL, info %p\n", info);
527 hr = IIDFromString(path, &iid);
528 ok(hr == S_OK, "IIDFromString(%s) error %#x\n", wine_dbgstr_w(path), hr);
529 hr = SchRpcDelete(path, 0);
530 ok(hr == S_OK, "expected S_OK, got %#x\n", hr);
531 MIDL_user_free(path);
533 hr = RpcBindingFree(&rpc_handle);
534 ok(hr == RPC_S_OK, "RpcBindingFree error %#x\n", hr);
537 void __RPC_FAR *__RPC_USER MIDL_user_allocate(SIZE_T n)
539 return HeapAlloc(GetProcessHeap(), 0, n);
542 void __RPC_USER MIDL_user_free(void __RPC_FAR *p)
544 HeapFree(GetProcessHeap(), 0, p);