From d6dcc30fc0488fae9de9d8482a370500563a9ccd Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Sat, 26 Apr 2014 18:06:03 +0000 Subject: [PATCH] [QMGR_WINETEST] * Sync with Wine 1.7.17. CORE-8080 svn path=/trunk/; revision=62999 --- rostests/winetests/qmgr/CMakeLists.txt | 5 +- rostests/winetests/qmgr/enum_files.c | 78 ++++++++------ rostests/winetests/qmgr/enum_jobs.c | 52 +-------- rostests/winetests/qmgr/file.c | 64 +++++++---- rostests/winetests/qmgr/job.c | 144 +++++++++++-------------- rostests/winetests/qmgr/qmgr.c | 84 +++++---------- 6 files changed, 188 insertions(+), 239 deletions(-) diff --git a/rostests/winetests/qmgr/CMakeLists.txt b/rostests/winetests/qmgr/CMakeLists.txt index 1efccfc6483..d58b096fb35 100644 --- a/rostests/winetests/qmgr/CMakeLists.txt +++ b/rostests/winetests/qmgr/CMakeLists.txt @@ -9,5 +9,8 @@ list(APPEND SOURCE add_executable(qmgr_winetest ${SOURCE}) set_module_type(qmgr_winetest win32cui) -add_importlibs(qmgr_winetest ole32 shlwapi user32 msvcrt kernel32 ntdll) +add_importlibs(qmgr_winetest ole32 shlwapi user32 msvcrt kernel32) +if(MSVC) + add_importlibs(qmgr_winetest ntdll) +endif() add_cd_file(TARGET qmgr_winetest DESTINATION reactos/bin FOR all) diff --git a/rostests/winetests/qmgr/enum_files.c b/rostests/winetests/qmgr/enum_files.c index 43c4b1430f8..1a8998359ca 100644 --- a/rostests/winetests/qmgr/enum_files.c +++ b/rostests/winetests/qmgr/enum_files.c @@ -66,7 +66,40 @@ static HRESULT addFileHelper(IBackgroundCopyJob* job, 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 */ @@ -118,11 +151,6 @@ static void test_GetCount(void) 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"); } @@ -138,11 +166,6 @@ static void test_Next_walkListNull(void) { 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); } @@ -166,11 +189,6 @@ static void test_Next_walkList_1(void) 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) @@ -198,11 +216,6 @@ static void test_Next_walkList_2(void) 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++) @@ -234,11 +247,6 @@ static void test_Skip_walkList(void) { 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); @@ -263,11 +271,6 @@ static void test_Reset(void) 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); } @@ -288,14 +291,23 @@ START_TEST(enum_files) 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)(); diff --git a/rostests/winetests/qmgr/enum_jobs.c b/rostests/winetests/qmgr/enum_jobs.c index 6aa1a58c2d6..518a7d2faff 100644 --- a/rostests/winetests/qmgr/enum_jobs.c +++ b/rostests/winetests/qmgr/enum_jobs.c @@ -118,19 +118,9 @@ static void test_GetCount(void) hres = IEnumBackgroundCopyJobs_GetCount(test_enumJobsA, &jobCountA); ok(hres == S_OK, "GetCount failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Couldn't get job count\n"); - return; - } hres = IEnumBackgroundCopyJobs_GetCount(test_enumJobsB, &jobCountB); ok(hres == S_OK, "GetCount failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Couldn't get job count\n"); - return; - } ok(jobCountB == jobCountA + 1, "Got incorrect count\n"); } @@ -147,11 +137,6 @@ static void test_Next_walkListNull(void) { hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, NULL); ok(hres == S_OK, "Next failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get job from Next\n"); - return; - } IBackgroundCopyJob_Release(job); } @@ -174,11 +159,6 @@ static void test_Next_walkList_1(void) fetched = 0; hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, 1, &job, &fetched); ok(hres == S_OK, "Next failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get job from Next\n"); - return; - } ok(fetched == 1, "Next returned the incorrect number of jobs: %08x\n", hres); IBackgroundCopyJob_Release(job); } @@ -199,24 +179,12 @@ static void test_Next_walkList_2(void) ULONG i; jobs = HeapAlloc(GetProcessHeap(), 0, test_jobCountB * sizeof *jobs); - if (!jobs) - { - skip("Couldn't allocate memory\n"); - return; - } - for (i = 0; i < test_jobCountB; i++) jobs[i] = NULL; fetched = 0; hres = IEnumBackgroundCopyJobs_Next(test_enumJobsB, test_jobCountB, jobs, &fetched); ok(hres == S_OK, "Next failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get file from test_enumJobs\n"); - HeapFree(GetProcessHeap(), 0, jobs); - return; - } ok(fetched == test_jobCountB, "Next returned the incorrect number of jobs: %08x\n", hres); for (i = 0; i < test_jobCountB; i++) @@ -250,11 +218,6 @@ static void test_Skip_walkList(void) { hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, 1); ok(hres == S_OK, "Skip failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to properly Skip jobs\n"); - return; - } } hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, 1); @@ -277,19 +240,9 @@ static void test_Reset(void) hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, test_jobCountB); ok(hres == S_OK, "Skip failed: %08x\n", hres); - if (hres != S_OK) - { - skip("Skip failed\n"); - return; - } hres = IEnumBackgroundCopyJobs_Reset(test_enumJobsB); ok(hres == S_OK, "Reset failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to Reset enumerator\n"); - return; - } hres = IEnumBackgroundCopyJobs_Skip(test_enumJobsB, test_jobCountB); ok(hres == S_OK, "Reset failed: %08x\n", hres); @@ -311,15 +264,16 @@ START_TEST(enum_jobs) 0 }; const test_t *test; + int i; CoInitialize(NULL); - for (test = tests; *test; ++test) + for (test = tests, i = 0; *test; ++test, ++i) { /* Keep state separate between tests */ if (!setup()) { teardown(); - skip("Unable to setup test\n"); + ok(0, "tests:%d: Unable to setup test\n", i); break; } (*test)(); diff --git a/rostests/winetests/qmgr/file.c b/rostests/winetests/qmgr/file.c index 2ea6248331f..74457b3dafe 100644 --- a/rostests/winetests/qmgr/file.c +++ b/rostests/winetests/qmgr/file.c @@ -65,7 +65,41 @@ static HRESULT addFileHelper(IBackgroundCopyJob* job, urlSize = MAX_PATH; UrlCreateFromPathW(test_remoteUrl, test_remoteUrl, &urlSize, 0); UrlUnescapeW(test_remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE); - return IBackgroundCopyJob_AddFile(test_job, test_remoteUrl, test_localFile); + + return IBackgroundCopyJob_AddFile(job, test_remoteUrl, test_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_localName, test_remoteName); + 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 */ @@ -129,11 +163,6 @@ static void test_GetRemoteName(void) hres = IBackgroundCopyFile_GetRemoteName(test_file, &name); ok(hres == S_OK, "GetRemoteName failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get remote name of test_file.\n"); - return; - } ok(lstrcmpW(name, test_remoteUrl) == 0, "Got incorrect remote name\n"); CoTaskMemFree(name); } @@ -146,11 +175,6 @@ static void test_GetLocalName(void) hres = IBackgroundCopyFile_GetLocalName(test_file, &name); ok(hres == S_OK, "GetLocalName failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get local name of test_file.\n"); - return; - } ok(lstrcmpW(name, test_localFile) == 0, "Got incorrect local name\n"); CoTaskMemFree(name); } @@ -163,11 +187,6 @@ static void test_GetProgress_PreTransfer(void) hres = IBackgroundCopyFile_GetProgress(test_file, &progress); ok(hres == S_OK, "GetProgress failed: %08x\n", hres); - if(hres != S_OK) - { - skip("Unable to get progress of test_file.\n"); - return; - } ok(progress.BytesTotal == BG_SIZE_UNKNOWN, "Got incorrect total size: %x%08x\n", (DWORD)(progress.BytesTotal >> 32), (DWORD)progress.BytesTotal); ok(progress.BytesTransferred == 0, "Got incorrect number of transferred bytes: %x%08x\n", @@ -186,14 +205,23 @@ START_TEST(file) 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)(); diff --git a/rostests/winetests/qmgr/job.c b/rostests/winetests/qmgr/job.c index 3b41739b54b..105ddda96d3 100644 --- a/rostests/winetests/qmgr/job.c +++ b/rostests/winetests/qmgr/job.c @@ -42,7 +42,27 @@ static IBackgroundCopyJob *test_job; 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}; @@ -141,11 +161,6 @@ static void test_GetId(void) 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"); } @@ -157,11 +172,6 @@ static void test_GetType(void) 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"); } @@ -173,11 +183,6 @@ static void test_GetName(void) 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); } @@ -190,11 +195,6 @@ static void test_AddFile(void) 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); @@ -223,19 +223,10 @@ static void test_EnumFiles(void) 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); @@ -249,12 +240,6 @@ static void test_GetProgress_preTransfer(void) 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); @@ -273,11 +258,6 @@ static void test_GetState(void) 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); } @@ -289,19 +269,10 @@ static void test_ResumeEmpty(void) 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); } @@ -359,19 +330,11 @@ static void test_CompleteLocal(void) 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"); @@ -437,22 +400,10 @@ static void test_CompleteLocalURL(void) 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"); @@ -488,6 +439,29 @@ static void test_CompleteLocalURL(void) 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) @@ -499,6 +473,8 @@ START_TEST(job) test_GetProgress_preTransfer, test_GetState, test_ResumeEmpty, + test_NotifyFlags, + test_NotifyInterface, 0 }; static const test_t tests_bits20[] = { @@ -510,17 +486,25 @@ START_TEST(job) 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)(); @@ -529,12 +513,12 @@ START_TEST(job) 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)(); diff --git a/rostests/winetests/qmgr/qmgr.c b/rostests/winetests/qmgr/qmgr.c index 596009578e5..67e7d46481f 100644 --- a/rostests/winetests/qmgr/qmgr.c +++ b/rostests/winetests/qmgr/qmgr.c @@ -35,31 +35,24 @@ static WCHAR progname[MAX_PATH]; -static void -test_CreateInstance(void) +static HRESULT test_create_manager(void) { HRESULT hres; - ULONG res; 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)) { - skip("Needed Service is disabled\n"); - return; - } - ok(hres == S_OK, "CoCreateInstance failed: %08x\n", hres); - if(hres != S_OK) { - skip("Unable to create bits instance.\n"); - return; + if(hres == HRESULT_FROM_WIN32(ERROR_SERVICE_DISABLED)) { + win_skip("Needed Service is disabled\n"); + return hres; } - /* Releasing bits manager */ - res = IBackgroundCopyManager_Release(manager); - ok(res == 0, "Bad ref count on release: %u\n", res); + if (hres == S_OK) + IBackgroundCopyManager_Release(manager); + return hres; } static void test_CreateJob(void) @@ -76,25 +69,16 @@ static void test_CreateJob(void) 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; - } + ok(hres == S_OK, "got 0x%08x\n", hres); /* 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); - } + res = IBackgroundCopyJob_Release(job); + ok(res == 0, "Bad ref count on release: %u\n", res); IBackgroundCopyManager_Release(manager); } @@ -108,36 +92,21 @@ static void test_EnumJobs(void) 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; - } + ok(hres == S_OK, "got 0x%08x\n", hres); + 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; - } + ok(hres == S_OK, "got 0x%08x\n", hres); 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); - } + IEnumBackgroundCopyJobs_Release(enumJobs); /* Tear down */ IBackgroundCopyJob_Release(job); @@ -171,11 +140,7 @@ static void do_child(const char *secretA) 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; - } + ok(hres == S_OK, "got 0x%08x\n", hres); MultiByteToWideChar(CP_ACP, 0, secretA, -1, secretW, MAX_PATH); hres = IBackgroundCopyManager_CreateJob(manager, secretW, @@ -195,11 +160,7 @@ static void test_globalness(void) 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; - } + ok(hres == S_OK, "got 0x%08x\n", hres); wsprintfW(secretName, format, GetTickCount()); run_child(secretName); @@ -226,8 +187,8 @@ static void test_globalness(void) CoTaskMemFree(name); IBackgroundCopyJob_Release(job); } - hres = IEnumBackgroundCopyJobs_Release(enumJobs); - ok(hres == S_OK, "Release failed: %08x\n", hres); + + IEnumBackgroundCopyJobs_Release(enumJobs); ok(found, "Adding a job in another process failed\n"); } @@ -241,11 +202,18 @@ START_TEST(qmgr) MultiByteToWideChar(CP_ACP, 0, argv[0], -1, progname, MAX_PATH); CoInitialize(NULL); + + if (FAILED(test_create_manager())) + { + win_skip("Failed to create Manager instance, skipping tests\n"); + CoUninitialize(); + return; + } + if (argc == 3) do_child(argv[2]); else { - test_CreateInstance(); test_CreateJob(); test_EnumJobs(); test_globalness();