Commit d0cd105d authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

user32/tests: Use device context layout functions directly.

parent 904a238b
...@@ -550,24 +550,13 @@ static void test_invisible_create(void) ...@@ -550,24 +550,13 @@ static void test_invisible_create(void)
static void test_dc_layout(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; HWND hwnd_cache_rtl, hwnd_owndc_rtl, hwnd_classdc_rtl, hwnd_classdc2_rtl;
HDC hdc; HDC hdc;
DWORD layout; 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 ); hdc = GetDC( hwnd_cache );
pSetLayout( hdc, LAYOUT_RTL ); SetLayout( hdc, LAYOUT_RTL );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ReleaseDC( hwnd_cache, hdc ); ReleaseDC( hwnd_cache, hdc );
if (!layout) if (!layout)
{ {
...@@ -584,42 +573,42 @@ static void test_dc_layout(void) ...@@ -584,42 +573,42 @@ static void test_dc_layout(void)
hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE, hwnd_classdc2_rtl = CreateWindowExA(WS_EX_LAYOUTRTL, "classdc_class", NULL, WS_OVERLAPPED | WS_VISIBLE,
200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL ); 200, 200, 100, 100, 0, 0, GetModuleHandleA(0), NULL );
hdc = GetDC( hwnd_cache_rtl ); hdc = GetDC( hwnd_cache_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
pSetLayout( hdc, 0 ); SetLayout( hdc, 0 );
ReleaseDC( hwnd_cache_rtl, hdc ); ReleaseDC( hwnd_cache_rtl, hdc );
hdc = GetDC( hwnd_owndc_rtl ); hdc = GetDC( hwnd_owndc_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
ReleaseDC( hwnd_cache_rtl, hdc ); ReleaseDC( hwnd_cache_rtl, hdc );
hdc = GetDC( hwnd_cache ); hdc = GetDC( hwnd_cache );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == 0, "wrong layout %x\n", layout ); ok( layout == 0, "wrong layout %x\n", layout );
ReleaseDC( hwnd_cache, hdc ); ReleaseDC( hwnd_cache, hdc );
hdc = GetDC( hwnd_owndc_rtl ); hdc = GetDC( hwnd_owndc_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
pSetLayout( hdc, 0 ); SetLayout( hdc, 0 );
ReleaseDC( hwnd_owndc_rtl, hdc ); ReleaseDC( hwnd_owndc_rtl, hdc );
hdc = GetDC( hwnd_owndc_rtl ); hdc = GetDC( hwnd_owndc_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
ReleaseDC( hwnd_owndc_rtl, hdc ); ReleaseDC( hwnd_owndc_rtl, hdc );
hdc = GetDC( hwnd_classdc_rtl ); hdc = GetDC( hwnd_classdc_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
pSetLayout( hdc, 0 ); SetLayout( hdc, 0 );
ReleaseDC( hwnd_classdc_rtl, hdc ); ReleaseDC( hwnd_classdc_rtl, hdc );
hdc = GetDC( hwnd_classdc2_rtl ); hdc = GetDC( hwnd_classdc2_rtl );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
ReleaseDC( hwnd_classdc2_rtl, hdc ); ReleaseDC( hwnd_classdc2_rtl, hdc );
hdc = GetDC( hwnd_classdc ); hdc = GetDC( hwnd_classdc );
layout = pGetLayout( hdc ); layout = GetLayout( hdc );
ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout ); ok( layout == LAYOUT_RTL, "wrong layout %x\n", layout );
ReleaseDC( hwnd_classdc_rtl, hdc ); ReleaseDC( hwnd_classdc_rtl, hdc );
......
...@@ -62,8 +62,6 @@ static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout ); ...@@ -62,8 +62,6 @@ static BOOL (WINAPI *pGetProcessDefaultLayout)( DWORD *layout );
static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout ); static BOOL (WINAPI *pSetProcessDefaultLayout)( DWORD layout );
static BOOL (WINAPI *pFlashWindow)( HWND hwnd, BOOL bInvert ); static BOOL (WINAPI *pFlashWindow)( HWND hwnd, BOOL bInvert );
static BOOL (WINAPI *pFlashWindowEx)( PFLASHWINFO pfwi ); 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 *pMirrorRgn)(HWND hwnd, HRGN hrgn);
static BOOL (WINAPI *pGetWindowDisplayAffinity)(HWND hwnd, DWORD *affinity); static BOOL (WINAPI *pGetWindowDisplayAffinity)(HWND hwnd, DWORD *affinity);
static BOOL (WINAPI *pSetWindowDisplayAffinity)(HWND hwnd, DWORD affinity); static BOOL (WINAPI *pSetWindowDisplayAffinity)(HWND hwnd, DWORD affinity);
...@@ -5908,6 +5906,7 @@ static void test_CreateWindow(void) ...@@ -5908,6 +5906,7 @@ static void test_CreateWindow(void)
RECT rc, rc_minmax; RECT rc, rc_minmax;
MINMAXINFO minmax; MINMAXINFO minmax;
BOOL res; BOOL res;
HDC hdc;
#define expect_menu(window, menu) \ #define expect_menu(window, menu) \
SetLastError(0xdeadbeef); \ SetLastError(0xdeadbeef); \
...@@ -6248,73 +6247,69 @@ static void test_CreateWindow(void) ...@@ -6248,73 +6247,69 @@ static void test_CreateWindow(void)
"invalid error %u\n", GetLastError()); "invalid error %u\n", GetLastError());
DestroyWindow(hwnd); DestroyWindow(hwnd);
if (pGetLayout && pSetLayout) hdc = GetDC( parent );
SetLayout( hdc, LAYOUT_RTL );
if (GetLayout( hdc ))
{ {
HDC hdc = GetDC( parent ); ReleaseDC( parent, hdc );
pSetLayout( hdc, LAYOUT_RTL ); DestroyWindow( parent );
if (pGetLayout( hdc )) 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 ); DWORD layout;
DestroyWindow( parent );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
parent = CreateWindowExA(WS_EX_APPWINDOW | WS_EX_LAYOUTRTL, "static", NULL, WS_POPUP, ok( !pGetProcessDefaultLayout( NULL ), "GetProcessDefaultLayout succeeded\n" );
0, 0, 100, 100, 0, 0, 0, NULL); ok( GetLastError() == ERROR_NOACCESS, "wrong error %u\n", GetLastError() );
ok( parent != 0, "creation failed err %u\n", GetLastError()); SetLastError( 0xdeadbeef );
expect_ex_style( parent, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL ); res = pGetProcessDefaultLayout( &layout );
hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); ok( res, "GetProcessDefaultLayout failed err %u\n", GetLastError ());
ok( hwnd != 0, "creation failed err %u\n", GetLastError()); ok( layout == 0, "GetProcessDefaultLayout wrong layout %x\n", layout );
expect_ex_style( hwnd, WS_EX_LAYOUTRTL ); SetLastError( 0xdeadbeef );
DestroyWindow( hwnd ); res = pSetProcessDefaultLayout( 7 );
hwnd = CreateWindowExA(0, "static", NULL, WS_POPUP, 0, 0, 20, 20, parent, 0, 0, NULL); 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()); ok( hwnd != 0, "creation failed err %u\n", GetLastError());
expect_ex_style( hwnd, 0 ); expect_ex_style( hwnd, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL );
DestroyWindow( hwnd ); DestroyWindow( hwnd );
SetWindowLongW( parent, GWL_EXSTYLE, WS_EX_APPWINDOW | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT ); hwnd = CreateWindowExA(WS_EX_APPWINDOW, "static", NULL, WS_POPUP,
hwnd = CreateWindowExA(0, "static", NULL, WS_CHILD, 0, 0, 20, 20, parent, 0, 0, NULL); 0, 0, 100, 100, parent, 0, 0, NULL);
ok( hwnd != 0, "creation failed err %u\n", GetLastError()); ok( hwnd != 0, "creation failed err %u\n", GetLastError());
expect_ex_style( hwnd, 0 ); expect_ex_style( hwnd, WS_EX_APPWINDOW );
DestroyWindow( hwnd ); DestroyWindow( hwnd );
pSetProcessDefaultLayout( 0 );
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" );
} }
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); DestroyWindow(parent);
...@@ -11856,8 +11851,6 @@ START_TEST(win) ...@@ -11856,8 +11851,6 @@ START_TEST(win)
pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" ); pSetProcessDefaultLayout = (void *)GetProcAddress( user32, "SetProcessDefaultLayout" );
pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" ); pFlashWindow = (void *)GetProcAddress( user32, "FlashWindow" );
pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" ); pFlashWindowEx = (void *)GetProcAddress( user32, "FlashWindowEx" );
pGetLayout = (void *)GetProcAddress( gdi32, "GetLayout" );
pSetLayout = (void *)GetProcAddress( gdi32, "SetLayout" );
pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" ); pMirrorRgn = (void *)GetProcAddress( gdi32, "MirrorRgn" );
pGetWindowDisplayAffinity = (void *)GetProcAddress( user32, "GetWindowDisplayAffinity" ); pGetWindowDisplayAffinity = (void *)GetProcAddress( user32, "GetWindowDisplayAffinity" );
pSetWindowDisplayAffinity = (void *)GetProcAddress( user32, "SetWindowDisplayAffinity" ); pSetWindowDisplayAffinity = (void *)GetProcAddress( user32, "SetWindowDisplayAffinity" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment