[PATCH 2/3] dwmapi: Add basic tests for DwmGetWindowAttribute.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Dec 6 10:22:05 CST 2019


Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 configure                     |  1 +
 configure.ac                  |  1 +
 dlls/dwmapi/tests/Makefile.in |  6 +++
 dlls/dwmapi/tests/dwmapi.c    | 88 +++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+)
 create mode 100644 dlls/dwmapi/tests/Makefile.in
 create mode 100644 dlls/dwmapi/tests/dwmapi.c

diff --git a/configure b/configure
index 822669d..5cf03fd 100755
--- a/configure
+++ b/configure
@@ -20388,6 +20388,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 7f2c3cd..a69e9df 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3243,6 +3243,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..778a40f
--- /dev/null
+++ b/dlls/dwmapi/tests/Makefile.in
@@ -0,0 +1,6 @@
+TESTDLL   = dwmapi.dll
+IMPORTS   = gdi32 user32
+
+
+C_SRCS = \
+	dwmapi.c
diff --git a/dlls/dwmapi/tests/dwmapi.c b/dlls/dwmapi/tests/dwmapi.c
new file mode 100644
index 0000000..a520991
--- /dev/null
+++ b/dlls/dwmapi/tests/dwmapi.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2019 Gabriel Ivăncescu 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 "windows.h"
+#include <dwmapi.h>
+#include "wine/test.h"
+
+static HRESULT (WINAPI *pDwmGetWindowAttribute)(HWND, DWORD, PVOID, DWORD);
+
+static HWND test_wnd;
+static LRESULT WINAPI test_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+    return DefWindowProcA(hwnd, message, wParam, lParam);
+}
+
+static void test_DwmGetWindowAttribute(void)
+{
+    BOOL nc_rendering;
+    HRESULT hr;
+
+    hr = pDwmGetWindowAttribute(NULL, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering));
+    ok(hr == E_HANDLE || broken(hr == E_INVALIDARG) /* Vista */, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr);
+    hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, NULL, sizeof(nc_rendering));
+    ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr);
+    hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, &nc_rendering, 0);
+    ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) returned 0x%08x.\n", hr);
+    nc_rendering = FALSE;
+    hr = pDwmGetWindowAttribute(test_wnd, 0xdeadbeef, &nc_rendering, sizeof(nc_rendering));
+    ok(hr == E_INVALIDARG, "DwmGetWindowAttribute(0xdeadbeef) returned 0x%08x.\n", hr);
+
+    nc_rendering = 0xdeadbeef;
+    hr = pDwmGetWindowAttribute(test_wnd, DWMWA_NCRENDERING_ENABLED, &nc_rendering, sizeof(nc_rendering));
+    ok(hr == S_OK, "DwmGetWindowAttribute(DWMWA_NCRENDERING_ENABLED) failed 0x%08x.\n", hr);
+    ok(nc_rendering == FALSE || nc_rendering == TRUE, "non-boolean value 0x%x.\n", nc_rendering);
+}
+
+START_TEST(dwmapi)
+{
+    HINSTANCE inst = GetModuleHandleA(NULL);
+    HMODULE module;
+    WNDCLASSA cls;
+
+    module = LoadLibraryA("dwmapi.dll");
+    if (!module)
+    {
+        win_skip("dwmapi.dll not found\n");
+        return;
+    }
+
+    pDwmGetWindowAttribute = (void*)GetProcAddress(module, "DwmGetWindowAttribute");
+
+    cls.style = 0;
+    cls.lpfnWndProc = test_wndproc;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = inst;
+    cls.hIcon = 0;
+    cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
+    cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "Test";
+    RegisterClassA(&cls);
+
+    test_wnd = CreateWindowExA(0, "Test", "Test Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
+                               100, 100, 200, 200, 0, 0, 0, NULL);
+    ok(test_wnd != NULL, "Failed to create test window.\n");
+
+    test_DwmGetWindowAttribute();
+
+    DestroyWindow(test_wnd);
+    UnregisterClassA("Test", inst);
+    FreeLibrary(module);
+}
-- 
2.21.0




More information about the wine-devel mailing list