ReactOS 0.4.16-dev-2104-gb84fa49
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 {
88 HGDIOBJ hOldObj = SelectObject(hdc, hrgn2);
89 ok(hOldObj == (PVOID)2 || broken(hOldObj == (PVOID)1), "hOldObj was 0x%p\n", hOldObj);
90 }
91
92 /* Test colors */
93 TEST(GetDCBrushColor(hdc) == RGB(12,34,56));
94 TEST(GetDCPenColor(hdc) == RGB(23,34,45));
95
96 /* Test coordinates */
100 TEST(pt.x == 12);
101 TEST(pt.y == 34);
103 TEST(pt.x == 56);
104 TEST(pt.y == 78);
105 GetWindowExtEx(hdc, &sz);
106 ok(sz.cx == 123, "sz.cx == %ld\n", sz.cx);
107 ok(sz.cy == 456, "sz.cy == %ld\n", sz.cy);
108 GetViewportExtEx(hdc, &sz);
109 TEST(sz.cx == 234);
110 TEST(sz.cy == 567);
111
112
113}
114
115
116static
117void
119{
123
124 SetLastError(0);
125 TEST(NtGdiRestoreDC(hdc, 2) == 0);
127
128 SetLastError(0);
129 TEST(NtGdiRestoreDC(hdc, 0) == 0);
131
132 SetLastError(0);
133 TEST(NtGdiRestoreDC(hdc, -2) == 0);
135
136 SetLastError(0);
137 TEST(NtGdiRestoreDC(hdc, 1) == 1);
138 TEST(GetLastError() == 0);
139
140 Test_IsSpecialState(hdc, bMemDC);
141}
142
143
145{
146 HDC hdc;
147
150
151 SetLastError(0);
152 TEST(NtGdiRestoreDC(0, -10) == 0);
154
155 SetLastError(0);
156 TEST(NtGdiRestoreDC(hdc, 0) == 0);
158
159 SetLastError(0);
160 TEST(NtGdiRestoreDC(hdc, 1) == 0);
162
163 /* Initialize objects */
164 hbrush = CreateSolidBrush(12345);
166 hpen = CreatePen(PS_SOLID, 4, RGB(10,12,32));
168 hbitmap = CreateBitmap(10, 10, 1, 1, NULL);
170 hfont = CreateFont(10, 0, 0, 0, FW_NORMAL, 0, 0, 0, ANSI_CHARSET,
172 DEFAULT_PITCH, "Arial");
174 hrgn = CreateRectRgn(12, 14, 14, 17);
176 hrgn2 = CreateRectRgn(1, 1, 2, 2);
178
179 /* Test mem dc */
181 DeleteDC(hdc);
182
183 /* Test screen DC */
184 hdc = GetDC(0);
187 ReleaseDC(0, hdc);
188
189 /* Test info dc */
190 hdc = CreateICW(L"DISPLAY", NULL, NULL, NULL);
193 DeleteDC(hdc);
194
195}
196
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 broken(x)
Definition: atltest.h:178
#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:78
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GdiIsHandleValid(_In_ HGDIOBJ hobj)
Definition: gditools.c:54
#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
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:4889
#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)