dmusic: Assign to structs instead of using memcpy.
[wine.git] / dlls / qmgr / tests / job.c
blob71c07597ffeb8eb52377c4325623c4aa7055182c
1 /*
2 * Unit test suite for Background Copy Job Interface
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 "bits.h"
28 /* Globals used by many tests */
29 static const WCHAR test_displayName[] = {'T', 'e', 's', 't', 0};
30 static IBackgroundCopyManager *test_manager;
31 static IBackgroundCopyJob *test_job;
32 static GUID test_jobId;
33 static BG_JOB_TYPE test_type;
35 /* Generic test setup */
36 static BOOL setup(void)
38 HRESULT hres;
40 test_manager = NULL;
41 test_job = NULL;
42 memset(&test_jobId, 0, sizeof test_jobId);
43 test_type = BG_JOB_TYPE_DOWNLOAD;
45 hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL,
46 CLSCTX_LOCAL_SERVER,
47 &IID_IBackgroundCopyManager,
48 (void **) &test_manager);
49 if(hres != S_OK)
50 return FALSE;
52 hres = IBackgroundCopyManager_CreateJob(test_manager, test_displayName,
53 test_type, &test_jobId, &test_job);
54 if(hres != S_OK)
56 IBackgroundCopyManager_Release(test_manager);
57 return FALSE;
60 return TRUE;
63 /* Generic test cleanup */
64 static void teardown(void)
66 IBackgroundCopyJob_Release(test_job);
67 IBackgroundCopyManager_Release(test_manager);
70 /* Test that the jobId is properly set */
71 static void test_GetId(void)
73 HRESULT hres;
74 GUID tmpId;
76 hres = IBackgroundCopyJob_GetId(test_job, &tmpId);
77 ok(hres == S_OK, "GetId failed: %08x\n", hres);
78 if(hres != S_OK)
80 skip("Unable to get ID of test_job.\n");
81 return;
83 ok(memcmp(&tmpId, &test_jobId, sizeof tmpId) == 0, "Got incorrect GUID\n");
86 typedef void (*test_t)(void);
88 START_TEST(job)
90 static const test_t tests[] = {
91 test_GetId,
94 const test_t *test;
96 CoInitialize(NULL);
97 for (test = tests; *test; ++test)
99 /* Keep state seperate between tests. */
100 if (!setup())
102 skip("Unable to setup test\n");
103 break;
105 (*test)();
106 teardown();
108 CoUninitialize();