static GUID test_jobId;
static BG_JOB_TYPE test_type;
-static VOID init_paths(void)
+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)
+ IBackgroundCopyManager_Release(manager);
+
+ return hres;
+}
+
+static void init_paths(void)
{
WCHAR tmpDir[MAX_PATH];
WCHAR prefix[] = {'q', 'm', 'g', 'r', 0};
hres = IBackgroundCopyJob_GetId(test_job, &tmpId);
ok(hres == S_OK, "GetId failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get ID of test_job.\n");
- return;
- }
ok(memcmp(&tmpId, &test_jobId, sizeof tmpId) == 0, "Got incorrect GUID\n");
}
hres = IBackgroundCopyJob_GetType(test_job, &type);
ok(hres == S_OK, "GetType failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get type of test_job.\n");
- return;
- }
ok(type == test_type, "Got incorrect type\n");
}
hres = IBackgroundCopyJob_GetDisplayName(test_job, &displayName);
ok(hres == S_OK, "GetName failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get display name of test_job.\n");
- return;
- }
ok(lstrcmpW(displayName, test_displayName) == 0, "Got incorrect type\n");
CoTaskMemFree(displayName);
}
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathA,
test_localPathA);
ok(hres == S_OK, "First call to AddFile failed: 0x%08x\n", hres);
- if (hres != S_OK)
- {
- skip("Unable to add first file to job\n");
- return;
- }
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathB,
test_localPathB);
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathA,
test_localPathA);
- if (hres != S_OK)
- {
- skip("Unable to add file to job\n");
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
hres = IBackgroundCopyJob_EnumFiles(test_job, &enumFiles);
ok(hres == S_OK, "EnumFiles failed: 0x%08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to create file enumerator.\n");
- return;
- }
res = IEnumBackgroundCopyFiles_Release(enumFiles);
ok(res == 0, "Bad ref count on release: %u\n", res);
hres = IBackgroundCopyJob_GetProgress(test_job, &progress);
ok(hres == S_OK, "GetProgress failed: 0x%08x\n", hres);
- if (hres != S_OK)
- {
- skip("Unable to get job progress\n");
- teardown();
- return;
- }
ok(progress.BytesTotal == 0, "Incorrect BytesTotal: %x%08x\n",
(DWORD)(progress.BytesTotal >> 32), (DWORD)progress.BytesTotal);
state = BG_JOB_STATE_ERROR;
hres = IBackgroundCopyJob_GetState(test_job, &state);
ok(hres == S_OK, "GetState failed: 0x%08x\n", hres);
- if (hres != S_OK)
- {
- skip("Unable to get job state\n");
- return;
- }
ok(state == BG_JOB_STATE_SUSPENDED, "Incorrect job state: %d\n", state);
}
hres = IBackgroundCopyJob_Resume(test_job);
ok(hres == BG_E_EMPTY, "Resume failed to return BG_E_EMPTY error: 0x%08x\n", hres);
- if (hres != BG_E_EMPTY)
- {
- skip("Failed calling resume job\n");
- return;
- }
state = BG_JOB_STATE_ERROR;
hres = IBackgroundCopyJob_GetState(test_job, &state);
- if (hres != S_OK)
- {
- skip("Unable to get job state\n");
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
ok(state == BG_JOB_STATE_SUSPENDED, "Incorrect job state: %d\n", state);
}
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathA,
test_localPathA);
- if (hres != S_OK)
- {
- skip("Unable to add file to job\n");
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
hres = IBackgroundCopyJob_AddFile(test_job, test_remotePathB,
test_localPathB);
- if (hres != S_OK)
- {
- skip("Unable to add file to job\n");
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
hres = IBackgroundCopyJob_Resume(test_job);
ok(hres == S_OK, "IBackgroundCopyJob_Resume\n");
lstrcatW(urlB, test_remotePathB);
hres = IBackgroundCopyJob_AddFile(test_job, urlA, test_localPathA);
- if (hres != S_OK)
- {
- skip("Unable to add file to job\n");
- HeapFree(GetProcessHeap(), 0, urlA);
- HeapFree(GetProcessHeap(), 0, urlB);
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
hres = IBackgroundCopyJob_AddFile(test_job, urlB, test_localPathB);
- if (hres != S_OK)
- {
- skip("Unable to add file to job\n");
- HeapFree(GetProcessHeap(), 0, urlA);
- HeapFree(GetProcessHeap(), 0, urlB);
- return;
- }
+ ok(hres == S_OK, "got 0x%08x\n", hres);
hres = IBackgroundCopyJob_Resume(test_job);
ok(hres == S_OK, "IBackgroundCopyJob_Resume\n");
HeapFree(GetProcessHeap(), 0, urlB);
}
+static void test_NotifyFlags(void)
+{
+ ULONG flags;
+ HRESULT hr;
+
+ /* check default flags */
+ flags = 0;
+ hr = IBackgroundCopyJob_GetNotifyFlags(test_job, &flags);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(flags == (BG_NOTIFY_JOB_ERROR | BG_NOTIFY_JOB_TRANSFERRED), "flags 0x%08x\n", flags);
+}
+
+static void test_NotifyInterface(void)
+{
+ HRESULT hr;
+ IUnknown *unk;
+
+ unk = (IUnknown*)0xdeadbeef;
+ hr = IBackgroundCopyJob_GetNotifyInterface(test_job, &unk);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(unk == NULL, "got %p\n", unk);
+}
+
typedef void (*test_t)(void);
START_TEST(job)
test_GetProgress_preTransfer,
test_GetState,
test_ResumeEmpty,
+ test_NotifyFlags,
+ test_NotifyInterface,
0
};
static const test_t tests_bits20[] = {
0
};
const test_t *test;
+ int i;
init_paths();
CoInitialize(NULL);
- for (test = tests; *test; ++test)
+ if (FAILED(test_create_manager()))
+ {
+ CoUninitialize();
+ win_skip("Failed to create Manager instance, skipping tests\n");
+ return;
+ }
+
+ for (test = tests, i = 0; *test; ++test, ++i)
{
/* Keep state separate between tests. */
if (!setup())
{
- skip("Unable to setup test\n");
+ ok(0, "tests:%d: Unable to setup test\n", i);
break;
}
(*test)();
if (check_bits20())
{
- for (test = tests_bits20; *test; ++test)
+ for (test = tests_bits20, i = 0; *test; ++test, ++i)
{
/* Keep state separate between tests. */
if (!setup())
{
- skip("Unable to setup test\n");
+ ok(0, "tests_bits20:%d: Unable to setup test\n", i);
break;
}
(*test)();