[v3 2/2] user32/tests: Add test for GetWindowDisplayAffinity.

Andrew Wesie awesie at gmail.com
Mon Jun 26 15:23:25 CDT 2017


Signed-off-by: Andrew Wesie <awesie at gmail.com>
---
 dlls/user32/tests/win.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 2399228..721f4e6 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -64,6 +64,8 @@ static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
 static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout );
 static BOOL (WINAPI *pFlashWindow)( HWND hwnd, BOOL bInvert );
 static BOOL (WINAPI *pFlashWindowEx)( PFLASHWINFO pfwi );
+static BOOL (WINAPI *pGetWindowDisplayAffinity)( HWND hwnd, DWORD *affinity );
+static BOOL (WINAPI *pSetWindowDisplayAffinity)( HWND hwnd, DWORD affinity );
 static DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout);
 static DWORD (WINAPI *pGetLayout)(HDC hdc);
 static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn);
@@ -9832,6 +9834,61 @@ static void test_desktop( void )
     }
 }
 
+static void test_display_affinity(void)
+{
+    BOOL ret;
+    DWORD affinity;
+    HWND hwnd;
+
+    if (!pGetWindowDisplayAffinity)
+    {
+        win_skip( "GetWindowDisplayAffinity not supported\n" );
+        return;
+    }
+
+    hwnd = CreateWindowExA(0, "MainWindowClass", "message window", WS_CAPTION,
+                           100, 100, 200, 200, 0, 0, 0, NULL);
+    assert( hwnd );
+    /* required for win7 */
+    SetWindowLongA( hwnd, GWL_EXSTYLE, GetWindowLongA(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED );
+
+    ret = pGetWindowDisplayAffinity( hwnd, &affinity );
+    ok( ret, "GetWindowDisplayAffinity returned with %d\n", GetLastError() );
+    ok( affinity == WDA_NONE, "GetWindowDisplayAffinity returned unexpected affinity %d\n", affinity );
+
+    ret = pSetWindowDisplayAffinity( hwnd, WDA_MONITOR );
+    ok( ret, "SetWindowDisplayAffinity returned with %d\n", GetLastError() );
+
+    ret = pGetWindowDisplayAffinity( hwnd, &affinity );
+    ok( ret, "GetWindowDisplayAffinity returned with %d\n", GetLastError() );
+    ok( affinity == WDA_MONITOR, "GetWindowDisplayAffinity returned unexpected affinity %d\n", affinity );
+
+    ret = pSetWindowDisplayAffinity( hwnd, WDA_NONE );
+    ok( ret, "SetWindowDisplayAffinity returned with %d\n", GetLastError() );
+
+    ret = pGetWindowDisplayAffinity( hwnd, &affinity );
+    ok( ret, "GetWindowDisplayAffinity returned with %d\n", GetLastError() );
+    ok( affinity == WDA_NONE, "GetWindowDisplayAffinity returned unexpected affinity %d\n", affinity );
+
+    ret = pSetWindowDisplayAffinity( hwnd, ~WDA_MONITOR );
+    ok( !ret, "SetWindowDisplayAffinity succeeded\n" );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "SetWindowDisplayAffinity returned error %d\n", GetLastError() );
+
+    ret = pGetWindowDisplayAffinity( GetDesktopWindow(), &affinity );
+    ok( !ret, "GetWindowDisplayAffinity succeeded\n" );
+    ok( GetLastError() == ERROR_INVALID_PARAMETER, "GetWindowDisplayAffinity returned error %d\n", GetLastError() );
+
+    ret = pSetWindowDisplayAffinity( GetDesktopWindow(), WDA_MONITOR );
+    ok( !ret, "SetWindowDisplayAffinity succeeded\n" );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "SetWindowDisplayAffinity returned error %d\n", GetLastError() );
+
+    ret = pSetWindowDisplayAffinity( GetDesktopWindow(), ~WDA_MONITOR );
+    ok( !ret, "SetWindowDisplayAffinity succeeded\n" );
+    ok( GetLastError() == ERROR_ACCESS_DENIED, "SetWindowDisplayAffinity returned error %d\n", GetLastError() );
+
+    DestroyWindow( hwnd );
+}
+
 START_TEST(win)
 {
     char **argv;
@@ -9853,6 +9910,8 @@ START_TEST(win)
     pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" );
     pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" );
     pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" );
+    pGetWindowDisplayAffinity = (void *)GetProcAddress( user32, "GetWindowDisplayAffinity" );
+    pSetWindowDisplayAffinity = (void *)GetProcAddress( user32, "SetWindowDisplayAffinity" );
     pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" );
     pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
     pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
@@ -9981,6 +10040,7 @@ START_TEST(win)
     test_deferwindowpos();
     test_LockWindowUpdate(hwndMain);
     test_desktop();
+    test_display_affinity();
 
     /* add the tests above this line */
     if (hhook) UnhookWindowsHookEx(hhook);
-- 
2.7.4




More information about the wine-patches mailing list