Commit 1e6b130b authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

ole32/tests: Add some more tests for interface redirection handling.

parent 5b66442b
TESTDLL = ole32.dll TESTDLL = ole32.dll
IMPORTS = oleaut32 ole32 user32 uuid gdi32 advapi32 IMPORTS = oleaut32 ole32 user32 uuid gdi32 advapi32
C_SRCS = \ SOURCES = \
clipboard.c \ clipboard.c \
compobj.c \ compobj.c \
defaulthandler.c \ defaulthandler.c \
...@@ -15,4 +15,6 @@ C_SRCS = \ ...@@ -15,4 +15,6 @@ C_SRCS = \
propvariant.c \ propvariant.c \
stg_prop.c \ stg_prop.c \
storage32.c \ storage32.c \
testlib.c \
testlib.spec \
usrmarshal.c usrmarshal.c
...@@ -82,9 +82,7 @@ static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override); ...@@ -82,9 +82,7 @@ static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override);
static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*); static BOOL (WINAPI *pActivateActCtx)(HANDLE,ULONG_PTR*);
static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW); static HANDLE (WINAPI *pCreateActCtxW)(PCACTCTXW);
static BOOL (WINAPI *pDeactivateActCtx)(DWORD,ULONG_PTR);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, LPBOOL); 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_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) #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 ...@@ -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_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_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_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 } }; 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); 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) ...@@ -214,6 +214,26 @@ static BOOL create_manifest_file(const char *filename, const char *manifest)
return TRUE; 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) static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
{ {
WCHAR path[MAX_PATH]; WCHAR path[MAX_PATH];
...@@ -235,7 +255,7 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie) ...@@ -235,7 +255,7 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
"handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError()); "handle == INVALID_HANDLE_VALUE, error %u\n", GetLastError());
if (handle == INVALID_HANDLE_VALUE) 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; handle = NULL;
} }
...@@ -260,6 +280,15 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie) ...@@ -260,6 +280,15 @@ static HANDLE activate_context(const char *manifest, ULONG_PTR *cookie)
return handle; 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[] = static const char actctx_manifest[] =
"<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">" "<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">"
"<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\"" "<assemblyIdentity version=\"1.2.3.4\" name=\"Wine.Test\" type=\"win32\""
...@@ -294,6 +323,10 @@ static const char actctx_manifest[] = ...@@ -294,6 +323,10 @@ static const char actctx_manifest[] =
" iid=\"{22222222-1234-1234-1234-56789abcdef0}\"" " iid=\"{22222222-1234-1234-1234-56789abcdef0}\""
" proxyStubClsid32=\"{66666666-8888-7777-6666-555555555555}\"" " proxyStubClsid32=\"{66666666-8888-7777-6666-555555555555}\""
" />" " />"
" <comInterfaceProxyStub "
" name=\"Iifaceps5\""
" iid=\"{82222222-1234-1234-1234-56789abcdef0}\""
" />"
"</file>" "</file>"
" <comInterfaceExternalProxyStub " " <comInterfaceExternalProxyStub "
" name=\"Iifaceps2\"" " name=\"Iifaceps2\""
...@@ -367,8 +400,7 @@ static void test_ProgIDFromCLSID(void) ...@@ -367,8 +400,7 @@ static void test_ProgIDFromCLSID(void)
hr = ProgIDFromCLSID(&IID_Testiface6, &progid); hr = ProgIDFromCLSID(&IID_Testiface6, &progid);
ok(hr == REGDB_E_CLASSNOTREG && progid == NULL, "got 0x%08x, progid %p\n", hr, progid); ok(hr == REGDB_E_CLASSNOTREG && progid == NULL, "got 0x%08x, progid %p\n", hr, progid);
pDeactivateActCtx(0, cookie); deactivate_context(handle, cookie);
pReleaseActCtx(handle);
} }
} }
...@@ -434,8 +466,7 @@ static void test_CLSIDFromProgID(void) ...@@ -434,8 +466,7 @@ static void test_CLSIDFromProgID(void)
ok(!IsEqualCLSID(&clsid, &CLSID_StdFont) && !IsEqualCLSID(&clsid, &CLSID_NULL) && !IsEqualCLSID(&clsid, &clsid1), ok(!IsEqualCLSID(&clsid, &CLSID_StdFont) && !IsEqualCLSID(&clsid, &CLSID_NULL) && !IsEqualCLSID(&clsid, &clsid1),
"got %s\n", wine_dbgstr_guid(&clsid)); "got %s\n", wine_dbgstr_guid(&clsid));
pDeactivateActCtx(0, cookie); deactivate_context(handle, cookie);
pReleaseActCtx(handle);
} }
} }
...@@ -725,8 +756,14 @@ static void test_CoGetClassObject(void) ...@@ -725,8 +756,14 @@ static void test_CoGetClassObject(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
IUnknown_Release(pUnk); IUnknown_Release(pUnk);
pDeactivateActCtx(0, cookie); hr = CoGetClassObject(&IID_Testiface7, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void **)&pUnk);
pReleaseActCtx(handle); 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(); CoUninitialize();
...@@ -1267,6 +1304,11 @@ static void test_CoGetPSClsid(void) ...@@ -1267,6 +1304,11 @@ static void test_CoGetPSClsid(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&clsid, &GUID_NULL), "got clsid %s\n", wine_dbgstr_guid(&clsid)); 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 */ /* register same interface and try to get CLSID back */
hr = CoRegisterPSClsid(&IID_Testiface, &IID_Testiface4); hr = CoRegisterPSClsid(&IID_Testiface, &IID_Testiface4);
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
...@@ -1275,8 +1317,7 @@ static void test_CoGetPSClsid(void) ...@@ -1275,8 +1317,7 @@ static void test_CoGetPSClsid(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(IsEqualGUID(&clsid, &IID_Testiface4), "got clsid %s\n", wine_dbgstr_guid(&clsid)); ok(IsEqualGUID(&clsid, &IID_Testiface4), "got clsid %s\n", wine_dbgstr_guid(&clsid));
pDeactivateActCtx(0, cookie); deactivate_context(handle, cookie);
pReleaseActCtx(handle);
} }
if (pRegDeleteKeyExA && if (pRegDeleteKeyExA &&
...@@ -1533,11 +1574,9 @@ static void test_CoRegisterClassObject(void) ...@@ -1533,11 +1574,9 @@ static void test_CoRegisterClassObject(void)
if ((handle = activate_context(actctx_manifest, &ctxcookie))) if ((handle = activate_context(actctx_manifest, &ctxcookie)))
{ {
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf); hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf);
todo_wine ok(hr == 0x80001234, "Unexpected hr %#x.\n", hr);
ok(hr == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND), "got 0x%08x\n", hr);
pDeactivateActCtx(0, ctxcookie); deactivate_context(handle, ctxcookie);
pReleaseActCtx(handle);
} }
hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf); hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void**)&pcf);
...@@ -2264,8 +2303,7 @@ static void test_OleRegGetMiscStatus(void) ...@@ -2264,8 +2303,7 @@ static void test_OleRegGetMiscStatus(void)
ok(hr == S_OK, "got 0x%08x\n", hr); ok(hr == S_OK, "got 0x%08x\n", hr);
ok(status == 0, "got 0x%08x\n", status); ok(status == 0, "got 0x%08x\n", status);
pDeactivateActCtx(0, cookie); deactivate_context(handle, cookie);
pReleaseActCtx(handle);
} }
} }
...@@ -2332,8 +2370,7 @@ static void test_OleRegGetUserType(void) ...@@ -2332,8 +2370,7 @@ static void test_OleRegGetUserType(void)
CoTaskMemFree(str); CoTaskMemFree(str);
} }
pDeactivateActCtx(0, cookie); deactivate_context(handle, cookie);
pReleaseActCtx(handle);
} }
/* test using registered CLSID */ /* test using registered CLSID */
...@@ -3789,9 +3826,7 @@ static void init_funcs(void) ...@@ -3789,9 +3826,7 @@ static void init_funcs(void)
pActivateActCtx = (void*)GetProcAddress(hkernel32, "ActivateActCtx"); pActivateActCtx = (void*)GetProcAddress(hkernel32, "ActivateActCtx");
pCreateActCtxW = (void*)GetProcAddress(hkernel32, "CreateActCtxW"); pCreateActCtxW = (void*)GetProcAddress(hkernel32, "CreateActCtxW");
pDeactivateActCtx = (void*)GetProcAddress(hkernel32, "DeactivateActCtx");
pIsWow64Process = (void*)GetProcAddress(hkernel32, "IsWow64Process"); pIsWow64Process = (void*)GetProcAddress(hkernel32, "IsWow64Process");
pReleaseActCtx = (void*)GetProcAddress(hkernel32, "ReleaseActCtx");
} }
static DWORD CALLBACK implicit_mta_proc(void *param) static DWORD CALLBACK implicit_mta_proc(void *param)
...@@ -3869,6 +3904,11 @@ START_TEST(compobj) ...@@ -3869,6 +3904,11 @@ START_TEST(compobj)
return; return;
} }
GetTempPathA(ARRAY_SIZE(testlib), testlib);
SetCurrentDirectoryA(testlib);
lstrcatA(testlib, "\\testlib.dll");
extract_resource("testlib.dll", "TESTDLL", testlib);
if (!pCreateActCtxW) if (!pCreateActCtxW)
win_skip("Activation contexts are not supported, some tests will be skipped.\n"); win_skip("Activation contexts are not supported, some tests will be skipped.\n");
...@@ -3910,4 +3950,5 @@ START_TEST(compobj) ...@@ -3910,4 +3950,5 @@ START_TEST(compobj)
test_CoGetInstanceFromFile(); test_CoGetInstanceFromFile();
test_GlobalOptions(); test_GlobalOptions();
test_implicit_mta(); test_implicit_mta();
DeleteFileA( testlib );
} }
/*
* Test library
*
* Copyright 2019 Nikolay Sivov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#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;
}
@ stdcall DllGetClassObject(ptr ptr ptr)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment