Commit 2daa5367 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

ole32/tests: Add a test for local server interaction using an in-process handler.

parent 289437dc
......@@ -55,6 +55,7 @@ static const struct
GUID_NAME(IStdMarshalInfo),
GUID_NAME(IExternalConnection),
GUID_NAME(IRunnableObject),
GUID_NAME(ICallFactory),
{ &CLSID_IdentityUnmarshal, "CLSID_IdentityUnmarshal" },
{ &CLSID_UnknownUnmarshal, "CLSID_UnknownUnmarshal" },
#undef GUID_NAME
......@@ -276,7 +277,7 @@ static void ole_server(void)
}
/******************************* OLE client *******************************/
static BOOL register_server(const char *server)
static BOOL register_server(const char *server, BOOL inproc_handler)
{
static const WCHAR clsidW[] = {'C','L','S','I','D','\\',0};
DWORD ret;
......@@ -296,6 +297,13 @@ static BOOL register_server(const char *server)
{
ret = RegSetValue(root, "LocalServer32", REG_SZ, server_path, strlen(server_path));
ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
if (inproc_handler)
{
ret = RegSetValue(root, "InprocHandler32", REG_SZ, "ole32.dll", 9);
ok(ret == ERROR_SUCCESS, "RegSetValue error %u\n", ret);
}
RegCloseKey(root);
}
......@@ -316,6 +324,8 @@ static void unregister_server(void)
DELETE, NULL, &root, NULL);
if (ret == ERROR_SUCCESS)
{
ret = RegDeleteKey(root, "InprocHandler32");
ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
ret = RegDeleteKey(root, "LocalServer32");
ok(ret == ERROR_SUCCESS, "RegDeleteKey error %u\n", ret);
ret = RegDeleteKey(root, "");
......@@ -359,6 +369,7 @@ START_TEST(ole_server)
IClassFactory *factory;
IUnknown *unknown;
IOleObject *oleobj;
IRunnableObject *runobj;
DWORD ret;
HANDLE mapping, done_event, init_done_event, process;
struct winetest_info *info;
......@@ -396,7 +407,7 @@ START_TEST(ole_server)
return;
}
if (!register_server(argv[0]))
if (!register_server(argv[0], FALSE))
{
win_skip("not enough permissions to create a server CLSID key\n");
return;
......@@ -415,14 +426,81 @@ START_TEST(ole_server)
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
ok(hr == REGDB_E_CLASSNOTREG, "expected REGDB_E_CLASSNOTREG, got %#x\n", hr);
/* server supports IID_IUnknown */
if (!register_server(argv[0], TRUE))
{
win_skip("not enough permissions to create a server CLSID key\n");
unregister_server();
return;
}
trace("call CoCreateInstance(&IID_NULL)\n");
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_NULL, (void **)&unknown);
trace("ret CoCreateInstance(&IID_NULL)\n");
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
/* in-process handler supports IID_IUnknown starting from Vista */
trace("call CoCreateInstance(&IID_IUnknown)\n");
hr = CoCreateInstance(&clsid, NULL, CLSCTX_INPROC_HANDLER, &IID_IUnknown, (void **)&unknown);
trace("ret CoCreateInstance(&IID_IUnknown)\n");
ok(hr == S_OK || broken(hr == REGDB_E_CLASSNOTREG) /* XP,win2000 and earlier */, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
if (hr != S_OK)
{
win_skip("In-process handler doesn't support IID_IUnknown on this platform\n");
goto test_local_server;
}
trace("call CoCreateInstance(&IID_IOleObject)\n");
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IOleObject, (void **)&oleobj);
trace("ret CoCreateInstance(&IID_IOleObject)\n");
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
ok(hr == S_OK, "QueryInterface(&IID_IRunnableObject) error %#x\n", hr);
ret = IRunnableObject_IsRunning(runobj);
ok(!ret, "expected 0, got %d\n", ret);
trace("call OleRun\n");
hr = OleRun(unknown);
trace("ret OleRun\n");
todo_wine
ok(hr == S_OK, "OleRun error %#x\n", hr);
ret = IRunnableObject_IsRunning(runobj);
todo_wine
ok(ret == 1, "expected 1, got %d\n", ret);
trace("call IRunnableObject_Release\n");
ret = IRunnableObject_Release(runobj);
trace("ret IRunnableObject_Release\n");
ok(ret == 1, "expected ref 1, got %u\n", ret);
trace("call IUnknown_QueryInterface(&IID_IOleObject)\n");
hr = IUnknown_QueryInterface(unknown, &IID_IOleObject, (void **)&oleobj);
trace("ret IUnknown_QueryInterface(&IID_IOleObject)\n");
ok(hr == S_OK, "QueryInterface(&IID_IOleObject) error %#x\n", hr);
trace("call IOleObject_Release\n");
ret = IOleObject_Release(oleobj);
trace("ret IOleObject_Release\n");
ok(ret == 1, "expected ref 1, got %u\n", ret);
trace("call IUnknown_Release\n");
ret = IUnknown_Release(unknown);
trace("ret IUnknown_Release\n");
ok(!ret, "expected ref 0, got %u\n", ret);
test_local_server:
/* local server supports IID_IUnknown */
trace("call CoCreateInstance(&IID_IUnknown)\n");
hr = CoCreateInstance(&clsid, NULL, CLSCTX_LOCAL_SERVER, &IID_IUnknown, (void **)&unknown);
trace("ret CoCreateInstance(&IID_IUnknown)\n");
ok(hr == S_OK, "CoCreateInstance(IID_IUnknown) error %#x\n", hr);
trace("call IUnknown_QueryInterface(&IID_IRunnableObject)\n");
hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&oleobj);
hr = IUnknown_QueryInterface(unknown, &IID_IRunnableObject, (void **)&runobj);
trace("ret IUnknown_QueryInterface(&IID_IRunnableObject)\n");
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
......@@ -446,9 +524,9 @@ START_TEST(ole_server)
trace("ret CoGetClassObject(&IID_IClassFactory)\n");
ok(hr == S_OK, "CoGetClassObject error %#x\n", hr);
trace("call IClassFactory_QueryInterface(&IID_IOleObject)\n");
hr = IClassFactory_QueryInterface(factory, &IID_IOleObject, (void **)&oleobj);
trace("ret IClassFactory_QueryInterface(&IID_IOleObject)\n");
trace("call IClassFactory_CreateInstance(&IID_NULL)\n");
hr = IClassFactory_CreateInstance(factory, NULL, &IID_NULL, (void **)&oleobj);
trace("ret IClassFactory_CreateInstance(&IID_NULL)\n");
ok(hr == E_NOINTERFACE, "expected E_NOINTERFACE, got %#x\n", hr);
trace("call IClassFactory_CreateInstance(&IID_IOleObject)\n");
......
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