[v3 PATCH 4/4] mfplat/tests: Add tests.

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Sun Apr 30 19:20:43 CDT 2017


From: Michael Müller <michael at fds-team.de>

Changes
- Added configure change
- Added CoUninitialize
- Added more test for invalid parameter
- Test against S_OK in tests
- Test MFTUnregister called on Removed entry.

v2
- Link statically
- Create mfplat.lib
- Correct input/output types.

v3
- Removed memcpy to assign input/output values

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 configure                     |   3 +-
 configure.ac                  |   3 +-
 dlls/mfplat/Makefile.in       |   1 +
 dlls/mfplat/tests/Makefile.in |   5 ++
 dlls/mfplat/tests/mfplat.c    | 165 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 175 insertions(+), 2 deletions(-)
 create mode 100644 dlls/mfplat/tests/Makefile.in
 create mode 100644 dlls/mfplat/tests/mfplat.c

diff --git a/configure b/configure
index 53882d5..5510e3b 100755
--- a/configure
+++ b/configure
@@ -18081,7 +18081,8 @@ wine_fn_config_dll mciseq enable_mciseq
 wine_fn_config_dll mciwave enable_mciwave
 wine_fn_config_dll mf enable_mf
 wine_fn_config_dll mf3216 enable_mf3216
-wine_fn_config_dll mfplat enable_mfplat
+wine_fn_config_dll mfplat enable_mfplat implib
+wine_fn_config_test dlls/mfplat/tests mfplat_test
 wine_fn_config_dll mfreadwrite enable_mfreadwrite
 wine_fn_config_dll mgmtapi enable_mgmtapi
 wine_fn_config_dll midimap enable_midimap
diff --git a/configure.ac b/configure.ac
index e86f143..80e75ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3135,7 +3135,8 @@ WINE_CONFIG_DLL(mciseq)
 WINE_CONFIG_DLL(mciwave)
 WINE_CONFIG_DLL(mf)
 WINE_CONFIG_DLL(mf3216)
-WINE_CONFIG_DLL(mfplat)
+WINE_CONFIG_DLL(mfplat,,[implib])
+WINE_CONFIG_TEST(dlls/mfplat/tests)
 WINE_CONFIG_DLL(mfreadwrite)
 WINE_CONFIG_DLL(mgmtapi)
 WINE_CONFIG_DLL(midimap)
diff --git a/dlls/mfplat/Makefile.in b/dlls/mfplat/Makefile.in
index 1a3ac3a..76843f5 100644
--- a/dlls/mfplat/Makefile.in
+++ b/dlls/mfplat/Makefile.in
@@ -1,4 +1,5 @@
 MODULE    = mfplat.dll
+IMPORTLIB = mfplat
 IMPORTS   = advapi32 ole32
 
 C_SRCS = \
