Commit 28df3990 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

gdi32/tests: Add EMF palette tests.

parent f45baaa1
......@@ -4802,6 +4802,83 @@ static void test_mf_palette(void)
ok(ret, "DeleteMetaFile(%p) error %ld\n", hmf, GetLastError());
}
static void test_emf_palette(void)
{
char logpalettebuf[sizeof(LOGPALETTE) + sizeof(logpalettedata)];
LOGPALETTE *logpalette = (PLOGPALETTE)logpalettebuf;
HPALETTE hpal, old_pal, def_pal;
HENHMETAFILE emf;
HDC hdc;
BOOL ret;
static const unsigned char palette_bits[] =
{
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xe6, 0xff, 0xff, 0xff, 0xe6, 0xff, 0xff, 0xff,
0x20, 0x45, 0x4d, 0x46, 0x00, 0x00, 0x01, 0x00,
0xf0, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x80, 0x07, 0x00, 0x00, 0xcd, 0x03, 0x00, 0x00,
0xfc, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x60, 0xc0, 0x07, 0x00,
0x9f, 0xed, 0x03, 0x00, 0x31, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x03, 0x08, 0x00, 0x10, 0x20, 0x30, 0x00,
0x20, 0x30, 0x40, 0x00, 0x30, 0x40, 0x50, 0x00,
0x40, 0x50, 0x60, 0x00, 0x50, 0x60, 0x70, 0x00,
0x60, 0x70, 0x80, 0x00, 0x70, 0x80, 0x90, 0x00,
0x80, 0x90, 0xa0, 0x00, 0x30, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x34, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x30, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00,
0x0f, 0x00, 0x00, 0x80, 0x0e, 0x00, 0x00, 0x00,
0x34, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x10, 0x20, 0x30, 0x00,
0x20, 0x30, 0x40, 0x00, 0x30, 0x40, 0x50, 0x00,
0x40, 0x50, 0x60, 0x00, 0x50, 0x60, 0x70, 0x00,
0x60, 0x70, 0x80, 0x00, 0x70, 0x80, 0x90, 0x00,
0x80, 0x90, 0xa0, 0x00, 0x34, 0x00, 0x00, 0x00
};
hdc = CreateEnhMetaFileA(NULL, NULL, NULL, NULL);
ok(hdc != 0, "CreateMetaFileA error %ld\n", GetLastError());
/* Initialize the logical palette with a few colours */
logpalette->palVersion = 0x300;
logpalette->palNumEntries = ARRAY_SIZE(logpalettedata);
memcpy(logpalette->palPalEntry, logpalettedata, sizeof(logpalettedata));
hpal = CreatePalette(logpalette);
old_pal = SelectPalette(hdc, hpal, FALSE);
def_pal = GetStockObject(DEFAULT_PALETTE);
ok(old_pal == def_pal, "old_pal=%p, expected %p\n", old_pal, def_pal);
ret = RealizePalette(hdc);
ok(!ret, "RealizePalette returned %d\n", ret);
old_pal = SelectPalette(hdc, GetStockObject(DEFAULT_PALETTE), FALSE);
ok(old_pal == hpal, "old_pal=%p, expected %p\n", old_pal, hpal);
ret = RealizePalette(hdc);
ok(!ret, "RealizePalette returned %d\n", ret);
emf = CloseEnhMetaFile(hdc);
ok(emf != 0, "CloseEnhMetaFile error %ld\n", GetLastError());
if (compare_emf_bits(emf, palette_bits, sizeof(palette_bits), "emf_palette", FALSE))
{
dump_emf_bits(emf, "emf_palette");
dump_emf_records(emf, "emf_palette");
}
ret = DeleteEnhMetaFile(emf);
ok(ret, "DeleteMetaFile error %ld\n", GetLastError());
}
static void test_mf_blit(void)
{
BITMAPINFO bmi = {{ sizeof(bmi) }};
......@@ -10670,6 +10747,7 @@ START_TEST(metafile)
test_emf_mask_blit();
test_emf_StretchDIBits();
test_emf_SetDIBitsToDevice();
test_emf_palette();
/* For win-format metafiles (mfdrv) */
test_mf_SaveDC();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment