Robert Shearman : ole32: Add a test for anti monikers.
Fix AntiMonikerImpl_Hash and AntiMonikerROTDataImpl_GetComparisonData
to pass the tests .
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 8 09:05:56 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: c8c93e6657f109ec38dd1d3dc20993e9dca4b14a
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=c8c93e6657f109ec38dd1d3dc20993e9dca4b14a
Author: Robert Shearman <rob at codeweavers.com>
Date: Mon May 8 12:37:08 2006 +0100
ole32: Add a test for anti monikers. Fix AntiMonikerImpl_Hash and AntiMonikerROTDataImpl_GetComparisonData to pass the tests.
---
dlls/ole32/antimoniker.c | 20 ++++++++++----
dlls/ole32/tests/moniker.c | 64 +++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 78 insertions(+), 6 deletions(-)
diff --git a/dlls/ole32/antimoniker.c b/dlls/ole32/antimoniker.c
index 98fa694..77d883a 100644
--- a/dlls/ole32/antimoniker.c
+++ b/dlls/ole32/antimoniker.c
@@ -339,7 +339,7 @@ static HRESULT WINAPI AntiMonikerImpl_Ha
if (pdwHash==NULL)
return E_POINTER;
- *pdwHash=0;
+ *pdwHash = 0x80000001;
return S_OK;
}
@@ -539,11 +539,21 @@ static ULONG WINAPI AntiMonikerROTDataIm
* AntiMonikerIROTData_GetComparaisonData
******************************************************************************/
static HRESULT WINAPI
-AntiMonikerROTDataImpl_GetComparaisonData(IROTData* iface, BYTE* pbData,
+AntiMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
ULONG cbMax, ULONG* pcbData)
{
- FIXME("(),stub!\n");
- return E_NOTIMPL;
+ DWORD constant = 1;
+
+ TRACE("(%p, %lu, %p)\n", pbData, cbMax, pcbData);
+
+ *pcbData = sizeof(CLSID) + sizeof(DWORD);
+ if (cbMax < *pcbData)
+ return E_OUTOFMEMORY;
+
+ memcpy(pbData, &CLSID_AntiMoniker, sizeof(CLSID));
+ memcpy(pbData+sizeof(CLSID), &constant, sizeof(DWORD));
+
+ return S_OK;
}
/********************************************************************************/
@@ -583,7 +593,7 @@ static const IROTDataVtbl VT_ROTDataImpl
AntiMonikerROTDataImpl_QueryInterface,
AntiMonikerROTDataImpl_AddRef,
AntiMonikerROTDataImpl_Release,
- AntiMonikerROTDataImpl_GetComparaisonData
+ AntiMonikerROTDataImpl_GetComparisonData
};
/******************************************************************************
diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c
index 22dd90b..cf14250 100644
--- a/dlls/ole32/tests/moniker.c
+++ b/dlls/ole32/tests/moniker.c
@@ -219,6 +219,29 @@ static const BYTE expected_item_moniker_
0x00,0x00,0x54,0x65,0x73,0x74,0x00,
};
+static const BYTE expected_anti_moniker_marshal_data[] =
+{
+ 0x4d,0x45,0x4f,0x57,0x04,0x00,0x00,0x00,
+ 0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
+ 0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
+ 0x00,0x00,0x00,0x00,0x14,0x00,0x00,0x00,
+ 0x01,0x00,0x00,0x00,
+};
+
+static const BYTE expected_anti_moniker_saved_data[] =
+{
+ 0x01,0x00,0x00,0x00,
+};
+
+static const BYTE expected_anti_moniker_comparison_data[] =
+{
+ 0x05,0x03,0x00,0x00,0x00,0x00,0x00,0x00,
+ 0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46,
+ 0x01,0x00,0x00,0x00,
+};
+
static void test_moniker(
const char *testname, IMoniker *moniker,
const BYTE *expected_moniker_marshal_data, size_t sizeof_expected_moniker_marshal_data,
@@ -469,7 +492,7 @@ static void test_file_monikers(void)
}
}
-static void test_item_moniker()
+static void test_item_moniker(void)
{
HRESULT hr;
IMoniker *moniker;
@@ -508,6 +531,44 @@ static void test_item_moniker()
IMoniker_Release(moniker);
}
+static void test_anti_moniker(void)
+{
+ HRESULT hr;
+ IMoniker *moniker;
+ IMoniker *inverse;
+ DWORD moniker_type;
+ DWORD hash;
+
+ hr = CreateAntiMoniker(&moniker);
+ ok_ole_success(hr, CreateAntiMoniker);
+ if (!moniker) return;
+
+ test_moniker("anti moniker", moniker,
+ expected_anti_moniker_marshal_data, sizeof(expected_anti_moniker_marshal_data),
+ expected_anti_moniker_saved_data, sizeof(expected_anti_moniker_saved_data),
+ expected_anti_moniker_comparison_data, sizeof(expected_anti_moniker_comparison_data));
+
+ /* Hashing */
+ hr = IMoniker_Hash(moniker, &hash);
+ ok_ole_success(hr, IMoniker_Hash);
+ ok(hash == 0x80000001,
+ "Hash value != 0x80000001, instead was 0x%08lx\n",
+ hash);
+
+ /* IsSystemMoniker test */
+ hr = IMoniker_IsSystemMoniker(moniker, &moniker_type);
+ ok_ole_success(hr, IMoniker_IsSystemMoniker);
+ ok(moniker_type == MKSYS_ANTIMONIKER,
+ "dwMkSys != MKSYS_ANTIMONIKER, instead was 0x%08lx",
+ moniker_type);
+
+ hr = IMoniker_Inverse(moniker, &inverse);
+ ok(hr == MK_E_NOINVERSE, "IMoniker_Inverse should have returned MK_E_NOINVERSE instead of 0x%08lx\n", hr);
+ ok(inverse == NULL, "inverse should have been set to NULL instead of %p\n", inverse);
+
+ IMoniker_Release(moniker);
+}
+
START_TEST(moniker)
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
@@ -516,6 +577,7 @@ START_TEST(moniker)
test_class_moniker();
test_file_monikers();
test_item_moniker();
+ test_anti_moniker();
/* FIXME: test moniker creation funcs and parsing other moniker formats */
More information about the wine-cvs
mailing list