From: Paul Gofman pgofman@codeweavers.com
--- dlls/user32/tests/win.c | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 354d6ed5ca3..6baf83e39e5 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -31,6 +31,7 @@ #include "wingdi.h" #include "winuser.h" #include "winreg.h" +#include "dwmapi.h"
#include "wine/test.h"
@@ -63,6 +64,9 @@ static BOOL (WINAPI *pSystemParametersInfoForDpi)(UINT,UINT,void*,UINT,UINT); static HICON (WINAPI *pInternalGetWindowIcon)(HWND window, UINT type); static BOOL (WINAPI *pSetProcessLaunchForegroundPolicy)(DWORD,DWORD);
+static HRESULT (WINAPI *pDwmSetWindowAttribute)(HWND,DWORD,const void *,DWORD); +static HRESULT (WINAPI *pDwmFlush)(void); + static BOOL test_lbuttondown_flag; static DWORD num_gettext_msgs; static DWORD num_settext_msgs; @@ -14255,12 +14259,95 @@ static void test_GW_ENABLEDPOPUP(void) DestroyWindow(parent2); }
+static LRESULT WINAPI test_initial_surface_colour_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + COLORREF c; + HDC hdc; + RECT r; + + switch(msg) + { + case WM_NCCREATE: + if (pDwmSetWindowAttribute) + { + BOOL disable = TRUE; + + /* with transition effect enabled the window bits, in the absence of painting those, will be gradually + * transitioned from pixels behind the window to white colour, featuring different colours in the test + * depending on sleep amount in WM_WINDOWPOSCHANGING. */ + pDwmSetWindowAttribute( hwnd, DWMWA_TRANSITIONS_FORCEDISABLED, &disable, sizeof(disable) ); + } + hdc = GetDC( hwnd ); + ok( !!hdc, "got %p.\n", hdc ); + GetClipBox( hdc, &r ); + ok( !r.left && !r.top && !r.right && !r.bottom, "got %s.\n", wine_dbgstr_rect( &r )); + c = GetPixel(hdc, 1, 1); + ReleaseDC(hwnd, hdc); + ok( c == CLR_INVALID, "got %#lx.\n", c ); + return TRUE; + + case WM_NCACTIVATE: + hdc = GetDC( hwnd ); + GetClipBox( hdc, &r ); + c = GetPixel(hdc, 50, 50); + ReleaseDC(hwnd, hdc); + if (!r.left && !r.top && !r.right && !r.bottom) + ok( c == CLR_INVALID, "got %#lx.\n", c ); + else + todo_wine ok( c == 0xffffff, "got %#lx, msg %#x.\n", c, msg ); + return TRUE; + + case WM_WINDOWPOSCHANGING: + /* This is racy on Windows, even without transition effect, if window is displayed too quick it may end up with + * the bits behind the window. */ + if (pDwmFlush) pDwmFlush(); + return TRUE; + + case WM_ERASEBKGND: + case WM_NCPAINT: + hdc = GetDC( hwnd ); + c = GetPixel(hdc, 50, 50); + ReleaseDC(hwnd, hdc); + todo_wine ok( c == 0xffffff, "got %#lx, msg %#x.\n", c, msg ); + return TRUE; + } + return DefWindowProcA( hwnd, msg, wparam, lparam ); +} + +static void test_initial_surface_colour(void) +{ + WNDCLASSA cls; + HWND hwnd; + BOOL bret; + + memset( &cls, 0, sizeof(cls) ); + cls.lpfnWndProc = test_initial_surface_colour_window_proc; + cls.hInstance = GetModuleHandleA( NULL ); + cls.hCursor = LoadCursorA( 0, (LPCSTR)IDC_ARROW ); + cls.hbrBackground = NULL; + cls.lpszClassName = "test_colour_class"; + + bret = RegisterClassA(&cls); + ok( bret, "got error %lu.\n", GetLastError() ); + + hwnd = CreateWindowExA( 0, "test_colour_class", "Test window", WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, + 0, 0, 100, 100, NULL, NULL, GetModuleHandleA( NULL ), NULL ); + ok( !!hwnd, "got NULL.\n" ); + pump_messages(); + DestroyWindow( hwnd ); + + bret = UnregisterClassA( "test_colour_class", GetModuleHandleA( NULL )); + ok( bret, "got error %lu.\n", GetLastError() ); +} + START_TEST(win) { char **argv; int argc = winetest_get_mainargs( &argv ); HMODULE user32 = GetModuleHandleA( "user32.dll" ); HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); + HMODULE dwmapi = LoadLibraryA("dwmapi.dll"); + pGetWindowInfo = (void *)GetProcAddress( user32, "GetWindowInfo" ); pGetWindowModuleFileNameA = (void *)GetProcAddress( user32, "GetWindowModuleFileNameA" ); pGetLayeredWindowAttributes = (void *)GetProcAddress( user32, "GetLayeredWindowAttributes" ); @@ -14281,6 +14368,9 @@ START_TEST(win) pInternalGetWindowIcon = (void *)GetProcAddress( user32, "InternalGetWindowIcon" ); pSetProcessLaunchForegroundPolicy = (void*)GetProcAddress( user32, "SetProcessLaunchForegroundPolicy" );
+ pDwmSetWindowAttribute = (void*)GetProcAddress( dwmapi, "DwmSetWindowAttribute" ); + pDwmFlush = (void*)GetProcAddress( dwmapi, "DwmFlush" ); + if (argc == 4) { HWND hwnd; @@ -14451,6 +14541,7 @@ START_TEST(win) test_cascade_windows(); test_tile_windows(); test_GW_ENABLEDPOPUP(); + test_initial_surface_colour();
/* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook);