This test and tests in last patch tested on Win7 laptop with DWM service both running and stopped Win7 testbots don`t have DWM service enabled so some tests will be skipped there. On win8 and higher DWM is enabled by default
Signed-off-by: Louis Lenders xerox.xerox2000x@gmail.com --- configure | 1 + configure.ac | 1 + dlls/dwmapi/tests/Makefile.in | 5 ++ dlls/dwmapi/tests/dwmapi.c | 92 +++++++++++++++++++++++++++++++++++ include/dwmapi.h | 3 ++ include/winerror.h | 2 + 6 files changed, 104 insertions(+) create mode 100644 dlls/dwmapi/tests/Makefile.in create mode 100644 dlls/dwmapi/tests/dwmapi.c
diff --git a/configure b/configure index 9d4a7a8b78..0b780a3576 100755 --- a/configure +++ b/configure @@ -19411,6 +19411,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 b64d99e9d1..ecb5b80e74 100644 --- a/configure.ac +++ b/configure.ac @@ -3264,6 +3264,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..1307206362 --- /dev/null +++ b/dlls/dwmapi/tests/dwmapi.c @@ -0,0 +1,92 @@ +/* + * 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); + +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) /*to test enable DWM service via services.msc*/ + dwmenabled = TRUE; + else /*to test disable DWM service via services.msc*/ + dwmenabled = FALSE; + + if (dwmenabled) /* disable and reenable dwm*/ + { + ret = -1; + res = pDwmEnableComposition(DWM_EC_DISABLECOMPOSITION); + ok(res == S_OK, "got %x expected S_OK\n", res); + + res = pDwmIsCompositionEnabled(&ret); + ok(res == S_OK && ret == FALSE, "got %x and %d\n", res, ret); + + ret = -1; + res = pDwmEnableComposition(DWM_EC_ENABLECOMPOSITION); + ok(res == S_OK, "got %x\n", res); + + res = pDwmIsCompositionEnabled(&ret); + todo_wine ok(res == S_OK && ret == TRUE, "got %x and %d\n", res, ret); + } + else + { + ret = -1; + res = pDwmEnableComposition(DWM_EC_ENABLECOMPOSITION); /*cannot enable DWM composition this way*/ + todo_wine ok(res == DWM_E_COMPOSITIONDISABLED, "got %x expected S_OK\n", res); + + res = pDwmIsCompositionEnabled(&ret); + ok(res == S_OK && ret == FALSE, "got %x and %d\n", res, ret); + } +} + +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"); + + if (!pDwmIsCompositionEnabled || !pDwmEnableComposition) + { + trace("essential function pointers not found, skipping tests\n"); + return; + } + + test_isdwmenabled(); +} 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 diff --git a/include/winerror.h b/include/winerror.h index d78c91e84e..a97b405c34 100644 --- a/include/winerror.h +++ b/include/winerror.h @@ -3090,6 +3090,8 @@ static inline HRESULT HRESULT_FROM_WIN32(unsigned int x) #define WININET_E_LOGIN_FAILURE_DISPLAY_ENTITY_BODY _HRESULT_TYPEDEF_(0x80072f8e) #define WININET_E_DECODING_FAILED _HRESULT_TYPEDEF_(0x80072f8f)
+#define DWM_E_COMPOSITIONDISABLED _HRESULT_TYPEDEF_(0x80263001) + #define D3D11_ERROR_TOO_MANY_UNIQUE_STATE_OBJECTS _HRESULT_TYPEDEF_(0x887c0001) #define D3D11_ERROR_FILE_NOT_FOUND _HRESULT_TYPEDEF_(0x887c0002) #define D3D11_ERROR_TOO_MANY_UNIQUE_VIEW_OBJECTS _HRESULT_TYPEDEF_(0x887c0003)