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
);
85 ok(hr
== HRESULT_FROM_WIN32(RPC_S_INVALID_NET_ADDR
), "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 V_VT(&v_null
) = VT_NULL
;
147 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
148 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
150 hr
= ITaskService_GetFolder(service
, slash
, &folder
);
152 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
154 hr
= ITaskService_GetFolder(service
, dot
, &folder
);
156 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
158 hr
= ITaskService_GetFolder(service
, bslash
, &folder
);
159 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
160 ITaskFolder_Release(folder
);
162 hr
= ITaskService_GetFolder(service
, NULL
, NULL
);
163 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
165 hr
= ITaskService_GetFolder(service
, empty
, &folder
);
166 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
167 ITaskFolder_Release(folder
);
169 hr
= ITaskService_GetFolder(service
, NULL
, &folder
);
170 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
172 hr
= ITaskFolder_get_Name(folder
, NULL
);
173 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
175 hr
= ITaskFolder_get_Name(folder
, &bstr
);
176 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
177 ok(!lstrcmpW(bstr
, bslash
), "expected '\\', got %s\n", wine_dbgstr_w(bstr
));
180 hr
= ITaskFolder_get_Path(folder
, NULL
);
181 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
183 hr
= ITaskFolder_get_Path(folder
, &bstr
);
184 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
185 ok(!lstrcmpW(bstr
, bslash
), "expected '\\', got %s\n", wine_dbgstr_w(bstr
));
188 hr
= ITaskFolder_CreateFolder(folder
, NULL
, v_null
, &subfolder
);
189 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
191 /* Just in case something was left from previous runs */
192 ITaskFolder_DeleteFolder(folder
, Wine_Folder1_Folder2
, 0);
193 ITaskFolder_DeleteFolder(folder
, Wine_Folder1
, 0);
194 ITaskFolder_DeleteFolder(folder
, Wine
, 0);
196 hr
= ITaskFolder_CreateFolder(folder
, slash
, v_null
, &subfolder
);
198 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
200 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, &subfolder
);
201 ok(hr
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "expected ERROR_PATH_NOT_FOUND, got %#x\n", hr
);
203 hr
= ITaskFolder_CreateFolder(folder
, bslash
, v_null
, &subfolder
);
205 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
207 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
, v_null
, &subfolder
);
208 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
209 ITaskFolder_Release(subfolder
);
211 hr
= ITaskFolder_CreateFolder(folder
, Wine
, v_null
, NULL
);
212 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
214 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_
, v_null
, &subfolder
);
216 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
218 hr
= ITaskFolder_CreateFolder(folder
, Wine
, v_null
, &subfolder
);
219 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
220 hr
= ITaskFolder_CreateFolder(folder
, Wine
+1, v_null
, &subfolder
);
221 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
222 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1
, v_null
, &subfolder
);
223 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
224 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1
+1, v_null
, &subfolder
);
225 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
226 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
, v_null
, &subfolder
);
227 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
228 hr
= ITaskFolder_CreateFolder(folder
, Wine_Folder1_Folder2
+1, v_null
, &subfolder
);
229 ok(hr
== HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS
), "expected ERROR_ALREADY_EXISTS, got %#x\n", hr
);
231 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, NULL
);
232 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
234 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
, &subfolder
);
235 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
237 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
238 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
239 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
241 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
242 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
243 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
), "expected \\Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
245 ITaskFolder_Release(subfolder
);
247 hr
= ITaskService_GetFolder(service
, Wine_Folder1_Folder2
+1, &subfolder
);
248 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
249 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
250 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
251 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
253 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
254 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
255 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
257 ITaskFolder_Release(subfolder
);
259 hr
= ITaskService_GetFolder(service
, Wine_Folder1
, &subfolder
);
260 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
261 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
262 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
263 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
265 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
266 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
267 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
269 ITaskFolder_Release(subfolder
);
271 hr
= ITaskService_GetFolder(service
, Wine
, &subfolder
);
272 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
273 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
274 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
275 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
277 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
278 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
279 ok(!lstrcmpW(bstr
, Wine
), "expected \\Wine, got %s\n", wine_dbgstr_w(bstr
));
281 ITaskFolder_Release(subfolder
);
283 hr
= ITaskService_GetFolder(service
, Wine
+1, &subfolder
);
284 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
285 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
286 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
287 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
289 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
290 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
291 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
294 hr
= ITaskFolder_GetFolder(subfolder
, bslash
, &subfolder2
);
296 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
298 hr
= ITaskFolder_GetFolder(subfolder
, NULL
, &subfolder2
);
299 ok(hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
301 hr
= ITaskFolder_GetFolder(subfolder
, empty
, &subfolder2
);
302 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
303 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
304 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
305 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
307 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
308 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
309 ok(!lstrcmpW(bstr
, Wine
+1), "expected Wine, got %s\n", wine_dbgstr_w(bstr
));
311 ITaskFolder_Release(subfolder2
);
313 hr
= ITaskFolder_GetFolder(subfolder
, Folder1_Folder2
, &subfolder2
);
314 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
315 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
316 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
317 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
319 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
320 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
321 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
323 ITaskFolder_Release(subfolder2
);
325 hr
= ITaskFolder_GetFolder(subfolder
, Folder1_Folder2
+1, &subfolder2
);
326 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
328 hr
= ITaskFolder_get_Name(subfolder2
, &bstr
);
329 ok (hr
== S_OK
, "get_Name error %#x\n", hr
);
330 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
332 hr
= ITaskFolder_get_Path(subfolder2
, &bstr
);
333 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
334 ok(!lstrcmpW(bstr
, Wine_Folder1_Folder2
+1), "expected Wine\\Folder1\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
336 ITaskFolder_Release(subfolder2
);
338 ITaskFolder_Release(subfolder
);
340 hr
= ITaskFolder_DeleteFolder(folder
, Wine_Folder1_Folder2
, 0);
341 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
342 ITaskFolder_DeleteFolder(folder
, Wine_Folder1
+1, 0);
343 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
344 hr
= ITaskFolder_DeleteFolder(folder
, Wine
+1, 0);
345 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
347 hr
= ITaskFolder_DeleteFolder(folder
, Wine
, 0);
348 ok(hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "expected ERROR_FILE_NOT_FOUND, got %#x\n", hr
);
350 hr
= ITaskFolder_DeleteFolder(folder
, NULL
, 0);
351 ok(hr
== E_ACCESSDENIED
|| hr
== E_INVALIDARG
/* Vista */, "expected E_ACCESSDENIED, got %#x\n", hr
);
353 hr
= ITaskFolder_DeleteFolder(folder
, empty
, 0);
354 ok(hr
== E_ACCESSDENIED
|| hr
== E_INVALIDARG
/* Vista */, "expected E_ACCESSDENIED, got %#x\n", hr
);
356 hr
= ITaskFolder_DeleteFolder(folder
, slash
, 0);
358 ok(hr
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), "expected ERROR_INVALID_NAME, got %#x\n", hr
);
360 ITaskFolder_Release(folder
);
361 ITaskService_Release(service
);
364 static void set_var(int vt
, VARIANT
*var
, LONG val
)
372 V_UI1(var
) = (BYTE
)val
;
377 V_UI2(var
) = (USHORT
)val
;
401 static void test_FolderCollection(void)
403 static WCHAR Wine
[] = { '\\','W','i','n','e',0 };
404 static WCHAR Wine_Folder1
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','1',0 };
405 static WCHAR Wine_Folder2
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','2',0 };
406 static WCHAR Wine_Folder3
[] = { '\\','W','i','n','e','\\','F','o','l','d','e','r','3',0 };
407 static const WCHAR Folder1
[] = { 'F','o','l','d','e','r','1',0 };
408 static const WCHAR Folder2
[] = { 'F','o','l','d','e','r','2',0 };
411 VARIANT v_null
, var
[3];
412 ITaskService
*service
;
413 ITaskFolder
*root
, *folder
, *subfolder
;
414 ITaskFolderCollection
*folders
;
416 IEnumVARIANT
*enumvar
;
419 static const int vt
[] = { VT_I1
, VT_I2
, VT_I4
, VT_I8
, VT_UI1
, VT_UI2
, VT_UI4
, VT_UI8
, VT_INT
, VT_UINT
};
421 hr
= CoCreateInstance(&CLSID_TaskScheduler
, NULL
, CLSCTX_INPROC_SERVER
, &IID_ITaskService
, (void **)&service
);
424 win_skip("CoCreateInstance(CLSID_TaskScheduler) error %#x\n", hr
);
428 V_VT(&v_null
) = VT_NULL
;
430 hr
= ITaskService_Connect(service
, v_null
, v_null
, v_null
, v_null
);
431 ok(hr
== S_OK
, "Connect error %#x\n", hr
);
433 hr
= ITaskService_GetFolder(service
, NULL
, &root
);
434 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
436 /* Just in case something was left from previous runs */
437 ITaskFolder_DeleteFolder(root
, Wine_Folder1
, 0);
438 ITaskFolder_DeleteFolder(root
, Wine_Folder2
, 0);
439 ITaskFolder_DeleteFolder(root
, Wine_Folder3
, 0);
440 ITaskFolder_DeleteFolder(root
, Wine
, 0);
442 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder1
, v_null
, &subfolder
);
443 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
444 ITaskFolder_Release(subfolder
);
446 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder2
, v_null
, &subfolder
);
447 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
448 ITaskFolder_Release(subfolder
);
450 hr
= ITaskFolder_GetFolder(root
, Wine
, &folder
);
451 ok(hr
== S_OK
, "GetFolder error %#x\n", hr
);
453 hr
= ITaskFolder_GetFolders(folder
, 0, &folders
);
454 ok(hr
== S_OK
, "GetFolders error %#x\n", hr
);
456 ITaskFolder_Release(folder
);
458 hr
= ITaskFolderCollection_get_Count(folders
, NULL
);
459 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
462 hr
= ITaskFolderCollection_get_Count(folders
, (LONG
*)&count
);
463 ok(hr
== S_OK
, "get_Count error %#x\n", hr
);
464 ok(count
== 2, "expected 2, got %d\n", count
);
466 hr
= ITaskFolder_CreateFolder(root
, Wine_Folder3
, v_null
, &subfolder
);
467 ok(hr
== S_OK
, "CreateFolder error %#x\n", hr
);
468 ITaskFolder_Release(subfolder
);
471 hr
= ITaskFolderCollection_get_Count(folders
, (LONG
*)&count
);
472 ok(hr
== S_OK
, "get_Count error %#x\n", hr
);
473 ok(count
== 2, "expected 2, got %d\n", count
);
475 set_var(VT_INT
, &idx
, 0);
476 hr
= ITaskFolderCollection_get_Item(folders
, idx
, NULL
);
477 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
479 for (i
= 0; i
< sizeof(vt
)/sizeof(vt
[0]); i
++)
481 set_var(vt
[i
], &idx
, 1);
482 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
483 ok(hr
== S_OK
, "get_Item(vt = %d) error %#x\n", vt
[i
], hr
);
484 ITaskFolder_Release(subfolder
);
487 for (i
= 0; i
<= count
; i
++)
491 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
494 ok (hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
497 ok(hr
== S_OK
, "get_Item error %#x\n", hr
);
499 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
500 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
502 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
504 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
507 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
508 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
510 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
512 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
514 ITaskFolder_Release(subfolder
);
516 V_VT(&idx
) = VT_BSTR
;
518 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
519 ok(hr
== S_OK
, "get_Item error %#x\n", hr
);
522 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
523 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
525 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
527 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
530 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
531 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
533 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
535 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
537 ITaskFolder_Release(subfolder
);
542 hr
= ITaskFolderCollection_get_Item(folders
, idx
, &subfolder
);
543 ok (hr
== E_INVALIDARG
, "expected E_INVALIDARG, got %#x\n", hr
);
545 hr
= ITaskFolderCollection_QueryInterface(folders
, &IID_IEnumVARIANT
, (void **)&enumvar
);
546 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
547 hr
= ITaskFolderCollection_QueryInterface(folders
, &IID_IEnumUnknown
, (void **)&enumvar
);
548 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
550 hr
= ITaskFolderCollection_get__NewEnum(folders
, NULL
);
551 ok (hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
553 hr
= ITaskFolderCollection_get__NewEnum(folders
, &unknown
);
554 ok(hr
== S_OK
, "get__NewEnum error %#x\n", hr
);
555 hr
= IUnknown_QueryInterface(unknown
, &IID_IEnumUnknown
, (void **)&enumvar
);
556 ok(hr
== E_NOINTERFACE
, "expected E_NOINTERFACE, got %#x\n", hr
);
557 hr
= IUnknown_QueryInterface(unknown
, &IID_IEnumVARIANT
, (void **)&enumvar
);
558 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
559 IEnumVARIANT_Release(enumvar
);
561 hr
= IUnknown_QueryInterface(unknown
, &IID_IUnknown
, (void **)&enumvar
);
562 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
564 hr
= IEnumVARIANT_Skip(enumvar
, 0);
565 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
566 hr
= IEnumVARIANT_Skip(enumvar
, 2);
567 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
568 hr
= IEnumVARIANT_Skip(enumvar
, 1);
569 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
571 hr
= IEnumVARIANT_Reset(enumvar
);
572 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
575 hr
= IEnumVARIANT_Next(enumvar
, 1, NULL
, &count
);
576 ok(hr
== E_POINTER
, "expected E_POINTER, got %#x\n", hr
);
578 memset(var
, 0, sizeof(var
));
580 hr
= IEnumVARIANT_Next(enumvar
, 1, var
, &count
);
581 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
582 ok(count
== 1, "expected 1, got %d\n", count
);
583 hr
= ITaskFolder_get_Path((ITaskFolder
*)V_DISPATCH(&var
[0]), &bstr
);
584 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
585 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
587 hr
= ITaskFolder_get_Name((ITaskFolder
*)V_DISPATCH(&var
[0]), &bstr
);
588 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
589 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
590 IDispatch_Release(V_DISPATCH(&var
[0]));
592 memset(var
, 0, sizeof(var
));
594 hr
= IEnumVARIANT_Next(enumvar
, 1, var
, &count
);
595 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
596 ok(count
== 0, "expected 0, got %d\n", count
);
599 hr
= IEnumVARIANT_Next(enumvar
, 1, NULL
, &count
);
600 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
601 ok(count
== 0, "expected 0, got %d\n", count
);
603 hr
= IEnumVARIANT_Reset(enumvar
);
604 ok(hr
== S_OK
, "expected S_OK, got %#x\n", hr
);
606 memset(var
, 0, sizeof(var
));
608 hr
= IEnumVARIANT_Next(enumvar
, 3, var
, &count
);
609 ok(hr
== S_FALSE
, "expected S_FALSE, got %#x\n", hr
);
610 ok(count
== 2, "expected 2, got %d\n", count
);
611 ok(V_VT(&var
[0]) == VT_DISPATCH
, "expected VT_DISPATCH, got %d\n", V_VT(&var
[0]));
612 ok(V_VT(&var
[1]) == VT_DISPATCH
, "expected VT_DISPATCH, got %d\n", V_VT(&var
[1]));
613 IEnumVARIANT_Release(enumvar
);
615 for (i
= 0; i
< count
; i
++)
617 hr
= IDispatch_QueryInterface(V_DISPATCH(&var
[i
]), &IID_ITaskFolder
, (void **)&subfolder
);
618 ok(hr
== S_OK
, "QueryInterface error %#x\n", hr
);
620 hr
= ITaskFolder_get_Path(subfolder
, &bstr
);
621 ok(hr
== S_OK
, "get_Path error %#x\n", hr
);
623 ok(!lstrcmpW(bstr
, Wine_Folder1
), "expected \\Wine\\Folder1, got %s\n", wine_dbgstr_w(bstr
));
625 ok(!lstrcmpW(bstr
, Wine_Folder2
), "expected \\Wine\\Folder2, got %s\n", wine_dbgstr_w(bstr
));
628 hr
= ITaskFolder_get_Name(subfolder
, &bstr
);
629 ok(hr
== S_OK
, "get_Name error %#x\n", hr
);
631 ok(!lstrcmpW(bstr
, Folder1
), "expected Folder1, got %s\n", wine_dbgstr_w(bstr
));
633 ok(!lstrcmpW(bstr
, Folder2
), "expected Folder2, got %s\n", wine_dbgstr_w(bstr
));
635 ITaskFolder_Release(subfolder
);
638 IDispatch_Release(V_DISPATCH(&var
[0]));
639 IDispatch_Release(V_DISPATCH(&var
[1]));
641 ITaskFolderCollection_Release(folders
);
643 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder1
, 0);
644 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
645 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder2
, 0);
646 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
647 hr
= ITaskFolder_DeleteFolder(root
, Wine_Folder3
, 0);
648 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
649 hr
= ITaskFolder_DeleteFolder(root
, Wine
, 0);
650 ok(hr
== S_OK
, "DeleteFolder error %#x\n", hr
);
652 ITaskFolder_Release(root
);
653 ITaskService_Release(service
);
656 START_TEST(scheduler
)
662 test_FolderCollection();