[GDI32_WINETEST] Sync with Wine Staging 1.7.43.
authorAmine Khaldi <amine.khaldi@reactos.org>
Mon, 25 May 2015 18:52:18 +0000 (18:52 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Mon, 25 May 2015 18:52:18 +0000 (18:52 +0000)
svn path=/trunk/; revision=67916

rostests/winetests/gdi32/bitmap.c
rostests/winetests/gdi32/font.c
rostests/winetests/gdi32/palette.c

index 7dd11e1..ecd7d66 100755 (executable)
@@ -56,8 +56,9 @@ static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHE
 {
     BITMAP bm;
     BITMAP bma[2];
-    INT ret, width_bytes;
+    INT ret, width_bytes, i;
     BYTE buf[512], buf_cmp[512];
+    INT test_size[] = {0 /*first value will be changed */, 0, -1, -1000, ~0, sizeof(buf)};
 
     ret = GetObjectW(hbm, sizeof(bm), &bm);
     ok(ret == sizeof(bm), "GetObject returned %d\n", ret);
@@ -75,17 +76,28 @@ static void test_bitmap_info(HBITMAP hbm, INT expected_depth, const BITMAPINFOHE
     assert(sizeof(buf) == sizeof(buf_cmp));
 
     SetLastError(0xdeadbeef);
-    ret = GetBitmapBits(hbm, 0, NULL);
-    ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
+    test_size[0] = bm.bmWidthBytes * bm.bmHeight;
+    /* NULL output buffer with different count values */
+    for (i = 0; i < sizeof(test_size) / sizeof(test_size[0]); i++)
+    {
+        ret = GetBitmapBits(hbm, test_size[i], NULL);
+        ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
+    }
 
     memset(buf_cmp, 0xAA, sizeof(buf_cmp));
     memset(buf_cmp, 0, bm.bmWidthBytes * bm.bmHeight);
 
-    memset(buf, 0xAA, sizeof(buf));
-    ret = GetBitmapBits(hbm, sizeof(buf), buf);
-    ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
-    ok(!memcmp(buf, buf_cmp, sizeof(buf)),
-        "buffers do not match, depth %d\n", bmih->biBitCount);
+    /* Correct output buffer with different count values */
+    for (i = 0; i < sizeof(test_size) / sizeof(test_size[0]); i++)
+    {
+        int expect = i == 1 ? 0 : bm.bmWidthBytes * bm.bmHeight;
+        memset(buf, 0xAA, sizeof(buf));
+        ret = GetBitmapBits(hbm, test_size[i], buf);
+        ok(ret == expect, "Test[%d]: %d != %d\n", i, ret, expect);
+        if (expect)
+            ok(!memcmp(buf, buf_cmp, sizeof(buf)),
+               "Test[%d]: buffers do not match, depth %d\n", i, bmih->biBitCount);
+    }
 
     /* test various buffer sizes for GetObject */
     ret = GetObjectW(hbm, sizeof(*bma) * 2, bma);
index eff1793..5388df1 100644 (file)
@@ -3708,9 +3708,10 @@ static void test_text_metrics(const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
         default_char = GET_BE_WORD(tt_os2.usDefaultChar);
         break_char = GET_BE_WORD(tt_os2.usBreakChar);
 
-        trace("font %s charset %u: %x-%x (%x-%x) default %x break %x OS/2 version %u vendor %4.4s\n",
-              font_name, lf->lfCharSet, os2_first_char, os2_last_char, cmap_first, cmap_last,
-              default_char, break_char, version, (LPCSTR)&tt_os2.achVendID);
+        if (winetest_debug > 1)
+            trace("font %s charset %u: %x-%x (%x-%x) default %x break %x OS/2 version %u vendor %4.4s\n",
+                  font_name, lf->lfCharSet, os2_first_char, os2_last_char, cmap_first, cmap_last,
+                  default_char, break_char, version, (LPCSTR)&tt_os2.achVendID);
 
         if (cmap_type == cmap_ms_symbol || (cmap_first >= 0xf000 && cmap_first < 0xf100))
         {
index f95c0d3..09a00a5 100644 (file)
@@ -191,9 +191,121 @@ static void test_halftone_palette(void)
     ReleaseDC( 0, hdc );
 }
 
+static void test_system_palette_entries(void)
+{
+    HDC hdc;
+    PALETTEENTRY entries[256];
+    PALETTEENTRY defpal[20];
+    int i, count;
+
+    hdc = GetDC(0);
+
+    if (!(GetDeviceCaps( hdc, RASTERCAPS ) & RC_PALETTE))
+    {
+        memset( defpal, 0xaa, sizeof(defpal) );
+        count = GetPaletteEntries( GetStockObject(DEFAULT_PALETTE), 0, 20, defpal );
+        ok( count == 20, "wrong size %u\n", count );
+
+        memset( entries, 0x55, sizeof(entries) );
+        count = GetSystemPaletteEntries( hdc, 0, 256, entries );
+        ok( count == 0, "wrong size %u\n", count);
+        for (i = 0; i < 10; i++)
+        {
+            ok( entries[i].peRed   == defpal[i].peRed &&
+                entries[i].peGreen == defpal[i].peGreen &&
+                entries[i].peBlue  == defpal[i].peBlue &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
+                defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
+        }
+        for (i = 10; i < 246; ++i)
+        {
+            ok( !entries[i].peRed   &&
+                !entries[i].peGreen &&
+                !entries[i].peBlue  &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
+        }
+        for (i = 246; i < 256; i++)
+        {
+            int idx = i - 246 + 10;
+            ok( entries[i].peRed   == defpal[idx].peRed &&
+                entries[i].peGreen == defpal[idx].peGreen &&
+                entries[i].peBlue  == defpal[idx].peBlue &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
+                defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
+        }
+
+        memset( entries, 0x55, sizeof(entries) );
+        count = GetSystemPaletteEntries( hdc, 0, 10, entries );
+        ok( count == 0, "wrong size %u\n", count);
+        for (i = 0; i < 10; i++)
+        {
+            ok( entries[i].peRed   == defpal[i].peRed &&
+                entries[i].peGreen == defpal[i].peGreen &&
+                entries[i].peBlue  == defpal[i].peBlue &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
+                defpal[i].peRed, defpal[i].peGreen, defpal[i].peBlue );
+        }
+
+        memset( entries, 0x55, sizeof(entries) );
+        count = GetSystemPaletteEntries( hdc, 10, 246, entries );
+        ok( count == 0, "wrong size %u\n", count);
+        for (i = 0; i < 236; ++i)
+        {
+            ok( !entries[i].peRed   &&
+                !entries[i].peGreen &&
+                !entries[i].peBlue  &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of 0,0,0\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags);
+        }
+        for (i = 236; i < 246; i++)
+        {
+            int idx = i - 236 + 10;
+            ok( entries[i].peRed   == defpal[idx].peRed &&
+                entries[i].peGreen == defpal[idx].peGreen &&
+                entries[i].peBlue  == defpal[idx].peBlue &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
+                defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
+        }
+
+        memset( entries, 0x55, sizeof(entries) );
+        count = GetSystemPaletteEntries( hdc, 246, 10, entries );
+        ok( count == 0, "wrong size %u\n", count);
+        for (i = 0; i < 10; i++)
+        {
+            int idx = i + 10;
+            ok( entries[i].peRed   == defpal[idx].peRed &&
+                entries[i].peGreen == defpal[idx].peGreen &&
+                entries[i].peBlue  == defpal[idx].peBlue &&
+                !entries[i].peFlags,
+                "%u: wrong color %02x,%02x,%02x,%02x instead of %02x,%02x,%02x\n", i,
+                entries[i].peRed, entries[i].peGreen, entries[i].peBlue, entries[i].peFlags,
+                defpal[idx].peRed, defpal[idx].peGreen, defpal[idx].peBlue );
+        }
+
+    }
+    else
+    {
+        skip( "device is palette-based, skipping test\n" );
+    }
+
+    ReleaseDC( 0, hdc );
+}
+
 START_TEST(palette)
 {
     test_DIB_PAL_COLORS();
     test_palette_entries();
     test_halftone_palette();
+    test_system_palette_entries();
 }