Convert gdi32api into wine style test
[reactos.git] / rostests / apitests / gdi32 / CreateCompatibleDC.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for CreateCompatibleDC
5 * PROGRAMMERS: Timo Kreuzer
6 */
7
8 #include <stdio.h>
9 #include <wine/test.h>
10 #include <windows.h>
11
12 void Test_CreateCompatibleDC()
13 {
14 HDC hdcScreen, hOldDC, hdc, hdc2;
15 HPEN hOldPen;
16 COLORREF color;
17
18 /* Get screen DC */
19 hdcScreen = GetDC(NULL);
20
21 /* Test NULL DC handle */
22 SetLastError(ERROR_SUCCESS);
23 hdc = CreateCompatibleDC(NULL);
24 ok(hdc != NULL, "CreateCompatibleDC(NULL) failed\n");
25 ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
26 if(hdc) DeleteDC(hdc);
27
28 /* Test invalid DC handle */
29 SetLastError(ERROR_SUCCESS);
30 hdc = CreateCompatibleDC((HDC)0x123456);
31 ok(hdc == NULL, "Expected NULL, got %p\n", hdc);
32 ok(GetLastError() == ERROR_SUCCESS, "GetLastError() == %ld\n", GetLastError());
33 if(hdc) DeleteDC(hdc);
34
35 hdc = CreateCompatibleDC(hdcScreen);
36 ok(hdc != NULL, "CreateCompatibleDC failed\n");
37
38 // Test if first selected pen is BLACK_PEN (? or same as screen DC's pen?)
39 hOldPen = SelectObject(hdc, GetStockObject(DC_PEN));
40 ok (hOldPen == GetStockObject(BLACK_PEN), "hOldPen == %p\n", hOldPen);
41 hOldPen = SelectObject(hdc, GetStockObject(BLACK_PEN));
42 ok (hOldPen == GetStockObject(DC_PEN), "hOldPen == %p\n", hOldPen);
43
44 /* Test for the starting Color == RGB(0,0,0) */
45 color = SetDCPenColor(hdc, RGB(1,2,3));
46 ok(color == RGB(0,0,0), "color == %lx\n", color);
47
48 /* Check for reuse counter */
49 hOldDC = hdc;
50 DeleteDC(hdc);
51 hdc = CreateCompatibleDC(hdcScreen);
52 hdc2 = CreateCompatibleDC(hOldDC);
53 ok(hdc2 == NULL, "Expected NULL, got %p\n", hdc);
54 if (hdc2 != NULL) DeleteDC(hdc2);
55
56 /* Check map mode */
57 hdc = CreateCompatibleDC(hdcScreen);
58 SetMapMode(hdc, MM_ISOTROPIC);
59 hdc2 = CreateCompatibleDC(hdc);
60 ok(GetMapMode(hdc2) == MM_TEXT, "GetMapMode(hdc2)==%d\n", GetMapMode(hdc2));
61
62 /* cleanup */
63 DeleteDC(hdc);
64
65 ReleaseDC(NULL, hdcScreen);
66 }
67
68 START_TEST(CreateCompatibleDC)
69 {
70 Test_CreateCompatibleDC();
71 }
72