[PATCH] wiaservc/tests: Basic test for device enumerator

Nikolay Sivov nsivov at codeweavers.com
Wed Oct 7 16:12:34 CDT 2015


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 configure.ac                    |  1 +
 dlls/wiaservc/tests/Makefile.in |  5 +++
 dlls/wiaservc/tests/wia.c       | 76 +++++++++++++++++++++++++++++++++++++++++
 include/wia_lh.idl              |  2 ++
 include/wia_xp.idl              |  2 ++
 include/wiadef.h                | 23 +++++++++++++
 6 files changed, 109 insertions(+)
 create mode 100644 dlls/wiaservc/tests/Makefile.in
 create mode 100644 dlls/wiaservc/tests/wia.c
 create mode 100644 include/wiadef.h

diff --git a/configure.ac b/configure.ac
index ce631e4..04eb736 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3385,6 +3385,7 @@ WINE_CONFIG_DLL(wer,,[implib])
 WINE_CONFIG_TEST(dlls/wer/tests)
 WINE_CONFIG_DLL(wevtapi)
 WINE_CONFIG_DLL(wiaservc,,[clean])
+WINE_CONFIG_TEST(dlls/wiaservc/tests)
 WINE_CONFIG_DLL(win32s16.dll16,enable_win16)
 WINE_CONFIG_DLL(win87em.dll16,enable_win16)
 WINE_CONFIG_DLL(winaspi.dll16,enable_win16)
diff --git a/dlls/wiaservc/tests/Makefile.in b/dlls/wiaservc/tests/Makefile.in
new file mode 100644
index 0000000..594e1b2
--- /dev/null
+++ b/dlls/wiaservc/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = wiaservc.dll
+IMPORTS = ole32
+
+C_SRCS = \
+	wia.c
diff --git a/dlls/wiaservc/tests/wia.c b/dlls/wiaservc/tests/wia.c
new file mode 100644
index 0000000..e3f4edb
--- /dev/null
+++ b/dlls/wiaservc/tests/wia.c
@@ -0,0 +1,76 @@
+/*
+ * Unit test suite for WIA system
+ *
+ * Copyright 2015 Nikolay Sivov for CodeWeavers
+ *
+ * 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 <stdio.h>
+
+#define COBJMACROS
+
+#include "objbase.h"
+#include "initguid.h"
+#include "wia_lh.h"
+
+#include "wine/test.h"
+
+static IWiaDevMgr *devmanager;
+
+static void test_EnumDeviceInfo(void)
+{
+    IEnumWIA_DEV_INFO *devenum;
+    HRESULT hr;
+    ULONG count;
+
+    hr = IWiaDevMgr_EnumDeviceInfo(devmanager, WIA_DEVINFO_ENUM_LOCAL, NULL);
+    ok(FAILED(hr), "got 0x%08x\n", hr);
+
+    hr = IWiaDevMgr_EnumDeviceInfo(devmanager, WIA_DEVINFO_ENUM_LOCAL, &devenum);
+todo_wine
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+
+if (hr == S_OK) {
+    hr = IEnumWIA_DEV_INFO_GetCount(devenum, NULL);
+    ok(FAILED(hr), "got 0x%08x\n", hr);
+
+    count = 1000;
+    hr = IEnumWIA_DEV_INFO_GetCount(devenum, &count);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(count != 1000, "got %u\n", count);
+
+    IEnumWIA_DEV_INFO_Release(devenum);
+}
+}
+
+START_TEST(wia)
+{
+    HRESULT hr;
+
+    CoInitialize(NULL);
+
+    hr = CoCreateInstance(&CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER, &IID_IWiaDevMgr, (void**)&devmanager);
+    if (FAILED(hr)) {
+        win_skip("Failed to create WiaDevMgr instance, 0x%08x\n", hr);
+        CoUninitialize();
+        return;
+    }
+
+    test_EnumDeviceInfo();
+
+    IWiaDevMgr_Release(devmanager);
+    CoUninitialize();
+}
diff --git a/include/wia_lh.idl b/include/wia_lh.idl
index 7cadbc6..284528a 100644
--- a/include/wia_lh.idl
+++ b/include/wia_lh.idl
@@ -20,6 +20,8 @@ import "unknwn.idl";
 import "oaidl.idl";
 import "propidl.idl";
 
+cpp_quote("#include <wiadef.h>")
+
 interface IEnumWIA_DEV_INFO;
 interface IWiaPropertyStorage;
 interface IWiaItem;
diff --git a/include/wia_xp.idl b/include/wia_xp.idl
index 7cadbc6..284528a 100644
--- a/include/wia_xp.idl
+++ b/include/wia_xp.idl
@@ -20,6 +20,8 @@ import "unknwn.idl";
 import "oaidl.idl";
 import "propidl.idl";
 
+cpp_quote("#include <wiadef.h>")
+
 interface IEnumWIA_DEV_INFO;
 interface IWiaPropertyStorage;
 interface IWiaItem;
diff --git a/include/wiadef.h b/include/wiadef.h
new file mode 100644
index 0000000..024cfd9
--- /dev/null
+++ b/include/wiadef.h
@@ -0,0 +1,23 @@
+/*
+ * WIA constants
+ *
+ * Copyright 2015 Nikolay Sivov for CodeWeavers
+ *
+ * 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
+ */
+
+#define WIA_DEVINFO_ENUM_ALL      0x0000000f
+#define WIA_DEVINFO_ENUM_LOCAL    0x00000010
+
-- 
2.5.3




More information about the wine-patches mailing list