diff --git a/rostests/winetests/ole32/clipboard.c b/rostests/winetests/ole32/clipboard.c index 26278b6417c..ee912ce773e 100644 --- a/rostests/winetests/ole32/clipboard.c +++ b/rostests/winetests/ole32/clipboard.c @@ -451,6 +451,8 @@ static void test_set_clipboard(void) ok(hr == S_OK, "expected current clipboard to be data1, hr = 0x%08x\n", hr); hr = OleIsCurrentClipboard(data2); ok(hr == S_FALSE, "did not expect current clipboard to be data2, hr = 0x%08x\n", hr); + hr = OleIsCurrentClipboard(NULL); + ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr); test_get_clipboard(); @@ -460,6 +462,8 @@ static void test_set_clipboard(void) ok(hr == S_FALSE, "did not expect current clipboard to be data1, hr = 0x%08x\n", hr); hr = OleIsCurrentClipboard(data2); ok(hr == S_OK, "expected current clipboard to be data2, hr = 0x%08x\n", hr); + hr = OleIsCurrentClipboard(NULL); + ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr); hr = OleFlushClipboard(); ok(hr == S_OK, "failed to flush clipboard, hr = 0x%08x\n", hr); @@ -467,6 +471,8 @@ static void test_set_clipboard(void) ok(hr == S_FALSE, "did not expect current clipboard to be data1, hr = 0x%08x\n", hr); hr = OleIsCurrentClipboard(data2); ok(hr == S_FALSE, "did not expect current clipboard to be data2, hr = 0x%08x\n", hr); + hr = OleIsCurrentClipboard(NULL); + ok(hr == S_FALSE, "expect S_FALSE, hr = 0x%08x\n", hr); ok(OleSetClipboard(NULL) == S_OK, "failed to clear clipboard, hr = 0x%08x\n", hr); diff --git a/rostests/winetests/ole32/compobj.c b/rostests/winetests/ole32/compobj.c index b2aaa226eb5..bdc34d9b69b 100644 --- a/rostests/winetests/ole32/compobj.c +++ b/rostests/winetests/ole32/compobj.c @@ -244,7 +244,9 @@ static void test_CoGetClassObject(void) ok(pUnk == NULL, "CoGetClassObject should have changed the passed in pointer to NULL, instead of %p\n", pUnk); hr = CoGetClassObject(&CLSID_MyComputer, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, NULL); - ok(hr == E_INVALIDARG, "CoGetClassObject should have returned E_INVALIDARG instead of 0x%08x\n", hr); + ok(hr == E_INVALIDARG || + broken(hr == CO_E_NOTINITIALIZED), /* win9x */ + "CoGetClassObject should have returned E_INVALIDARG instead of 0x%08x\n", hr); } static ATOM register_dummy_class(void) @@ -944,7 +946,9 @@ static void test_CoFreeUnusedLibraries(void) ok(is_module_loaded("urlmon.dll"), "urlmon.dll should be loaded\n"); - ok(pUnk != NULL, "Expected a valid pointer\n"); + ok(pUnk != NULL || + broken(pUnk == NULL), /* win9x */ + "Expected a valid pointer\n"); if (pUnk) IUnknown_Release(pUnk); diff --git a/rostests/winetests/ole32/marshal.c b/rostests/winetests/ole32/marshal.c index fade8b075a1..0443b63291a 100644 --- a/rostests/winetests/ole32/marshal.c +++ b/rostests/winetests/ole32/marshal.c @@ -27,12 +27,16 @@ #include "windef.h" #include "winbase.h" +#include "initguid.h" #include "objbase.h" +#include "olectl.h" #include "shlguid.h" #include "shobjidl.h" #include "wine/test.h" +DEFINE_GUID(CLSID_StdGlobalInterfaceTable,0x00000323,0x0000,0x0000,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46); + /* functions that are not present on all versions of Windows */ HRESULT (WINAPI * pCoInitializeEx)(LPVOID lpReserved, DWORD dwCoInit); @@ -2333,20 +2337,23 @@ static void test_handler_marshaling(void) ok_ole_success(hr, "CoUnmarshalInterface"); IStream_Release(pStream); - ok_more_than_one_lock(); + if(hr == S_OK) + { + ok_more_than_one_lock(); - hr = IUnknown_QueryInterface(pProxy, &IID_IWineTest, (void **)&pObject); - ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface with unknown IID should have returned E_NOINTERFACE instead of 0x%08x\n", hr); + hr = IUnknown_QueryInterface(pProxy, &IID_IWineTest, (void **)&pObject); + ok(hr == E_NOINTERFACE, "IUnknown_QueryInterface with unknown IID should have returned E_NOINTERFACE instead of 0x%08x\n", hr); - /* it's a handler as it supports IOleObject */ - hr = IUnknown_QueryInterface(pProxy, &IID_IOleObject, (void **)&pObject); - todo_wine - ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)"); - if (SUCCEEDED(hr)) IUnknown_Release(pObject); + /* it's a handler as it supports IOleObject */ + hr = IUnknown_QueryInterface(pProxy, &IID_IOleObject, (void **)&pObject); + todo_wine + ok_ole_success(hr, "IUnknown_QueryInterface(&IID_IOleObject)"); + if (SUCCEEDED(hr)) IUnknown_Release(pObject); - IUnknown_Release(pProxy); + IUnknown_Release(pProxy); - ok_no_locks(); + ok_no_locks(); + } end_host_object(tid, thread); diff --git a/rostests/winetests/ole32/moniker.c b/rostests/winetests/ole32/moniker.c index b15cce43e5e..468eb62de74 100644 --- a/rostests/winetests/ole32/moniker.c +++ b/rostests/winetests/ole32/moniker.c @@ -571,26 +571,18 @@ static void test_ROT(void) /* try with our own moniker that doesn't support IROTData */ hr = IRunningObjectTable_Register(pROT, ROTFLAGS_REGISTRATIONKEEPSALIVE, (IUnknown*)&Test_ClassFactory, &MonikerNoROTData, &dwCookie); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_Register); - } ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_more_than_one_lock(); - } expected_method_list = methods_isrunning_no_ROTData; hr = IRunningObjectTable_IsRunning(pROT, &MonikerNoROTData); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_IsRunning); - } ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); hr = IRunningObjectTable_Revoke(pROT, dwCookie); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_Revoke); - } ok_no_locks(); @@ -598,26 +590,18 @@ static void test_ROT(void) /* try with our own moniker */ hr = IRunningObjectTable_Register(pROT, ROTFLAGS_REGISTRATIONKEEPSALIVE, (IUnknown*)&Test_ClassFactory, &Moniker, &dwCookie); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_Register); - } ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_more_than_one_lock(); - } expected_method_list = methods_isrunning; hr = IRunningObjectTable_IsRunning(pROT, &Moniker); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_IsRunning); - } ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); hr = IRunningObjectTable_Revoke(pROT, dwCookie); - todo_wine { /* only fails because of lack of IMoniker marshaling */ ok_ole_success(hr, IRunningObjectTable_Revoke); - } ok_no_locks(); @@ -1765,7 +1749,9 @@ static void test_bind_context(void) bind_opts.cbStruct = -1; hr = IBindCtx_GetBindOptions(pBindCtx, (BIND_OPTS *)&bind_opts); ok_ole_success(hr, "IBindCtx_GetBindOptions"); - ok(bind_opts.cbStruct == sizeof(bind_opts), "bind_opts.cbStruct was %d\n", bind_opts.cbStruct); + ok(bind_opts.cbStruct == sizeof(bind_opts) || + bind_opts.cbStruct == 36, /* Vista */ + "bind_opts.cbStruct was %d\n", bind_opts.cbStruct); bind_opts.cbStruct = sizeof(BIND_OPTS); hr = IBindCtx_GetBindOptions(pBindCtx, (BIND_OPTS *)&bind_opts); diff --git a/rostests/winetests/ole32/ole2.c b/rostests/winetests/ole32/ole2.c index 8d72b153317..cc3476d60f7 100644 --- a/rostests/winetests/ole32/ole2.c +++ b/rostests/winetests/ole32/ole2.c @@ -782,10 +782,14 @@ static void test_OleCreate(IStorage *pStorage) expected_method_list = methods_olerender_format; trace("OleCreate with OLERENDER_FORMAT:\n"); hr = OleCreate(&CLSID_Equation3, &IID_IOleObject, OLERENDER_FORMAT, &formatetc, (IOleClientSite *)0xdeadbeef, pStorage, (void **)&pObject); - ok_ole_success(hr, "OleCreate"); + ok(hr == S_OK || + broken(hr == E_INVALIDARG), /* win2k */ + "OleCreate failed with error 0x%08x\n", hr); if (pObject) + { IOleObject_Release(pObject); - ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + } expected_method_list = methods_olerender_asis; trace("OleCreate with OLERENDER_ASIS:\n"); @@ -839,10 +843,14 @@ static void test_OleLoad(IStorage *pStorage) expected_method_list = methods_oleload; trace("OleLoad:\n"); hr = OleLoad(pStorage, &IID_IOleObject, (IOleClientSite *)0xdeadbeef, (void **)&pObject); - ok_ole_success(hr, "OleLoad"); + ok(hr == S_OK || + broken(hr == E_INVALIDARG), /* win98 and win2k */ + "OleLoad failed with error 0x%08x\n", hr); if (pObject) + { IOleObject_Release(pObject); - ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + ok(!*expected_method_list, "Method sequence starting from %s not called\n", *expected_method_list); + } } static BOOL STDMETHODCALLTYPE draw_continue(ULONG_PTR param) diff --git a/rostests/winetests/ole32/stg_prop.c b/rostests/winetests/ole32/stg_prop.c index 5a007e48105..a7024b38296 100644 --- a/rostests/winetests/ole32/stg_prop.c +++ b/rostests/winetests/ole32/stg_prop.c @@ -19,6 +19,12 @@ #define COBJMACROS #include "objbase.h" #include "wine/test.h" +#include "initguid.h" + +DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); +DEFINE_GUID(FMTID_SummaryInformation,0xF29F85E0,0x4FF9,0x1068,0xAB,0x91,0x08,0x00,0x2B,0x27,0xB3,0xD9); +DEFINE_GUID(FMTID_DocSummaryInformation,0xD5CDD502,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE); +DEFINE_GUID(FMTID_UserDefinedProperties,0xD5CDD505,0x2E9C,0x101B,0x93,0x97,0x08,0x00,0x2B,0x2C,0xF9,0xAE); #ifndef PID_BEHAVIOR #define PID_BEHAVIOR 0x80000003 diff --git a/rostests/winetests/ole32/storage32.c b/rostests/winetests/ole32/storage32.c index 7dc633c9fb7..d825ab66bfa 100644 --- a/rostests/winetests/ole32/storage32.c +++ b/rostests/winetests/ole32/storage32.c @@ -999,6 +999,218 @@ static void test_ReadClassStm(void) ok(IsEqualCLSID(&clsid, &test_stg_cls), "clsid should have been set to CLSID_WineTest\n"); } +struct access_res +{ + BOOL gothandle; + DWORD lasterr; +}; + +static const struct access_res create[16] = +{ + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS } +}; + +static const struct access_res create_commit[16] = +{ + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { FALSE, ERROR_SHARING_VIOLATION }, + { TRUE, ERROR_SUCCESS } +}; + +static const struct access_res create_close[16] = +{ + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS }, + { TRUE, ERROR_SUCCESS } +}; + +static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line) +{ + DWORD access = 0, share = 0; + DWORD lasterr; + HANDLE hfile; + int i, j, idx = 0; + + for (i = 0; i < 4; i++) + { + if (i == 0) access = 0; + if (i == 1) access = GENERIC_READ; + if (i == 2) access = GENERIC_WRITE; + if (i == 3) access = GENERIC_READ | GENERIC_WRITE; + + for (j = 0; j < 4; j++) + { + if (j == 0) share = 0; + if (j == 1) share = FILE_SHARE_READ; + if (j == 2) share = FILE_SHARE_WRITE; + if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE; + + SetLastError(0xdeadbeef); + hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, 0); + lasterr = GetLastError(); + + ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle, + "(%d, handle, %d): Expected %d, got %d\n", + line, idx, ares[idx].gothandle, + (hfile != INVALID_HANDLE_VALUE)); + + ok(lasterr == ares[idx].lasterr, + "(%d, lasterr, %d): Expected %d, got %d\n", + line, idx, ares[idx].lasterr, lasterr); + + CloseHandle(hfile); + idx++; + } + } +} + +#define test_file_access(file, ares) _test_file_access(file, ares, __LINE__) + +static void test_access(void) +{ + IStorage *stg; + HRESULT hr; + + static const WCHAR fileW[] = {'w','i','n','e','t','e','s','t',0}; + + /* STGM_TRANSACTED */ + + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | + STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, 0, &stg); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create); + + hr = IStorage_Commit(stg, STGC_DEFAULT); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create_commit); + + IStorage_Release(stg); + + test_file_access("winetest", create_close); + + DeleteFileA("winetest"); + + /* STGM_DIRECT */ + + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | + STGM_SHARE_EXCLUSIVE | STGM_DIRECT, 0, &stg); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create); + + hr = IStorage_Commit(stg, STGC_DEFAULT); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create_commit); + + IStorage_Release(stg); + + test_file_access("winetest", create_close); + + DeleteFileA("winetest"); + + /* STGM_SHARE_DENY_NONE */ + + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | + STGM_SHARE_DENY_NONE | STGM_TRANSACTED, 0, &stg); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create); + + hr = IStorage_Commit(stg, STGC_DEFAULT); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create_commit); + + IStorage_Release(stg); + + test_file_access("winetest", create_close); + + DeleteFileA("winetest"); + + /* STGM_SHARE_DENY_READ */ + + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | + STGM_SHARE_DENY_READ | STGM_TRANSACTED, 0, &stg); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create); + + hr = IStorage_Commit(stg, STGC_DEFAULT); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create_commit); + + IStorage_Release(stg); + + test_file_access("winetest", create_close); + + DeleteFileA("winetest"); + + /* STGM_SHARE_DENY_WRITE */ + + hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE | + STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create); + + hr = IStorage_Commit(stg, STGC_DEFAULT); + ok(hr == S_OK, "Expected S_OK, got %08x\n", hr); + + test_file_access("winetest", create_commit); + + IStorage_Release(stg); + + test_file_access("winetest", create_close); + + DeleteFileA("winetest"); +} + START_TEST(storage32) { test_hglobal_storage_stat(); @@ -1010,4 +1222,5 @@ START_TEST(storage32) test_streamenum(); test_transact(); test_ReadClassStm(); + test_access(); }