urlSize = MAX_PATH;
UrlCreateFromPathW(remoteFile, remoteUrl, &urlSize, 0);
UrlUnescapeW(remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE);
- return IBackgroundCopyJob_AddFile(test_job, remoteUrl, localFile);
+ return IBackgroundCopyJob_AddFile(job, remoteUrl, localFile);
+}
+
+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;
}
/* Generic test setup */
hres = IEnumBackgroundCopyFiles_GetCount(test_enumFiles, &fileCount);
ok(hres == S_OK, "GetCount failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get count from test_enumFiles.\n");
- return;
- }
ok(fileCount == test_fileCount, "Got incorrect count\n");
}
{
hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, NULL);
ok(hres == S_OK, "Next failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get file from test_enumFiles\n");
- return;
- }
IBackgroundCopyFile_Release(file);
}
fetched = 0;
hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, 1, &file, &fetched);
ok(hres == S_OK, "Next failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get file from test_enumFiles\n");
- return;
- }
ok(fetched == 1, "Next returned the incorrect number of files: %08x\n", hres);
ok(file != NULL, "Next returned NULL\n");
if (file)
fetched = 0;
hres = IEnumBackgroundCopyFiles_Next(test_enumFiles, test_fileCount, files, &fetched);
ok(hres == S_OK, "Next failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to get file from test_enumFiles\n");
- return;
- }
ok(fetched == test_fileCount, "Next returned the incorrect number of files: %08x\n", hres);
for (i = 0; i < test_fileCount; i++)
{
hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
ok(hres == S_OK, "Skip failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to properly Skip files\n");
- return;
- }
}
hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, 1);
ok(hres == S_OK, "Skip failed: %08x\n", hres);
hres = IEnumBackgroundCopyFiles_Reset(test_enumFiles);
ok(hres == S_OK, "Reset failed: %08x\n", hres);
- if(hres != S_OK)
- {
- skip("Unable to Reset enumerator\n");
- return;
- }
hres = IEnumBackgroundCopyFiles_Skip(test_enumFiles, test_fileCount);
ok(hres == S_OK, "Reset failed: %08x\n", hres);
}
0
};
const test_t *test;
+ int i;
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)();