qmgr/tests: Fixed some test failures on older windows versions.

This commit is contained in:
Nikolay Sivov 2013-11-30 14:47:19 +04:00 committed by Alexandre Julliard
parent 7a728d1813
commit 202e71769e
2 changed files with 77 additions and 22 deletions

View File

@ -56,7 +56,40 @@ static HRESULT addFileHelper(IBackgroundCopyJob* job,
urlSize = MAX_PATH; urlSize = MAX_PATH;
UrlCreateFromPathW(remoteFile, remoteUrl, &urlSize, 0); UrlCreateFromPathW(remoteFile, remoteUrl, &urlSize, 0);
UrlUnescapeW(remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE); 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 */ /* Generic test setup */
@ -251,6 +284,14 @@ START_TEST(enum_files)
int i; int i;
CoInitialize(NULL); CoInitialize(NULL);
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) for (test = tests, i = 0; *test; ++test, ++i)
{ {
/* Keep state separate between tests. */ /* Keep state separate between tests. */

View File

@ -40,26 +40,6 @@ static IBackgroundCopyManager *test_manager;
static IEnumBackgroundCopyFiles *test_enumFiles; static IEnumBackgroundCopyFiles *test_enumFiles;
static IBackgroundCopyFile *test_file; static IBackgroundCopyFile *test_file;
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;
}
/* Helper function to add a file to a job. The helper function takes base /* Helper function to add a file to a job. The helper function takes base
file name and creates properly formed path and URL strings for creation of file name and creates properly formed path and URL strings for creation of
the file. */ the file. */
@ -75,7 +55,41 @@ static HRESULT addFileHelper(IBackgroundCopyJob* job,
urlSize = MAX_PATH; urlSize = MAX_PATH;
UrlCreateFromPathW(test_remoteUrl, test_remoteUrl, &urlSize, 0); UrlCreateFromPathW(test_remoteUrl, test_remoteUrl, &urlSize, 0);
UrlUnescapeW(test_remoteUrl, NULL, &urlSize, URL_UNESCAPE_INPLACE); 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 */ /* Generic test setup */