ReactOS 0.4.15-dev-6054-gbddd8b0
SetWorldTransform.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 SetWorldTransform
5 * PROGRAMMERS: Timo Kreuzer
6 * Katayama Hirofumi MZ
7 */
8
9#include "precomp.h"
10
12{
13 HDC hdcScreen, hdc;
14 XFORM xform;
16 //PGDI_TABLE_ENTRY pEntry;
17 //DC_ATTR* pdcattr;
18
19 /* Create a DC */
20 hdcScreen = GetDC(NULL);
21 hdc = CreateCompatibleDC(hdcScreen);
22 ReleaseDC(NULL, hdcScreen);
24
25 /* Set identity transform */
26 xform.eM11 = 1;
27 xform.eM12 = 0;
28 xform.eM21 = 0;
29 xform.eM22 = 1;
30 xform.eDx = 0;
31 xform.eDy = 0;
32 result = SetWorldTransform(hdc, &xform);
33 ok(result == 1, "SetWorldTransform should succeed\n");
34
35 /* Set eM11 to 0 */
36 xform.eM11 = 0;
37 result = SetWorldTransform(hdc, &xform);
38 ok(result == 0, "SetWorldTransform should fail\n");
39
40 /* Set eM22 to 0 */
41 xform.eM11 = 1;
42 xform.eM22 = 0;
43 result = SetWorldTransform(hdc, &xform);
44 ok(result == 0, "SetWorldTransform should fail\n");
45
46 /* Set values that result in the determinant being 0 */
47 xform.eM11 = 2;
48 xform.eM12 = 3;
49 xform.eM21 = 4;
50 xform.eM22 = 6;
51 result = SetWorldTransform(hdc, &xform);
52 ok(result == 0, "SetWorldTransform should fail\n");
53
54 /* Small modification to make the determinant != 0 */
55 xform.eM12 = (FLOAT)3.0001;
56 result = SetWorldTransform(hdc, &xform);
57 ok(result == 1, "SetWorldTransform should succeed\n");
58
59 /* Set values that result in the determinant being 0 due to rounding */
60 xform.eM11 = 1;
61 xform.eM12 = (FLOAT)0.9999999;
62 xform.eM21 = (FLOAT)1.0000001;
63 xform.eM22 = 1;
64 ok(xform.eM12 != (FLOAT)1.0, "xform.eM12 shouldn't be 1.0\n");
65 ok(xform.eM21 != (FLOAT)1.0, "xform.eM21 shouldn't be 1.0\n");
66#if 0 // FIXME: x86 uses 80 bits internally, so the result doesn't reflect the actual FLOAT result
67 ok(xform.eM12 * xform.eM21 != (FLOAT)1.0, "xform.eM12 * xform.eM21 shouldn't be 1.0\n");
68#endif
69 result = SetWorldTransform(hdc, &xform);
70 ok(result == 0, "SetWorldTransform should fail\n");
71
72 /* Test world transform (should be unchanged by previous failure) */
73 result = GetWorldTransform(hdc, &xform);
74 ok(result == 1, "GetWorldTransform should succeed\n");
75 ok(xform.eM11 == 2, "xform.eM11 should be 2\n");
76 ok(xform.eM12 == (FLOAT)3.0001, "xform.eM12 should be 3.0001\n");
77 ok(xform.eM21 == 4, "xform.eM21 should be 4\n");
78 ok(xform.eM22 == 6, "xform.eM22 should be 6\n");
79
80 /* Set smallest possible values */
81 xform.eM11 = 1.17549435e-38f;
82 xform.eM12 = 0;
83 xform.eM21 = 0;
84 xform.eM22 = 1.17549435e-38f;
85 ok(xform.eM11 != (FLOAT)0.0, "xform.eM11 shouldn't be 0.0\n");
86 ok(xform.eM22 != (FLOAT)0.0, "xform.eM22 shouldn't be 0.0\n");
87#if 0 // FIXME: x86 uses 80 bits internally, so the result doesn't reflect the actual FLOAT result
88 ok(xform.eM11 * xform.eM22 != (FLOAT)0.0, "xform.eM12 * xform.eM21 shouldn't be 0.0\n");
89#endif
90 result = SetWorldTransform(hdc, &xform);
91 ok(result == 1, "SetWorldTransform should succeed\n");
92
93 /* Test world transform */
94 result = GetWorldTransform(hdc, &xform);
95 ok(result == 1, "GetWorldTransform should succeed\n");
96 ok(xform.eM11 > 0, "xform.eM11 should not be 0\n");
97 ok(xform.eM12 == 0, "xform.eM12 should be 0\n");
98 ok(xform.eM21 == 0, "xform.eM21 should be 0\n");
99 ok(xform.eM22 > 0, "xform.eM22 should not be 0\n");
100
101 xform.eM11 = 0;
102 xform.eM12 = 1;
103 xform.eM21 = 1;
104 xform.eM22 = 0;
105 result = SetWorldTransform(hdc, &xform);
106 ok_int(result, 1);
107
108 xform.eM11 = 1;
109 xform.eM12 = 1;
110 xform.eM21 = 1;
111 xform.eM22 = 1;
112 result = SetWorldTransform(hdc, &xform);
113 ok_int(result, 0);
114
115 result = GetWorldTransform(hdc, &xform);
116 ok_int(result, 1);
117 ok(xform.eM11 == 0, "xform.eM11 should be 0\n");
118 ok(xform.eM12 == 1, "xform.eM12 should be 1\n");
119 ok(xform.eM21 == 1, "xform.eM21 should be 1\n");
120 ok(xform.eM22 == 0, "xform.eM22 should be 0\n");
121
122 DeleteDC(hdc);
123}
124
126{
128}
void Test_SetWorldTransform()
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define ok_int(expression, result)
Definition: atltest.h:134
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint64EXT * result
Definition: glext.h:11304
#define FLOAT
Definition: i386-dis.c:525
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
FLOAT eDy
Definition: wingdi.h:1726
FLOAT eM11
Definition: wingdi.h:1721
FLOAT eM21
Definition: wingdi.h:1723
FLOAT eM22
Definition: wingdi.h:1724
FLOAT eM12
Definition: wingdi.h:1722
FLOAT eDx
Definition: wingdi.h:1725
float FLOAT
Definition: typedefs.h:69
int WINAPI SetGraphicsMode(_In_ HDC, _In_ int)
Definition: dc.c:1226
#define GM_ADVANCED
Definition: wingdi.h:865
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI GetWorldTransform(_In_ HDC, _Out_ LPXFORM)
Definition: coord.c:278
BOOL WINAPI SetWorldTransform(_In_ HDC, _In_ const XFORM *)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)