[4/4] qmgr: Implement IBackgroundCopyManager_EnumJobs with test.

Dan Hipschman dsh at linux.ucla.edu
Mon Feb 25 19:44:03 CST 2008


Implement IBackgroundCopyManager_EnumJobs.

From: Roy Shea <roy at cs.hmc.edu>
Date: Thu Dec 20 18:38:31 CST 2007

---
 dlls/qmgr/enum_jobs.c  |   18 ++++++++++++++++++
 dlls/qmgr/qmgr.c       |    4 ++--
 dlls/qmgr/tests/qmgr.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/dlls/qmgr/enum_jobs.c b/dlls/qmgr/enum_jobs.c
index 7aa9346..b03393e 100644
--- a/dlls/qmgr/enum_jobs.c
+++ b/dlls/qmgr/enum_jobs.c
@@ -120,3 +120,21 @@ static const IEnumBackgroundCopyJobsVtbl BITS_IEnumBackgroundCopyJobs_Vtbl =
     BITS_IEnumBackgroundCopyJobs_Clone,
     BITS_IEnumBackgroundCopyJobs_GetCount
 };
+
+HRESULT EnumBackgroundCopyJobsConstructor(LPVOID *ppObj,
+                                          IBackgroundCopyManager* copyManager)
+{
+    BackgroundCopyManagerImpl *qmgr = (BackgroundCopyManagerImpl *) copyManager;
+    EnumBackgroundCopyJobsImpl *This;
+
+    TRACE("%p, %p)\n", ppObj, copyManager);
+
+    This = HeapAlloc(GetProcessHeap(), 0, sizeof *This);
+    if (!This)
+        return E_OUTOFMEMORY;
+    This->lpVtbl = &BITS_IEnumBackgroundCopyJobs_Vtbl;
+    This->ref = 1;
+
+    *ppObj = &This->lpVtbl;
+    return S_OK;
+}
diff --git a/dlls/qmgr/qmgr.c b/dlls/qmgr/qmgr.c
index e274159..c6f3db1 100644
--- a/dlls/qmgr/qmgr.c
+++ b/dlls/qmgr/qmgr.c
@@ -110,8 +110,8 @@ static HRESULT WINAPI BITS_IBackgroundCopyManager_EnumJobs(
         DWORD dwFlags,
         IEnumBackgroundCopyJobs **ppEnum)
 {
-    FIXME("Not implemented\n");
-    return E_NOTIMPL;
+    TRACE("\n");
+    return EnumBackgroundCopyJobsConstructor((LPVOID *) ppEnum, iface);
 }
 
 static HRESULT WINAPI BITS_IBackgroundCopyManager_GetErrorDescription(
diff --git a/dlls/qmgr/tests/qmgr.c b/dlls/qmgr/tests/qmgr.c
index e36ff36..07af527 100644
--- a/dlls/qmgr/tests/qmgr.c
+++ b/dlls/qmgr/tests/qmgr.c
@@ -84,10 +84,57 @@ static void test_CreateJob(void)
     IBackgroundCopyManager_Release(manager);
 }
 
+static void test_EnumJobs(void)
+{
+    /* Job Enumerator */
+    IEnumBackgroundCopyJobs* enumJobs;
+
+    static const WCHAR copyNameW[] = {'T', 'e', 's', 't', 0};
+    IBackgroundCopyManager *manager = NULL;
+    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;
+    }
+    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;
+    }
+
+    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);
+    }
+
+    /* Tear down */
+    IBackgroundCopyJob_Release(job);
+    IBackgroundCopyManager_Release(manager);
+}
+
 START_TEST(qmgr)
 {
     CoInitialize(NULL);
     test_CreateInstance();
     test_CreateJob();
+    test_EnumJobs();
     CoUninitialize();
 }



More information about the wine-patches mailing list