qmgr: Implement IBackgroundCopyManager_CreateJob with test.
This commit is contained in:
parent
fee94bbc9e
commit
111e6929ac
|
@ -25,6 +25,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
|||
|
||||
static void BackgroundCopyJobDestructor(BackgroundCopyJobImpl *This)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This->displayName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
}
|
||||
|
||||
|
@ -361,3 +362,42 @@ static const IBackgroundCopyJobVtbl BITS_IBackgroundCopyJob_Vtbl =
|
|||
BITS_IBackgroundCopyJob_GetProxySettings,
|
||||
BITS_IBackgroundCopyJob_TakeOwnership,
|
||||
};
|
||||
|
||||
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
||||
GUID *pJobId, LPVOID *ppObj)
|
||||
{
|
||||
HRESULT hr;
|
||||
BackgroundCopyJobImpl *This;
|
||||
int n;
|
||||
|
||||
TRACE("(%s,%d,%p)\n", debugstr_w(displayName), type, ppObj);
|
||||
|
||||
This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
|
||||
if (!This)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
This->lpVtbl = &BITS_IBackgroundCopyJob_Vtbl;
|
||||
This->ref = 1;
|
||||
This->type = type;
|
||||
|
||||
n = (lstrlenW(displayName) + 1) * sizeof *displayName;
|
||||
This->displayName = HeapAlloc(GetProcessHeap(), 0, n);
|
||||
if (!This->displayName)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
memcpy(This->displayName, displayName, n);
|
||||
|
||||
hr = CoCreateGuid(&This->jobId);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This->displayName);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return hr;
|
||||
}
|
||||
memcpy(pJobId, &This->jobId, sizeof(GUID));
|
||||
|
||||
*ppObj = &This->lpVtbl;
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
@ -91,8 +91,9 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_CreateJob(
|
|||
GUID *pJobId,
|
||||
IBackgroundCopyJob **ppJob)
|
||||
{
|
||||
FIXME("Not implemented\n");
|
||||
return E_NOTIMPL;
|
||||
TRACE("\n");
|
||||
return BackgroundCopyJobConstructor(DisplayName, Type, pJobId,
|
||||
(LPVOID *) ppJob);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BITS_IBackgroundCopyManager_GetJob(
|
||||
|
|
|
@ -34,6 +34,9 @@ typedef struct
|
|||
{
|
||||
const IBackgroundCopyJobVtbl *lpVtbl;
|
||||
LONG ref;
|
||||
LPWSTR displayName;
|
||||
BG_JOB_TYPE type;
|
||||
GUID jobId;
|
||||
} BackgroundCopyJobImpl;
|
||||
|
||||
/* Background copy manager vtbl and related data */
|
||||
|
@ -51,6 +54,8 @@ typedef struct
|
|||
extern ClassFactoryImpl BITS_ClassFactory;
|
||||
|
||||
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
|
||||
HRESULT BackgroundCopyJobConstructor(LPCWSTR displayName, BG_JOB_TYPE type,
|
||||
GUID *pJobId, LPVOID *ppObj);
|
||||
|
||||
/* Little helper functions */
|
||||
static inline char *
|
||||
|
|
|
@ -48,9 +48,46 @@ test_CreateInstance(void)
|
|||
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
START_TEST(qmgr)
|
||||
{
|
||||
CoInitialize(NULL);
|
||||
test_CreateInstance();
|
||||
test_CreateJob();
|
||||
CoUninitialize();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue