Commit 116743c4 authored by Jactry Zeng's avatar Jactry Zeng Committed by Alexandre Julliard

devenum: Implement IMoniker::IsEqual().

parent ff0a25cb
......@@ -528,9 +528,36 @@ static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Enum(IMoniker *iface, BOOL fForwa
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
{
FIXME("(%p)->(%p): stub\n", iface, pmkOtherMoniker);
CLSID clsid;
LPOLESTR this_name, other_name;
IBindCtx *bind;
HRESULT res;
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", iface, pmkOtherMoniker);
if (!pmkOtherMoniker)
return E_INVALIDARG;
IMoniker_GetClassID(pmkOtherMoniker, &clsid);
if (!IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker))
return S_FALSE;
res = CreateBindCtx(0, &bind);
if (FAILED(res))
return res;
res = S_FALSE;
if (SUCCEEDED(IMoniker_GetDisplayName(iface, bind, NULL, &this_name)) &&
SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker, bind, NULL, &other_name)))
{
int result = lstrcmpiW(this_name, other_name);
CoTaskMemFree(this_name);
CoTaskMemFree(other_name);
if (!result)
res = S_OK;
}
IBindCtx_Release(bind);
return res;
}
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Hash(IMoniker *iface, DWORD *pdwHash)
......
......@@ -135,6 +135,94 @@ static void test_devenum(IBindCtx *bind_ctx)
if(sizeof(void*) == 4)
ok(have_mrle, "mrle codec not found\n");
}
static void test_moniker_isequal(void)
{
HRESULT res;
ICreateDevEnum *create_devenum = NULL;
IEnumMoniker *enum_moniker0 = NULL, *enum_moniker1 = NULL;
IMoniker *moniker0 = NULL, *moniker1 = NULL;
res = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
&IID_ICreateDevEnum, (LPVOID*)&create_devenum);
if (FAILED(res))
{
skip("Cannot create SystemDeviceEnum object (%x)\n", res);
return;
}
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
if (SUCCEEDED(res))
{
if (SUCCEEDED(IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL)) &&
SUCCEEDED(IEnumMoniker_Next(enum_moniker0, 1, &moniker1, NULL)))
{
res = IMoniker_IsEqual(moniker0, moniker1);
ok(res == S_FALSE, "IMoniker_IsEqual should fail (res = %x)\n", res);
res = IMoniker_IsEqual(moniker1, moniker0);
ok(res == S_FALSE, "IMoniker_IsEqual should fail (res = %x)\n", res);
IMoniker_Release(moniker0);
IMoniker_Release(moniker1);
}
else
skip("Cannot get moniker for testing.\n");
}
IEnumMoniker_Release(enum_moniker0);
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_AudioRendererCategory, &enum_moniker1, 0);
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
if (SUCCEEDED(res))
{
if (SUCCEEDED(IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL)) &&
SUCCEEDED(IEnumMoniker_Next(enum_moniker1, 1, &moniker1, NULL)))
{
res = IMoniker_IsEqual(moniker0, moniker1);
ok(res == S_FALSE, "IMoniker_IsEqual should failed (res = %x)\n", res);
res = IMoniker_IsEqual(moniker1, moniker0);
ok(res == S_FALSE, "IMoniker_IsEqual should failed (res = %x)\n", res);
IMoniker_Release(moniker0);
IMoniker_Release(moniker1);
}
else
skip("Cannot get moniker for testing.\n");
}
IEnumMoniker_Release(enum_moniker0);
IEnumMoniker_Release(enum_moniker1);
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker0, 0);
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
res = ICreateDevEnum_CreateClassEnumerator(create_devenum, &CLSID_LegacyAmFilterCategory, &enum_moniker1, 0);
ok(SUCCEEDED(res), "Cannot create enum moniker (res = %x)\n", res);
if (SUCCEEDED(res))
{
if (SUCCEEDED(IEnumMoniker_Next(enum_moniker0, 1, &moniker0, NULL)) &&
SUCCEEDED(IEnumMoniker_Next(enum_moniker1, 1, &moniker1, NULL)))
{
res = IMoniker_IsEqual(moniker0, moniker1);
ok(res == S_OK, "IMoniker_IsEqual failed (res = %x)\n", res);
res = IMoniker_IsEqual(moniker1, moniker0);
ok(res == S_OK, "IMoniker_IsEqual failed (res = %x)\n", res);
IMoniker_Release(moniker0);
IMoniker_Release(moniker1);
}
else
skip("Cannot get moniker for testing.\n");
}
IEnumMoniker_Release(enum_moniker0);
IEnumMoniker_Release(enum_moniker1);
ICreateDevEnum_Release(create_devenum);
return;
}
/* CLSID_CDeviceMoniker */
......@@ -155,5 +243,7 @@ START_TEST(devenum)
IBindCtx_Release(bind_ctx);
}
test_moniker_isequal();
CoUninitialize();
}
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