Connor McAdams : uiautomationcore/tests: Add tests for ReservedValue COM interfaces.

Alexandre Julliard julliard at winehq.org
Fri Nov 5 17:15:53 CDT 2021


Module: wine
Branch: master
Commit: 475dce071c5f508aacaa040477d4e29327b232bf
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=475dce071c5f508aacaa040477d4e29327b232bf

Author: Connor McAdams <cmcadams at codeweavers.com>
Date:   Thu Nov  4 15:14:13 2021 -0400

uiautomationcore/tests: Add tests for ReservedValue COM interfaces.

Signed-off-by: Connor McAdams <cmcadams at codeweavers.com>
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/uiautomationcore/tests/Makefile.in    |   2 +-
 dlls/uiautomationcore/tests/uiautomation.c | 133 +++++++++++++++++++++++++++++
 2 files changed, 134 insertions(+), 1 deletion(-)

diff --git a/dlls/uiautomationcore/tests/Makefile.in b/dlls/uiautomationcore/tests/Makefile.in
index c39b062b6fd..1d08e19093f 100644
--- a/dlls/uiautomationcore/tests/Makefile.in
+++ b/dlls/uiautomationcore/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL = uiautomationcore.dll
-IMPORTS = uiautomationcore user32
+IMPORTS = uiautomationcore user32 ole32
 
 C_SRCS = \
 	uiautomation.c
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c
index cbcba1af294..52a6648dad2 100644
--- a/dlls/uiautomationcore/tests/uiautomation.c
+++ b/dlls/uiautomationcore/tests/uiautomation.c
@@ -86,7 +86,140 @@ if (hr == S_OK)
     UnregisterClassA("HostProviderFromHwnd class", NULL);
 }
 
+static DWORD WINAPI uia_reserved_val_iface_marshal_thread(LPVOID param)
+{
+    IStream **stream = param;
+    IUnknown *unk_ns, *unk_ns2, *unk_ma, *unk_ma2;
+    HRESULT hr;
+
+    CoInitializeEx(NULL, COINIT_MULTITHREADED);
+
+    hr = CoGetInterfaceAndReleaseStream(stream[0], &IID_IUnknown, (void **)&unk_ns);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    hr = CoGetInterfaceAndReleaseStream(stream[1], &IID_IUnknown, (void **)&unk_ma);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    hr = UiaGetReservedNotSupportedValue(&unk_ns2);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    hr = UiaGetReservedMixedAttributeValue(&unk_ma2);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    ok(unk_ns2 == unk_ns, "UiaGetReservedNotSupported pointer mismatch, unk_ns2 %p, unk_ns %p\n", unk_ns2, unk_ns);
+    ok(unk_ma2 == unk_ma, "UiaGetReservedMixedAttribute pointer mismatch, unk_ma2 %p, unk_ma %p\n", unk_ma2, unk_ma);
+
+    CoUninitialize();
+
+    return 0;
+}
+
+static void test_uia_reserved_value_ifaces(void)
+{
+    IUnknown *unk_ns, *unk_ns2, *unk_ma, *unk_ma2;
+    IStream *stream[2];
+    IMarshal *marshal;
+    HANDLE thread;
+    ULONG refcnt;
+    HRESULT hr;
+
+    /* ReservedNotSupportedValue. */
+    hr = UiaGetReservedNotSupportedValue(NULL);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+    hr = UiaGetReservedNotSupportedValue(&unk_ns);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(unk_ns != NULL, "UiaGetReservedNotSupportedValue returned NULL interface.\n");
+
+    refcnt = IUnknown_AddRef(unk_ns);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IUnknown_AddRef(unk_ns);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IUnknown_Release(unk_ns);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    hr = UiaGetReservedNotSupportedValue(&unk_ns2);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(unk_ns2 != NULL, "UiaGetReservedNotSupportedValue returned NULL interface.");
+    ok(unk_ns2 == unk_ns, "UiaGetReservedNotSupported pointer mismatch, unk_ns2 %p, unk_ns %p\n", unk_ns2, unk_ns);
+
+    marshal = NULL;
+    hr = IUnknown_QueryInterface(unk_ns, &IID_IMarshal, (void **)&marshal);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(marshal != NULL, "Failed to get IMarshal interface.\n");
+
+    refcnt = IMarshal_AddRef(marshal);
+    ok(refcnt == 2, "Expected refcnt %d, got %d\n", 2, refcnt);
+
+    refcnt = IMarshal_Release(marshal);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IMarshal_Release(marshal);
+    ok(refcnt == 0, "Expected refcnt %d, got %d\n", 0, refcnt);
+
+    /* ReservedMixedAttributeValue. */
+    hr = UiaGetReservedMixedAttributeValue(NULL);
+    ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
+
+    hr = UiaGetReservedMixedAttributeValue(&unk_ma);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(unk_ma != NULL, "UiaGetReservedMixedAttributeValue returned NULL interface.");
+
+    refcnt = IUnknown_AddRef(unk_ma);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IUnknown_AddRef(unk_ma);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IUnknown_Release(unk_ma);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    hr = UiaGetReservedMixedAttributeValue(&unk_ma2);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(unk_ma2 != NULL, "UiaGetReservedMixedAttributeValue returned NULL interface.");
+    ok(unk_ma2 == unk_ma, "UiaGetReservedMixedAttribute pointer mismatch, unk_ma2 %p, unk_ma %p\n", unk_ma2, unk_ma);
+
+    marshal = NULL;
+    hr = IUnknown_QueryInterface(unk_ma, &IID_IMarshal, (void **)&marshal);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    ok(marshal != NULL, "Failed to get IMarshal interface.\n");
+
+    refcnt = IMarshal_AddRef(marshal);
+    ok(refcnt == 2, "Expected refcnt %d, got %d\n", 2, refcnt);
+
+    refcnt = IMarshal_Release(marshal);
+    ok(refcnt == 1, "Expected refcnt %d, got %d\n", 1, refcnt);
+
+    refcnt = IMarshal_Release(marshal);
+    ok(refcnt == 0, "Expected refcnt %d, got %d\n", 0, refcnt);
+
+    /* Test cross-thread marshaling behavior. */
+    CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+    hr = CoMarshalInterThreadInterfaceInStream(&IID_IUnknown, unk_ns, &stream[0]);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+    hr = CoMarshalInterThreadInterfaceInStream(&IID_IUnknown, unk_ma, &stream[1]);
+    ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+    thread = CreateThread(NULL, 0, uia_reserved_val_iface_marshal_thread, (void *)stream, 0, NULL);
+    while (MsgWaitForMultipleObjects(1, &thread, FALSE, INFINITE, QS_ALLINPUT) != WAIT_OBJECT_0)
+    {
+        MSG msg;
+        while(PeekMessageW(&msg, 0, 0, 0, PM_REMOVE))
+        {
+            TranslateMessage(&msg);
+            DispatchMessageW(&msg);
+        }
+    }
+    CloseHandle(thread);
+
+    CoUninitialize();
+}
+
 START_TEST(uiautomation)
 {
     test_UiaHostProviderFromHwnd();
+    test_uia_reserved_value_ifaces();
 }




More information about the wine-cvs mailing list