[PATCH v5 4/5] comsvcs: Implement ISharedPropertyGroupManager_get_Group().

Jactry Zeng jzeng at codeweavers.com
Fri Oct 30 01:33:46 CDT 2020


Signed-off-by: Jactry Zeng <jzeng at codeweavers.com>

---
v5: No Changes.
v4: No changes.
v3:
- Add more tests.
v2: No changes.
---
 dlls/comsvcs/property.c       | 19 +++++++++++++++++--
 dlls/comsvcs/tests/property.c | 30 +++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/dlls/comsvcs/property.c b/dlls/comsvcs/property.c
index 6cd6d5efdd8..4db19491c15 100644
--- a/dlls/comsvcs/property.c
+++ b/dlls/comsvcs/property.c
@@ -385,8 +385,23 @@ static HRESULT WINAPI group_manager_CreatePropertyGroup(ISharedPropertyGroupMana
 
 static HRESULT WINAPI group_manager_get_Group(ISharedPropertyGroupManager *iface, BSTR name, ISharedPropertyGroup **group)
 {
-    FIXME("iface %p, name %s, group %p: stub.\n", iface, debugstr_w(name), group);
-    return E_NOTIMPL;
+    struct group_manager *manager = impl_from_ISharedPropertyGroupManager(iface);
+    struct property_group *property_group;
+
+    TRACE("iface %p, name %s, group %p.\n", iface, debugstr_w(name), group);
+
+    if (!name || !group)
+        return E_POINTER;
+
+    EnterCriticalSection(&manager->cs);
+    property_group = find_propery_group(manager, name);
+    LeaveCriticalSection(&manager->cs);
+
+    if (!property_group)
+        return E_INVALIDARG;
+
+    return ISharedPropertyGroup_QueryInterface(&property_group->ISharedPropertyGroup_iface,
+            &IID_ISharedPropertyGroup, (void **)group);
 }
 
 static HRESULT WINAPI group_manager_get__NewEnum(ISharedPropertyGroupManager *iface, IUnknown **retval)
diff --git a/dlls/comsvcs/tests/property.c b/dlls/comsvcs/tests/property.c
index 8ac5e522f5e..7321bbcfe63 100644
--- a/dlls/comsvcs/tests/property.c
+++ b/dlls/comsvcs/tests/property.c
@@ -166,7 +166,7 @@ static void test_interfaces(void)
 
 static void test_property_group(void)
 {
-    ISharedPropertyGroup *group, *group1;
+    ISharedPropertyGroup *group, *group1, *group2;
     ISharedPropertyGroupManager *manager;
     ULONG refcount, expected_refcount;
     LONG isolation, release;
@@ -284,6 +284,34 @@ static void test_property_group(void)
     TEST_TYPEINFO(dispatch, test_name_ids, ARRAY_SIZE(test_name_ids), &IID_ISharedPropertyGroup);
     IDispatch_Release(dispatch);
 
+    hr = ISharedPropertyGroupManager_get_Group(manager, NULL, &group2);
+    ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+    name = SysAllocString(L"nonexistgroup");
+    hr = ISharedPropertyGroupManager_get_Group(manager, name, &group2);
+    ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
+    SysFreeString(name);
+
+    name = SysAllocString(L"testgroupname");
+    hr = ISharedPropertyGroupManager_get_Group(manager, name, NULL);
+    ok(hr == E_POINTER, "Got hr %#x.\n", hr);
+
+    expected_refcount = get_refcount(manager);
+    hr = ISharedPropertyGroupManager_get_Group(manager, name, &group2);
+    ok(hr == S_OK, "Got hr %#x.\n", hr);
+    ok(group2 == group, "Got unexpected pointer %p.\n", group2);
+    refcount = get_refcount(group);
+    ok(refcount == 2, "Got unexpected refcount: %u.\n", refcount);
+    refcount = get_refcount(manager);
+    ok(refcount == expected_refcount, "Got refcount: %u, expected %u.\n", refcount, expected_refcount);
+    ISharedPropertyGroup_Release(group2);
+    SysFreeString(name);
+
+    name = SysAllocString(L"Testgroupname");
+    hr = ISharedPropertyGroupManager_get_Group(manager, name, &group2);
+    ok(hr == E_INVALIDARG, "Got hr %#x.\n", hr);
+    SysFreeString(name);
+
     expected_refcount = get_refcount(manager) - 1;
     ISharedPropertyGroup_Release(group);
     refcount = get_refcount(manager);
-- 
2.28.0




More information about the wine-devel mailing list