[PATCH] dwmapi: add initial tests
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sun May 5 23:48:16 CDT 2019
From: Louis Lenders <xerox.xerox2000x at gmail.com>
Signed-off-by: Louis Lenders <xerox.xerox2000x at gmail.com>
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
configure | 1 +
configure.ac | 1 +
dlls/dwmapi/tests/Makefile.in | 5 ++
dlls/dwmapi/tests/dwmapi.c | 108 ++++++++++++++++++++++++++++++++++++++++++
4 files changed, 115 insertions(+)
create mode 100644 dlls/dwmapi/tests/Makefile.in
create mode 100644 dlls/dwmapi/tests/dwmapi.c
diff --git a/configure b/configure
index 588364f..ba145e3 100755
--- a/configure
+++ b/configure
@@ -20310,6 +20310,7 @@ wine_fn_config_makefile dlls/dssenh/tests enable_tests
wine_fn_config_makefile dlls/dswave enable_dswave
wine_fn_config_makefile dlls/dswave/tests enable_tests
wine_fn_config_makefile dlls/dwmapi enable_dwmapi
+wine_fn_config_makefile dlls/dwmapi/tests enable_tests
wine_fn_config_makefile dlls/dwrite enable_dwrite
wine_fn_config_makefile dlls/dwrite/tests enable_tests
wine_fn_config_makefile dlls/dx8vb enable_dx8vb
diff --git a/configure.ac b/configure.ac
index 0ad8417..0eb2ebb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3267,6 +3267,7 @@ WINE_CONFIG_MAKEFILE(dlls/dssenh/tests)
WINE_CONFIG_MAKEFILE(dlls/dswave)
WINE_CONFIG_MAKEFILE(dlls/dswave/tests)
WINE_CONFIG_MAKEFILE(dlls/dwmapi)
+WINE_CONFIG_MAKEFILE(dlls/dwmapi/tests)
WINE_CONFIG_MAKEFILE(dlls/dwrite)
WINE_CONFIG_MAKEFILE(dlls/dwrite/tests)
WINE_CONFIG_MAKEFILE(dlls/dx8vb)
diff --git a/dlls/dwmapi/tests/Makefile.in b/dlls/dwmapi/tests/Makefile.in
new file mode 100644
index 0000000..f365f96
--- /dev/null
+++ b/dlls/dwmapi/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = dwmapi.dll
+IMPORTS = dwmapi
+
+C_SRCS = \
+ dwmapi.c
diff --git a/dlls/dwmapi/tests/dwmapi.c b/dlls/dwmapi/tests/dwmapi.c
new file mode 100644
index 0000000..7c51e77
--- /dev/null
+++ b/dlls/dwmapi/tests/dwmapi.c
@@ -0,0 +1,108 @@
+/*
+ * Unit tests for dwmapi
+ *
+ * Copyright 2018 Louis Lenders
+ *
+ * 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 "dwmapi.h"
+
+#include "wine/test.h"
+
+static HRESULT (WINAPI *pDwmIsCompositionEnabled)(BOOL*);
+static HRESULT (WINAPI *pDwmEnableComposition)(UINT);
+static HRESULT (WINAPI *pDwmGetTransportAttributes)(BOOL*,BOOL*,DWORD*);
+
+BOOL dwmenabled;
+
+static void test_isdwmenabled(void)
+{
+ HRESULT res;
+ BOOL ret;
+
+ ret = -1;
+ res = pDwmIsCompositionEnabled(&ret);
+ ok((res == S_OK && ret == TRUE) || (res == S_OK && ret == FALSE), "got %x and %d\n", res, ret);
+
+ if (res == S_OK && ret == TRUE)
+ dwmenabled = TRUE;
+ else
+ dwmenabled = FALSE;
+ /*tested on win7 by enabling/disabling DWM service via services.msc*/
+ if (dwmenabled)
+ {
+ res = pDwmEnableComposition(DWM_EC_DISABLECOMPOSITION); /* try disable and reenable dwm*/
+ ok(res == S_OK, "got %x expected S_OK\n", res);
+
+ ret = -1;
+ res = pDwmIsCompositionEnabled(&ret);
+ ok((res == S_OK && ret == FALSE) /*wvista win7*/ || (res == S_OK && ret == TRUE) /*>win7*/, "got %x and %d\n", res, ret);
+
+ res = pDwmEnableComposition(DWM_EC_ENABLECOMPOSITION);
+ ok(res == S_OK, "got %x\n", res);
+
+ ret = -1;
+ res = pDwmIsCompositionEnabled(&ret);
+ todo_wine ok(res == S_OK && ret == TRUE, "got %x and %d\n", res, ret);
+ }
+ else
+ {
+ res = pDwmEnableComposition(DWM_EC_ENABLECOMPOSITION); /*cannot enable DWM composition this way*/
+ ok(res == S_OK /*win7 testbot*/ || res == DWM_E_COMPOSITIONDISABLED /*win7 laptop*/, "got %x\n", res);
+ if (winetest_debug > 1)
+ trace("returning %x\n", res);
+
+ ret = -1;
+ res = pDwmIsCompositionEnabled(&ret);
+ ok(res == S_OK && ret == FALSE, "got %x and %d\n", res, ret);
+ }
+}
+
+static void test_dwm_get_transport_attributes(void)
+{
+ BOOL isremoting, isconnected;
+ DWORD generation;
+ HRESULT res;
+
+ res = pDwmGetTransportAttributes(&isremoting, &isconnected, &generation);
+ if (dwmenabled)
+ ok(res == S_OK, "got %x\n", res);
+ else
+ {
+ ok(res == S_OK /*win7 testbot*/ || res == DWM_E_COMPOSITIONDISABLED /*win7 laptop*/, "got %x\n", res);
+ if (winetest_debug > 1)
+ trace("returning %x\n", res);
+ }
+}
+
+START_TEST(dwmapi)
+{
+ HMODULE hmod = LoadLibraryA("dwmapi.dll");
+
+ if (!hmod)
+ {
+ trace("dwmapi not found, skipping tests\n");
+ return;
+ }
+
+ pDwmIsCompositionEnabled = (void *)GetProcAddress(hmod, "DwmIsCompositionEnabled");
+ pDwmEnableComposition = (void *)GetProcAddress(hmod, "DwmEnableComposition");
+ pDwmGetTransportAttributes = (void *)GetProcAddress(hmod, "DwmGetTransportAttributes");
+
+ test_isdwmenabled();
+ test_dwm_get_transport_attributes();
+}
--
1.9.1
More information about the wine-devel
mailing list