[TEST] user32/tests: Add tests for LockWindowUpdate.
Lauri Kenttä
lauri.kentta at gmail.com
Wed Dec 7 11:10:48 CST 2016
This is for the test bot. Sorry for the noise. (Waiting for account.)
Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
dlls/user32/tests/win.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 82 insertions(+)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 428a88f..5943df9 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -9325,6 +9325,87 @@ todo_wine
ok(ret, "got %d\n", ret);
}
+static void test_LockWindowUpdate(HWND hwnd_w)
+{
+ typedef struct
+ {
+ HWND hwnd_lock, hwnd_draw;
+ BOOL allow_drawing;
+ COLORREF expect[6];
+ COLORREF broken[6];
+ BOOL todo[6];
+ } TEST;
+
+ HWND hwnd_d = GetDesktopWindow();
+ int i;
+
+ COLORREF c0 = CLR_INVALID, c1 = 0x111100, c2 = 0x222200;
+ TEST tests[] = {
+ {hwnd_w, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+ {hwnd_w, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0}, {0, 0, 0, 0, 0, 0}},
+ {hwnd_w, hwnd_d, 0, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}},
+ {hwnd_w, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}},
+ {hwnd_d, hwnd_w, 0, {c1, c0, c0, c0, c1, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+ {hwnd_d, hwnd_w, 1, {c1, c1, c1, c2, c2, c2}, {0}, {0, 0, 0, 0, 0, 0}},
+ {hwnd_d, hwnd_d, 0, {c1, c0, c0, c0, c0, c1}, {0}, {0, 1, 1, 1, 1, 1}},
+ {hwnd_d, hwnd_d, 1, {c1, c0, c1, c2, c0, c2}, {0}, {0, 1, 0, 0, 1, 0}}
+ };
+
+ ShowWindow(hwnd_w, SW_SHOW);
+ UpdateWindow(hwnd_w);
+ flush_events(TRUE);
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); ++i)
+ {
+ HDC hdc;
+ POINT p = {10, 10};
+ BOOL ret;
+ DWORD dc_flags = tests[i].allow_drawing ? DCX_LOCKWINDOWUPDATE : 0;
+
+ if (tests[i].hwnd_draw == hwnd_d)
+ ClientToScreen(hwnd_w, &p);
+ else
+ dc_flags |= DCX_USESTYLE;
+
+ trace("hwnd_lock = %s, hwnd_draw = %s, allow_drawing = %d\n",
+ tests[i].hwnd_lock == hwnd_d ? "desktop" : "hwnd_w",
+ tests[i].hwnd_draw == hwnd_d ? "desktop" : "hwnd_w",
+ tests[i].allow_drawing);
+
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+
+ #define TEST_PIXEL(j) \
+ do { \
+ COLORREF c = GetPixel(hdc, p.x, p.y); \
+ COLORREF e = tests[i].expect[j], b = tests[i].broken[j]; \
+ todo_wine_if(tests[i].todo[j]) \
+ ok(c == e || (b && broken(c == b)), "test %d: GetPixel: got %08x, expected %08x\n", j, c, e); \
+ } while (0)
+
+ SetPixel(hdc, p.x, p.y, c1);
+ TEST_PIXEL(0);
+ GdiFlush();
+ TEST_PIXEL(0);
+ ret = LockWindowUpdate(tests[i].hwnd_lock);
+ ok(ret, "LockWindowUpdate failed\n");
+ TEST_PIXEL(1);
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+ TEST_PIXEL(2);
+ SetPixel(hdc, p.x, p.y, c2);
+ TEST_PIXEL(3);
+ GdiFlush();
+ TEST_PIXEL(3);
+ LockWindowUpdate(0);
+ TEST_PIXEL(4);
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ hdc = GetDCEx(tests[i].hwnd_draw, 0, dc_flags);
+ TEST_PIXEL(5);
+ ReleaseDC(tests[i].hwnd_draw, hdc);
+ #undef TEST_PIXEL
+ }
+}
+
START_TEST(win)
{
char **argv;
@@ -9470,6 +9551,7 @@ START_TEST(win)
test_activateapp(hwndMain);
test_winproc_handles(argv[0]);
test_deferwindowpos();
+ test_LockWindowUpdate(hwndMain);
/* add the tests above this line */
if (hhook) UnhookWindowsHookEx(hhook);
--
2.10.2
More information about the wine-patches
mailing list