[FASTFAT]
[reactos.git] / rostests / apitests / user32api / tests / ScrollDC.c
1 #include "../user32api.h"
2
3 INT
4 Test_ScrollDC(PTESTINFO pti)
5 {
6 HWND hWnd, hWnd2;
7 HDC hDC;
8 HRGN hrgn;
9 RECT rcClip;
10
11 /* Create a window */
12 hWnd = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
13 100, 100, 100, 100,
14 NULL, NULL, g_hInstance, 0);
15 UpdateWindow(hWnd);
16 hDC = GetDC(hWnd);
17
18 /* Assert that no update region is there */
19 hrgn = CreateRectRgn(0,0,0,0);
20 ASSERT(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION);
21
22 /* Test normal scrolling */
23 TEST(ScrollDC(hDC, 0, 0, NULL, NULL, hrgn, NULL) == TRUE);
24
25 /* Scroll with invalid update region */
26 DeleteObject(hrgn);
27 TEST(ScrollDC(hDC, 50, 0, NULL, NULL, hrgn, NULL) == FALSE);
28 hrgn = CreateRectRgn(0,0,0,0);
29 TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION);
30
31 /* Scroll with invalid update rect pointer */
32 TEST(ScrollDC(hDC, 50, 0, NULL, NULL, NULL, (PRECT)1) == 0);
33 TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION);
34
35 /* Scroll with a clip rect */
36 rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100;
37 TEST(ScrollDC(hDC, 50, 0, NULL, &rcClip, hrgn, NULL) == TRUE);
38 TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION);
39
40 /* Scroll with a clip rect */
41 rcClip.left = 50; rcClip.top = 0; rcClip.right = 100; rcClip.bottom = 100;
42 TEST(ScrollDC(hDC, 50, 50, NULL, &rcClip, hrgn, NULL) == TRUE);
43 TEST(GetUpdateRgn(hWnd, hrgn, FALSE) == NULLREGION);
44
45 /* Overlap with another window */
46 hWnd2 = CreateWindowW(L"BUTTON", L"TestWindow", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
47 30, 160, 100, 100,
48 NULL, NULL, g_hInstance, 0);
49 UpdateWindow(hWnd2);
50
51 /* Cleanup */
52 ReleaseDC(hWnd, hDC);
53 DestroyWindow(hWnd);
54 DestroyWindow(hWnd2);
55
56 return APISTATUS_NORMAL;
57 }