From: Louis Lenders Subject: [PATCH 2/2] dwampi: add initial tests Message-Id: <20181205121826.2124-2-xerox.xerox2000x@gmail.com> Date: Wed, 5 Dec 2018 13:18:26 +0100 In-Reply-To: <20181205121826.2124-1-xerox.xerox2000x@gmail.com> References: <20181205121826.2124-1-xerox.xerox2000x@gmail.com> Signed-off-by: Louis Lenders --- configure | 1 + configure.ac | 1 + dlls/dwmapi/tests/Makefile.in | 5 ++ dlls/dwmapi/tests/dwmapi.c | 108 ++++++++++++++++++++++++++++++++++ include/dwmapi.h | 3 + 5 files changed, 118 insertions(+) create mode 100644 dlls/dwmapi/tests/Makefile.in create mode 100644 dlls/dwmapi/tests/dwmapi.c diff --git a/configure b/configure index d00057ba2f..e1dde1813b 100755 --- a/configure +++ b/configure @@ -19392,6 +19392,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 50cf9a0bd0..607a46f5a9 100644 --- a/configure.ac +++ b/configure.ac @@ -3255,6 +3255,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 0000000000..f365f96c72 --- /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 0000000000..fe5ee33996 --- /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(); +} diff --git a/include/dwmapi.h b/include/dwmapi.h index b2f39deae5..12527aee62 100644 --- a/include/dwmapi.h +++ b/include/dwmapi.h @@ -101,6 +101,9 @@ typedef struct _MilMatrix3x2D DOUBLE DY; } MilMatrix3x2D; +#define DWM_EC_DISABLECOMPOSITION 0 +#define DWM_EC_ENABLECOMPOSITION 1 + #define DWM_BB_ENABLE 0x00000001 #define DWM_BB_BLURREGION 0x00000002 #define DWM_BB_TRANSITIONONMAXIMIZED 0x00000004 -- 2.17.1