/* Generic test setup */ static BOOL setup(void) { HRESULT hres; GUID test_jobId; hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &test_manager); if(hres != S_OK) return FALSE; hres = IBackgroundCopyManager_CreateJob(test_manager, test_displayName, BG_JOB_TYPE_DOWNLOAD, &test_jobId, &test_job); if(hres != S_OK) { IBackgroundCopyManager_Release(test_manager); return FALSE; } if (addFileHelper(test_job, test_localNameA, test_remoteNameA) != S_OK || addFileHelper(test_job, test_localNameB, test_remoteNameB) != S_OK || IBackgroundCopyJob_EnumFiles(test_job, &test_enumFiles) != S_OK) { IBackgroundCopyJob_Release(test_job); IBackgroundCopyManager_Release(test_manager); return FALSE; } return TRUE; }
static HRESULT test_create_manager(void) { HRESULT hres; IBackgroundCopyManager *manager = NULL; /* Creating BITS instance */ hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); if(hres == HRESULT_FROM_WIN32(ERROR_SERVICE_DISABLED)) { win_skip("Needed Service is disabled\n"); return hres; } if (hres == S_OK) { IBackgroundCopyJob *job; GUID jobId; hres = IBackgroundCopyManager_CreateJob(manager, test_displayName, BG_JOB_TYPE_DOWNLOAD, &jobId, &job); if (hres == S_OK) { hres = addFileHelper(job, test_localNameA, test_remoteNameA); if (hres != S_OK) win_skip("AddFile() with file:// protocol failed. Tests will be skipped.\n"); IBackgroundCopyJob_Release(job); } IBackgroundCopyManager_Release(manager); } return hres; }
static void test_CreateJob(void) { /* Job information */ static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0}; IBackgroundCopyJob* job = NULL; GUID tmpId; HRESULT hres; ULONG res; IBackgroundCopyManager* manager = NULL; /* Setup */ hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); if(hres != S_OK) { skip("Unable to create bits instance required for test.\n"); return; } /* Create bits job */ hres = IBackgroundCopyManager_CreateJob(manager, copyNameW, BG_JOB_TYPE_DOWNLOAD, &tmpId, &job); ok(hres == S_OK, "CreateJob failed: %08x\n", hres); if(hres != S_OK) skip("Unable to create bits job.\n"); else { res = IBackgroundCopyJob_Release(job); ok(res == 0, "Bad ref count on release: %u\n", res); } IBackgroundCopyManager_Release(manager); }
static void test_EnumJobs(void) { /* Job Enumerator */ IEnumBackgroundCopyJobs* enumJobs; static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0}; IBackgroundCopyManager *manager = NULL; IBackgroundCopyJob *job = NULL; HRESULT hres; GUID tmpId; ULONG res; /* Setup */ hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); if(hres != S_OK) { skip("Unable to create bits instance required for test.\n"); return; } hres = IBackgroundCopyManager_CreateJob(manager, copyNameW, BG_JOB_TYPE_DOWNLOAD, &tmpId, &job); if(hres != S_OK) { skip("Unable to create bits job.\n"); IBackgroundCopyManager_Release(manager); return; } hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs); ok(hres == S_OK, "EnumJobs failed: %08x\n", hres); if(hres != S_OK) skip("Unable to create job enumerator.\n"); else { res = IEnumBackgroundCopyJobs_Release(enumJobs); ok(res == 0, "Bad ref count on release: %u\n", res); } /* Tear down */ IBackgroundCopyJob_Release(job); IBackgroundCopyManager_Release(manager); }
static void test_globalness(void) { static const WCHAR format[] = {'t','e','s','t','_','%','u', 0}; WCHAR secretName[MAX_PATH]; IEnumBackgroundCopyJobs* enumJobs; IBackgroundCopyManager *manager = NULL; HRESULT hres; hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); if(hres != S_OK) { skip("Unable to create bits instance required for test.\n"); return; } wsprintfW(secretName, format, GetTickCount()); run_child(secretName); hres = IBackgroundCopyManager_EnumJobs(manager, 0, &enumJobs); ok(hres == S_OK, "EnumJobs failed: %08x\n", hres); if(hres != S_OK) skip("Unable to create job enumerator.\n"); else { ULONG i, n; IBackgroundCopyJob *job; BOOL found = FALSE; hres = IEnumBackgroundCopyJobs_GetCount(enumJobs, &n); for (i = 0; i < n && !found; ++i) { LPWSTR name; IEnumBackgroundCopyJobs_Next(enumJobs, 1, &job, NULL); IBackgroundCopyJob_GetDisplayName(job, &name); if (lstrcmpW(name, secretName) == 0) found = TRUE; CoTaskMemFree(name); IBackgroundCopyJob_Release(job); } hres = IEnumBackgroundCopyJobs_Release(enumJobs); ok(found, "Adding a job in another process failed\n"); } IBackgroundCopyManager_Release(manager); }
/* Generic test cleanup */ static void teardown(void) { if (test_enumJobsB) IEnumBackgroundCopyJobs_Release(test_enumJobsB); test_enumJobsB = NULL; if (test_jobB) IBackgroundCopyJob_Release(test_jobB); test_jobB = NULL; if (test_enumJobsA) IEnumBackgroundCopyJobs_Release(test_enumJobsA); test_enumJobsA = NULL; if (test_jobA) IBackgroundCopyJob_Release(test_jobA); test_jobA = NULL; if (test_manager) IBackgroundCopyManager_Release(test_manager); test_manager = NULL; }
static void test_CreateInstance(void) { HRESULT hres; ULONG res; IBackgroundCopyManager *manager = NULL; /* Creating BITS instance */ hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); if(hres != S_OK) { skip("Unable to create bits instance.\n"); return; } /* Releasing bits manager */ res = IBackgroundCopyManager_Release(manager); ok(res == 0, "Bad ref count on release: %u\n", res); }
static void do_child(const char *secretA) { WCHAR secretW[MAX_PATH]; IBackgroundCopyManager *manager = NULL; GUID id; IBackgroundCopyJob *job; HRESULT hres; hres = CoCreateInstance(&CLSID_BackgroundCopyManager, NULL, CLSCTX_LOCAL_SERVER, &IID_IBackgroundCopyManager, (void **) &manager); if(hres != S_OK) { skip("Unable to create bits instance required for test.\n"); return; } MultiByteToWideChar(CP_ACP, 0, secretA, -1, secretW, MAX_PATH); hres = IBackgroundCopyManager_CreateJob(manager, secretW, BG_JOB_TYPE_DOWNLOAD, &id, &job); ok(hres == S_OK, "CreateJob in child process\n"); IBackgroundCopyJob_Release(job); IBackgroundCopyManager_Release(manager); }
/* Generic test cleanup */ static void teardown(void) { IEnumBackgroundCopyFiles_Release(test_enumFiles); IBackgroundCopyJob_Release(test_job); IBackgroundCopyManager_Release(test_manager); }