Sweden-Number/dlls/gdiplus/tests/metafile.c

90 lines
2.6 KiB
C
Raw Normal View History

2011-01-27 00:23:44 +01:00
/*
* Unit test suite for metafiles
*
* Copyright (C) 2011 Vincent Povirk for CodeWeavers
*
* 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 "windows.h"
#include <stdio.h>
#include "gdiplus.h"
#include "wine/test.h"
#define expect(expected, got) ok(got == expected, "Expected %.8x, got %.8x\n", expected, got)
static void test_empty(void)
{
GpStatus stat;
GpMetafile *metafile;
GpGraphics *graphics;
HDC hdc;
HENHMETAFILE hemf, dummy;
BOOL ret;
static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
hdc = CreateCompatibleDC(0);
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
todo_wine expect(Ok, stat);
DeleteDC(hdc);
if (stat != Ok)
return;
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(InvalidParameter, stat);
stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
expect(Ok, stat);
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(InvalidParameter, stat);
stat = GdipDeleteGraphics(graphics);
expect(Ok, stat);
stat = GdipGetHemfFromMetafile(metafile, &hemf);
expect(Ok, stat);
stat = GdipGetHemfFromMetafile(metafile, &dummy);
expect(InvalidParameter, stat);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
ret = DeleteEnhMetaFile(hemf);
ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
}
START_TEST(metafile)
{
struct GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
gdiplusStartupInput.GdiplusVersion = 1;
gdiplusStartupInput.DebugEventCallback = NULL;
gdiplusStartupInput.SuppressBackgroundThread = 0;
gdiplusStartupInput.SuppressExternalCodecs = 0;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
test_empty();
GdiplusShutdown(gdiplusToken);
}