1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for ScrollDC 5 * PROGRAMMERS: Timo Kreuzer 6 */ 7 8 #include "precomp.h" 9 10 void Test_ScrollDC() 11 { 12 HWND hWnd, hWnd2; 13 HDC hDC; 14 HRGN hrgn; 15 RECT rcClip; 16 int iResult; 17 18 /* Create a window */ 19 hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 20 100, 100, 100, 100, 21 NULL, NULL, 0, 0); 22 UpdateWindow(hWnd); 23 hDC = GetDC(hWnd); 24 25 /* Test that no update region is there */ 26 hrgn = CreateRectRgn(0,0,0,0); 27 iResult = GetUpdateRgn(hWnd, hrgn, FALSE); 28 ok (iResult == NULLREGION, "Expected NULLREGION, got %d\n", iResult); 29 30 /* Test normal scrolling */ 31 ok(ScrollDC(hDC, 0, 0, NULL, NULL, hrgn, NULL) == TRUE, "ScrollDC failed\n"); 32 33 /* Scroll with invalid update region */ 34 DeleteObject(hrgn); 35 ok(ScrollDC(hDC, 50, 0, NULL, NULL, (HRGN)0x12345678, NULL) == FALSE, "ScrollDC successed\n"); 36 ok(ScrollDC(hDC, 50, 0, NULL, NULL, hrgn, NULL) == FALSE, "ScrollDC successed\n"); 37 hrgn = CreateRectRgn(0,0,0,0); 38 iResult = GetUpdateRgn(hWnd, hrgn, FALSE); 39 ok(iResult == NULLREGION, "Expected NULLREGION, got %d\n", iResult); 40 41 /* Scroll with invalid update rect pointer */ 42 ok(ScrollDC(hDC, 50, 0, NULL, NULL, NULL, (PRECT)1) == FALSE, "ScrollDC failed\n"); 43 iResult = GetUpdateRgn(hWnd, hrgn, FALSE); 44 ok(iResult == NULLREGION, "Expected NULLREGION, got %d\n", iResult); 45 46 /* Scroll with a clip rect */ 47 rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; 48 ok(ScrollDC(hDC, 50, 0, NULL, &rcClip, hrgn, NULL) == TRUE, "ScrollDC failed\n"); 49 iResult = GetUpdateRgn(hWnd, hrgn, FALSE); 50 ok(iResult == NULLREGION, "Expected NULLREGION, got %d\n", iResult); 51 52 /* Scroll with a clip rect */ 53 rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100; 54 ok(ScrollDC(hDC, 50, 50, NULL, &rcClip, hrgn, NULL) == TRUE, "ScrollDC failed\n"); 55 iResult = GetUpdateRgn(hWnd, hrgn, FALSE); 56 ok(iResult == NULLREGION, "Expected NULLREGION, got %d\n", iResult); 57 58 /* Overlap with another window */ 59 hWnd2 = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 60 30, 160, 100, 100, 61 NULL, NULL, 0, 0); 62 UpdateWindow(hWnd2); 63 64 /* Cleanup */ 65 ReleaseDC(hWnd, hDC); 66 DestroyWindow(hWnd); 67 DestroyWindow(hWnd2); 68 69 } 70 71 START_TEST(ScrollDC) 72 { 73 Test_ScrollDC(); 74 } 75