[PATCH 1/3] ole32/tests: Add some more tests for interface redirection handling.

Nikolay Sivov nsivov at codeweavers.com
Tue Oct 29 08:36:04 CDT 2019


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/ole32/tests/Makefile.in  |  2 +
 dlls/ole32/tests/compobj.c    | 81 ++++++++++++++++++++++++++---------
 dlls/ole32/tests/testlib.c    | 17 ++++++++
 dlls/ole32/tests/testlib.spec |  1 +
 4 files changed, 80 insertions(+), 21 deletions(-)
 create mode 100644 dlls/ole32/tests/testlib.c
 create mode 100644 dlls/ole32/tests/testlib.spec

diff --git a/dlls/ole32/tests/Makefile.in b/dlls/ole32/tests/Makefile.in
index 6bf57e3e41..8f116147a1 100644
--- a/dlls/ole32/tests/Makefile.in
+++ b/dlls/ole32/tests/Makefile.in
@@ -15,4 +15,6 @@ C_SRCS = \
 	propvariant.c \
 	stg_prop.c \
 	storage32.c \
+	testlib.c \
+	testlib.spec \
 	usrmarshal.c
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c
index ea5ea35a11..5e72eb650e 100644
--- a/dlls/ole32/tests/compobj.c
+++ b/dlls/ole32/tests/compobj.c
@@ -82,9 +82,7 @@ static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override);
 
 static BOOL   (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
 static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
-static BOOL   (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
 static BOOL   (WINAPI *pIsWow64Process)(HANDLE, LPBOOL);
-static void   (WINAPI *pReleaseActCtx)(HANDLE);
 
 #define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
 #define ok_more_than_one_lock() ok(cLocks > 0, "Number of locks should be > 0, but actually is %d\n", cLocks)
@@ -98,6 +96,8 @@ static const GUID IID_Testiface3 = { 0x42222222, 0x1234, 0x1234, { 0x12, 0x34, 0
 static const GUID IID_Testiface4 = { 0x52222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
 static const GUID IID_Testiface5 = { 0x62222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
 static const GUID IID_Testiface6 = { 0x72222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
+static const GUID IID_Testiface7 = { 0x82222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
+static const GUID IID_Testiface8 = { 0x92222222, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0 } };
 static const GUID IID_TestPS = { 0x66666666, 0x8888, 0x7777, { 0x66, 0x66, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55 } };
 
 DEFINE_GUID(CLSID_testclsid, 0xacd014c7,0x9535,0x4fac,0x8b,0x53,0xa4,0x8c,0xa7,0xf4,0xd7,0x26);
@@ -214,6 +214,26 @@ static BOOL create_manifest_file(const char *filename, const char *manifest)
     return TRUE;
 }
 
+static void extract_resource(const char *name, const char *type, const char *path)
+{
+    DWORD written;
+    HANDLE file;
+    HRSRC res;
+    void *ptr;
+
+    file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    ok(file != INVALID_HANDLE_VALUE, "Failed to create a file at %s, error %d.\n", path, GetLastError());
+
+    res = FindResourceA(NULL, name, type);
+    ok(res != 0, "Failed to find resource.\n");
+    ptr = LockResource(LoadResource(GetModuleHandleA(NULL), res));
+    WriteFile(file, ptr, SizeofResource(GetModuleHandleA(NULL), res), &written, NULL);
+    ok(written == SizeofResource(GetModuleHandleA(NULL), res), "Failed to write file.\n" );
+    CloseHandle(file);
+}
+
+static char testlib[MAX_PATH];
+
 static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
 {
     WCHAR path[MAX_PATH];
@@ -235,7 +255,7 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
         "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
     if (handle == INVALID_HANDLE_VALUE)
     {
-        win_skip("activation context generation failed, some tests will be skipped\n");
+        win_skip("activation context generation failed, some tests will be skipped. Error %d\n", GetLastError());
         handle = NULL;
     }
 
@@ -260,6 +280,15 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
     return handle;
 }
 
+static void deactivate_context(HANDLE handle, ULONG_PTR cookie)
+{
+    BOOL ret;
+
+    ret = DeactivateActCtx(0, cookie);
+    ok(ret, "Failed to deactivate context, error %d.\n", GetLastError());
+    ReleaseActCtx(handle);
+}
+
 static const char actctx_manifest[] =
 "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
 "<assemblyIdentity version=\"1.2.3.4\"  name=\"Wine.Test\" type=\"win32\""
@@ -294,6 +323,10 @@ static const char actctx_manifest[] =
 "        iid=\"{22222222-1234-1234-1234-56789abcdef0}\""
 "        proxyStubClsid32=\"{66666666-8888-7777-6666-555555555555}\""
 "    />"
+"    <comInterfaceProxyStub "
+"        name=\"Iifaceps5\""
+"        iid=\"{82222222-1234-1234-1234-56789abcdef0}\""
+"    />"
 "</file>"
 "    <comInterfaceExternalProxyStub "
 "        name=\"Iifaceps2\""
@@ -367,8 +400,7 @@ static void test_ProgIDFromCLSID(void)
         hr = ProgIDFromCLSID(&IID_Testiface6, &progid);
         ok(hr == REGDB_E_CLASSNOTREG && progid == NULL, "got 0x%08x, progid %p\n", hr, progid);
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, cookie);
     }
 }
 
@@ -434,8 +466,7 @@ static void test_CLSIDFromProgID(void)
         ok(!IsEqualCLSID(&clsid, &CLSID_StdFont) && !IsEqualCLSID(&clsid, &CLSID_NULL) && !IsEqualCLSID(&clsid, &clsid1),
             "got %s\n", wine_dbgstr_guid(&clsid));
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, cookie);
     }
 }
 
