2 * Test suite for TaskScheduler interface
4 * Copyright (C) 2008 Google (Roy Shea)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
29 static ITaskScheduler *test_task_scheduler;
31 static void test_NewWorkItem(void)
35 const WCHAR task_name[] = {'T', 'e', 's', 't', 'i', 'n', 'g', 0};
38 /* Initialize a GUID that will not be a recognized CLSID or a IID */
39 CoCreateGuid(&GUID_BAD);
41 /* Create TaskScheduler */
42 hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
43 &IID_ITaskScheduler, (void **) &test_task_scheduler);
44 ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
47 skip("Failed to create task scheduler. Skipping tests.\n");
51 /* Test basic task creation */
52 hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
53 &CLSID_CTask, &IID_ITask, (IUnknown**)&task);
54 ok(hres == S_OK, "NewNetworkItem failed: %08x\n", hres);
58 /* Task creation attempt using invalid work item class ID */
59 hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
60 &GUID_BAD, &IID_ITask, (IUnknown**)&task);
61 ok(hres == CLASS_E_CLASSNOTAVAILABLE,
62 "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
64 /* Task creation attempt using invalid interface ID */
65 hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
66 &CLSID_CTask, &GUID_BAD, (IUnknown**)&task);
67 ok(hres == E_NOINTERFACE, "Expected E_NOINTERFACE: %08x\n", hres);
69 /* Task creation attempt using invalid work item class and interface ID */
70 hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
71 &GUID_BAD, &GUID_BAD, (IUnknown**)&task);
72 ok(hres == CLASS_E_CLASSNOTAVAILABLE,
73 "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
75 ITaskScheduler_Release(test_task_scheduler);
79 static void test_Activate(void)
83 const WCHAR not_task_name[] =
84 {'N', 'o', 'S', 'u', 'c', 'h', 'T', 'a', 's', 'k', 0};
86 /* Create TaskScheduler */
87 hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
88 &IID_ITaskScheduler, (void **) &test_task_scheduler);
89 ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
92 skip("Failed to create task scheduler. Skipping tests.\n");
96 /* Attempt to activate a nonexistent task */
97 hres = ITaskScheduler_Activate(test_task_scheduler, not_task_name,
98 &IID_ITask, (IUnknown**)&task);
99 ok(hres == COR_E_FILENOTFOUND, "Expected COR_E_FILENOTFOUND: %08x\n", hres);
101 ITaskScheduler_Release(test_task_scheduler);
105 START_TEST(task_scheduler)