winmm: dwBytesRecorded controls how much is played, not dwBufferLength.
[wine/hramrach.git] / dlls / mstask / tests / task_scheduler.c
blob2de0e160496d24d33ba3f13592c99bf512bd8468
1 /*
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
21 #define COBJMACROS
23 #include "corerror.h"
25 #include "initguid.h"
26 #include "mstask.h"
27 #include "wine/test.h"
29 static ITaskScheduler *test_task_scheduler;
31 static void test_NewWorkItem(void)
33 HRESULT hres;
34 ITask *task;
35 const WCHAR task_name[] = {'T', 'e', 's', 't', 'i', 'n', 'g', 0};
36 GUID GUID_BAD;
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);
45 if (hres != S_OK)
47 skip("Failed to create task scheduler. Skipping tests.\n");
48 return;
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);
55 if (hres == S_OK)
56 ITask_Release(task);
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);
76 return;
79 static void test_Activate(void)
81 HRESULT hres;
82 ITask *task = NULL;
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);
90 if (hres != S_OK)
92 skip("Failed to create task scheduler. Skipping tests.\n");
93 return;
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);
102 return;
105 START_TEST(task_scheduler)
107 CoInitialize(NULL);
108 test_NewWorkItem();
109 test_Activate();
110 CoUninitialize();