From d0cd105d5987b5e3ca97b3200f4ef23fd5b4f124 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 10 Jan 2020 08:32:22 +0300 Subject: [PATCH] user32/tests: Use device context layout functions directly. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/user32/tests/dce.c | 37 +++++-------- dlls/user32/tests/win.c | 117 +++++++++++++++++++--------------------- 2 files changed, 68 insertions(+), 86 deletions(-) diff --git a/dlls/user32/tests/dce.c b/dlls/user32/tests/dce.c index 116a6177b0b..b76f8fac45b 100644 --- a/dlls/user32/tests/dce.c +++ b/dlls/user32/tests/dce.c @@ -550,24 +550,13 @@ static void test_invisible_create(void) static void test_dc_layout(void) { - DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout); - DWORD (WINAPI *pGetLayout)(HDC hdc); HWND hwnd_cache_rtl, hwnd_owndc_rtl, hwnd_classdc_rtl, hwnd_classdc2_rtl; HDC hdc; DWORD layout; - HMODULE mod = GetModuleHandleA("gdi32.dll"); - - pGetLayout = (void *)GetProcAddress( mod, "GetLayout" ); - pSetLayout = (void *)GetProcAddress( mod, "SetLayout" ); - if (!pGetLayout || !pSetLayout) - { - win_skip( "Don't have SetLayout\n" ); - return; - } hdc = GetDC( hwnd_cache ); - pSetLayout( hdc, LAYOUT_RTL ); - layout = pGetLayout( hdc ); + SetLayout( hdc, LAYOUT_RTL ); + layout = GetLayout( hdc ); ReleaseDC( hwnd_cache, hdc ); if (!layout) { @@ -584,42 +573,42 @@ static void test_dc_layout(void) hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE, 200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); hdc = GetDC( hwnd_cache_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); - pSetLayout( hdc, 0 ); + SetLayout( hdc, 0 ); ReleaseDC( hwnd_cache_rtl, hdc ); hdc = GetDC( hwnd_owndc_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ReleaseDC( hwnd_cache_rtl, hdc ); hdc = GetDC( hwnd_cache ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == 0, "wrong layout %x\n", layout ); ReleaseDC( hwnd_cache, hdc ); hdc = GetDC( hwnd_owndc_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); - pSetLayout( hdc, 0 ); + SetLayout( hdc, 0 ); ReleaseDC( hwnd_owndc_rtl, hdc ); hdc = GetDC( hwnd_owndc_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ReleaseDC( hwnd_owndc_rtl, hdc ); hdc = GetDC( hwnd_classdc_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); - pSetLayout( hdc, 0 ); + SetLayout( hdc, 0 ); ReleaseDC( hwnd_classdc_rtl, hdc ); hdc = GetDC( hwnd_classdc2_rtl ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ReleaseDC( hwnd_classdc2_rtl, hdc ); hdc = GetDC( hwnd_classdc ); - layout = pGetLayout( hdc ); + layout = GetLayout( hdc ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ReleaseDC( hwnd_classdc_rtl, hdc ); diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 9230c4cf794..0f683f858a1 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -62,8 +62,6 @@ 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 DWORD (WINAPI *pSetLayout)(HDC hdc, DWORD layout); -static DWORD (WINAPI *pGetLayout)(HDC hdc); static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn); static BOOL (WINAPI *pGetWindowDisplayAffinity)(HWND hwnd, DWORD *affinity); static BOOL (WINAPI *pSetWindowDisplayAffinity)(HWND hwnd, DWORD affinity); @@ -5908,6 +5906,7 @@ static void test_CreateWindow(void) RECT rc, rc_minmax; MINMAXINFO minmax; BOOL res; + HDC hdc; #define expect_menu(window, menu) \ SetLastError(0xdeadbeef); \ @@ -6248,73 +6247,69 @@ static void test_CreateWindow(void) "invalid error %u\n", GetLastError()); DestroyWindow(hwnd); - if (pGetLayout && pSetLayout) + hdc = GetDC( parent ); + SetLayout( hdc, LAYOUT_RTL ); + if (GetLayout( hdc )) { - HDC hdc = GetDC( parent ); - pSetLayout( hdc, LAYOUT_RTL ); - if (pGetLayout( hdc )) + ReleaseDC( parent, hdc ); + DestroyWindow( parent ); + SetLastError( 0xdeadbeef ); + parent = CreateWindowExA(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, + 0, 0, 100, 100, 0, 0, 0, NULL); + ok( parent != 0, "creation failed err %u\n", GetLastError()); + expect_ex_style( parent, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); + ok( hwnd != 0, "creation failed err %u\n", GetLastError()); + expect_ex_style( hwnd, WS_EX_LAYOUTRTL ); + DestroyWindow( hwnd ); + hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 20, 20, parent, 0, 0, NULL); + ok( hwnd != 0, "creation failed err %u\n", GetLastError()); + expect_ex_style( hwnd, 0 ); + DestroyWindow( hwnd ); + SetWindowLongW( parent, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT ); + hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); + ok( hwnd != 0, "creation failed err %u\n", GetLastError()); + expect_ex_style( hwnd, 0 ); + DestroyWindow( hwnd ); + + if (pGetProcessDefaultLayout && pSetProcessDefaultLayout) { - ReleaseDC( parent, hdc ); - DestroyWindow( parent ); + DWORD layout; + SetLastError( 0xdeadbeef ); - parent = CreateWindowExA(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, - 0, 0, 100, 100, 0, 0, 0, NULL); - ok( parent != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( parent, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); - hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); + ok( !pGetProcessDefaultLayout( NULL ), "GetProcessDefaultLayout succeeded\n" ); + ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() ); + SetLastError( 0xdeadbeef ); + res = pGetProcessDefaultLayout( &layout ); + ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); + ok( layout == 0, "GetProcessDefaultLayout wrong layout %x\n", layout ); + SetLastError( 0xdeadbeef ); + res = pSetProcessDefaultLayout( 7 ); + ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ()); + res = pGetProcessDefaultLayout( &layout ); + ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); + ok( layout == 7, "GetProcessDefaultLayout wrong layout %x\n", layout ); + SetLastError( 0xdeadbeef ); + res = pSetProcessDefaultLayout( LAYOUT_RTL ); + ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ()); + res = pGetProcessDefaultLayout( &layout ); + ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); + ok( layout == LAYOUT_RTL, "GetProcessDefaultLayout wrong layout %x\n", layout ); + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, + 0, 0, 100, 100, 0, 0, 0, NULL); ok( hwnd != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( hwnd, WS_EX_LAYOUTRTL ); + expect_ex_style( hwnd, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); DestroyWindow( hwnd ); - hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 20, 20, parent, 0, 0, NULL); + hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, + 0, 0, 100, 100, parent, 0, 0, NULL); ok( hwnd != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( hwnd, 0 ); + expect_ex_style( hwnd, WS_EX_APPWINDOW ); DestroyWindow( hwnd ); - SetWindowLongW( parent, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT ); - hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); - ok( hwnd != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( hwnd, 0 ); - DestroyWindow( hwnd ); - - if (pGetProcessDefaultLayout && pSetProcessDefaultLayout) - { - DWORD layout; - - SetLastError( 0xdeadbeef ); - ok( !pGetProcessDefaultLayout( NULL ), "GetProcessDefaultLayout succeeded\n" ); - ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() ); - SetLastError( 0xdeadbeef ); - res = pGetProcessDefaultLayout( &layout ); - ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); - ok( layout == 0, "GetProcessDefaultLayout wrong layout %x\n", layout ); - SetLastError( 0xdeadbeef ); - res = pSetProcessDefaultLayout( 7 ); - ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ()); - res = pGetProcessDefaultLayout( &layout ); - ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); - ok( layout == 7, "GetProcessDefaultLayout wrong layout %x\n", layout ); - SetLastError( 0xdeadbeef ); - res = pSetProcessDefaultLayout( LAYOUT_RTL ); - ok( res, "SetProcessDefaultLayout failed err %u\n", GetLastError ()); - res = pGetProcessDefaultLayout( &layout ); - ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ()); - ok( layout == LAYOUT_RTL, "GetProcessDefaultLayout wrong layout %x\n", layout ); - hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, - 0, 0, 100, 100, 0, 0, 0, NULL); - ok( hwnd != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( hwnd, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); - DestroyWindow( hwnd ); - hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP, - 0, 0, 100, 100, parent, 0, 0, NULL); - ok( hwnd != 0, "creation failed err %u\n", GetLastError()); - expect_ex_style( hwnd, WS_EX_APPWINDOW ); - DestroyWindow( hwnd ); - pSetProcessDefaultLayout( 0 ); - } - else win_skip( "SetProcessDefaultLayout not supported\n" ); + pSetProcessDefaultLayout( 0 ); } - else win_skip( "SetLayout not supported\n" ); + else win_skip( "SetProcessDefaultLayout not supported\n" ); } - else win_skip( "SetLayout not available\n" ); + else win_skip( "SetLayout not supported\n" ); DestroyWindow(parent); @@ -11856,8 +11851,6 @@ START_TEST(win) pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" ); pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" ); pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" ); - pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" ); - pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" ); pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" ); pGetWindowDisplayAffinity = (void *)GetProcAddress( user32, "GetWindowDisplayAffinity" ); pSetWindowDisplayAffinity = (void *)GetProcAddress( user32, "SetWindowDisplayAffinity" );