update winetest gdi32 with more wine test

svn path=/trunk/; revision=24264
This commit is contained in:
Magnus Olsen 2006-09-24 22:27:00 +00:00
parent 2b9e96e558
commit 6f10b47b94
4 changed files with 290 additions and 2 deletions

View file

@ -12,6 +12,8 @@
<file>dc.c</file>
<file>gdiobj.c</file>
<file>font.c</file>
<file>mapping.c</file>
<file>metafile.c</file>
<file>palette.c</file>
<file>testlist.c</file>
</module>

View file

@ -0,0 +1,160 @@
/*
* Unit tests for mapping functions
*
* Copyright (c) 2005 Huw Davies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <assert.h>
#include <stdio.h>
#include <math.h>
#include "wine/test.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
void test_modify_world_transform(void)
{
HDC hdc = GetDC(0);
int ret;
ret = SetGraphicsMode(hdc, GM_ADVANCED);
if(!ret) /* running in win9x so quit */
{
ReleaseDC(0, hdc);
return;
}
ret = ModifyWorldTransform(hdc, NULL, MWT_IDENTITY);
ok(ret, "ret = %d\n", ret);
ret = ModifyWorldTransform(hdc, NULL, MWT_LEFTMULTIPLY);
ok(!ret, "ret = %d\n", ret);
ret = ModifyWorldTransform(hdc, NULL, MWT_RIGHTMULTIPLY);
ok(!ret, "ret = %d\n", ret);
ReleaseDC(0, hdc);
}
void test_SetWindowExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
{
SIZE windowExt, viewportExt;
POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
GetWindowOrgEx(hdc, &windowOrg);
GetViewportOrgEx(hdc, &viewportOrg);
SetWindowExtEx(hdc, cx, cy, NULL);
GetWindowExtEx(hdc, &windowExt);
ok(windowExt.cx == cx && windowExt.cy == cy,
"Window extension: Expected %ldx%ld, got %ldx%ld\n",
cx, cy, windowExt.cx, windowExt.cy);
GetViewportExtEx(hdc, &viewportExt);
ok(viewportExt.cx == expected_vp_cx && viewportExt.cy == expected_vp_cy,
"Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n",
expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
GetWindowOrgEx(hdc, &windowOrgAfter);
ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
"Window origin changed from (%ld,%ld) to (%ld,%ld)\n",
windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
GetViewportOrgEx(hdc, &viewportOrgAfter);
ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
"Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n",
viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
}
void test_SetViewportExt(HDC hdc, LONG cx, LONG cy, LONG expected_vp_cx, LONG expected_vp_cy)
{
SIZE windowExt, windowExtAfter, viewportExt;
POINT windowOrg, windowOrgAfter, viewportOrg, viewportOrgAfter;
GetWindowOrgEx(hdc, &windowOrg);
GetViewportOrgEx(hdc, &viewportOrg);
GetWindowExtEx(hdc, &windowExt);
SetViewportExtEx(hdc, cx, cy, NULL);
GetViewportExtEx(hdc, &viewportExt);
ok(viewportExt.cx == expected_vp_cx && viewportExt.cy == expected_vp_cy,
"Viewport extents have not been properly adjusted: Expected %ldx%ld, got %ldx%ld\n",
expected_vp_cx, expected_vp_cy, viewportExt.cx, viewportExt.cy);
GetWindowExtEx(hdc, &windowExtAfter);
ok(windowExt.cx == windowExtAfter.cx && windowExt.cy == windowExtAfter.cy,
"Window extension changed from %ldx%ld to %ldx%ld\n",
windowExt.cx, windowExt.cy, windowExtAfter.cx, windowExtAfter.cy);
GetWindowOrgEx(hdc, &windowOrgAfter);
ok(windowOrg.x == windowOrgAfter.x && windowOrg.y == windowOrgAfter.y,
"Window origin changed from (%ld,%ld) to (%ld,%ld)\n",
windowOrg.x, windowOrg.y, windowOrgAfter.x, windowOrgAfter.y);
GetViewportOrgEx(hdc, &viewportOrgAfter);
ok(viewportOrg.x == viewportOrgAfter.x && viewportOrg.y == viewportOrgAfter.y,
"Viewport origin changed from (%ld,%ld) to (%ld,%ld)\n",
viewportOrg.x, viewportOrg.y, viewportOrgAfter.x, viewportOrgAfter.y);
}
void test_isotropic_mapping(void)
{
SIZE win, vp;
HDC hdc = GetDC(0);
SetMapMode(hdc, MM_ISOTROPIC);
/* MM_ISOTROPIC is set up like MM_LOMETRIC.
Initial values after SetMapMode():
(1 inch = 25.4 mm)
Windows 9x: Windows NT:
Window Ext: 254 x -254 HORZSIZE*10 x VERTSIZE*10
Viewport Ext: LOGPIXELSX x LOGPIXELSY HORZRES x -VERTRES
To test without rounding errors, we have to use multiples of
these values!
*/
GetWindowExtEx(hdc, &win);
GetViewportExtEx(hdc, &vp);
test_SetViewportExt(hdc, 10 * vp.cx, 10 * vp.cy, 10 * vp.cx, 10 * vp.cy);
test_SetWindowExt(hdc, win.cx, win.cy, 10 * vp.cx, 10 * vp.cy);
test_SetWindowExt(hdc, 2 * win.cx, win.cy, 10 * vp.cx, 5 * vp.cy);
test_SetWindowExt(hdc, win.cx, win.cy, 5 * vp.cx, 5 * vp.cy);
test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
test_SetViewportExt(hdc, vp.cx, 2 * vp.cy, vp.cx, vp.cy);
test_SetViewportExt(hdc, 2 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
test_SetViewportExt(hdc, 4 * vp.cx, 2 * vp.cy, 2 * vp.cx, 2 * vp.cy);
test_SetWindowExt(hdc, 4 * win.cx, 2 * win.cy, 2 * vp.cx, vp.cy);
test_SetViewportExt(hdc, -2 * vp.cx, -4 * vp.cy, -2 * vp.cx, -vp.cy);
test_SetViewportExt(hdc, -2 * vp.cx, -1 * vp.cy, -2 * vp.cx, -vp.cy);
test_SetWindowExt(hdc, -4 * win.cx, -2 * win.cy, -2 * vp.cx, -vp.cy);
test_SetWindowExt(hdc, 4 * win.cx, -4 * win.cy, -vp.cx, -vp.cy);
ReleaseDC(0, hdc);
}
START_TEST(mapping)
{
test_modify_world_transform();
test_isotropic_mapping();
}

View file

@ -0,0 +1,126 @@
/*
* Unit test suite for palettes
*
* Copyright 2005 Glenn Wurster
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "mmsystem.h"
#include "wine/test.h"
static const PALETTEENTRY logpalettedata[8] = {
{ 0x10, 0x20, 0x30, PC_NOCOLLAPSE },
{ 0x20, 0x30, 0x40, PC_NOCOLLAPSE },
{ 0x30, 0x40, 0x50, PC_NOCOLLAPSE },
{ 0x40, 0x50, 0x60, PC_NOCOLLAPSE },
{ 0x50, 0x60, 0x70, PC_NOCOLLAPSE },
{ 0x60, 0x70, 0x80, PC_NOCOLLAPSE },
{ 0x70, 0x80, 0x90, PC_NOCOLLAPSE },
{ 0x80, 0x90, 0xA0, PC_NOCOLLAPSE },
};
static void test_DIB_PAL_COLORS(void) {
HDC hdc = GetDC( NULL );
HDC memhdc = CreateCompatibleDC( hdc );
HBITMAP hbmp, hbmpOld;
char bmpbuf[sizeof(BITMAPINFO) + 10 * sizeof(WORD)];
PBITMAPINFO bmp = (PBITMAPINFO)bmpbuf;
WORD * bmpPalPtr;
char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
PLOGPALETTE logpalette = (PLOGPALETTE)logpalettebuf;
HPALETTE hpal, hpalOld;
COLORREF setColor, chkColor, getColor;
int i;
/* Initalize the logical palette with a few colours */
logpalette->palVersion = 0x300;
logpalette->palNumEntries = 8;
memcpy( logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata) );
hpal = CreatePalette( logpalette );
hpalOld = SelectPalette( memhdc, hpal, FALSE );
ok( hpalOld != NULL, "error=%ld\n", GetLastError() );
/* Create a DIB BMP which references colours in the logical palette */
memset( bmp, 0x00, sizeof(BITMAPINFO) );
bmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmp->bmiHeader.biWidth = 1;
bmp->bmiHeader.biHeight = 1;
bmp->bmiHeader.biPlanes = 1;
bmp->bmiHeader.biBitCount = 8;
bmp->bmiHeader.biCompression = BI_RGB;
bmp->bmiHeader.biClrUsed = 10;
bmp->bmiHeader.biClrImportant = 0;
bmpPalPtr = (WORD *)&bmp->bmiColors;
for( i = 0; i < 8; i++ ) {
*bmpPalPtr++ = i;
}
*bmpPalPtr++ = 8; /* Pointer to logical palette index just outside range */
*bmpPalPtr++ = 19; /* Pointer to bad logical palette index */
hbmp = CreateDIBSection( memhdc, bmp, DIB_PAL_COLORS, 0, 0, 0 );
ok( hbmp != NULL, "error=%ld\n", GetLastError() );
hbmpOld = SelectObject( memhdc, hbmp );
ok( hbmpOld != NULL, "error=%ld\n", GetLastError() );
/* Test with a RGB to DIB_PAL_COLORS */
setColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
SetPixel( memhdc, 0, 0, setColor );
chkColor = RGB( logpalettedata[1].peRed, logpalettedata[1].peGreen, logpalettedata[1].peBlue );
getColor = GetPixel( memhdc, 0, 0 );
ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
/* Test with a valid DIBINDEX to DIB_PAL_COLORS */
setColor = DIBINDEX( 2 );
SetPixel( memhdc, 0, 0, setColor );
chkColor = RGB( logpalettedata[2].peRed, logpalettedata[2].peGreen, logpalettedata[2].peBlue );
getColor = GetPixel( memhdc, 0, 0 );
ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
/* Test with a invalid DIBINDEX to DIB_PAL_COLORS */
setColor = DIBINDEX( 12 );
SetPixel( memhdc, 0, 0, setColor );
chkColor = RGB( 0, 0, 0 );
getColor = GetPixel( memhdc, 0, 0 );
ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
/* Test for double wraparound on logical palette references from */
/* DIBINDEX by DIB_PAL_COLORS. */
setColor = DIBINDEX( 9 );
SetPixel( memhdc, 0, 0, setColor );
chkColor = RGB( logpalettedata[3].peRed, logpalettedata[3].peGreen, logpalettedata[3].peBlue );
getColor = GetPixel( memhdc, 0, 0 );
ok( getColor == chkColor, "getColor=%08X\n", (UINT)getColor );
SelectPalette( memhdc, hpalOld, FALSE );
DeleteObject( hpal );
SelectObject( memhdc, hbmpOld );
DeleteObject( hbmp );
DeleteDC( memhdc );
ReleaseDC( NULL, hdc );
}
START_TEST(palette)
{
test_DIB_PAL_COLORS();
}

View file

@ -27,9 +27,9 @@ const struct test winetest_testlist[] =
{ "font", func_font },
{ "gdiobj", func_gdiobj },
// { "generated", func_generated },
// { "mapping", func_mapping },
{ "mapping", func_mapping },
{ "metafile", func_metafile },
// { "palette", func_palette },
{ "palette", func_palette },
// { "pen", func_pen },
{ 0, 0 }
};