diff --git a/dlls/mfplat/tests/Makefile.in b/dlls/mfplat/tests/Makefile.in
new file mode 100644
index 0000000..a5553a5
--- /dev/null
+++ b/dlls/mfplat/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL   = mfplat.dll
+IMPORTS   = ole32 mfplat
+
+C_SRCS = \
+	mfplat.c
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c
new file mode 100644
index 0000000..4a95137
--- /dev/null
+++ b/dlls/mfplat/tests/mfplat.c
@@ -0,0 +1,165 @@
+/*
+ * Unit test suite for mfplat.
+ *
+ * Copyright 2015 Michael Müller
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "winreg.h"
+
+#include "initguid.h"
+#include "mfapi.h"
+#include "mferror.h"
+
+#include "wine/test.h"
+
+DEFINE_GUID(MFT_CATEGORY_OTHER, 0x90175d57,0xb7ea,0x4901,0xae,0xb3,0x93,0x3a,0x87,0x47,0x75,0x6f);
+
+DEFINE_GUID(DUMMY_CLSID, 0x12345678,0x1234,0x1234,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19);
+DEFINE_GUID(DUMMY_GUID1, 0x12345678,0x1234,0x1234,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21);
+DEFINE_GUID(DUMMY_GUID2, 0x12345678,0x1234,0x1234,0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22);
+
+static BOOL check_clsid(CLSID *clsids, UINT32 count)
+{
+    int i;
+    for (i = 0; i < count; i++)
+    {
+        if (IsEqualGUID(&clsids[i], &DUMMY_CLSID))
+            return TRUE;
+    }
+    return FALSE;
+}
+
+static void test_register(void)
+{
+    static WCHAR name[] = {'W','i','n','e',' ','t','e','s','t',0};
+    MFT_REGISTER_TYPE_INFO input[] =
+    {
+        { DUMMY_CLSID, DUMMY_GUID1 }
+    };
+    MFT_REGISTER_TYPE_INFO output[] =
+    {
+        { DUMMY_CLSID, DUMMY_GUID2 }
+    };
+    CLSID *clsids;
+    UINT32 count;
+    HRESULT ret;
+
+    ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 1, input, 1, output, NULL);
+    ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret);
+    if (FAILED(ret))
+        return;
+
+if(0)
+{
+    /* NULL name crashes on windows */
+    ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, NULL, 0, 1, input, 1, output, NULL);
+    ok(ret == E_INVALIDARG, "got %x\n", ret);
+}
+
+    ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 0, NULL, 0, NULL, NULL);
+    ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret);
+
+    ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 1, NULL, 0, NULL, NULL);
+    ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret);
+
+    ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 0, NULL, 1, NULL, NULL);
+    ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret);
+
+if(0)
+{
+    /* NULL clsids/count crashes on windows (vista) */
+    count = 0;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, NULL, &count);
+    ok(ret == E_POINTER, "Failed to enumerate filters: %x\n", ret);
+    ok(count == 0, "Expected count > 0\n");
+
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, &clsids, NULL);
+    ok(ret == E_POINTER, "Failed to enumerate filters: %x\n", ret);
+    ok(count == 0, "Expected count > 0\n");
+}
+
+    count = 0;
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, &clsids, &count);
+    ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret);
+    ok(count > 0, "Expected count > 0\n");
+    ok(clsids != NULL, "Expected clsids != NULL\n");
+    ok(check_clsid(clsids, count), "Filter was not part of enumeration\n");
+    CoTaskMemFree(clsids);
+
+    count = 0;
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, input, NULL, NULL, &clsids, &count);
+    ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret);
+    ok(count > 0, "Expected count > 0\n");
+    ok(clsids != NULL, "Expected clsids != NULL\n");
+    ok(check_clsid(clsids, count), "Filter was not part of enumeration\n");
+    CoTaskMemFree(clsids);
+
+    count = 0;
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, output, NULL, &clsids, &count);
+    ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret);
+    ok(count > 0, "Expected count > 0\n");
+    ok(clsids != NULL, "Expected clsids != NULL\n");
+    ok(check_clsid(clsids, count), "Filter was not part of enumeration\n");
+    CoTaskMemFree(clsids);
+
+    count = 0;
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, input, output, NULL, &clsids, &count);
+    ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret);
+    ok(count > 0, "Expected count > 0\n");
+    ok(clsids != NULL, "Expected clsids != NULL\n");
+    ok(check_clsid(clsids, count), "Filter was not part of enumeration\n");
+    CoTaskMemFree(clsids);
+
+    /* exchange input and output */
+    count = 0;
+    clsids = NULL;
+    ret = MFTEnum(MFT_CATEGORY_OTHER, 0, output, input, NULL, &clsids, &count);
+    ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret);
+    ok(!count, "got %d\n", count);
+    ok(clsids == NULL, "Expected clsids == NULL\n");
+
+    ret = MFTUnregister(DUMMY_CLSID);
+    ok(ret == S_OK ||
+       /* w7pro64 */
+       broken(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)), "got %x\n", ret);
+
+    ret = MFTUnregister(DUMMY_CLSID);
+    ok(ret == S_OK || broken(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)), "got %x\n", ret);
+}
+
+
+START_TEST(mfplat)
+{
+    CoInitialize(NULL);
+
+    test_register();
+
+    CoUninitialize();
+}
-- 
1.9.1



More information about the wine-patches mailing list