From 6b6657657c56659f81542eeaf7faa534a8a2ba6a Mon Sep 17 00:00:00 2001 From: Mikolaj Zalewski Date: Mon, 8 Oct 2007 16:32:58 -0700 Subject: [PATCH] ole32: OleIsRunnable should return TRUE if the class doesn't implement IRunnableObject (with testcase) --- dlls/ole32/ole2.c | 2 +- dlls/ole32/tests/ole2.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/dlls/ole32/ole2.c b/dlls/ole32/ole2.c index e58385b..2f5cc64 100644 --- a/dlls/ole32/ole2.c +++ b/dlls/ole32/ole2.c @@ -2515,7 +2515,7 @@ BOOL WINAPI OleIsRunning(LPOLEOBJECT pOb hr = IOleObject_QueryInterface(pObject, &IID_IRunnableObject, (void **)&pRunnable); if (FAILED(hr)) - return FALSE; + return TRUE; running = IRunnableObject_IsRunning(pRunnable); IRunnableObject_Release(pRunnable); return running; diff --git a/dlls/ole32/tests/ole2.c b/dlls/ole32/tests/ole2.c index 73378dd..6732c13 100644 --- a/dlls/ole32/tests/ole2.c +++ b/dlls/ole32/tests/ole2.c @@ -46,6 +46,9 @@ static const CLSID CLSID_WineTest = static char const * const *expected_method_list; +BOOL g_showRunnable = TRUE; +BOOL g_isRunning = TRUE; + #define CHECK_EXPECTED_METHOD(method_name) \ do { \ trace("%s\n", method_name); \ @@ -70,7 +73,7 @@ static HRESULT WINAPI OleObject_QueryInt *ppv = &OleObjectPersistStg; else if (IsEqualIID(riid, &IID_IOleCache)) *ppv = cache; - else if (IsEqualIID(riid, &IID_IRunnableObject)) + else if (IsEqualIID(riid, &IID_IRunnableObject) && g_showRunnable) *ppv = runnable; if(*ppv) { @@ -616,7 +619,7 @@ static HRESULT WINAPI OleObjectRunnable_ static BOOL WINAPI OleObjectRunnable_IsRunning(IRunnableObject *iface) { CHECK_EXPECTED_METHOD("OleObjectRunnable_IsRunning"); - return TRUE; + return g_isRunning; } static HRESULT WINAPI OleObjectRunnable_LockRunning( @@ -1453,6 +1456,43 @@ static void test_default_handler(void) IOleObject_Release(pObject); } +void test_runnable(void) +{ + static const char *methods_query_runnable[] = + { + "OleObject_QueryInterface", + "OleObjectRunnable_AddRef", + "OleObjectRunnable_IsRunning", + "OleObjectRunnable_Release", + NULL + }; + + static const char *methods_no_runnable[] = + { + "OleObject_QueryInterface", + NULL + }; + + IOleObject *object = (IOleObject *)&OleObject; + + expected_method_list = methods_query_runnable; + ok(OleIsRunning(object), "Object should be running\n"); + ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + + g_isRunning = FALSE; + expected_method_list = methods_query_runnable; + ok(OleIsRunning(object) == FALSE, "Object should not be running\n"); + ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + + g_showRunnable = FALSE; /* QueryInterface(IID_IRunnableObject, ...) will fail */ + expected_method_list = methods_no_runnable; + ok(OleIsRunning(object), "Object without IRunnableObject should be running\n"); + ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + + g_isRunning = TRUE; + g_showRunnable = TRUE; +} + START_TEST(ole2) { DWORD dwRegister; @@ -1483,6 +1523,7 @@ START_TEST(ole2) test_data_cache(); test_default_handler(); + test_runnable(); CoUninitialize(); } -- 1.4.1