ReactOS  0.4.14-dev-293-g2b39b42
ScrollDC.c
Go to the documentation of this file.
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 
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);
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 */
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);
63 
64  /* Cleanup */
65  ReleaseDC(hWnd, hDC);
68 
69 }
70 
72 {
73  Test_ScrollDC();
74 }
#define TRUE
Definition: types.h:120
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
BOOL WINAPI UpdateWindow(_In_ HWND)
HWND hWnd
Definition: settings.c:17
#define NULLREGION
Definition: wingdi.h:360
LONG top
Definition: windef.h:292
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
BOOL WINAPI DestroyWindow(_In_ HWND)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4217
int WINAPI GetUpdateRgn(_In_ HWND, _In_ HRGN, _In_ BOOL)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI ScrollDC(_In_ HDC, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
HWND hWnd2
Definition: button.c:416
void Test_ScrollDC()
Definition: ScrollDC.c:10
static const WCHAR L[]
Definition: oid.c:1250
START_TEST(ScrollDC)
Definition: ScrollDC.c:71
static HRGN hrgn
Definition: win.c:55
static HDC hDC
Definition: 3dtext.c:33
#define ok(value,...)
Definition: atltest.h:57
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
LONG bottom
Definition: windef.h:294
#define WS_VISIBLE
Definition: pedump.c:620