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 11 void Test_SetWorldTransform() 12 { 13 HDC hdcScreen, hdc; 14 XFORM xform; 15 BOOL result; 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); 23 SetGraphicsMode(hdc, GM_ADVANCED); 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 ok(xform.eM12 * xform.eM21 != (FLOAT)1.0, "xform.eM12 * xform.eM21 shouldn't be 1.0\n"); 67 result = SetWorldTransform(hdc, &xform); 68 ok(result == 0, "SetWorldTransform should fail\n"); 69 70 /* Test world transform (should be unchanged by previous failure) */ 71 result = GetWorldTransform(hdc, &xform); 72 ok(result == 1, "GetWorldTransform should succeed\n"); 73 ok(xform.eM11 == 2, "xform.eM11 should be 2\n"); 74 ok(xform.eM12 == (FLOAT)3.0001, "xform.eM12 should be 3.0001\n"); 75 ok(xform.eM21 == 4, "xform.eM21 should be 4\n"); 76 ok(xform.eM22 == 6, "xform.eM22 should be 6\n"); 77 78 /* Set smallest possible values */ 79 xform.eM11 = 1.17549435e-38f; 80 xform.eM12 = 0; 81 xform.eM21 = 0; 82 xform.eM22 = 1.17549435e-38f; 83 ok(xform.eM11 != (FLOAT)0.0, "xform.eM11 shouldn't be 0.0\n"); 84 ok(xform.eM22 != (FLOAT)0.0, "xform.eM22 shouldn't be 0.0\n"); 85 ok(xform.eM11 * xform.eM22 != (FLOAT)0.0, "xform.eM12 * xform.eM21 shouldn't be 0.0\n"); 86 result = SetWorldTransform(hdc, &xform); 87 ok(result == 1, "SetWorldTransform should succeed\n"); 88 89 /* Test world transform */ 90 result = GetWorldTransform(hdc, &xform); 91 ok(result == 1, "GetWorldTransform should succeed\n"); 92 ok(xform.eM11 > 0, "xform.eM11 should not be 0\n"); 93 ok(xform.eM12 == 0, "xform.eM12 should be 0\n"); 94 ok(xform.eM21 == 0, "xform.eM21 should be 0\n"); 95 ok(xform.eM22 > 0, "xform.eM22 should not be 0\n"); 96 97 xform.eM11 = 0; 98 xform.eM12 = 1; 99 xform.eM21 = 1; 100 xform.eM22 = 0; 101 result = SetWorldTransform(hdc, &xform); 102 ok_int(result, 1); 103 104 xform.eM11 = 1; 105 xform.eM12 = 1; 106 xform.eM21 = 1; 107 xform.eM22 = 1; 108 result = SetWorldTransform(hdc, &xform); 109 ok_int(result, 0); 110 111 result = GetWorldTransform(hdc, &xform); 112 ok_int(result, 1); 113 ok(xform.eM11 == 0, "xform.eM11 should be 0\n"); 114 ok(xform.eM12 == 1, "xform.eM12 should be 1\n"); 115 ok(xform.eM21 == 1, "xform.eM21 should be 1\n"); 116 ok(xform.eM22 == 0, "xform.eM22 should be 0\n"); 117 118 DeleteDC(hdc); 119 } 120 121 START_TEST(SetWorldTransform) 122 { 123 Test_SetWorldTransform(); 124 } 125