Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 64 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index d911ce57e9..4fec233a57 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -31,6 +31,7 @@ #include "ocidl.h" #include "comcat.h" #include "olectl.h" +#include "initguid.h"
#include "wine/test.h"
@@ -62,6 +63,13 @@ static const CLSID CLSID_TestMoniker = {0xb9, 0x3e, 0x2f, 0xf9, 0xc8, 0x32, 0x23, 0xd7} };
+DEFINE_OLEGUID(CLSID_FileMoniker, 0x303, 0, 0); +DEFINE_OLEGUID(CLSID_ItemMoniker, 0x304, 0, 0); +DEFINE_OLEGUID(CLSID_AntiMoniker, 0x305, 0, 0); +DEFINE_OLEGUID(CLSID_CompositeMoniker, 0x309, 0, 0); +DEFINE_OLEGUID(CLSID_ClassMoniker, 0x31a, 0, 0); +DEFINE_OLEGUID(CLSID_PointerMoniker, 0x306, 0, 0); + static LONG cLocks;
static void LockModule(void) @@ -1543,7 +1551,15 @@ static void test_class_moniker(void)
hr = CreateClassMoniker(&CLSID_StdComponentCategoriesMgr, &moniker); ok_ole_success(hr, CreateClassMoniker); - if (!moniker) return; + + hr = IMoniker_QueryInterface(moniker, &CLSID_ClassMoniker, (void **)&unknown); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(unknown == (IUnknown *)moniker, "Unexpected interface.\n"); + IUnknown_Release(unknown); + }
test_moniker("class moniker", moniker, expected_class_moniker_marshal_data, sizeof(expected_class_moniker_marshal_data), @@ -1603,11 +1619,21 @@ static void test_file_moniker(WCHAR* path) { IStream *stream; IMoniker *moniker1 = NULL, *moniker2 = NULL; + IUnknown *unk; HRESULT hr;
hr = CreateFileMoniker(path, &moniker1); ok_ole_success(hr, CreateFileMoniker);
+ hr = IMoniker_QueryInterface(moniker1, &CLSID_FileMoniker, (void **)&unk); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(unk == (IUnknown *)moniker1, "Unexpected interface.\n"); + IUnknown_Release(unk); + } + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok_ole_success(hr, CreateStreamOnHGlobal);
@@ -1719,6 +1745,15 @@ static void test_item_moniker(void) hr = CreateItemMoniker(NULL, wszObjectName, &moniker); ok(hr == S_OK, "Failed to create item moniker, hr %#x.\n", hr);
+ hr = IMoniker_QueryInterface(moniker, &CLSID_ItemMoniker, (void **)&unknown); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(unknown == (IUnknown *)moniker, "Unexpected interface.\n"); + IUnknown_Release(unknown); + } + test_moniker("item moniker 2", moniker, expected_item_moniker_marshal_data2, sizeof(expected_item_moniker_marshal_data2), expected_item_moniker_saved_data2, sizeof(expected_item_moniker_saved_data2), @@ -1860,7 +1895,15 @@ static void test_anti_moniker(void)
hr = CreateAntiMoniker(&moniker); ok_ole_success(hr, CreateAntiMoniker); - if (!moniker) return; + + hr = IMoniker_QueryInterface(moniker, &CLSID_AntiMoniker, (void **)&unknown); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(unknown == (IUnknown *)moniker, "Unexpected interface.\n"); + IUnknown_Release(unknown); + }
test_moniker("anti moniker", moniker, expected_anti_moniker_marshal_data, sizeof(expected_anti_moniker_marshal_data), @@ -1932,6 +1975,13 @@ static void test_generic_composite_moniker(void) hr = CreateGenericComposite(moniker1, moniker2, &moniker); ok_ole_success(hr, CreateGenericComposite);
+ /* Generic composite is special, as it does not addref in this case. */ + hr = IMoniker_QueryInterface(moniker, &CLSID_CompositeMoniker, (void **)&unknown); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + ok(unknown == (IUnknown *)moniker, "Unexpected interface.\n"); + test_moniker("generic composite moniker", moniker, expected_gc_moniker_marshal_data, sizeof(expected_gc_moniker_marshal_data), expected_gc_moniker_saved_data, sizeof(expected_gc_moniker_saved_data), @@ -2007,7 +2057,15 @@ static void test_pointer_moniker(void)
hr = CreatePointerMoniker((IUnknown *)&Test_ClassFactory, &moniker); ok_ole_success(hr, CreatePointerMoniker); - if (!moniker) return; + + hr = IMoniker_QueryInterface(moniker, &CLSID_PointerMoniker, (void **)&unknown); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + if (SUCCEEDED(hr)) + { + ok(unknown == (IUnknown *)moniker, "Unexpected interface.\n"); + IUnknown_Release(unknown); + }
ok_more_than_one_lock();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 4fec233a57..a275671a69 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -1728,6 +1728,23 @@ static void test_item_moniker(void) { item_moniker_unicode_item_stream, sizeof(item_moniker_unicode_item_stream), L"!B" }, { item_moniker_unicode_delim_item_stream, sizeof(item_moniker_unicode_delim_item_stream), L"!C" }, }; + static const struct + { + const WCHAR *delim1; + const WCHAR *item1; + const WCHAR *delim2; + const WCHAR *item2; + HRESULT hr; + } isequal_tests[] = + { + { L"!", L"Item1", L"!", L"ITEM1", S_OK }, + { NULL, L"Item1", L"!", L"ITEM1", S_OK }, + { L"", L"Item1", L"!", L"ITEM1", S_OK }, + { L"&", L"Item1", L"!", L"ITEM1", S_OK }, + {L"&&", L"Item1", L"&", L"&Item1", S_FALSE }, + { NULL, L"Item1", NULL, L"Item2", S_FALSE }, + { NULL, L"Item1", NULL, L"ITEM1", S_OK }, + }; IMoniker *moniker, *moniker2; HRESULT hr; DWORD moniker_type, i; @@ -1879,6 +1896,27 @@ todo_wine IMoniker_Release(inverse);
IMoniker_Release(moniker); + + /* IsEqual */ + for (i = 0; i < ARRAY_SIZE(isequal_tests); ++i) + { + hr = CreateItemMoniker(isequal_tests[i].delim1, isequal_tests[i].item1, &moniker); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + hr = CreateItemMoniker(isequal_tests[i].delim2, isequal_tests[i].item2, &moniker2); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + hr = IMoniker_IsEqual(moniker, moniker2); + todo_wine_if(i == 4 || i == 5) + ok(hr == isequal_tests[i].hr, "%d: unexpected result %#x.\n", i, hr); + + hr = IMoniker_IsEqual(moniker2, moniker); + todo_wine_if(i == 4 || i == 5) + ok(hr == isequal_tests[i].hr, "%d: unexpected result %#x.\n", i, hr); + + IMoniker_Release(moniker); + IMoniker_Release(moniker2); + } }
static void test_anti_moniker(void)
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index a275671a69..51fad3ae2f 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -1609,7 +1609,10 @@ todo_wine IBindCtx_Release(bindctx);
hr = IMoniker_Inverse(moniker, &inverse); - ok_ole_success(hr, IMoniker_Inverse); + ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(inverse, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_ANTIMONIKER, "Unexpected moniker type %d.\n", moniker_type); IMoniker_Release(inverse);
IMoniker_Release(moniker); @@ -1617,8 +1620,9 @@ todo_wine
static void test_file_moniker(WCHAR* path) { + IMoniker *moniker1 = NULL, *moniker2 = NULL, *inverse; + DWORD moniker_type; IStream *stream; - IMoniker *moniker1 = NULL, *moniker2 = NULL; IUnknown *unk; HRESULT hr;
@@ -1634,6 +1638,13 @@ todo_wine IUnknown_Release(unk); }
+ hr = IMoniker_Inverse(moniker1, &inverse); + ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(inverse, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_ANTIMONIKER, "Unexpected moniker type %d.\n", moniker_type); + IMoniker_Release(inverse); + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); ok_ole_success(hr, CreateStreamOnHGlobal);
@@ -1892,7 +1903,10 @@ todo_wine IBindCtx_Release(bindctx);
hr = IMoniker_Inverse(moniker, &inverse); - ok_ole_success(hr, IMoniker_Inverse); + ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(inverse, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_ANTIMONIKER, "Unexpected moniker type %d.\n", moniker_type); IMoniker_Release(inverse);
IMoniker_Release(moniker); @@ -2068,7 +2082,10 @@ todo_wine IBindCtx_Release(bindctx);
hr = IMoniker_Inverse(moniker, &inverse); - ok_ole_success(hr, IMoniker_Inverse); + ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(inverse, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_GENERICCOMPOSITE, "Unexpected moniker type %d.\n", moniker_type); IMoniker_Release(inverse);
IMoniker_Release(moniker); @@ -2150,7 +2167,10 @@ todo_wine moniker_type);
hr = IMoniker_Inverse(moniker, &inverse); - ok_ole_success(hr, IMoniker_Inverse); + ok(hr == S_OK, "Failed to get inverse, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(inverse, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_ANTIMONIKER, "Unexpected moniker type %d.\n", moniker_type); IMoniker_Release(inverse);
hr = CreateBindCtx(0, &bindctx);
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 104 ++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 51fad3ae2f..984f3a753c 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -1933,10 +1933,26 @@ todo_wine } }
+static void stream_write_dword(IStream *stream, DWORD value) +{ + LARGE_INTEGER pos; + HRESULT hr; + + pos.QuadPart = 0; + hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + ok(hr == S_OK, "Failed to seek, hr %#x.\n", hr); + + hr = IStream_Write(stream, &value, sizeof(value), NULL); + ok(hr == S_OK, "Stream write failed, hr %#x.\n", hr); + + hr = IStream_Seek(stream, pos, STREAM_SEEK_SET, NULL); + ok(hr == S_OK, "Failed to seek, hr %#x.\n", hr); +} + static void test_anti_moniker(void) { + IMoniker *moniker, *moniker2, *moniker3; HRESULT hr; - IMoniker *moniker; DWORD moniker_type; DWORD hash; IBindCtx *bindctx; @@ -1944,6 +1960,8 @@ static void test_anti_moniker(void) IMoniker *inverse; IUnknown *unknown; static const WCHAR expected_display_name[] = { '\','.','.',0 }; + IStream *stream; + WCHAR *name;
hr = CreateAntiMoniker(&moniker); ok_ole_success(hr, CreateAntiMoniker); @@ -1997,8 +2015,90 @@ todo_wine hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown); ok(hr == E_NOTIMPL, "IMoniker_BindToStorage should return E_NOTIMPL, not 0x%08x\n", hr);
- IBindCtx_Release(bindctx); + /* ComposeWith */ + hr = CreateAntiMoniker(&moniker2); + ok(hr == S_OK, "Failed to create moniker, hr %#x.\n", hr); + + moniker3 = moniker; + hr = IMoniker_ComposeWith(moniker, moniker2, TRUE, &moniker3); + ok(hr == MK_E_NEEDGENERIC, "Unexpected hr %#x.\n", hr); + ok(!moniker3, "Unexpected interface.\n"); + + hr = IMoniker_ComposeWith(moniker, moniker2, FALSE, &moniker3); + ok(hr == S_OK, "Failed to compose, hr %#x.\n", hr); + hr = IMoniker_IsSystemMoniker(moniker3, &moniker_type); + ok(hr == S_OK, "Failed to get moniker type, hr %#x.\n", hr); + ok(moniker_type == MKSYS_GENERICCOMPOSITE, "Unexpected moniker type %d.\n", moniker_type); + IMoniker_Release(moniker3); + + IMoniker_Release(moniker2); + + /* Load with composed number > 1. */ + hr = CreateStreamOnHGlobal(NULL, TRUE, &stream); + ok(hr == S_OK, "Failed to create a stream, hr %#x.\n", hr); + + stream_write_dword(stream, 2); + + hr = IMoniker_Load(moniker, stream); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_Hash(moniker, &hash); + ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr); +todo_wine + ok(hash == 0x80000002, "Unexpected hash value %#x.\n", hash);
+ /* Display name reflects anti combination. */ + hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name); + ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr); +todo_wine + ok(!lstrcmpW(name, L"\..\.."), "Unexpected display name %s.\n", wine_dbgstr_w(name)); + CoTaskMemFree(name); + + /* Limit is at 0xfffff. */ + stream_write_dword(stream, 0xfffff); + + hr = IMoniker_Load(moniker, stream); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_Hash(moniker, &hash); + ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr); +todo_wine + ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash); + + stream_write_dword(stream, 0xfffff + 1); + + hr = IMoniker_Load(moniker, stream); +todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_Hash(moniker, &hash); + ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr); +todo_wine + ok(hash == 0x800fffff, "Unexpected hash value %#x.\n", hash); + + /* Zero combining counter is also valid. */ + stream_write_dword(stream, 0); + + hr = IMoniker_Load(moniker, stream); +todo_wine + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = IMoniker_Hash(moniker, &hash); + ok(hr == S_OK, "Failed to get hash value, hr %#x.\n", hr); +todo_wine + ok(hash == 0x80000000, "Unexpected hash value %#x.\n", hash); + + hr = IMoniker_GetDisplayName(moniker, bindctx, NULL, &name); + ok(hr == S_OK, "Failed to get display name, hr %#x.\n", hr); +todo_wine + ok(!lstrcmpW(name, L""), "Unexpected display name %s.\n", wine_dbgstr_w(name)); + CoTaskMemFree(name); + + IStream_Release(stream); + + IBindCtx_Release(bindctx); IMoniker_Release(moniker); }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/moniker.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 984f3a753c..7b4bf5c0fa 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -41,14 +41,13 @@
#define CHECK_EXPECTED_METHOD(method_name) \ do { \ - trace("%s\n", method_name); \ - ok(*expected_method_list != NULL, "Extra method %s called\n", method_name); \ - if (*expected_method_list) \ - { \ - ok(!strcmp(*expected_method_list, method_name), "Expected %s to be called instead of %s\n", \ - *expected_method_list, method_name); \ - expected_method_list++; \ - } \ + ok(*expected_method_list != NULL, "Extra method %s called\n", method_name); \ + if (*expected_method_list) \ + { \ + ok(!strcmp(*expected_method_list, method_name), "Expected %s to be called instead of %s\n", \ + *expected_method_list, method_name); \ + expected_method_list++; \ + } \ } while(0)
static char const * const *expected_method_list; @@ -116,8 +115,6 @@ static ULONG WINAPI ExternalConnection_Release(IExternalConnection *iface)
static DWORD WINAPI ExternalConnection_AddConnection(IExternalConnection *iface, DWORD extconn, DWORD reserved) { - trace("add connection\n"); - ok(extconn == EXTCONN_STRONG, "extconn = %d\n", extconn); ok(!reserved, "reserved = %x\n", reserved); return ++external_connections; @@ -126,8 +123,6 @@ static DWORD WINAPI ExternalConnection_AddConnection(IExternalConnection *iface, static DWORD WINAPI ExternalConnection_ReleaseConnection(IExternalConnection *iface, DWORD extconn, DWORD reserved, BOOL fLastReleaseCloses) { - trace("release connection\n"); - ok(extconn == EXTCONN_STRONG, "extconn = %d\n", extconn); ok(!reserved, "reserved = %x\n", reserved);
@@ -838,7 +833,6 @@ static int count_moniker_matches(IBindCtx * pbc, IEnumMoniker * spEM) CoTaskMemFree(szDisplayn); } } - trace("Total number of monikers is %i\n", monCnt); return matchCnt; }
@@ -1071,7 +1065,6 @@ todo_wine ok(hr == S_OK, "Failed to get interface, hr %#x.\n", hr);
matchCnt = count_moniker_matches(pbc, spEM1); - trace("Number of matches is %i\n", matchCnt);
grflags= grflags | ROTFLAGS_REGISTRATIONKEEPSALIVE; hr = IRunningObjectTable_Register(pprot, grflags, lpEM1, pmk1, &pdwReg1); @@ -1088,12 +1081,10 @@ todo_wine matchCnt = count_moniker_matches(pbc, spEM2); ok(matchCnt==2, "Number of matches should be equal to 2 not %i\n", matchCnt);
- trace("IEnumMoniker::Clone\n"); IEnumMoniker_Clone(spEM2, &spEM3);
matchCnt = count_moniker_matches(pbc, spEM3); ok(matchCnt==0, "Number of matches should be equal to 0 not %i\n", matchCnt); - trace("IEnumMoniker::Reset\n"); IEnumMoniker_Reset(spEM3);
matchCnt = count_moniker_matches(pbc, spEM3);