2010-08-24 13:54:10 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS api tests
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
|
|
|
* PURPOSE: Test for SetMapMode
|
|
|
|
* PROGRAMMERS: Timo Kreuzer
|
|
|
|
*/
|
2008-10-08 10:58:41 +00:00
|
|
|
|
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>
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2010-10-17 14:50:02 +00:00
|
|
|
#define TEST(x) ok(x, #x"\n")
|
|
|
|
#define RTEST(x) ok(x, #x"\n")
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
void Test_SetMapMode()
|
2008-10-08 10:58:41 +00:00
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
SIZE WindowExt, ViewportExt;
|
2009-01-29 19:16:45 +00:00
|
|
|
ULONG ulMapMode;
|
2008-10-08 10:58:41 +00:00
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
2010-08-24 13:54:10 +00:00
|
|
|
ok(hDC != 0, "CreateCompatibleDC failed, skipping tests.\n");
|
|
|
|
if (!hDC) return;
|
2008-10-08 10:58:41 +00:00
|
|
|
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
|
|
|
|
2009-01-29 19:16:45 +00:00
|
|
|
ulMapMode = SetMapMode(hDC, MM_ISOTROPIC);
|
|
|
|
TEST(ulMapMode == MM_TEXT);
|
|
|
|
TEST(WindowExt.cx == 1);
|
|
|
|
TEST(WindowExt.cy == 1);
|
|
|
|
TEST(ViewportExt.cx == 1);
|
|
|
|
TEST(ViewportExt.cy == 1);
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2009-01-29 19:16:45 +00:00
|
|
|
SetLastError(0);
|
|
|
|
ulMapMode = SetMapMode(hDC, 0);
|
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
|
|
|
|
/* Go through all valid values */
|
|
|
|
ulMapMode = SetMapMode(hDC, 1);
|
|
|
|
TEST(ulMapMode == MM_ISOTROPIC);
|
|
|
|
ulMapMode = SetMapMode(hDC, 2);
|
|
|
|
TEST(ulMapMode == 1);
|
|
|
|
ulMapMode = SetMapMode(hDC, 3);
|
|
|
|
TEST(ulMapMode == 2);
|
|
|
|
ulMapMode = SetMapMode(hDC, 4);
|
|
|
|
TEST(ulMapMode == 3);
|
|
|
|
ulMapMode = SetMapMode(hDC, 5);
|
|
|
|
TEST(ulMapMode == 4);
|
|
|
|
ulMapMode = SetMapMode(hDC, 6);
|
|
|
|
TEST(ulMapMode == 5);
|
|
|
|
ulMapMode = SetMapMode(hDC, 7);
|
|
|
|
TEST(ulMapMode == 6);
|
|
|
|
ulMapMode = SetMapMode(hDC, 8);
|
|
|
|
TEST(ulMapMode == 7);
|
|
|
|
|
|
|
|
/* Test invalid value */
|
|
|
|
ulMapMode = SetMapMode(hDC, 9);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
ulMapMode = SetMapMode(hDC, 10);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
|
|
|
|
TEST(GetLastError() == 0);
|
|
|
|
|
|
|
|
/* Test NULL DC */
|
|
|
|
ulMapMode = SetMapMode((HDC)0, 2);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
/* Test NULL DC and invalid mode */
|
|
|
|
ulMapMode = SetMapMode((HDC)0, 10);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
/* Test invalid DC */
|
|
|
|
ulMapMode = SetMapMode((HDC)0x12345, 2);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
/* Test invalid DC and invalid mode */
|
|
|
|
ulMapMode = SetMapMode((HDC)0x12345, 10);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
/* Test a deleted DC */
|
|
|
|
ulMapMode = SetMapMode(hDC, 2);
|
|
|
|
TEST(ulMapMode == 0);
|
|
|
|
TEST(GetLastError() == ERROR_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
/* Test MM_TEXT */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_TEXT);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
|
|
|
TEST(WindowExt.cx == 1);
|
|
|
|
TEST(WindowExt.cy == 1);
|
|
|
|
TEST(ViewportExt.cx == 1);
|
|
|
|
TEST(ViewportExt.cy == 1);
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
/* Test MM_ISOTROPIC */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
2008-10-08 10:58:41 +00:00
|
|
|
SetMapMode(hDC, MM_ISOTROPIC);
|
2009-01-29 19:16:45 +00:00
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 3600);
|
|
|
|
//TEST(WindowExt.cy == 2700);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
|
|
|
DeleteDC(hDC);
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2009-01-29 19:16:45 +00:00
|
|
|
/* Test MM_ANISOTROPIC */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_ANISOTROPIC);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
|
|
|
TEST(WindowExt.cx == 1);
|
|
|
|
TEST(WindowExt.cy == 1);
|
|
|
|
TEST(ViewportExt.cx == 1);
|
|
|
|
TEST(ViewportExt.cy == 1);
|
|
|
|
|
|
|
|
/* set MM_ISOTROPIC first, the values will be kept */
|
|
|
|
SetMapMode(hDC, MM_ISOTROPIC);
|
|
|
|
SetMapMode(hDC, MM_ANISOTROPIC);
|
2008-10-08 10:58:41 +00:00
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 3600);
|
|
|
|
//TEST(WindowExt.cy == 2700);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
|
|
|
DeleteDC(hDC);
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2009-01-29 19:16:45 +00:00
|
|
|
/* Test MM_LOMETRIC */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_LOMETRIC);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 3600);
|
|
|
|
//TEST(WindowExt.cy == 2700);
|
2008-10-08 10:58:41 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
2009-01-29 19:16:45 +00:00
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
/* Test MM_HIMETRIC */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_HIMETRIC);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 36000);
|
|
|
|
//TEST(WindowExt.cy == 27000);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
/* Test MM_LOENGLISH */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_LOENGLISH);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 1417);
|
|
|
|
//TEST(WindowExt.cy == 1063);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
|
|
|
DeleteDC(hDC);
|
|
|
|
|
|
|
|
/* Test MM_HIENGLISH */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_HIENGLISH);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 14173);
|
|
|
|
//TEST(WindowExt.cy == 10630);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
|
|
|
DeleteDC(hDC);
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2009-01-29 19:16:45 +00:00
|
|
|
/* Test MM_TWIPS */
|
|
|
|
hDC = CreateCompatibleDC(NULL);
|
|
|
|
SetMapMode(hDC, MM_TWIPS);
|
|
|
|
GetWindowExtEx(hDC, &WindowExt);
|
|
|
|
GetViewportExtEx(hDC, &ViewportExt);
|
2010-08-24 13:54:10 +00:00
|
|
|
//TEST(WindowExt.cx == 20409);
|
|
|
|
//TEST(WindowExt.cy == 15307);
|
2009-01-29 19:16:45 +00:00
|
|
|
TEST(ViewportExt.cx == GetDeviceCaps(GetDC(0), HORZRES));
|
|
|
|
TEST(ViewportExt.cy == -GetDeviceCaps(GetDC(0), VERTRES));
|
2008-10-08 10:58:41 +00:00
|
|
|
DeleteDC(hDC);
|
2010-08-24 13:54:10 +00:00
|
|
|
}
|
2008-10-08 10:58:41 +00:00
|
|
|
|
2010-08-24 13:54:10 +00:00
|
|
|
START_TEST(SetMapMode)
|
|
|
|
{
|
|
|
|
Test_SetMapMode();
|
2008-10-08 10:58:41 +00:00
|
|
|
}
|
2010-08-24 13:54:10 +00:00
|
|
|
|