2 * Unit tests for mapping functions
4 * Copyright (c) 2005 Huw Davies
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #include "wine/test.h"
32 static void test_modify_world_transform(void)
37 ret = SetGraphicsMode(hdc, GM_ADVANCED);
38 if(!ret) /* running in win9x so quit */
44 ret = ModifyWorldTransform(hdc, NULL, MWT_IDENTITY);
45 ok(ret, "ret = %d\n", ret);
47 ret = ModifyWorldTransform(hdc, NULL, MWT_LEFTMULTIPLY);
48 ok(!ret, "ret = %d\n", ret);
50 ret = ModifyWorldTransform(hdc, NULL, MWT_RIGHTMULTIPLY);
51 ok(!ret, "ret = %d\n", ret);
56 #define rough_match(got, expected) ((got >= expected - 2) && (got <= expected + 2))
58 static void test_SetWindowExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
60 SIZE windowExt, viewportExt;
61 POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
63 GetWindowOrgEx(hdc, &windowOrg);
64 GetViewportOrgEx(hdc, &viewportOrg);
66 SetWindowExtEx(hdc, cx, cy, NULL);
67 GetWindowExtEx(hdc, &windowExt);
68 ok(windowExt.cx == cx && windowExt.cy == cy,
69 "Window extension: Expected %dx%d, got %dx%d\n",
70 cx, cy, windowExt.cx, windowExt.cy);
72 GetViewportExtEx(hdc, &viewportExt);
73 ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
74 "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
75 expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
77 GetWindowOrgEx(hdc, &windowOrgAfter);
78 ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
79 "Window origin changed from (%d,%d) to (%d,%d)\n",
80 windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
82 GetViewportOrgEx(hdc, &viewportOrgAfter);
83 ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
84 "Viewport origin changed from (%d,%d) to (%d,%d)\n",
85 viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
88 static void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
90 SIZE windowExt, windowExtAfter, viewportExt;
91 POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
93 GetWindowOrgEx(hdc, &windowOrg);
94 GetViewportOrgEx(hdc, &viewportOrg);
95 GetWindowExtEx(hdc, &windowExt);
97 SetViewportExtEx(hdc, cx, cy, NULL);
98 GetViewportExtEx(hdc, &viewportExt);
99 ok(rough_match(viewportExt.cx, expected_vp_cx) && rough_match(viewportExt.cy, expected_vp_cy),
100 "Viewport extents have not been properly adjusted: Expected %dx%d, got %dx%d\n",
101 expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
103 GetWindowExtEx(hdc, &windowExtAfter);
104 ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
105 "Window extension changed from %dx%d to %dx%d\n",
106 windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);
108 GetWindowOrgEx(hdc, &windowOrgAfter);
109 ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
110 "Window origin changed from (%d,%d) to (%d,%d)\n",
111 windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
113 GetViewportOrgEx(hdc, &viewportOrgAfter);
114 ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
115 "Viewport origin changed from (%d,%d) to (%d,%d)\n",
116 viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
119 static void test_isotropic_mapping(void)
124 SetMapMode(hdc, MM_ISOTROPIC);
126 /* MM_ISOTROPIC is set up like MM_LOMETRIC.
127 Initial values after SetMapMode():
130 Windows 9x: Windows NT:
131 Window Ext: 254 x -254 HORZSIZE*10 x VERTSIZE*10
132 Viewport Ext: LOGPIXELSX x LOGPIXELSY HORZRES x -VERTRES
134 To test without rounding errors, we have to use multiples of
138 GetWindowExtEx(hdc, &win);
139 GetViewportExtEx(hdc, &vp);
141 test_SetViewportExt(hdc, 10 * vp.cx, 10 * vp.cy, 10 * vp.cx, 10 * vp.cy);
142 test_SetWindowExt(hdc, win.cx, win.cy, 10 * vp.cx, 10 * vp.cy);
143 test_SetWindowExt(hdc, 2 * win.cx, win.cy, 10 * vp.cx, 5 * vp.cy);
144 test_SetWindowExt(hdc, win.cx, win.cy, 5 * vp.cx, 5 * vp.cy);
145 test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
146 test_SetViewportExt(hdc, vp.cx, 2 * vp.cy, vp.cx, vp.cy);
147 test_SetViewportExt(hdc, 2 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
148 test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
149 test_SetWindowExt(hdc, 4 * win.cx, 2 * win.cy, 2 * vp.cx, vp.cy);
150 test_SetViewportExt(hdc, -2 * vp.cx, -4 * vp.cy, -2 * vp.cx, -vp.cy);
151 test_SetViewportExt(hdc, -2 * vp.cx, -1 * vp.cy, -2 * vp.cx, -vp.cy);
152 test_SetWindowExt(hdc, -4 * win.cx, -2 * win.cy, -2 * vp.cx, -vp.cy);
153 test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy);
160 test_modify_world_transform();
161 test_isotropic_mapping();