wined3d: Implement independent color write masks.
[wine/multimedia.git] / dlls / qmgr / tests / qmgr.c
blob8c955862a11b78accf37b49e1e902932ede75bd9
1 /*
2 * Unit test suite for bits functions
4 * Copyright 2007 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 #include <stdio.h>
23 #define COBJMACROS
25 #include "wine/test.h"
26 #include "initguid.h"
27 #include "bits.h"
29 static WCHAR progname[MAX_PATH];
31 static void
32 test_CreateInstance(void)
34 HRESULT hres;
35 ULONG res;
36 IBackgroundCopyManager *manager = NULL;
38 /* Creating BITS instance */
39 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
40 &IID_IBackgroundCopyManager, (void **) &manager);
41 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
42 if(hres != S_OK) {
43 skip("Unable to create bits instance.\n");
44 return;
47 /* Releasing bits manager */
48 res = IBackgroundCopyManager_Release(manager);
49 ok(res == 0, "Bad ref count on release: %u\n", res);
53 static void test_CreateJob(void)
55 /* Job information */
56 static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
57 IBackgroundCopyJob* job = NULL;
58 GUID tmpId;
59 HRESULT hres;
60 ULONG res;
61 IBackgroundCopyManager* manager = NULL;
63 /* Setup */
64 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
65 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
66 (void **) &manager);
67 if(hres != S_OK)
69 skip("Unable to create bits instance required for test.\n");
70 return;
73 /* Create bits job */
74 hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
75 BG_JOB_TYPE_DOWNLOAD, &tmpId,
76 &job);
77 ok(hres == S_OK, "CreateJob failed: %08x\n", hres);
78 if(hres != S_OK)
79 skip("Unable to create bits job.\n");
80 else
82 res = IBackgroundCopyJob_Release(job);
83 ok(res == 0, "Bad ref count on release: %u\n", res);
86 IBackgroundCopyManager_Release(manager);
89 static void test_EnumJobs(void)
91 /* Job Enumerator */
92 IEnumBackgroundCopyJobs* enumJobs;
94 static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
95 IBackgroundCopyManager *manager = NULL;
96 IBackgroundCopyJob *job = NULL;
97 HRESULT hres;
98 GUID tmpId;
99 ULONG res;
101 /* Setup */
102 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
103 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
104 (void **) &manager);
105 if(hres != S_OK)
107 skip("Unable to create bits instance required for test.\n");
108 return;
110 hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
111 BG_JOB_TYPE_DOWNLOAD, &tmpId,
112 &job);
113 if(hres != S_OK)
115 skip("Unable to create bits job.\n");
116 IBackgroundCopyManager_Release(manager);
117 return;
120 hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
121 ok(hres == S_OK, "EnumJobs failed: %08x\n", hres);
122 if(hres != S_OK)
123 skip("Unable to create job enumerator.\n");
124 else
126 res = IEnumBackgroundCopyJobs_Release(enumJobs);
127 ok(res == 0, "Bad ref count on release: %u\n", res);
130 /* Tear down */
131 IBackgroundCopyJob_Release(job);
132 IBackgroundCopyManager_Release(manager);
135 static void run_child(WCHAR *secret)
137 static const WCHAR format[] = {'%','s',' ','q','m','g','r',' ','%','s', 0};
138 WCHAR cmdline[MAX_PATH];
139 PROCESS_INFORMATION info;
140 STARTUPINFOW startup;
142 memset(&startup, 0, sizeof startup);
143 startup.cb = sizeof startup;
145 wsprintfW(cmdline, format, progname, secret);
146 ok(CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n");
147 winetest_wait_child_process(info.hProcess);
148 ok(CloseHandle(info.hProcess), "CloseHandle\n");
149 ok(CloseHandle(info.hThread), "CloseHandle\n");
152 static void do_child(const char *secretA)
154 WCHAR secretW[MAX_PATH];
155 IBackgroundCopyManager *manager = NULL;
156 GUID id;
157 IBackgroundCopyJob *job;
158 HRESULT hres;
159 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
160 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
161 (void **) &manager);
162 if(hres != S_OK)
164 skip("Unable to create bits instance required for test.\n");
165 return;
168 MultiByteToWideChar(CP_ACP, 0, secretA, -1, secretW, MAX_PATH);
169 hres = IBackgroundCopyManager_CreateJob(manager, secretW,
170 BG_JOB_TYPE_DOWNLOAD, &id, &job);
171 ok(hres == S_OK, "CreateJob in child process\n");
172 IBackgroundCopyJob_Release(job);
173 IBackgroundCopyManager_Release(manager);
176 static void test_globalness(void)
178 static const WCHAR format[] = {'t','e','s','t','_','%','u', 0};
179 WCHAR secretName[MAX_PATH];
180 IEnumBackgroundCopyJobs* enumJobs;
181 IBackgroundCopyManager *manager = NULL;
182 HRESULT hres;
183 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
184 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
185 (void **) &manager);
186 if(hres != S_OK)
188 skip("Unable to create bits instance required for test.\n");
189 return;
192 wsprintfW(secretName, format, GetTickCount());
193 run_child(secretName);
195 hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
196 ok(hres == S_OK, "EnumJobs failed: %08x\n", hres);
197 if(hres != S_OK)
198 skip("Unable to create job enumerator.\n");
199 else
201 ULONG i, n;
202 IBackgroundCopyJob *job;
203 BOOL found = FALSE;
205 hres = IEnumBackgroundCopyJobs_GetCount(enumJobs, &n);
206 for (i = 0; i < n && !found; ++i)
208 LPWSTR name;
209 IEnumBackgroundCopyJobs_Next(enumJobs, 1, &job, NULL);
210 IBackgroundCopyJob_GetDisplayName(job, &name);
211 if (lstrcmpW(name, secretName) == 0)
212 found = TRUE;
213 CoTaskMemFree(name);
214 IBackgroundCopyJob_Release(job);
216 hres = IEnumBackgroundCopyJobs_Release(enumJobs);
217 ok(found, "Adding a job in another process failed\n");
220 IBackgroundCopyManager_Release(manager);
223 START_TEST(qmgr)
225 char **argv;
226 int argc = winetest_get_mainargs(&argv);
227 MultiByteToWideChar(CP_ACP, 0, argv[0], -1, progname, MAX_PATH);
229 CoInitialize(NULL);
230 if (argc == 3)
231 do_child(argv[2]);
232 else
234 test_CreateInstance();
235 test_CreateJob();
236 test_EnumJobs();
237 test_globalness();
239 CoUninitialize();