richedit: Added in support for streaming in and out nested tables.
[wine] / dlls / mstask / tests / task_scheduler.c
1 /*
2  * Test suite for TaskScheduler interface
3  *
4  * Copyright (C) 2008 Google (Roy Shea)
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #define COBJMACROS
22
23 #include "initguid.h"
24 #include "mstask.h"
25 #include "wine/test.h"
26
27 static ITaskScheduler *test_task_scheduler;
28
29 static void test_NewWorkItem(void)
30 {
31     HRESULT hres;
32     ITask *task;
33     const WCHAR task_name[] = {'T', 'e', 's', 't', 'i', 'n', 'g', 0};
34     GUID GUID_BAD;
35
36     /* Initialize a GUID that will not be a recognized CLSID or a IID */
37     CoCreateGuid(&GUID_BAD);
38
39     /* Create TaskScheduler */
40     hres = CoCreateInstance(&CLSID_CTaskScheduler, NULL, CLSCTX_INPROC_SERVER,
41             &IID_ITaskScheduler, (void **) &test_task_scheduler);
42     ok(hres == S_OK, "CTaskScheduler CoCreateInstance failed: %08x\n", hres);
43     if (hres != S_OK)
44     {
45         skip("Failed to create task scheduler.  Skipping tests.\n");
46         return;
47     }
48
49     /* Test basic task creation */
50     hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
51             &CLSID_CTask, &IID_ITask, (IUnknown**)&task);
52     ok(hres == S_OK, "NewNetworkItem failed: %08x\n", hres);
53     if (hres == S_OK)
54         ITask_Release(task);
55
56     /* Task creation attempt using invalid work item class ID */
57     hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
58             &GUID_BAD, &IID_ITask, (IUnknown**)&task);
59     ok(hres == CLASS_E_CLASSNOTAVAILABLE,
60             "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
61
62     /* Task creation attempt using invalid interface ID */
63     hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
64             &CLSID_CTask, &GUID_BAD, (IUnknown**)&task);
65     ok(hres == E_NOINTERFACE, "Expected E_NOINTERFACE: %08x\n", hres);
66
67     /* Task creation attempt using invalid work item class and interface ID */
68     hres = ITaskScheduler_NewWorkItem(test_task_scheduler, task_name,
69             &GUID_BAD, &GUID_BAD, (IUnknown**)&task);
70     ok(hres == CLASS_E_CLASSNOTAVAILABLE,
71             "Expected CLASS_E_CLASSNOTAVAILABLE: %08x\n", hres);
72
73     ITaskScheduler_Release(test_task_scheduler);
74     return;
75 }
76
77 START_TEST(task_scheduler)
78 {
79     CoInitialize(NULL);
80     test_NewWorkItem();
81     CoUninitialize();
82 }