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
30 #include <wine/test.h>
32 static void test_Connect(void)
34 static WCHAR empty
[] = { 0 };
35 static const WCHAR deadbeefW
[] = { '0','.','0','.','0','.','0',0 };
36 WCHAR comp_name
[MAX_COMPUTERNAME_LENGTH
+ 1];
40 VARIANT v_null
, v_comp
;
43 ITaskService
*service
;
45 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
48 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
52 hr
= ITaskService_get_Connected(service
, NULL
);
53 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
56 hr
= ITaskService_get_Connected(service
, &vbool
);
57 ok(hr
== S_OK
, "get_Connected error %#x\n", hr
);
58 ok(vbool
== VARIANT_FALSE
, "expected VARIANT_FALSE, got %d\n", vbool
);
60 hr
= ITaskService_get_TargetServer(service
, NULL
);
61 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
63 hr
= ITaskService_get_TargetServer(service
, &bstr
);
64 ok(hr
== HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
), "expected ERROR_ONLY_IF_CONNECTED, got %#x\n", hr
);
66 /* Win7 doesn't support UNC \\ prefix, but according to a user
67 * comment on MSDN Win8 supports both ways.
69 len
= sizeof(comp_name
)/sizeof(comp_name
[0]);
70 GetComputerNameW(comp_name
, &len
);
72 V_VT(&v_null
) = VT_NULL
;
74 V_VT(&v_comp
) = VT_BSTR
;
75 V_BSTR(&v_comp
) = SysAllocString(comp_name
);
77 hr
= ITaskService_Connect(service
, v_comp
, v_null
, v_null
, v_null
);
78 ok(hr
== S_OK
|| hr
== E_ACCESSDENIED
/* not an administrator */, "Connect error %#x\n", hr
);
79 was_connected
= hr
== S_OK
;
80 SysFreeString(V_BSTR(&v_comp
));
82 V_BSTR(&v_comp
) = SysAllocString(deadbeefW
);
83 hr
= ITaskService_Connect(service
, v_comp
, v_null
, v_null
, v_null
);
84 ok(hr
== HRESULT_FROM_WIN32(RPC_S_INVALID_NET_ADDR
) || hr
== HRESULT_FROM_WIN32(ERROR_BAD_NETPATH
) /* VM */,
85 "expected RPC_S_INVALID_NET_ADDR, got %#x\n", hr
);
86 SysFreeString(V_BSTR(&v_comp
));
89 hr
= ITaskService_get_Connected(service
, &vbool
);
90 ok(hr
== S_OK
, "get_Connected error %#x\n", hr
);
91 ok(vbool
== VARIANT_FALSE
|| (was_connected
&& vbool
== VARIANT_TRUE
),
92 "Connect shouldn't trash an existing connection, got %d (was connected %d)\n", vbool
, was_connected
);
94 V_BSTR(&v_comp
) = SysAllocString(empty
);
95 hr
= ITaskService_Connect(service
, v_comp
, v_null
, v_null
, v_null
);
96 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
97 SysFreeString(V_BSTR(&v_comp
));
99 V_BSTR(&v_comp
) = NULL
;
100 hr
= ITaskService_Connect(service
, v_comp
, v_null
, v_null
, v_null
);
101 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
103 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
104 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
107 hr
= ITaskService_get_Connected(service
, &vbool
);
108 ok(hr
== S_OK
, "get_Connected error %#x\n", hr
);
109 ok(vbool
== VARIANT_TRUE
, "expected VARIANT_TRUE, got %d\n", vbool
);
111 hr
= ITaskService_get_TargetServer(service
, &bstr
);
112 ok(hr
== S_OK
, "get_TargetServer error %#x\n", hr
);
113 ok(!lstrcmpW(comp_name
, bstr
), "compname %s != server name %s\n", wine_dbgstr_w(comp_name
), wine_dbgstr_w(bstr
));
116 ITaskService_Release(service
);
119 static void test_GetFolder(void)
121 static WCHAR dot
[] = { '.',0 };
122 static WCHAR empty
[] = { 0 };
123 static WCHAR slash
[] = { '/',0 };
124 static WCHAR bslash
[] = { '\\',0 };
125 static WCHAR Wine
[] = { '\\','W','i','n','e',0 };
126 static WCHAR Wine_Folder1
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1',0 };
127 static WCHAR Wine_Folder1_
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1','\\',0 };
128 static WCHAR Wine_Folder1_Folder2
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1','\\','F','o','l','d','e','r','2',0 };
129 static WCHAR Folder1_Folder2
[] = { '\\','F','o','l','d','e','r','1','\\','F','o','l','d','e','r','2',0 };
130 static const WCHAR Folder1
[] = { 'F','o','l','d','e','r','1',0 };
131 static const WCHAR Folder2
[] = { 'F','o','l','d','e','r','2',0 };
135 ITaskService
*service
;
136 ITaskFolder
*folder
, *subfolder
, *subfolder2
;
138 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
141 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
145 hr
= ITaskService_GetFolder(service
, NULL
, &folder
);
146 ok(hr
== HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED
), "expected ERROR_ONLY_IF_CONNECTED, got %#x\n", hr
);
148 V_VT(&v_null
) = VT_NULL
;
150 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
151 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
153 hr
= ITaskService_GetFolder(service
, slash
, &folder
);
155 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
157 hr
= ITaskService_GetFolder(service
, dot
, &folder
);
159 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
161 hr
= ITaskService_GetFolder(service
, bslash
, &folder
);
162 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
163 ITaskFolder_Release(folder
);
165 hr
= ITaskService_GetFolder(service
, NULL
, NULL
);
166 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
168 hr
= ITaskService_GetFolder(service
, empty
, &folder
);
169 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
170 ITaskFolder_Release(folder
);
172 hr
= ITaskService_GetFolder(service
, NULL
, &folder
);
173 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
175 hr
= ITaskFolder_get_Name(folder
, NULL
);
176 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
178 hr
= ITaskFolder_get_Name(folder
, &bstr
);
179 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
180 ok(!lstrcmpW(bstr
, bslash
), "expected '\\', got %s\n", wine_dbgstr_w(bstr
));
183 hr
= ITaskFolder_get_Path(folder
, NULL
);
184 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
186 hr
= ITaskFolder_get_Path(folder
, &bstr
);
187 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
188 ok(!lstrcmpW(bstr
, bslash
), "expected '\\', got %s\n", wine_dbgstr_w(bstr
));
191 hr
= ITaskFolder_CreateFolder(folder
, NULL
, v_null
, &subfolder
);
192 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
194 /* Just in case something was left from previous runs */
195 ITaskFolder_DeleteFolder(folder
, Wine_Folder1_Folder2
, 0);
196 ITaskFolder_DeleteFolder(folder
, Wine_Folder1
, 0);
197 ITaskFolder_DeleteFolder(folder
, Wine
, 0);
199 hr
= ITaskFolder_CreateFolder(folder
, slash
, v_null
, &subfolder
);
201 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
203 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, &subfolder
);
204 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "expected ERROR_PATH_NOT_FOUND, got %#x\n", hr
);
206 hr
= ITaskFolder_CreateFolder(folder
, bslash
, v_null
, &subfolder
);
208 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
210 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
, v_null
, &subfolder
);
211 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
212 ITaskFolder_Release(subfolder
);
214 hr
= ITaskFolder_CreateFolder(folder
, Wine
, v_null
, NULL
);
215 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
217 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_
, v_null
, &subfolder
);
219 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
221 hr
= ITaskFolder_CreateFolder(folder
, Wine
, v_null
, &subfolder
);
222 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
223 hr
= ITaskFolder_CreateFolder(folder
, Wine
+1, v_null
, &subfolder
);
224 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
225 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1
, v_null
, &subfolder
);
226 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
227 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1
+1, v_null
, &subfolder
);
228 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
229 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
, v_null
, &subfolder
);
230 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
231 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
+1, v_null
, &subfolder
);
232 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
234 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, NULL
);
235 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
237 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, &subfolder
);
238 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
240 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
241 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
242 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
244 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
245 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
246 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
), "expected \\Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
248 ITaskFolder_Release(subfolder
);
250 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
+1, &subfolder
);
251 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
252 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
253 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
254 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
256 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
257 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
258 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
260 ITaskFolder_Release(subfolder
);
262 hr
= ITaskService_GetFolder(service
, Wine_Folder1
, &subfolder
);
263 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
264 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
265 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
266 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
268 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
269 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
270 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
272 ITaskFolder_Release(subfolder
);
274 hr
= ITaskService_GetFolder(service
, Wine
, &subfolder
);
275 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
276 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
277 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
278 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
280 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
281 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
282 ok(!lstrcmpW(bstr
, Wine
), "expected \\Wine, got %s\n", wine_dbgstr_w(bstr
));
284 ITaskFolder_Release(subfolder
);
286 hr
= ITaskService_GetFolder(service
, Wine
+1, &subfolder
);
287 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
288 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
289 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
290 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
292 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
293 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
294 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
297 hr
= ITaskFolder_GetFolder(subfolder
, bslash
, &subfolder2
);
299 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
301 hr
= ITaskFolder_GetFolder(subfolder
, NULL
, &subfolder2
);
302 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
304 hr
= ITaskFolder_GetFolder(subfolder
, empty
, &subfolder2
);
305 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
306 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
307 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
308 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
310 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
311 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
312 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
314 ITaskFolder_Release(subfolder2
);
316 hr
= ITaskFolder_GetFolder(subfolder
, Folder1_Folder2
, &subfolder2
);
317 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
318 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
319 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
320 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
322 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
323 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
324 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
326 ITaskFolder_Release(subfolder2
);
328 hr
= ITaskFolder_GetFolder(subfolder
, Folder1_Folder2
+1, &subfolder2
);
329 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
331 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
332 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
333 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
335 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
336 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
337 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
339 ITaskFolder_Release(subfolder2
);
341 ITaskFolder_Release(subfolder
);
343 hr
= ITaskFolder_DeleteFolder(folder
, Wine
, 0);
344 ok(hr
== HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY
), "expected ERROR_DIR_NOT_EMPTY, got %#x\n", hr
);
346 hr
= ITaskFolder_DeleteFolder(folder
, Wine_Folder1_Folder2
, 0);
347 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
348 hr
= ITaskFolder_DeleteFolder(folder
, Wine_Folder1
+1, 0);
349 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
350 hr
= ITaskFolder_DeleteFolder(folder
, Wine
+1, 0);
351 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
353 hr
= ITaskFolder_DeleteFolder(folder
, Wine
, 0);
354 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr
);
356 hr
= ITaskFolder_DeleteFolder(folder
, NULL
, 0);
357 ok(hr
== E_ACCESSDENIED
|| hr
== E_INVALIDARG
/* Vista */, "expected E_ACCESSDENIED, got %#x\n", hr
);
359 hr
= ITaskFolder_DeleteFolder(folder
, empty
, 0);
360 ok(hr
== E_ACCESSDENIED
|| hr
== E_INVALIDARG
/* Vista */, "expected E_ACCESSDENIED, got %#x\n", hr
);
362 hr
= ITaskFolder_DeleteFolder(folder
, slash
, 0);
364 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
366 ITaskFolder_Release(folder
);
367 ITaskService_Release(service
);
370 static void set_var(int vt
, VARIANT
*var
, LONG val
)
378 V_UI1(var
) = (BYTE
)val
;
383 V_UI2(var
) = (USHORT
)val
;
407 static void test_FolderCollection(void)
409 static WCHAR Wine
[] = { '\\','W','i','n','e',0 };
410 static WCHAR Wine_Folder1
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1',0 };
411 static WCHAR Wine_Folder2
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','2',0 };
412 static WCHAR Wine_Folder3
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','3',0 };
413 static const WCHAR Folder1
[] = { 'F','o','l','d','e','r','1',0 };
414 static const WCHAR Folder2
[] = { 'F','o','l','d','e','r','2',0 };
417 VARIANT v_null
, var
[3];
418 ITaskService
*service
;
419 ITaskFolder
*root
, *folder
, *subfolder
;
420 ITaskFolderCollection
*folders
;
422 IEnumVARIANT
*enumvar
;
426 static const int vt
[] = { VT_I1
, VT_I2
, VT_I4
, VT_I8
, VT_UI1
, VT_UI2
, VT_UI4
, VT_UI8
, VT_INT
, VT_UINT
};
428 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
431 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
435 V_VT(&v_null
) = VT_NULL
;
437 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
438 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
440 hr
= ITaskService_GetFolder(service
, NULL
, &root
);
441 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
443 /* Just in case something was left from previous runs */
444 ITaskFolder_DeleteFolder(root
, Wine_Folder1
, 0);
445 ITaskFolder_DeleteFolder(root
, Wine_Folder2
, 0);
446 ITaskFolder_DeleteFolder(root
, Wine_Folder3
, 0);
447 ITaskFolder_DeleteFolder(root
, Wine
, 0);
449 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder1
, v_null
, &subfolder
);
450 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
451 ITaskFolder_Release(subfolder
);
453 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder2
, v_null
, &subfolder
);
454 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
455 ITaskFolder_Release(subfolder
);
457 hr
= ITaskFolder_GetFolder(root
, Wine
, &folder
);
458 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
460 hr
= ITaskFolder_GetFolders(folder
, 0, NULL
);
461 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
463 hr
= ITaskFolder_GetFolders(folder
, 0, &folders
);
464 ok(hr
== S_OK
, "GetFolders error %#x\n", hr
);
466 ITaskFolder_Release(folder
);
468 hr
= ITaskFolderCollection_get_Count(folders
, NULL
);
469 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
472 hr
= ITaskFolderCollection_get_Count(folders
, (LONG
*)&count
);
473 ok(hr
== S_OK
, "get_Count error %#x\n", hr
);
474 ok(count
== 2, "expected 2, got %d\n", count
);
476 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder3
, v_null
, &subfolder
);
477 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
478 ITaskFolder_Release(subfolder
);
481 hr
= ITaskFolderCollection_get_Count(folders
, (LONG
*)&count
);
482 ok(hr
== S_OK
, "get_Count error %#x\n", hr
);
483 ok(count
== 2, "expected 2, got %d\n", count
);
485 set_var(VT_INT
, &idx
, 0);
486 hr
= ITaskFolderCollection_get_Item(folders
, idx
, NULL
);
487 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
489 for (i
= 0; i
< sizeof(vt
)/sizeof(vt
[0]); i
++)
491 set_var(vt
[i
], &idx
, 1);
492 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
493 ok(hr
== S_OK
, "get_Item(vt = %d) error %#x\n", vt
[i
], hr
);
494 ITaskFolder_Release(subfolder
);
497 for (i
= 0; i
<= count
; i
++)
501 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
504 ok (hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
507 ok(hr
== S_OK
, "get_Item error %#x\n", hr
);
509 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
510 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
511 is_first
= !lstrcmpW(bstr
, Wine_Folder1
);
513 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
515 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
518 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
519 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
521 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
523 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
525 ITaskFolder_Release(subfolder
);
527 V_VT(&idx
) = VT_BSTR
;
529 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
530 ok(hr
== S_OK
, "get_Item error %#x\n", hr
);
533 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
534 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
536 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
538 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
541 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
542 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
544 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
546 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
548 ITaskFolder_Release(subfolder
);
553 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
554 ok (hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
556 hr
= ITaskFolderCollection_QueryInterface(folders
, &IID_IEnumVARIANT
, (void **)&enumvar
);
557 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
558 hr
= ITaskFolderCollection_QueryInterface(folders
, &IID_IEnumUnknown
, (void **)&enumvar
);
559 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
561 hr
= ITaskFolderCollection_get__NewEnum(folders
, NULL
);
562 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
564 hr
= ITaskFolderCollection_get__NewEnum(folders
, &unknown
);
565 ok(hr
== S_OK
, "get__NewEnum error %#x\n", hr
);
566 hr
= IUnknown_QueryInterface(unknown
, &IID_IEnumUnknown
, (void **)&enumvar
);
567 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
568 hr
= IUnknown_QueryInterface(unknown
, &IID_IEnumVARIANT
, (void **)&enumvar
);
569 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
570 IEnumVARIANT_Release(enumvar
);
572 hr
= IUnknown_QueryInterface(unknown
, &IID_IUnknown
, (void **)&enumvar
);
573 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
575 hr
= IEnumVARIANT_Skip(enumvar
, 0);
576 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
577 hr
= IEnumVARIANT_Skip(enumvar
, 2);
578 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
579 hr
= IEnumVARIANT_Skip(enumvar
, 1);
580 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
582 hr
= IEnumVARIANT_Reset(enumvar
);
583 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
586 hr
= IEnumVARIANT_Next(enumvar
, 1, NULL
, &count
);
587 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
589 memset(var
, 0, sizeof(var
));
591 hr
= IEnumVARIANT_Next(enumvar
, 1, var
, &count
);
592 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
593 ok(count
== 1, "expected 1, got %d\n", count
);
594 hr
= ITaskFolder_get_Path((ITaskFolder
*)V_DISPATCH(&var
[0]), &bstr
);
595 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
596 is_first
= !lstrcmpW(bstr
, Wine_Folder1
);
598 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
600 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
602 hr
= ITaskFolder_get_Name((ITaskFolder
*)V_DISPATCH(&var
[0]), &bstr
);
603 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
605 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
607 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
608 IDispatch_Release(V_DISPATCH(&var
[0]));
610 memset(var
, 0, sizeof(var
));
612 hr
= IEnumVARIANT_Next(enumvar
, 1, var
, &count
);
613 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
614 ok(count
== 0, "expected 0, got %d\n", count
);
617 hr
= IEnumVARIANT_Next(enumvar
, 1, NULL
, &count
);
618 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
619 ok(count
== 0, "expected 0, got %d\n", count
);
621 hr
= IEnumVARIANT_Reset(enumvar
);
622 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
624 memset(var
, 0, sizeof(var
));
626 hr
= IEnumVARIANT_Next(enumvar
, 3, var
, &count
);
627 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
628 ok(count
== 2, "expected 2, got %d\n", count
);
629 ok(V_VT(&var
[0]) == VT_DISPATCH
, "expected VT_DISPATCH, got %d\n", V_VT(&var
[0]));
630 ok(V_VT(&var
[1]) == VT_DISPATCH
, "expected VT_DISPATCH, got %d\n", V_VT(&var
[1]));
631 IEnumVARIANT_Release(enumvar
);
633 for (i
= 0; i
< count
; i
++)
635 hr
= IDispatch_QueryInterface(V_DISPATCH(&var
[i
]), &IID_ITaskFolder
, (void **)&subfolder
);
636 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
638 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
639 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
640 is_first
= !lstrcmpW(bstr
, Wine_Folder1
);
642 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
644 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
647 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
648 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
650 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
652 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
654 ITaskFolder_Release(subfolder
);
657 IDispatch_Release(V_DISPATCH(&var
[0]));
658 IDispatch_Release(V_DISPATCH(&var
[1]));
660 ITaskFolderCollection_Release(folders
);
662 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder1
, 0);
663 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
664 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder2
, 0);
665 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
666 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder3
, 0);
667 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
668 hr
= ITaskFolder_DeleteFolder(root
, Wine
, 0);
669 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
671 ITaskFolder_Release(root
);
672 ITaskService_Release(service
);
675 static void test_GetTask(void)
677 static WCHAR Wine
[] = { '\\','W','i','n','e',0 };
678 static WCHAR Wine_Task1
[] = { '\\','W','i','n','e','\\','T','a','s','k','1',0 };
679 static WCHAR Wine_Task2
[] = { '\\','W','i','n','e','\\','T','a','s','k','2',0 };
680 static WCHAR Task1
[] = { 'T','a','s','k','1',0 };
681 static WCHAR Task2
[] = { 'T','a','s','k','2',0 };
682 static const char xml1
[] =
683 "<?xml version=\"1.0\"?>\n"
684 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
685 " <RegistrationInfo>\n"
686 " <Description>\"Task1\"</Description>\n"
687 " </RegistrationInfo>\n"
689 " <Enabled>false</Enabled>\n"
690 " <Hidden>false</Hidden>\n"
694 " <Command>\"task1.exe\"</Command>\n"
698 static const char xml2
[] =
699 "<?xml version=\"1.0\"?>\n"
700 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
701 " <RegistrationInfo>\n"
702 " <Description>\"Task2\"</Description>\n"
703 " </RegistrationInfo>\n"
705 " <Enabled>true</Enabled>\n"
706 " <Hidden>true</Hidden>\n"
710 " <Command>\"task2.exe\"</Command>\n"
717 } create_new_task
[] =
720 { TASK_CREATE
, S_OK
},
721 { TASK_UPDATE
, 0x80070002 /* HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) */ },
722 { TASK_CREATE
| TASK_UPDATE
, S_OK
}
727 } open_existing_task
[] =
729 { 0, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
730 { TASK_CREATE
, 0x800700b7 /* HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS) */ },
731 { TASK_UPDATE
, S_OK
},
732 { TASK_CREATE
| TASK_UPDATE
, S_OK
}
734 WCHAR xmlW
[sizeof(xml1
)];
740 ITaskService
*service
;
741 ITaskFolder
*root
, *folder
;
742 IRegisteredTask
*task1
, *task2
;
746 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
749 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
753 V_VT(&v_null
) = VT_NULL
;
755 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
756 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
758 hr
= ITaskService_GetFolder(service
, NULL
, &root
);
759 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
761 /* Just in case something was left from previous runs */
762 ITaskFolder_DeleteTask(root
, Wine_Task1
, 0);
763 ITaskFolder_DeleteTask(root
, Wine_Task2
, 0);
764 ITaskFolder_DeleteFolder(root
, Wine
, 0);
766 hr
= ITaskFolder_GetTask(root
, Wine_Task1
, &task1
);
767 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "expected ERROR_PATH_NOT_FOUND, got %#x\n", hr
);
769 hr
= ITaskFolder_CreateFolder(root
, Wine
, v_null
, &folder
);
770 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
772 hr
= ITaskFolder_GetTask(root
, Wine
, &task1
);
773 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "expected ERROR_PATH_NOT_FOUND, got %#x\n", hr
);
775 MultiByteToWideChar(CP_ACP
, 0, xml1
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
777 for (i
= 0; i
< sizeof(create_new_task
)/sizeof(create_new_task
[0]); i
++)
779 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, create_new_task
[i
].flags
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
780 ok(hr
== create_new_task
[i
].hr
, "%d: expected %#x, got %#x\n", i
, create_new_task
[i
].hr
, hr
);
783 hr
= ITaskFolder_DeleteTask(root
, Wine_Task1
, 0);
784 ok(hr
== S_OK
, "DeleteTask error %#x\n", hr
);
788 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, NULL
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, NULL
);
789 ok(hr
== HRESULT_FROM_WIN32(RPC_X_NULL_REF_POINTER
), "expected RPC_X_NULL_REF_POINTER, got %#x\n", hr
);
791 hr
= ITaskFolder_RegisterTask(root
, Wine
, xmlW
, TASK_VALIDATE_ONLY
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, NULL
);
792 ok(hr
== S_OK
, "RegisterTask error %#x\n", hr
);
794 hr
= ITaskFolder_RegisterTask(root
, Wine
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, NULL
);
796 ok(hr
== HRESULT_FROM_WIN32(ERROR_ACCESS_DENIED
) || broken(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
)) /* Vista */, "expected ERROR_ACCESS_DENIED, got %#x\n", hr
);
798 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, NULL
);
799 ok(hr
== S_OK
, "RegisterTask error %#x\n", hr
);
801 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
802 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
804 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, 0, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, NULL
);
805 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
807 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, TASK_CREATE_OR_UPDATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
808 ok(hr
== S_OK
, "RegisterTask error %#x\n", hr
);
810 for (i
= 0; i
< sizeof(open_existing_task
)/sizeof(open_existing_task
[0]); i
++)
812 hr
= ITaskFolder_RegisterTask(root
, Wine_Task1
, xmlW
, open_existing_task
[i
].flags
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
813 ok(hr
== open_existing_task
[i
].hr
, "%d: expected %#x, got %#x\n", i
, open_existing_task
[i
].hr
, hr
);
816 hr
= IRegisteredTask_get_Name(task1
, NULL
);
817 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
819 hr
= IRegisteredTask_get_Name(task1
, &bstr
);
820 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
821 ok(!lstrcmpW(bstr
, Task1
), "expected Task1, got %s\n", wine_dbgstr_w(bstr
));
823 hr
= IRegisteredTask_get_Path(task1
, &bstr
);
824 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
825 ok(!lstrcmpW(bstr
, Wine_Task1
), "expected \\Wine\\Task1, got %s\n", wine_dbgstr_w(bstr
));
827 hr
= IRegisteredTask_get_State(task1
, &state
);
828 ok(hr
== S_OK
, "get_State error %#x\n", hr
);
829 ok(state
== TASK_STATE_DISABLED
, "expected TASK_STATE_DISABLED, got %d\n", state
);
830 hr
= IRegisteredTask_get_Enabled(task1
, &vbool
);
831 ok(hr
== S_OK
, "get_Enabled error %#x\n", hr
);
832 ok(vbool
== VARIANT_FALSE
, "expected VARIANT_FALSE, got %d\n", vbool
);
834 IRegisteredTask_Release(task1
);
836 hr
= ITaskFolder_RegisterTask(folder
, Task1
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task2
);
837 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
839 MultiByteToWideChar(CP_ACP
, 0, xml2
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
841 hr
= ITaskFolder_RegisterTask(folder
, Task2
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task2
);
842 ok(hr
== S_OK
, "RegisterTask error %#x\n", hr
);
844 hr
= IRegisteredTask_get_Name(task2
, &bstr
);
845 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
846 ok(!lstrcmpW(bstr
, Task2
), "expected Task2, got %s\n", wine_dbgstr_w(bstr
));
848 hr
= IRegisteredTask_get_Path(task2
, &bstr
);
849 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
850 ok(!lstrcmpW(bstr
, Wine_Task2
), "expected \\Wine\\Task2, got %s\n", wine_dbgstr_w(bstr
));
852 hr
= IRegisteredTask_get_State(task2
, &state
);
853 ok(hr
== S_OK
, "get_State error %#x\n", hr
);
855 ok(state
== TASK_STATE_READY
, "expected TASK_STATE_READY, got %d\n", state
);
856 hr
= IRegisteredTask_get_Enabled(task2
, &vbool
);
857 ok(hr
== S_OK
, "get_Enabled error %#x\n", hr
);
859 ok(vbool
== VARIANT_TRUE
, "expected VARIANT_TRUE, got %d\n", vbool
);
861 IRegisteredTask_Release(task2
);
863 hr
= ITaskFolder_GetTask(root
, NULL
, &task1
);
864 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
866 hr
= ITaskFolder_GetTask(root
, Wine_Task1
, NULL
);
867 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
869 hr
= ITaskFolder_GetTask(root
, Wine_Task1
, &task1
);
870 ok(hr
== S_OK
, "GetTask error %#x\n", hr
);
872 hr
= IRegisteredTask_get_Name(task1
, &bstr
);
873 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
874 ok(!lstrcmpW(bstr
, Task1
), "expected Task1, got %s\n", wine_dbgstr_w(bstr
));
876 hr
= IRegisteredTask_get_Path(task1
, &bstr
);
877 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
878 ok(!lstrcmpW(bstr
, Wine_Task1
), "expected \\Wine\\Task1, got %s\n", wine_dbgstr_w(bstr
));
880 hr
= IRegisteredTask_get_State(task1
, &state
);
881 ok(hr
== S_OK
, "get_State error %#x\n", hr
);
882 ok(state
== TASK_STATE_DISABLED
, "expected TASK_STATE_DISABLED, got %d\n", state
);
883 hr
= IRegisteredTask_get_Enabled(task1
, &vbool
);
884 ok(hr
== S_OK
, "get_Enabled error %#x\n", hr
);
885 ok(vbool
== VARIANT_FALSE
, "expected VARIANT_FALSE, got %d\n", vbool
);
887 hr
= IRegisteredTask_put_Enabled(task1
, VARIANT_TRUE
);
889 ok(hr
== S_OK
, "put_Enabled error %#x\n", hr
);
890 hr
= IRegisteredTask_get_State(task1
, &state
);
891 ok(hr
== S_OK
, "get_State error %#x\n", hr
);
893 ok(state
== TASK_STATE_READY
, "expected TASK_STATE_READY, got %d\n", state
);
894 hr
= IRegisteredTask_get_Enabled(task1
, &vbool
);
895 ok(hr
== S_OK
, "get_Enabled error %#x\n", hr
);
897 ok(vbool
== VARIANT_TRUE
, "expected VARIANT_TRUE, got %d\n", vbool
);
899 IRegisteredTask_Release(task1
);
901 hr
= ITaskFolder_GetTask(folder
, Task2
, &task2
);
902 ok(hr
== S_OK
, "GetTask error %#x\n", hr
);
904 hr
= IRegisteredTask_get_Name(task2
, &bstr
);
905 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
906 ok(!lstrcmpW(bstr
, Task2
), "expected Task2, got %s\n", wine_dbgstr_w(bstr
));
908 hr
= IRegisteredTask_get_Path(task2
, &bstr
);
909 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
910 ok(!lstrcmpW(bstr
, Wine_Task2
), "expected \\Wine\\Task2, got %s\n", wine_dbgstr_w(bstr
));
912 hr
= IRegisteredTask_get_State(task2
, &state
);
913 ok(hr
== S_OK
, "get_State error %#x\n", hr
);
915 ok(state
== TASK_STATE_READY
, "expected TASK_STATE_READY, got %d\n", state
);
916 hr
= IRegisteredTask_get_Enabled(task2
, &vbool
);
917 ok(hr
== S_OK
, "get_Enabled error %#x\n", hr
);
919 ok(vbool
== VARIANT_TRUE
, "expected VARIANT_TRUE, got %d\n", vbool
);
921 hr
= IRegisteredTask_get_State(task2
, NULL
);
922 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
923 hr
= IRegisteredTask_get_Enabled(task2
, NULL
);
924 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
926 IRegisteredTask_Release(task2
);
928 hr
= ITaskFolder_DeleteTask(folder
, NULL
, 0);
930 ok(hr
== HRESULT_FROM_WIN32(ERROR_DIR_NOT_EMPTY
), "expected ERROR_DIR_NOT_EMPTY, got %#x\n", hr
);
932 hr
= ITaskFolder_DeleteTask(root
, Wine_Task1
, 0);
933 ok(hr
== S_OK
, "DeleteTask error %#x\n", hr
);
934 hr
= ITaskFolder_DeleteTask(folder
, Task2
, 0);
935 ok(hr
== S_OK
, "DeleteTask error %#x\n", hr
);
937 hr
= ITaskFolder_DeleteTask(folder
, Task2
, 0);
938 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr
);
940 hr
= ITaskFolder_RegisterTask(root
, NULL
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
941 ok(hr
== S_OK
, "RegisterTask error %#x\n", hr
);
943 hr
= IRegisteredTask_get_Name(task1
, &bstr
);
944 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
945 hr
= IIDFromString(bstr
, &iid
);
946 ok(hr
== S_OK
, "IIDFromString error %#x\n", hr
);
948 IRegisteredTask_Release(task1
);
950 hr
= ITaskFolder_DeleteTask(root
, bstr
, 0);
951 ok(hr
== S_OK
, "DeleteTask error %#x\n", hr
);
953 hr
= ITaskFolder_RegisterTask(folder
, NULL
, xmlW
, TASK_CREATE
, v_null
, v_null
, TASK_LOGON_NONE
, v_null
, &task1
);
954 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
956 ITaskFolder_Release(folder
);
958 hr
= ITaskFolder_DeleteFolder(root
, Wine
, 0);
959 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
961 ITaskFolder_Release(root
);
962 ITaskService_Release(service
);
967 WCHAR restart_interval
[20];
968 WCHAR execution_time_limit
[20];
969 WCHAR delete_expired_task_after
[20];
972 TASK_INSTANCES_POLICY policy
;
973 TASK_COMPATIBILITY compatibility
;
974 VARIANT_BOOL allow_on_demand_start
;
975 VARIANT_BOOL stop_if_going_on_batteries
;
976 VARIANT_BOOL disallow_start_if_on_batteries
;
977 VARIANT_BOOL allow_hard_terminate
;
978 VARIANT_BOOL start_when_available
;
979 VARIANT_BOOL run_only_if_network_available
;
980 VARIANT_BOOL enabled
;
982 VARIANT_BOOL run_only_if_idle
;
983 VARIANT_BOOL wake_to_run
;
986 /* test the version 1 compatibility settings */
987 static void test_settings_v1(ITaskDefinition
*taskdef
, struct settings
*test
, struct settings
*def
)
994 TASK_INSTANCES_POLICY policy
;
995 TASK_COMPATIBILITY compat
;
997 hr
= ITaskDefinition_get_Settings(taskdef
, &set
);
998 ok(hr
== S_OK
, "get_Settings error %#x\n", hr
);
1000 hr
= ITaskSettings_get_AllowDemandStart(set
, &vbool
);
1001 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1002 ok(vbool
== def
->allow_on_demand_start
, "expected %d, got %d\n", def
->allow_on_demand_start
, vbool
);
1004 hr
= ITaskSettings_get_RestartInterval(set
, &bstr
);
1005 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1006 if (!def
->restart_interval
[0])
1007 ok(bstr
== NULL
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1009 ok(!lstrcmpW(bstr
, def
->restart_interval
), "expected %s, got %s\n", wine_dbgstr_w(def
->restart_interval
), wine_dbgstr_w(bstr
));
1011 hr
= ITaskSettings_get_RestartCount(set
, &vint
);
1012 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1013 ok(vint
== def
->restart_count
, "expected %d, got %d\n", def
->restart_count
, vint
);
1015 hr
= ITaskSettings_get_MultipleInstances(set
, &policy
);
1016 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1017 ok(policy
== def
->policy
, "expected %d, got %d\n", def
->policy
, policy
);
1019 hr
= ITaskSettings_get_StopIfGoingOnBatteries(set
, &vbool
);
1020 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1021 ok(vbool
== test
->stop_if_going_on_batteries
, "expected %d, got %d\n", test
->stop_if_going_on_batteries
, vbool
);
1023 hr
= ITaskSettings_get_DisallowStartIfOnBatteries(set
, &vbool
);
1024 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1025 ok(vbool
== test
->disallow_start_if_on_batteries
, "expected %d, got %d\n", test
->disallow_start_if_on_batteries
, vbool
);
1027 hr
= ITaskSettings_get_AllowHardTerminate(set
, &vbool
);
1028 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1029 ok(vbool
== def
->allow_hard_terminate
, "expected %d, got %d\n", def
->allow_hard_terminate
, vbool
);
1031 hr
= ITaskSettings_get_StartWhenAvailable(set
, &vbool
);
1032 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1033 ok(vbool
== def
->start_when_available
, "expected %d, got %d\n", def
->start_when_available
, vbool
);
1035 hr
= ITaskSettings_get_RunOnlyIfNetworkAvailable(set
, &vbool
);
1036 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1037 ok(vbool
== def
->run_only_if_network_available
, "expected %d, got %d\n", def
->run_only_if_network_available
, vbool
);
1039 hr
= ITaskSettings_get_ExecutionTimeLimit(set
, &bstr
);
1040 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1041 if (!test
->execution_time_limit
[0])
1042 ok(bstr
== NULL
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1044 ok(!lstrcmpW(bstr
, test
->execution_time_limit
), "expected %s, got %s\n", wine_dbgstr_w(test
->execution_time_limit
), wine_dbgstr_w(bstr
));
1046 hr
= ITaskSettings_get_Enabled(set
, &vbool
);
1047 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1048 ok(vbool
== test
->enabled
, "expected %d, got %d\n", test
->enabled
, vbool
);
1050 hr
= ITaskSettings_get_DeleteExpiredTaskAfter(set
, &bstr
);
1051 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1052 if (!test
->delete_expired_task_after
[0])
1053 ok(bstr
== NULL
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1055 ok(!lstrcmpW(bstr
, test
->delete_expired_task_after
), "expected %s, got %s\n", wine_dbgstr_w(test
->delete_expired_task_after
), wine_dbgstr_w(bstr
));
1057 hr
= ITaskSettings_get_Priority(set
, &vint
);
1058 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1059 ok(vint
== test
->priority
, "expected %d, got %d\n", test
->priority
, vint
);
1061 hr
= ITaskSettings_get_Compatibility(set
, &compat
);
1062 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1063 ok(compat
== test
->compatibility
, "expected %d, got %d\n", test
->compatibility
, compat
);
1065 hr
= ITaskSettings_get_Hidden(set
, &vbool
);
1066 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1067 ok(vbool
== test
->hidden
, "expected %d, got %d\n", test
->hidden
, vbool
);
1069 hr
= ITaskSettings_get_RunOnlyIfIdle(set
, &vbool
);
1070 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1071 ok(vbool
== test
->run_only_if_idle
, "expected %d, got %d\n", test
->run_only_if_idle
, vbool
);
1073 hr
= ITaskSettings_get_WakeToRun(set
, &vbool
);
1074 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1075 ok(vbool
== test
->wake_to_run
, "expected %d, got %d\n", test
->wake_to_run
, vbool
);
1077 /* FIXME: test IIdleSettings and INetworkSettings */
1079 ITaskSettings_Release(set
);
1082 static void change_settings(ITaskDefinition
*taskdef
, struct settings
*test
)
1087 hr
= ITaskDefinition_get_Settings(taskdef
, &set
);
1088 ok(hr
== S_OK
, "get_Settings error %#x\n", hr
);
1090 if (!test
->restart_interval
[0])
1091 hr
= ITaskSettings_put_RestartInterval(set
, NULL
);
1093 hr
= ITaskSettings_put_RestartInterval(set
, test
->restart_interval
);
1095 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1096 /* FIXME: Remove once implemented */
1097 if (hr
!= S_OK
) return;
1099 hr
= ITaskSettings_put_RestartCount(set
, test
->restart_count
);
1100 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1102 hr
= ITaskSettings_put_MultipleInstances(set
, test
->policy
);
1103 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1105 hr
= ITaskSettings_put_StopIfGoingOnBatteries(set
, test
->stop_if_going_on_batteries
);
1106 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1108 hr
= ITaskSettings_put_DisallowStartIfOnBatteries(set
, test
->disallow_start_if_on_batteries
);
1109 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1111 hr
= ITaskSettings_put_AllowHardTerminate(set
, test
->allow_hard_terminate
);
1112 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1114 hr
= ITaskSettings_put_StartWhenAvailable(set
, test
->start_when_available
);
1115 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1117 hr
= ITaskSettings_put_RunOnlyIfNetworkAvailable(set
, test
->run_only_if_network_available
);
1118 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1120 if (!test
->execution_time_limit
[0])
1121 hr
= ITaskSettings_put_ExecutionTimeLimit(set
, NULL
);
1123 hr
= ITaskSettings_put_ExecutionTimeLimit(set
, test
->execution_time_limit
);
1124 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1126 hr
= ITaskSettings_put_Enabled(set
, test
->enabled
);
1127 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1129 if (!test
->delete_expired_task_after
[0])
1130 hr
= ITaskSettings_put_DeleteExpiredTaskAfter(set
, NULL
);
1132 hr
= ITaskSettings_put_DeleteExpiredTaskAfter(set
, test
->delete_expired_task_after
);
1133 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1135 hr
= ITaskSettings_put_Priority(set
, test
->priority
);
1136 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1138 hr
= ITaskSettings_put_Compatibility(set
, test
->compatibility
);
1139 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1141 hr
= ITaskSettings_put_Hidden(set
, test
->hidden
);
1142 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1144 hr
= ITaskSettings_put_RunOnlyIfIdle(set
, test
->run_only_if_idle
);
1145 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1147 hr
= ITaskSettings_put_WakeToRun(set
, test
->wake_to_run
);
1148 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1150 hr
= ITaskSettings_put_AllowDemandStart(set
, test
->allow_on_demand_start
);
1151 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
1153 /* FIXME: set IIdleSettings and INetworkSettings */
1155 ITaskSettings_Release(set
);
1158 static void create_action(ITaskDefinition
*taskdef
)
1160 static WCHAR task1_exe
[] = { 't','a','s','k','1','.','e','x','e',0 };
1162 IActionCollection
*actions
;
1164 IExecAction
*exec_action
;
1166 hr
= ITaskDefinition_get_Actions(taskdef
, &actions
);
1168 ok(hr
== S_OK
, "get_Actions error %#x\n", hr
);
1169 /* FIXME: Remove once implemented */
1170 if (hr
!= S_OK
) return;
1172 hr
= IActionCollection_Create(actions
, TASK_ACTION_EXEC
, &action
);
1173 ok(hr
== S_OK
, "Create action error %#x\n", hr
);
1175 hr
= IAction_QueryInterface(action
, &IID_IExecAction
, (void **)&exec_action
);
1176 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
1178 hr
= IExecAction_put_Path(exec_action
, task1_exe
);
1179 ok(hr
== S_OK
, "put_Path error %#x\n", hr
);
1181 IExecAction_Release(exec_action
);
1182 IAction_Release(action
);
1183 IActionCollection_Release(actions
);
1186 static void test_TaskDefinition(void)
1188 static const char xml1
[] =
1189 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
1190 " <RegistrationInfo>\n"
1191 " <Description>\"Task1\"</Description>\n"
1192 " </RegistrationInfo>\n"
1194 " <Enabled>false</Enabled>\n"
1195 " <Hidden>false</Hidden>\n"
1199 " <Command>\"task1.exe\"</Command>\n"
1203 static const char xml2
[] =
1205 " <RegistrationInfo>\n"
1206 " <Description>\"Task1\"</Description>\n"
1207 " </RegistrationInfo>\n"
1209 " <Enabled>false</Enabled>\n"
1210 " <Hidden>false</Hidden>\n"
1214 " <Command>\"task1.exe\"</Command>\n"
1218 static const char xml3
[] =
1220 " <RegistrationInfo>\n"
1221 " <Description>\"Task1\"</Description>\n"
1222 " </RegistrationInfo>\n"
1224 " <Enabled>false</Enabled>\n"
1225 " <Hidden>false</Hidden>\n"
1229 " <Command>\"task1.exe\"</Command>\n"
1233 static const char xml4
[] =
1234 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
1235 " <RegistrationInfo/>\n"
1239 " <Command>\"task1.exe\"</Command>\n"
1243 static const char xml5
[] =
1244 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
1245 " <RegistrationInfo/>\n"
1249 static const char xml6
[] =
1250 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
1251 " <RegistrationInfo/>\n"
1254 " <Command>\"task1.exe\"</Command>\n"
1259 static const char xml7
[] =
1260 "<Task xmlns=\"http://schemas.microsoft.com/windows/2004/02/mit/task\">\n"
1261 " <RegistrationInfo/>\n"
1263 " <Enabled>FALSE</Enabled>\n"
1267 " <Command>\"task1.exe\"</Command>\n"
1271 static WCHAR Task1
[] = { '"','T','a','s','k','1','"',0 };
1272 static struct settings def_settings
= { { 0 }, { 'P','T','7','2','H',0 }, { 0 },
1273 0, 7, TASK_INSTANCES_IGNORE_NEW
, TASK_COMPATIBILITY_V2
, VARIANT_TRUE
, VARIANT_TRUE
,
1274 VARIANT_TRUE
, VARIANT_TRUE
, VARIANT_FALSE
, VARIANT_FALSE
, VARIANT_TRUE
, VARIANT_FALSE
,
1275 VARIANT_FALSE
, VARIANT_FALSE
};
1276 static struct settings new_settings
= { { 'P','1','Y',0 }, { 'P','T','1','0','M',0 }, { 0 },
1277 100, 1, TASK_INSTANCES_STOP_EXISTING
, TASK_COMPATIBILITY_V1
, VARIANT_FALSE
, VARIANT_FALSE
,
1278 VARIANT_FALSE
, VARIANT_FALSE
, VARIANT_TRUE
, VARIANT_TRUE
, VARIANT_FALSE
, VARIANT_TRUE
,
1279 VARIANT_TRUE
, VARIANT_TRUE
};
1281 ITaskService
*service
;
1282 ITaskDefinition
*taskdef
;
1283 IRegistrationInfo
*reginfo
;
1286 WCHAR xmlW
[sizeof(xml1
)];
1288 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
1291 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
1295 hr
= ITaskService_NewTask(service
, 0, &taskdef
);
1296 ok(hr
== S_OK
, "NewTask error %#x\n", hr
);
1298 test_settings_v1(taskdef
, &def_settings
, &def_settings
);
1299 change_settings(taskdef
, &new_settings
);
1301 /* Action is mandatory for v1 compatibility */
1302 create_action(taskdef
);
1304 hr
= ITaskDefinition_get_XmlText(taskdef
, &xml
);
1305 ok(hr
== S_OK
, "get_XmlText error %#x\n", hr
);
1307 ITaskDefinition_Release(taskdef
);
1309 hr
= ITaskService_NewTask(service
, 0, &taskdef
);
1310 ok(hr
== S_OK
, "NewTask error %#x\n", hr
);
1312 hr
= ITaskDefinition_put_XmlText(taskdef
, xml
);
1313 ok(hr
== S_OK
, "put_XmlText error %#x\n", hr
);
1316 /* FIXME: uncomment once changing settings is implemented
1317 test_settings_v1(taskdef, &new_settings, &def_settings);
1320 hr
= ITaskDefinition_put_XmlText(taskdef
, NULL
);
1321 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
1323 MultiByteToWideChar(CP_ACP
, 0, xml1
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1324 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1325 ok(hr
== S_OK
, "put_XmlText error %#x\n", hr
);
1327 MultiByteToWideChar(CP_ACP
, 0, xml2
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1328 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1329 ok(hr
== SCHED_E_NAMESPACE
, "expected SCHED_E_NAMESPACE, got %#x\n", hr
);
1331 MultiByteToWideChar(CP_ACP
, 0, xml3
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1332 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1334 ok(hr
== SCHED_E_UNEXPECTEDNODE
, "expected SCHED_E_UNEXPECTEDNODE, got %#x\n", hr
);
1336 MultiByteToWideChar(CP_ACP
, 0, xml4
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1337 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1338 ok(hr
== S_OK
, "put_XmlText error %#x\n", hr
);
1340 MultiByteToWideChar(CP_ACP
, 0, xml5
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1341 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1343 ok(hr
== SCHED_E_MISSINGNODE
, "expected SCHED_E_MISSINGNODE, got %#x\n", hr
);
1345 MultiByteToWideChar(CP_ACP
, 0, xml6
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1346 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1347 ok(hr
== SCHED_E_MALFORMEDXML
, "expected SCHED_E_MALFORMEDXML, got %#x\n", hr
);
1349 MultiByteToWideChar(CP_ACP
, 0, xml7
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1350 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1351 ok(hr
== SCHED_E_INVALIDVALUE
, "expected SCHED_E_INVALIDVALUE, got %#x\n", hr
);
1354 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1355 ok(hr
== SCHED_E_MALFORMEDXML
, "expected SCHED_E_MALFORMEDXML, got %#x\n", hr
);
1357 /* test registration info */
1358 MultiByteToWideChar(CP_ACP
, 0, xml1
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1359 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1360 ok(hr
== S_OK
, "put_XmlText error %#x\n", hr
);
1361 hr
= ITaskDefinition_get_RegistrationInfo(taskdef
, ®info
);
1362 ok(hr
== S_OK
, "get_RegistrationInfo error %#x\n", hr
);
1364 hr
= IRegistrationInfo_get_Description(reginfo
, &bstr
);
1365 ok(hr
== S_OK
, "get_Description error %#x\n", hr
);
1366 ok(!lstrcmpW(bstr
, Task1
), "expected Task1, got %s\n", wine_dbgstr_w(bstr
));
1367 SysFreeString(bstr
);
1368 hr
= IRegistrationInfo_get_Author(reginfo
, &bstr
);
1369 ok(hr
== S_OK
, "get_Author error %#x\n", hr
);
1370 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1371 hr
= IRegistrationInfo_get_Version(reginfo
, &bstr
);
1372 ok(hr
== S_OK
, "get_Version error %#x\n", hr
);
1373 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1374 hr
= IRegistrationInfo_get_Date(reginfo
, &bstr
);
1375 ok(hr
== S_OK
, "get_Date error %#x\n", hr
);
1376 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1377 hr
= IRegistrationInfo_get_Documentation(reginfo
, &bstr
);
1378 ok(hr
== S_OK
, "get_Documentation error %#x\n", hr
);
1379 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1380 hr
= IRegistrationInfo_get_URI(reginfo
, &bstr
);
1381 ok(hr
== S_OK
, "get_URI error %#x\n", hr
);
1382 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1383 hr
= IRegistrationInfo_get_Source(reginfo
, &bstr
);
1384 ok(hr
== S_OK
, "get_Source error %#x\n", hr
);
1385 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1386 V_VT(&var
) = VT_BSTR
;
1387 V_BSTR(&var
) = NULL
;
1388 hr
= IRegistrationInfo_get_SecurityDescriptor(reginfo
, &var
);
1390 ok(hr
== S_OK
, "get_SecurityDescriptor error %#x\n", hr
);
1392 ok(V_VT(&var
) == VT_EMPTY
, "expected VT_EMPTY, got %u\n", V_VT(&var
));
1394 IRegistrationInfo_Release(reginfo
);
1396 MultiByteToWideChar(CP_ACP
, 0, xml4
, -1, xmlW
, sizeof(xmlW
)/sizeof(xmlW
[0]));
1397 hr
= ITaskDefinition_put_XmlText(taskdef
, xmlW
);
1398 ok(hr
== S_OK
, "put_XmlText error %#x\n", hr
);
1399 hr
= ITaskDefinition_get_RegistrationInfo(taskdef
, ®info
);
1400 ok(hr
== S_OK
, "get_RegistrationInfo error %#x\n", hr
);
1402 hr
= IRegistrationInfo_get_Description(reginfo
, &bstr
);
1403 ok(hr
== S_OK
, "get_Description error %#x\n", hr
);
1405 ok(!bstr
, "expected NULL, got %s\n", wine_dbgstr_w(bstr
));
1407 IRegistrationInfo_Release(reginfo
);
1408 ITaskDefinition_Release(taskdef
);
1409 ITaskService_Release(service
);
1412 START_TEST(scheduler
)
1414 OleInitialize(NULL
);
1418 test_FolderCollection();
1420 test_TaskDefinition();