1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for NtUserScrollDC 5 * PROGRAMMERS: 6 */ 7 8 #include <win32nt.h> 9 10 START_TEST(NtUserScrollDC) 11 { 12 HINSTANCE hinst = GetModuleHandle(NULL); 13 HWND hWnd; 14 HDC hDC; 15 HRGN hRgn, hTmpRgn; 16 RECT rcScroll, rcClip, rcUpdate; 17 RECT rect = {0,0,100,100}; 18 INT Result; 19 20 hWnd = CreateWindowA("BUTTON", 21 "Test", 22 BS_PUSHBUTTON | WS_VISIBLE, 23 0, 24 0, 25 50, 26 100, 27 NULL, 28 NULL, 29 hinst, 30 0); 31 ASSERT(hWnd); 32 RedrawWindow(hWnd, &rect, NULL, RDW_UPDATENOW); 33 34 hDC = GetDC(hWnd); 35 ASSERT(hDC); 36 37 hRgn = CreateRectRgn(0,0,10,10); 38 39 40 /* Test inverted clip rect */ 41 rcScroll.left = 0; 42 rcScroll.top = 25; 43 rcScroll.right = 100; 44 rcScroll.bottom = 40; 45 rcClip.left = 0; 46 rcClip.top = 35; 47 rcClip.right = -70; 48 rcClip.bottom = -1000; 49 SetLastError(ERROR_SUCCESS); 50 Result = NtUserScrollDC(hDC, 10, 20, &rcScroll, &rcClip, hRgn, &rcUpdate); 51 RTEST(Result == 1); 52 RTEST(GetLastError() == ERROR_SUCCESS); 53 54 /* Test inverted scroll rect */ 55 rcScroll.left = 0; 56 rcScroll.top = 25; 57 rcScroll.right = -100; 58 rcScroll.bottom = -40; 59 rcClip.left = 0; 60 rcClip.top = 35; 61 rcClip.right = 70; 62 rcClip.bottom = 1000; 63 SetLastError(ERROR_SUCCESS); 64 Result = NtUserScrollDC(hDC, 10, 20, &rcScroll, &rcClip, hRgn, &rcUpdate); 65 RTEST(Result == 1); 66 RTEST(GetLastError() == ERROR_SUCCESS); 67 68 rcScroll.left = 0; 69 rcScroll.top = 25; 70 rcScroll.right = 100; 71 rcScroll.bottom = 40; 72 73 /* Test invalid update region */ 74 SetLastError(ERROR_SUCCESS); 75 Result = NtUserScrollDC(hDC, 10, 20, &rcScroll, &rcClip, (HRGN)0x123456, &rcUpdate); 76 RTEST(Result == 0); 77 TEST(GetLastError() == ERROR_INVALID_HANDLE); 78 79 /* Test invalid dc */ 80 SetLastError(ERROR_SUCCESS); 81 Result = NtUserScrollDC((HDC)0x123456, 10, 20, &rcScroll, &rcClip, hRgn, &rcUpdate); 82 RTEST(Result == 0); 83 RTEST(GetLastError() == ERROR_SUCCESS); 84 85 /* Test invalid update rect */ 86 SetLastError(ERROR_SUCCESS); 87 Result = NtUserScrollDC(hDC, 10, 20, &rcScroll, &rcClip, hRgn, (PVOID)0x80001000); 88 RTEST(Result == 0); 89 RTEST(GetLastError() == ERROR_NOACCESS); 90 91 Result = NtUserScrollDC(hDC, 10, 20, &rcScroll, &rcClip, hRgn, &rcUpdate); 92 93 RTEST(Result == TRUE); 94 RTEST(rcUpdate.left == 0); 95 RTEST(rcUpdate.top == 35); 96 RTEST(rcUpdate.right == 70); 97 RTEST(rcUpdate.bottom == 55); 98 99 hTmpRgn = CreateRectRgn(10,45,70,55); 100 Result = CombineRgn(hRgn, hRgn, hTmpRgn, RGN_XOR); 101 RTEST(Result == SIMPLEREGION); 102 103 SetRectRgn(hTmpRgn,0,35,70,40); 104 Result = CombineRgn(hRgn, hRgn, hTmpRgn, RGN_XOR); 105 RTEST(Result == NULLREGION); 106 107 DeleteObject(hTmpRgn); 108 109 /* TODO: Test with another window in front */ 110 /* TODO: Test with different viewport extension */ 111 112 ReleaseDC(hWnd, hDC); 113 DestroyWindow(hWnd); 114 DeleteObject(hRgn); 115 116 } 117 118