1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for ... 5 * PROGRAMMERS: Timo Kreuzer 6 */ 7 8 #include "precomp.h" 9 10 void Test_DPtoLP_Params() 11 { 12 HDC hdc; 13 POINT apt[2]; 14 15 apt[0].x = 0; 16 apt[0].y = 0; 17 apt[1].x = -1000; 18 apt[1].y = 1000; 19 20 SetLastError(ERROR_SUCCESS); 21 ok_int(DPtoLP(NULL, NULL, 0), 1); 22 ok_err(ERROR_SUCCESS); 23 24 ok_int(DPtoLP(NULL, NULL, -1), 1); 25 ok_err(ERROR_SUCCESS); 26 27 ok_int(DPtoLP(NULL, (PVOID)0x80000000, -1), 1); 28 ok_err(ERROR_SUCCESS); 29 30 ok_int(DPtoLP(NULL, NULL, 2), 0); 31 ok_err(ERROR_INVALID_PARAMETER); 32 33 SetLastError(ERROR_SUCCESS); 34 ok_int(DPtoLP(NULL, apt, 2), 0); 35 ok_err(ERROR_INVALID_PARAMETER); 36 37 SetLastError(ERROR_SUCCESS); 38 ok_int(DPtoLP(NULL, apt, 0), 1); 39 ok(GetLastError() == ERROR_SUCCESS, "Exected ERROR_SUCCESS, got %ld\n", GetLastError()); 40 41 SetLastError(ERROR_SUCCESS); 42 ok_int(DPtoLP(NULL, apt, -2), 1); 43 ok_err(ERROR_SUCCESS); 44 45 SetLastError(ERROR_SUCCESS); 46 ok_int(DPtoLP((HDC)-4, apt, -2), 1); 47 ok_err(ERROR_SUCCESS); 48 49 hdc = GetDC(0); 50 SetLastError(ERROR_SUCCESS); 51 ok_int(DPtoLP(hdc, NULL, 2), 1); 52 ok_err(ERROR_SUCCESS); 53 54 hdc = GetDC(0); 55 SetLastError(ERROR_SUCCESS); 56 ok_int(DPtoLP(hdc, (PVOID)0x80000000, 2), 1); 57 ok_err(ERROR_SUCCESS); 58 59 60 ReleaseDC(0, hdc); 61 } 62 63 void Test_DPtoLP() 64 { 65 HDC hdc; 66 POINT apt[2]; 67 XFORM xform; 68 LONG lLogPixelsX, lLogPixelsY; 69 70 apt[0].x = 1; 71 apt[0].y = 1; 72 apt[1].x = -1000; 73 apt[1].y = 1000; 74 75 hdc = GetDC(0); 76 lLogPixelsX = GetDeviceCaps(hdc, LOGPIXELSX); 77 lLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY); 78 79 SetMapMode(hdc, MM_TEXT); 80 ok_int(DPtoLP(hdc, apt, 2), 1); 81 ok_int(apt[0].x, 1); 82 ok_int(apt[0].y, 1); 83 ok_int(apt[1].x, -1000); 84 ok_int(apt[1].y, 1000); 85 86 apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000; 87 SetMapMode(hdc, MM_LOMETRIC); 88 ok_int(DPtoLP(hdc, apt, 2), 1); 89 ok_int(apt[0].x * lLogPixelsX, 33888 ); 90 ok_int(apt[0].y * lLogPixelsY, -86688 ); 91 ok_int(apt[1].x * lLogPixelsX, -338688 ); 92 ok_int(apt[1].y * lLogPixelsY, -338688 ); 93 SetGraphicsMode(hdc, GM_ADVANCED); 94 SetMapMode(hdc, MM_ANISOTROPIC); 95 96 xform.eM11 = 1.; 97 xform.eM12 = 0.; 98 xform.eM21 = 0.; 99 xform.eM22 = 1.; 100 xform.eDx = (FLOAT)4294967167.999999761; 101 xform.eDy = 1.; 102 ok_int(SetWorldTransform(hdc, &xform), 1); 103 104 apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000; 105 ok_int(DPtoLP(hdc, apt, 2), 1); 106 ok_int(apt[0].x * lLogPixelsX, 58464 ); 107 ok_int(apt[0].y * lLogPixelsY, -86784 ); 108 ok_int(apt[1].x * lLogPixelsX, -314112 ); 109 ok_int(apt[1].y * lLogPixelsY, -338784 ); 110 111 apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000; 112 xform.eM11 = 10000000.; 113 ok_int(SetWorldTransform(hdc, &xform), 1); 114 ok_int(DPtoLP(hdc, apt, 2), 1); 115 ok_int(apt[0].x * lLogPixelsX, -41184 ); 116 ok_int(apt[0].y * lLogPixelsY, -86784 ); 117 ok_int(apt[1].x * lLogPixelsX, -41184 ); 118 ok_int(apt[1].y * lLogPixelsY, -338784 ); 119 120 apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000; 121 xform.eM11 = 1.; 122 xform.eDx = (FLOAT)4294967167.999999762; // this is too big 123 ok_int(SetWorldTransform(hdc, &xform), 1); 124 ok_int(DPtoLP(hdc, apt, 2), 0); 125 ok_int(apt[0].x, 100 ); 126 ok_int(apt[0].y, 256 ); 127 ok_int(apt[1].x, -1000 ); 128 ok_int(apt[1].y, 1000 ); 129 130 xform.eM11 = 2.; 131 xform.eDx = (FLOAT)4294967167.999999762; 132 ok_int(SetWorldTransform(hdc, &xform), 1); 133 ok_int(DPtoLP(hdc, apt, 2), 1); 134 ok_int(apt[0].x * lLogPixelsX, 16896 ); 135 ok_int(apt[0].y * lLogPixelsY, -86784 ); 136 ok_int(apt[1].x * lLogPixelsX, -169344 ); 137 ok_int(apt[1].y * lLogPixelsY, -338784 ); 138 139 apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000; 140 xform.eM11 = 10000000.; 141 ok_int(SetWorldTransform(hdc, &xform), 1); 142 ok_int(DPtoLP(hdc, apt, 2), 1); 143 ok_int(apt[0].x * lLogPixelsX, -41184 ); 144 ok_int(apt[0].y * lLogPixelsY, -86784 ); 145 ok_int(apt[1].x * lLogPixelsX, -41184 ); 146 ok_int(apt[1].y * lLogPixelsY, -338784 ); 147 148 xform.eM11 = 1000000.; 149 ok_int(SetWorldTransform(hdc, &xform), 1); 150 ok_int(DPtoLP(hdc, apt, 2), 1); 151 ok_int(apt[0].x * lLogPixelsX, -412320 ); 152 ok_int(apt[0].y * lLogPixelsY, 306048 ); 153 ok_int(apt[1].x * lLogPixelsX, -412320 ); 154 ok_int(apt[1].y * lLogPixelsY, 1195104 ); 155 156 ReleaseDC(0, hdc); 157 } 158 159 START_TEST(DPtoLP) 160 { 161 Test_DPtoLP_Params(); 162 Test_DPtoLP(); 163 } 164 165