push 014043c4937c940c54cd1214c96e33a3b3c8cf7d
[wine/hacks.git] / dlls / qmgr / tests / qmgr.c
blob07af5272c6a4ab3e71de741cbe9968c0a03cb67e
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 void
30 test_CreateInstance(void)
32 HRESULT hres;
33 ULONG res;
34 IBackgroundCopyManager *manager = NULL;
36 /* Creating BITS instance */
37 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER,
38 &IID_IBackgroundCopyManager, (void **) &manager);
39 ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres);
40 if(hres != S_OK) {
41 skip("Unable to create bits instance.\n");
42 return;
45 /* Releasing bits manager */
46 res = IBackgroundCopyManager_Release(manager);
47 ok(res == 0, "Bad ref count on release: %u\n", res);
51 static void test_CreateJob(void)
53 /* Job information */
54 static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
55 IBackgroundCopyJob* job = NULL;
56 GUID tmpId;
57 HRESULT hres;
58 ULONG res;
59 IBackgroundCopyManager* manager = NULL;
61 /* Setup */
62 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
63 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
64 (void **) &manager);
65 if(hres != S_OK)
67 skip("Unable to create bits instance required for test.\n");
68 return;
71 /* Create bits job */
72 hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
73 BG_JOB_TYPE_DOWNLOAD, &tmpId,
74 &job);
75 ok(hres == S_OK, "CreateJob failed: %08x\n", hres);
76 if(hres != S_OK)
77 skip("Unable to create bits job.\n");
78 else
80 res = IBackgroundCopyJob_Release(job);
81 ok(res == 0, "Bad ref count on release: %u\n", res);
84 IBackgroundCopyManager_Release(manager);
87 static void test_EnumJobs(void)
89 /* Job Enumerator */
90 IEnumBackgroundCopyJobs* enumJobs;
92 static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
93 IBackgroundCopyManager *manager = NULL;
94 IBackgroundCopyJob *job = NULL;
95 HRESULT hres;
96 GUID tmpId;
97 ULONG res;
99 /* Setup */
100 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
101 CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager,
102 (void **) &manager);
103 if(hres != S_OK)
105 skip("Unable to create bits instance required for test.\n");
106 return;
108 hres = IBackgroundCopyManager_CreateJob(manager, copyNameW,
109 BG_JOB_TYPE_DOWNLOAD, &tmpId,
110 &job);
111 if(hres != S_OK)
113 skip("Unable to create bits job.\n");
114 IBackgroundCopyManager_Release(manager);
115 return;
118 hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs);
119 ok(hres == S_OK, "EnumJobs failed: %08x\n", hres);
120 if(hres != S_OK)
121 skip("Unable to create job enumerator.\n");
122 else
124 res = IEnumBackgroundCopyJobs_Release(enumJobs);
125 ok(res == 0, "Bad ref count on release: %u\n", res);
128 /* Tear down */
129 IBackgroundCopyJob_Release(job);
130 IBackgroundCopyManager_Release(manager);
133 START_TEST(qmgr)
135 CoInitialize(NULL);
136 test_CreateInstance();
137 test_CreateJob();
138 test_EnumJobs();
139 CoUninitialize();