2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for Rectangle
5 * PROGRAMMERS: Jérôme Gardou
11 void Test_Rectangle(void)
20 hdc
= CreateCompatibleDC(NULL
);
21 ok(hdc
!= NULL
, "Failed to create the DC!\n");
22 hBmp
= CreateCompatibleBitmap(hdc
, 4, 4);
23 ok(hBmp
!= NULL
, "Failed to create the Bitmap!\n");
24 hBmp
= SelectObject(hdc
, hBmp
);
25 ok(hBmp
!= NULL
, "Failed to select the Bitmap!\n");
27 hBrush
= CreateSolidBrush(RGB(0, 0, 0));
28 ok(hBrush
!= NULL
, "Failed to create a solid brush!\n");
29 hBrush
= SelectObject(hdc
, hBrush
);
30 ok(hBrush
!= NULL
, "Failed to select the brush!\n");
32 /* Blank the bitmap */
33 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
34 ok(ret
, "BitBlt failed to blank the bitmap!\n");
36 /* Try inverted rectangle coordinates */
37 ret
= Rectangle(hdc
, 0, 2, 2, 0);
38 ok(ret
, "Rectangle failed!");
39 color
= GetPixel(hdc
, 0, 0);
40 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
41 color
= GetPixel(hdc
, 2, 2);
42 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
43 color
= GetPixel(hdc
, 0, 2);
44 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
45 color
= GetPixel(hdc
, 2, 0);
46 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
47 color
= GetPixel(hdc
, 1, 1);
48 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
50 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
51 ok(ret
, "BitBlt failed to blank the bitmap!\n");
52 /* Try well ordered rectangle coordinates */
53 ret
= Rectangle(hdc
, 0, 0, 2, 2);
54 ok(ret
, "Rectangle failed!");
55 color
= GetPixel(hdc
, 0, 0);
56 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
57 color
= GetPixel(hdc
, 2, 2);
58 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
59 color
= GetPixel(hdc
, 0, 2);
60 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
61 color
= GetPixel(hdc
, 2, 0);
62 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
63 color
= GetPixel(hdc
, 1, 1);
64 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
66 /* tests with NULL pen */
67 hPen
= SelectObject(hdc
, GetStockObject(NULL_PEN
));
69 /* Blank the bitmap */
70 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
71 ok(ret
, "BitBlt failed to blank the bitmap!\n");
73 ret
= Rectangle(hdc
, 0, 0, 3, 3);
74 ok(ret
, "Rectangle failed!");
75 color
= GetPixel(hdc
, 0, 0);
76 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
77 color
= GetPixel(hdc
, 2, 2);
78 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
79 color
= GetPixel(hdc
, 0, 2);
80 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
81 color
= GetPixel(hdc
, 2, 0);
82 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
83 color
= GetPixel(hdc
, 1, 1);
84 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
86 SelectObject(hdc
, hPen
);
88 /* Same tests with GM_ADVANCED */
89 ok(SetGraphicsMode(hdc
, GM_ADVANCED
) == GM_COMPATIBLE
, "Default mode for the DC is not GM_COMPATIBLE.\n");
91 /* Blank the bitmap */
92 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
93 ok(ret
, "BitBlt failed to blank the bitmap!\n");
95 /* Try inverted rectangle coordinates */
96 ret
= Rectangle(hdc
, 0, 2, 2, 0);
97 ok(ret
, "Rectangle failed!");
98 color
= GetPixel(hdc
, 0, 0);
99 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
100 color
= GetPixel(hdc
, 2, 2);
101 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
102 color
= GetPixel(hdc
, 0, 2);
103 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
104 color
= GetPixel(hdc
, 2, 0);
105 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
106 color
= GetPixel(hdc
, 1, 1);
107 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
109 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
110 ok(ret
, "BitBlt failed to blank the bitmap!\n");
111 /* Try well ordered rectangle coordinates */
112 ret
= Rectangle(hdc
, 0, 0, 2, 2);
113 ok(ret
, "Rectangle failed!");
114 color
= GetPixel(hdc
, 0, 0);
115 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
116 color
= GetPixel(hdc
, 2, 2);
117 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
118 color
= GetPixel(hdc
, 0, 2);
119 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
120 color
= GetPixel(hdc
, 2, 0);
121 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
122 color
= GetPixel(hdc
, 1, 1);
123 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
126 hBmp
= SelectObject(hdc
, hBmp
);
127 hBrush
= SelectObject(hdc
, hBrush
);
129 DeleteObject(hBrush
);
134 START_TEST(Rectangle
)