2011-01-16 20:53:48 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for ...
|
|
|
|
* PROGRAMMERS: Timo Kreuzer
|
|
|
|
*/
|
|
|
|
|
2013-09-22 17:52:42 +00:00
|
|
|
#include <apitest.h>
|
|
|
|
|
2013-02-05 17:54:22 +00:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
void Test_DPtoLP_Params()
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
POINT apt[2];
|
|
|
|
|
|
|
|
apt[0].x = 0;
|
|
|
|
apt[0].y = 0;
|
|
|
|
apt[1].x = -1000;
|
|
|
|
apt[1].y = 1000;
|
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, NULL, 0), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, NULL, -1), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, (PVOID)0x80000000, -1), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, NULL, 2), 0);
|
|
|
|
ok_err(ERROR_INVALID_PARAMETER);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, apt, 2), 0);
|
|
|
|
ok_err(ERROR_INVALID_PARAMETER);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, apt, 0), 1);
|
|
|
|
ok(GetLastError() == ERROR_SUCCESS, "Exected ERROR_SUCCESS, got %ld\n", GetLastError());
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(NULL, apt, -2), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP((HDC)-4, apt, -2), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(hdc, NULL, 2), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
hdc = GetDC(0);
|
|
|
|
SetLastError(ERROR_SUCCESS);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(hdc, (PVOID)0x80000000, 2), 1);
|
|
|
|
ok_err(ERROR_SUCCESS);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Test_DPtoLP()
|
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
POINT apt[2];
|
|
|
|
XFORM xform;
|
2012-05-05 14:19:22 +00:00
|
|
|
LONG lLogPixelsX, lLogPixelsY;
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
apt[0].x = 1;
|
|
|
|
apt[0].y = 1;
|
|
|
|
apt[1].x = -1000;
|
|
|
|
apt[1].y = 1000;
|
|
|
|
|
|
|
|
hdc = GetDC(0);
|
2012-05-05 14:19:22 +00:00
|
|
|
lLogPixelsX = GetDeviceCaps(hdc, LOGPIXELSX);
|
|
|
|
lLogPixelsY = GetDeviceCaps(hdc, LOGPIXELSY);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
SetMapMode(hdc, MM_TEXT);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
2011-01-16 20:53:48 +00:00
|
|
|
ok_int(apt[0].x, 1);
|
|
|
|
ok_int(apt[0].y, 1);
|
|
|
|
ok_int(apt[1].x, -1000);
|
|
|
|
ok_int(apt[1].y, 1000);
|
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000;
|
2011-01-16 20:53:48 +00:00
|
|
|
SetMapMode(hdc, MM_LOMETRIC);
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, 33888 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, -86688 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -338688 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, -338688 );
|
2011-01-16 20:53:48 +00:00
|
|
|
SetGraphicsMode(hdc, GM_ADVANCED);
|
|
|
|
SetMapMode(hdc, MM_ANISOTROPIC);
|
|
|
|
|
|
|
|
xform.eM11 = 1.;
|
|
|
|
xform.eM12 = 0.;
|
|
|
|
xform.eM21 = 0.;
|
|
|
|
xform.eM22 = 1.;
|
2012-05-05 14:19:22 +00:00
|
|
|
xform.eDx = (FLOAT)4294967167.999999761;
|
2011-01-16 20:53:48 +00:00
|
|
|
xform.eDy = 1.;
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
2011-01-16 20:53:48 +00:00
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000;
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, 58464 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, -86784 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -314112 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, -338784 );
|
2011-01-16 20:53:48 +00:00
|
|
|
|
2012-05-05 14:19:22 +00:00
|
|
|
apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000;
|
2011-01-16 20:53:48 +00:00
|
|
|
xform.eM11 = 10000000.;
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, -41184 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, -86784 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -41184 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, -338784 );
|
|
|
|
|
|
|
|
apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000;
|
2011-01-16 20:53:48 +00:00
|
|
|
xform.eM11 = 1.;
|
2012-05-05 14:19:22 +00:00
|
|
|
xform.eDx = (FLOAT)4294967167.999999762; // this is too big
|
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 0);
|
|
|
|
ok_int(apt[0].x, 100 );
|
|
|
|
ok_int(apt[0].y, 256 );
|
|
|
|
ok_int(apt[1].x, -1000 );
|
|
|
|
ok_int(apt[1].y, 1000 );
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
xform.eM11 = 2.;
|
2012-05-05 14:19:22 +00:00
|
|
|
xform.eDx = (FLOAT)4294967167.999999762;
|
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, 16896 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, -86784 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -169344 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, -338784 );
|
|
|
|
|
|
|
|
apt[0].x = 100; apt[0].y = 256; apt[1].x = -1000; apt[1].y = 1000;
|
2011-01-16 20:53:48 +00:00
|
|
|
xform.eM11 = 10000000.;
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, -41184 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, -86784 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -41184 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, -338784 );
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
xform.eM11 = 1000000.;
|
2012-05-05 14:19:22 +00:00
|
|
|
ok_int(SetWorldTransform(hdc, &xform), 1);
|
|
|
|
ok_int(DPtoLP(hdc, apt, 2), 1);
|
|
|
|
ok_int(apt[0].x * lLogPixelsX, -412320 );
|
|
|
|
ok_int(apt[0].y * lLogPixelsY, 306048 );
|
|
|
|
ok_int(apt[1].x * lLogPixelsX, -412320 );
|
|
|
|
ok_int(apt[1].y * lLogPixelsY, 1195104 );
|
2011-01-16 20:53:48 +00:00
|
|
|
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(DPtoLP)
|
|
|
|
{
|
|
|
|
Test_DPtoLP_Params();
|
|
|
|
Test_DPtoLP();
|
|
|
|
}
|
|
|
|
|