44030a9a0487c4c6249e871a726935db383e0541
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
12 void Test_Rectangle(void)
21 hdc
= CreateCompatibleDC(NULL
);
22 ok(hdc
!= NULL
, "Failed to create the DC!\n");
23 hBmp
= CreateCompatibleBitmap(hdc
, 4, 4);
24 ok(hBmp
!= NULL
, "Failed to create the Bitmap!\n");
25 hBmp
= SelectObject(hdc
, hBmp
);
26 ok(hBmp
!= NULL
, "Failed to select the Bitmap!\n");
28 hBrush
= CreateSolidBrush(RGB(0, 0, 0));
29 ok(hBrush
!= NULL
, "Failed to create a solid brush!\n");
30 hBrush
= SelectObject(hdc
, hBrush
);
31 ok(hBrush
!= NULL
, "Failed to select the brush!\n");
33 /* Blank the bitmap */
34 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
35 ok(ret
, "BitBlt failed to blank the bitmap!\n");
37 /* Try inverted rectangle coordinates */
38 ret
= Rectangle(hdc
, 0, 2, 2, 0);
39 ok(ret
, "Rectangle failed!");
40 color
= GetPixel(hdc
, 0, 0);
41 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
42 color
= GetPixel(hdc
, 2, 2);
43 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
44 color
= GetPixel(hdc
, 0, 2);
45 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
46 color
= GetPixel(hdc
, 2, 0);
47 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
48 color
= GetPixel(hdc
, 1, 1);
49 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
51 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
52 ok(ret
, "BitBlt failed to blank the bitmap!\n");
53 /* Try well ordered rectangle coordinates */
54 ret
= Rectangle(hdc
, 0, 0, 2, 2);
55 ok(ret
, "Rectangle failed!");
56 color
= GetPixel(hdc
, 0, 0);
57 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
58 color
= GetPixel(hdc
, 2, 2);
59 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
60 color
= GetPixel(hdc
, 0, 2);
61 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
62 color
= GetPixel(hdc
, 2, 0);
63 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
64 color
= GetPixel(hdc
, 1, 1);
65 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
67 /* tests with NULL pen */
68 hPen
= SelectObject(hdc
, GetStockObject(NULL_PEN
));
70 /* Blank the bitmap */
71 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
72 ok(ret
, "BitBlt failed to blank the bitmap!\n");
74 ret
= Rectangle(hdc
, 0, 0, 3, 3);
75 ok(ret
, "Rectangle failed!");
76 color
= GetPixel(hdc
, 0, 0);
77 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
78 color
= GetPixel(hdc
, 2, 2);
79 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
80 color
= GetPixel(hdc
, 0, 2);
81 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
82 color
= GetPixel(hdc
, 2, 0);
83 ok( color
== RGB(255, 255, 255), "Expected 0x00FFFFFF, got 0x%08x\n", (UINT
)color
);
84 color
= GetPixel(hdc
, 1, 1);
85 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
87 SelectObject(hdc
, hPen
);
89 /* Same tests with GM_ADVANCED */
90 ok(SetGraphicsMode(hdc
, GM_ADVANCED
) == GM_COMPATIBLE
, "Default mode for the DC is not GM_COMPATIBLE.\n");
92 /* Blank the bitmap */
93 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
94 ok(ret
, "BitBlt failed to blank the bitmap!\n");
96 /* Try inverted rectangle coordinates */
97 ret
= Rectangle(hdc
, 0, 2, 2, 0);
98 ok(ret
, "Rectangle failed!");
99 color
= GetPixel(hdc
, 0, 0);
100 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
101 color
= GetPixel(hdc
, 2, 2);
102 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
103 color
= GetPixel(hdc
, 0, 2);
104 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
105 color
= GetPixel(hdc
, 2, 0);
106 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
107 color
= GetPixel(hdc
, 1, 1);
108 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
110 ret
= BitBlt(hdc
, 0, 0, 4, 4, NULL
, 0, 0, WHITENESS
);
111 ok(ret
, "BitBlt failed to blank the bitmap!\n");
112 /* Try well ordered rectangle coordinates */
113 ret
= Rectangle(hdc
, 0, 0, 2, 2);
114 ok(ret
, "Rectangle failed!");
115 color
= GetPixel(hdc
, 0, 0);
116 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
117 color
= GetPixel(hdc
, 2, 2);
118 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
119 color
= GetPixel(hdc
, 0, 2);
120 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
121 color
= GetPixel(hdc
, 2, 0);
122 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
123 color
= GetPixel(hdc
, 1, 1);
124 ok( color
== RGB(0, 0, 0), "Expected 0, got 0x%08x\n", (UINT
)color
);
127 hBmp
= SelectObject(hdc
, hBmp
);
128 hBrush
= SelectObject(hdc
, hBrush
);
130 DeleteObject(hBrush
);
135 START_TEST(Rectangle
)