ReactOS 0.4.16-dev-197-g92996da
NtGdiRestoreDC.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 NtGdiRestoreDC
5 * PROGRAMMERS:
6 */
7
8#include "../win32nt.h"
9
10static HBRUSH hbrush;
12static HPEN hpen;
13static HFONT hfont;
14static HRGN hrgn, hrgn2;
15
16static
17void
19{
20 /* Select spcial Objects */
26
27 /* Colors */
28 SetDCBrushColor(hdc, RGB(12,34,56));
29 SetDCPenColor(hdc, RGB(23,34,45));
30
31 /* Coordinates */
34 SetWindowOrgEx(hdc, 12, 34, NULL);
35 SetViewportOrgEx(hdc, 56, 78, NULL);
36 SetWindowExtEx(hdc, 123, 456, NULL);
37 SetViewportExtEx(hdc, 234, 567, NULL);
38
39
40
41}
42
43static
44void
46{
47 /* Select spcial Objects */
53
54 /* Colors */
55 SetDCBrushColor(hdc, RGB(65,43,21));
56 SetDCPenColor(hdc, RGB(54,43,32));
57
58 /* Coordinates */
61 SetWindowOrgEx(hdc, 43, 21, NULL);
62 SetViewportOrgEx(hdc, 87, 65, NULL);
63 SetWindowExtEx(hdc, 654, 321, NULL);
64 SetViewportExtEx(hdc, 765, 432, NULL);
65
66
67}
68
69static
70void
72{
73 POINT pt;
74 SIZE sz;
75
76 /* Test Objects */
80 if (bMemDC)
81 {
84 }
85 else
86 {
89 }
90
91 /* Test colors */
92 TEST(GetDCBrushColor(hdc) == RGB(12,34,56));
93 TEST(GetDCPenColor(hdc) == RGB(23,34,45));
94
95 /* Test coordinates */
99 TEST(pt.x == 12);
100 TEST(pt.y == 34);
102 TEST(pt.x == 56);
103 TEST(pt.y == 78);
104 GetWindowExtEx(hdc, &sz);
105 ok(sz.cx == 123, "sz.cx == %ld\n", sz.cx);
106 ok(sz.cy == 456, "sz.cy == %ld\n", sz.cy);
107 GetViewportExtEx(hdc, &sz);
108 TEST(sz.cx == 234);
109 TEST(sz.cy == 567);
110
111
112}
113
114
115static
116void
118{
122
123 SetLastError(0);
124 TEST(NtGdiRestoreDC(hdc, 2) == 0);
126
127 SetLastError(0);
128 TEST(NtGdiRestoreDC(hdc, 0) == 0);
130
131 SetLastError(0);
132 TEST(NtGdiRestoreDC(hdc, -2) == 0);
134
135 SetLastError(0);
136 TEST(NtGdiRestoreDC(hdc, 1) == 1);
137 TEST(GetLastError() == 0);
138
139 Test_IsSpecialState(hdc, bMemDC);
140}
141
142
144{
145 HDC hdc;
146
149
150 SetLastError(0);
151 TEST(NtGdiRestoreDC(0, -10) == 0);
153
154 SetLastError(0);
155 TEST(NtGdiRestoreDC(hdc, 0) == 0);
157
158 SetLastError(0);
159 TEST(NtGdiRestoreDC(hdc, 1) == 0);
161
162 /* Initialize objects */
163 hbrush = CreateSolidBrush(12345);
165 hpen = CreatePen(PS_SOLID, 4, RGB(10,12,32));
167 hbitmap = CreateBitmap(10, 10, 1, 1, NULL);
169 hfont = CreateFont(10, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
171 DEFAULT_PITCH, "Arial");
173 hrgn = CreateRectRgn(12, 14, 14, 17);
175 hrgn2 = CreateRectRgn(1, 1, 2, 2);
177
178 /* Test mem dc */
180 DeleteDC(hdc);
181
182 /* Test screen DC */
183 hdc = GetDC(0);
186 ReleaseDC(0, hdc);
187
188 /* Test info dc */
189 hdc = CreateICW(L"DISPLAY", NULL, NULL, NULL);
192 DeleteDC(hdc);
193
194}
195
static void Test_IsSpecialState(HDC hdc, BOOL bMemDC)
static void SetSpecialDCState2(HDC hdc)
static HRGN hrgn2
static HFONT hfont
static void SetSpecialDCState(HDC hdc)
static HRGN hrgn
static HBRUSH hbrush
static void Test_SaveRestore(HDC hdc, BOOL bMemDC)
static HPEN hpen
static HBITMAP hbitmap
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
#define pt(x, y)
Definition: drawing.c:79
#define RGB(r, g, b)
Definition: precomp.h:71
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:29
#define ASSERT(a)
Definition: mode.c:44
#define TEST(x)
Definition: precomp.h:20
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
__kernel_entry W32KAPI BOOL APIENTRY NtGdiRestoreDC(_In_ HDC hdc, _In_ INT iLevel)
__kernel_entry W32KAPI INT APIENTRY NtGdiSaveDC(_In_ HDC hdc)
#define DEFAULT_BITMAP
Definition: ntgdityp.h:195
#define L(x)
Definition: ntvdm.h:50
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
COLORREF WINAPI SetDCPenColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:941
COLORREF WINAPI GetDCPenColor(_In_ HDC hdc)
Definition: dc.c:884
COLORREF WINAPI SetDCBrushColor(_In_ HDC hdc, _In_ COLORREF crColor)
Definition: dc.c:905
COLORREF WINAPI GetDCBrushColor(_In_ HDC hdc)
Definition: dc.c:863
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI SetMapMode(_In_ HDC, _In_ int)
#define GM_COMPATIBLE
Definition: wingdi.h:864
#define DEFAULT_PITCH
Definition: wingdi.h:443
HGDIOBJ WINAPI GetStockObject(_In_ int)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1233
#define GM_ADVANCED
Definition: wingdi.h:865
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI GetGraphicsMode(_In_ HDC)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
#define DEFAULT_QUALITY
Definition: wingdi.h:436
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
BOOL WINAPI GetWindowOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:439
#define DEFAULT_GUI_FONT
Definition: wingdi.h:909
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define MM_ANISOTROPIC
Definition: wingdi.h:867
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
int WINAPI GetMapMode(_In_ HDC)
Definition: coord.c:114
#define OUT_DEFAULT_PRECIS
Definition: wingdi.h:415
#define MM_ISOTROPIC
Definition: wingdi.h:870
#define CreateFont
Definition: wingdi.h:4443
#define ANSI_CHARSET
Definition: wingdi.h:383
BOOL WINAPI GetWindowExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:411
#define CLIP_DEFAULT_PRECIS
Definition: wingdi.h:426
#define FW_NORMAL
Definition: wingdi.h:373
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI GetViewportExtEx(_In_ HDC, _Out_ LPSIZE)
Definition: coord.c:351
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI GetViewportOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:383
#define PS_SOLID
Definition: wingdi.h:586
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)