msdmo: Return a valid enumerator even if the category doesn't exist.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-05-08 18:54:59 -05:00 committed by Alexandre Julliard
parent 7f955f22d3
commit 216e1f25a4
3 changed files with 39 additions and 7 deletions

View File

@ -390,7 +390,6 @@ static HRESULT IEnumDMO_Constructor(
{
IEnumDMOImpl* lpedmo;
HRESULT hr;
LONG ret;
*obj = NULL;
@ -405,6 +404,7 @@ static HRESULT IEnumDMO_Constructor(
lpedmo->dwFlags = dwFlags;
lpedmo->cInTypes = cInTypes;
lpedmo->cOutTypes = cOutTypes;
lpedmo->hkey = NULL;
hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes);
if (FAILED(hr))
@ -417,8 +417,7 @@ static HRESULT IEnumDMO_Constructor(
/* If not filtering by category enum from media objects root */
if (IsEqualGUID(guidCategory, &GUID_NULL))
{
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey)))
hr = HRESULT_FROM_WIN32(ret);
RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey);
}
else
{
@ -426,8 +425,7 @@ static HRESULT IEnumDMO_Constructor(
WCHAR szKey[MAX_PATH];
wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory));
if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey)))
hr = HRESULT_FROM_WIN32(ret);
RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey);
}
lerr:

View File

@ -1,5 +1,5 @@
TESTDLL = msdmo.dll
IMPORTS = msdmo
IMPORTS = advapi32 dmoguids msdmo uuid
C_SRCS = \
msdmo.c

View File

@ -18,7 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "initguid.h"
#include <stdio.h>
#define COBJMACROS
#include "dmo.h"
#include "wine/test.h"
@ -27,8 +28,19 @@ static const GUID GUID_unknowndmo = {0x14d99047,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x
static const GUID GUID_unknowncategory = {0x14d99048,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x67,0x99,0xaf,0x34,0x75}};
static const GUID GUID_wmp1 = {0x13a7995e,0x7d8f,0x45b4,{0x9c,0x77,0x81,0x92,0x65,0x22,0x57,0x63}};
static const char *guid_to_string(const GUID *guid)
{
static char buffer[50];
sprintf(buffer, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
return buffer;
}
static void test_DMOUnregister(void)
{
static char buffer[200];
static const WCHAR testdmoW[] = {'t','e','s','t','d','m','o',0};
HRESULT hr;
@ -53,6 +65,10 @@ static void test_DMOUnregister(void)
hr = DMOUnregister(&GUID_unknowndmo, &GUID_NULL);
ok(hr == S_FALSE, "got 0x%08x\n", hr);
/* clean up category since Windows doesn't */
sprintf(buffer, "DirectShow\\MediaObjects\\Categories\\%s", guid_to_string(&GUID_unknowncategory));
RegDeleteKeyA(HKEY_CLASSES_ROOT, buffer);
}
static void test_DMOGetName(void)
@ -70,8 +86,26 @@ static void test_DMOGetName(void)
ok(name[0] == 'a', "got %x\n", name[0]);
}
static void test_DMOEnum(void)
{
IEnumDMO *enum_dmo;
HRESULT hr;
CLSID clsid;
WCHAR *name;
hr = DMOEnum(&GUID_unknowncategory, 0, 0, NULL, 0, NULL, &enum_dmo);
ok(hr == S_OK, "DMOEnum() failed with %#x\n", hr);
hr = IEnumDMO_Next(enum_dmo, 1, &clsid, &name, NULL);
todo_wine
ok(hr == S_FALSE, "expected S_FALSE, got %#x\n", hr);
IEnumDMO_Release(enum_dmo);
}
START_TEST(msdmo)
{
test_DMOUnregister();
test_DMOGetName();
test_DMOEnum();
}