@@ -725,8 +756,14 @@ static void test_CoGetClassObject(void)
         ok(hr == S_OK, "got 0x%08x\n", hr);
         IUnknown_Release(pUnk);
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        hr = CoGetClassObject(&IID_Testiface7, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
+    todo_wine
+        ok(hr == 0x80001235, "Unexpected hr %#x.\n", hr);
+
+        hr = CoGetClassObject(&IID_Testiface8, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
+        ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr);
+
+        deactivate_context(handle, cookie);
     }
 
     CoUninitialize();
@@ -1267,6 +1304,11 @@ static void test_CoGetPSClsid(void)
         ok(hr == S_OK, "got 0x%08x\n", hr);
         ok(IsEqualGUID(&clsid, &GUID_NULL), "got clsid %s\n", wine_dbgstr_guid(&clsid));
 
+        memset(&clsid, 0xaa, sizeof(clsid));
+        hr = CoGetPSClsid(&IID_Testiface7, &clsid);
+        ok(hr == S_OK, "Failed to get PS CLSID, hr %#x.\n", hr);
+        ok(IsEqualGUID(&clsid, &IID_Testiface7), "Unexpected CLSID %s.\n", wine_dbgstr_guid(&clsid));
+
         /* register same interface and try to get CLSID back */
         hr = CoRegisterPSClsid(&IID_Testiface, &IID_Testiface4);
         ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -1275,8 +1317,7 @@ static void test_CoGetPSClsid(void)
         ok(hr == S_OK, "got 0x%08x\n", hr);
         ok(IsEqualGUID(&clsid, &IID_Testiface4), "got clsid %s\n", wine_dbgstr_guid(&clsid));
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, cookie);
     }
 
     if (pRegDeleteKeyExA &&
@@ -1533,11 +1574,9 @@ static void test_CoRegisterClassObject(void)
     if ((handle = activate_context(actctx_manifest, &ctxcookie)))
     {
         hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf);
-todo_wine
-        ok(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), "got 0x%08x\n", hr);
+        ok(hr == 0x80001234, "Unexpected hr %#x.\n", hr);
 
-        pDeactivateActCtx(0, ctxcookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, ctxcookie);
     }
 
     hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf);
@@ -2264,8 +2303,7 @@ static void test_OleRegGetMiscStatus(void)
         ok(hr == S_OK, "got 0x%08x\n", hr);
         ok(status == 0, "got 0x%08x\n", status);
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, cookie);
     }
 }
 
@@ -2332,8 +2370,7 @@ static void test_OleRegGetUserType(void)
             CoTaskMemFree(str);
         }
 
-        pDeactivateActCtx(0, cookie);
-        pReleaseActCtx(handle);
+        deactivate_context(handle, cookie);
     }
 
     /* test using registered CLSID */
@@ -3789,9 +3826,7 @@ static void init_funcs(void)
 
     pActivateActCtx = (void*)GetProcAddress(hkernel32, "ActivateActCtx");
     pCreateActCtxW = (void*)GetProcAddress(hkernel32, "CreateActCtxW");
-    pDeactivateActCtx = (void*)GetProcAddress(hkernel32, "DeactivateActCtx");
     pIsWow64Process = (void*)GetProcAddress(hkernel32, "IsWow64Process");
-    pReleaseActCtx = (void*)GetProcAddress(hkernel32, "ReleaseActCtx");
 }
 
 static DWORD CALLBACK implicit_mta_proc(void *param)
@@ -3869,6 +3904,10 @@ START_TEST(compobj)
         return;
     }
 
+    GetCurrentDirectoryA(ARRAY_SIZE(testlib), testlib);
+    lstrcatA(testlib, "\\testlib.dll");
+    extract_resource("testlib.dll", "TESTDLL", testlib);
+
     if (!pCreateActCtxW)
         win_skip("Activation contexts are not supported, some tests will be skipped.\n");
 
diff --git a/dlls/ole32/tests/testlib.c b/dlls/ole32/tests/testlib.c
new file mode 100644
index 0000000000..d28147b750
--- /dev/null
+++ b/dlls/ole32/tests/testlib.c
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <windows.h>
+#include <initguid.h>
+
+DEFINE_GUID(CLSID_WineOOPTest, 0x5201163f, 0x8164, 0x4fd0, 0xa1, 0xa2, 0x5d, 0x5a, 0x36, 0x54, 0xd3, 0xbd);
+DEFINE_GUID(IID_Testiface7, 0x82222222, 0x1234, 0x1234, 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0);
+
+HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID riid, void **obj)
+{
+    if (IsEqualGUID(clsid, &CLSID_WineOOPTest))
+        return 0x80001234;
+
+    if (IsEqualGUID(clsid, &IID_Testiface7))
+        return 0x80001235;
+
+    return E_NOTIMPL;
+}
diff --git a/dlls/ole32/tests/testlib.spec b/dlls/ole32/tests/testlib.spec
new file mode 100644
index 0000000000..8737274e9c
--- /dev/null
+++ b/dlls/ole32/tests/testlib.spec
@@ -0,0 +1 @@
+@ stdcall DllGetClassObject(ptr ptr ptr)
-- 
2.23.0




More information about the wine-devel mailing list