[PATCH] gdi32/tests: Simplify tests using todo_wine_if()

Nikolay Sivov nsivov at codeweavers.com
Wed Feb 10 20:02:14 CST 2016


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/gdi32/tests/dc.c   | 28 +++++-----------------------
 dlls/gdi32/tests/dib.c  |  5 +----
 dlls/gdi32/tests/font.c | 49 +++++++++++++++++--------------------------------
 dlls/gdi32/tests/path.c | 10 ++--------
 4 files changed, 25 insertions(+), 67 deletions(-)

diff --git a/dlls/gdi32/tests/dc.c b/dlls/gdi32/tests/dc.c
index cb42219..09c05c1 100644
--- a/dlls/gdi32/tests/dc.c
+++ b/dlls/gdi32/tests/dc.c
@@ -424,9 +424,7 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale
         else
             ok( ret || broken(!ret) /* NT4 */, "GetDeviceGammaRamp failed on %s (type %d), error %u\n", descr, GetObjectType( hdc ), GetLastError() );
         type = GetClipBox( hdc, &rect );
-        if (GetObjectType( hdc ) == OBJ_ENHMETADC)
-            todo_wine ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
-        else
+        todo_wine_if (GetObjectType( hdc ) == OBJ_ENHMETADC)
             ok( type == SIMPLEREGION, "GetClipBox returned %d on memdc for %s\n", type, descr );
 
         type = GetBoundsRect( hdc, &rect, 0 );
@@ -443,12 +441,7 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale
         SetMapMode( hdc, MM_TEXT );
         Rectangle( hdc, 2, 2, 4, 4 );
         type = GetBoundsRect( hdc, &rect, DCB_RESET );
-        if (GetObjectType( hdc ) == OBJ_ENHMETADC || (GetObjectType( hdc ) == OBJ_DC && GetDeviceCaps( hdc, TECHNOLOGY ) == DT_RASPRINTER))
-            todo_wine
-            ok( rect.left == 2 && rect.top == 2 && rect.right == 4 && rect.bottom == 4 && type == DCB_SET,
-                "GetBoundsRect returned %d,%d,%d,%d type %x for %s\n",
-                rect.left, rect.top, rect.right, rect.bottom, type, descr );
-        else
+        todo_wine_if (GetObjectType( hdc ) == OBJ_ENHMETADC || (GetObjectType( hdc ) == OBJ_DC && GetDeviceCaps( hdc, TECHNOLOGY ) == DT_RASPRINTER))
             ok( rect.left == 2 && rect.top == 2 && rect.right == 4 && rect.bottom == 4 && type == DCB_SET,
                 "GetBoundsRect returned %d,%d,%d,%d type %x for %s\n",
                 rect.left, rect.top, rect.right, rect.bottom, type, descr );
@@ -462,20 +455,12 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale
         ok( type == SIMPLEREGION, "GetClipBox returned %d on %s\n", type, descr );
         if (GetDeviceCaps( ref_dc, TECHNOLOGY ) == DT_RASDISPLAY)
         {
-            if (GetSystemMetrics( SM_CXSCREEN ) != GetSystemMetrics( SM_CXVIRTUALSCREEN ))
-                todo_wine ok( GetDeviceCaps( ref_dc, DESKTOPHORZRES ) == GetSystemMetrics( SM_CXSCREEN ),
-                              "Got DESKTOPHORZRES %d on %s, expected %d\n",
-                              GetDeviceCaps( ref_dc, DESKTOPHORZRES ), descr, GetSystemMetrics( SM_CXSCREEN ) );
-            else
+            todo_wine_if (GetSystemMetrics( SM_CXSCREEN ) != GetSystemMetrics( SM_CXVIRTUALSCREEN ))
                 ok( GetDeviceCaps( ref_dc, DESKTOPHORZRES ) == GetSystemMetrics( SM_CXSCREEN ),
                     "Got DESKTOPHORZRES %d on %s, expected %d\n",
                     GetDeviceCaps( ref_dc, DESKTOPHORZRES ), descr, GetSystemMetrics( SM_CXSCREEN ) );
 
-            if (GetSystemMetrics( SM_CYSCREEN ) != GetSystemMetrics( SM_CYVIRTUALSCREEN ))
-                todo_wine ok( GetDeviceCaps( ref_dc, DESKTOPVERTRES ) == GetSystemMetrics( SM_CYSCREEN ),
-                              "Got DESKTOPVERTRES %d on %s, expected %d\n",
-                              GetDeviceCaps( ref_dc, DESKTOPVERTRES ), descr, GetSystemMetrics( SM_CYSCREEN ) );
-            else
+            todo_wine_if (GetSystemMetrics( SM_CYSCREEN ) != GetSystemMetrics( SM_CYVIRTUALSCREEN ))
                 ok( GetDeviceCaps( ref_dc, DESKTOPVERTRES ) == GetSystemMetrics( SM_CYSCREEN ),
                     "Got DESKTOPVERTRES %d on %s, expected %d\n",
                     GetDeviceCaps( ref_dc, DESKTOPVERTRES ), descr, GetSystemMetrics( SM_CYSCREEN ) );
@@ -490,11 +475,8 @@ static void test_device_caps( HDC hdc, HDC ref_dc, const char *descr, int scale
                      GetDeviceCaps( ref_dc, DESKTOPVERTRES ) );
         }
 
-        if (GetDeviceCaps( ref_dc, TECHNOLOGY ) == DT_RASDISPLAY && GetObjectType( hdc ) != OBJ_ENHMETADC &&
+        todo_wine_if (GetDeviceCaps( ref_dc, TECHNOLOGY ) == DT_RASDISPLAY && GetObjectType( hdc ) != OBJ_ENHMETADC &&
             (GetSystemMetrics( SM_XVIRTUALSCREEN ) || GetSystemMetrics( SM_YVIRTUALSCREEN )))
-            todo_wine ok( EqualRect( &rect, &ref_rect ), "GetClipBox returned %d,%d,%d,%d on %s\n",
-                          rect.left, rect.top, rect.right, rect.bottom, descr );
-        else
             ok( EqualRect( &rect, &ref_rect ), "GetClipBox returned %d,%d,%d,%d on %s\n",
                 rect.left, rect.top, rect.right, rect.bottom, descr );
     }
diff --git a/dlls/gdi32/tests/dib.c b/dlls/gdi32/tests/dib.c
index d12c752..693df4a 100644
--- a/dlls/gdi32/tests/dib.c
+++ b/dlls/gdi32/tests/dib.c
@@ -1318,10 +1318,7 @@ static void compare_hash_broken_todo(HDC hdc, const BITMAPINFO *bmi, BYTE *bits,
     for(i = 1; i <= num_broken; i++)
         ok_cond = ok_cond || broken( !strcmp(hash, current_sha1[i]) );
 
-    if(todo)
-        todo_wine ok( ok_cond, "%s: %s: expected hash %s got %s\n",
-                      dst_format, info, *current_sha1, hash );
-    else
+    todo_wine_if(todo)
         ok( ok_cond, "%s: %s: expected hash %s got %s\n",
             dst_format, info, *current_sha1, hash );
 
diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c
index d1896a3..a1917b4 100644
--- a/dlls/gdi32/tests/font.c
+++ b/dlls/gdi32/tests/font.c
@@ -974,9 +974,7 @@ static void test_bitmap_font_metrics(void)
             {
                 if (font_res == fd[i].dpi && lf.lfCharSet == expected_cs)
                 {
-                    if (ret) /* FIXME: Remove once Wine is fixed */
-                        todo_wine ok(!ret, "%s height %d charset %d dpi %d should be enumerated\n", lf.lfFaceName, lf.lfHeight, lf.lfCharSet, fd[i].dpi);
-                    else
+                    todo_wine_if (ret) /* FIXME: Remove once Wine is fixed */
                         ok(!ret, "%s height %d charset %d dpi %d should be enumerated\n", lf.lfFaceName, lf.lfHeight, lf.lfCharSet, fd[i].dpi);
                 }
             }
@@ -1136,26 +1134,26 @@ static void ABCWidths_helper(const char* description, HDC hdc, WORD *glyphs, ABC
     ret = pGetCharABCWidthsI(hdc, 0, 1, glyphs, abc);
     ok(ret, "%s: GetCharABCWidthsI should have succeeded\n", description);
     ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
-    if (todo) todo_wine ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
-    else ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
-    if (todo) todo_wine ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
-    else ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abc->abcA * base_abci->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abc->abcC * base_abci->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
 
     ret = pGetCharABCWidthsW(hdc, 'i', 'i', abc);
     ok(ret, "%s: GetCharABCWidthsW should have succeeded\n", description);
     ok ((INT)abc->abcB > 0, "%s: abcB should be positive\n", description);
-    if (todo) todo_wine ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
-    else ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
-    if (todo) todo_wine ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
-    else ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abc->abcA * base_abcw->abcA >= 0, "%s: abcA's sign should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abc->abcC * base_abcw->abcC >= 0, "%s: abcC's sign should be unchanged\n", description);
 
     ret = pGetCharABCWidthsFloatW(hdc, 'i', 'i', abcf);
     ok(ret, "%s: GetCharABCWidthsFloatW should have succeeded\n", description);
     ok (abcf->abcfB > 0.0, "%s: abcfB should be positive\n", description);
-    if (todo) todo_wine ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
-    else ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's should be unchanged\n", description);
-    if (todo) todo_wine ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
-    else ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abcf->abcfA * base_abcf->abcfA >= 0.0, "%s: abcfA's sign should be unchanged\n", description);
+    todo_wine_if (todo)
+        ok(abcf->abcfC * base_abcf->abcfC >= 0.0, "%s: abcfC's sign should be unchanged\n", description);
 }
 
 static void test_GetCharABCWidths(void)
@@ -3864,11 +3862,7 @@ static void test_text_metrics(const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
         expect_default_A  = expect_default_W;
 
         /* Wine currently uses SYMBOL_CHARSET to identify whether the ANSI metrics need special handling */
-        if(cmap_type != cmap_ms_symbol && tmA.tmCharSet == SYMBOL_CHARSET && expect_first_A != 0x1e)
-            todo_wine ok(tmA.tmFirstChar == expect_first_A ||
-                         tmA.tmFirstChar == expect_first_A + 1 /* win9x */,
-                         "A: tmFirstChar for %s got %02x expected %02x\n", font_name, tmA.tmFirstChar, expect_first_A);
-        else
+        todo_wine_if(cmap_type != cmap_ms_symbol && tmA.tmCharSet == SYMBOL_CHARSET && expect_first_A != 0x1e)
             ok(tmA.tmFirstChar == expect_first_A ||
                tmA.tmFirstChar == expect_first_A + 1 /* win9x */,
                "A: tmFirstChar for %s got %02x expected %02x\n", font_name, tmA.tmFirstChar, expect_first_A);
@@ -3892,18 +3886,12 @@ static void test_text_metrics(const LOGFONTA *lf, const NEWTEXTMETRICA *ntm)
         if (ret)
         {
             /* Wine uses the os2 first char */
-            if(cmap_first != os2_first_char && cmap_type != cmap_ms_symbol)
-                todo_wine ok(tmW.tmFirstChar == expect_first_W, "W: tmFirstChar for %s got %02x expected %02x\n",
-                             font_name, tmW.tmFirstChar, expect_first_W);
-            else
+            todo_wine_if(cmap_first != os2_first_char && cmap_type != cmap_ms_symbol)
                 ok(tmW.tmFirstChar == expect_first_W, "W: tmFirstChar for %s got %02x expected %02x\n",
                    font_name, tmW.tmFirstChar, expect_first_W);
 
             /* Wine uses the os2 last char */
-            if(expect_last_W != os2_last_char && cmap_type != cmap_ms_symbol)
-                todo_wine ok(tmW.tmLastChar == expect_last_W, "W: tmLastChar for %s got %02x expected %02x\n",
-                             font_name, tmW.tmLastChar, expect_last_W);
-            else
+            todo_wine_if(expect_last_W != os2_last_char && cmap_type != cmap_ms_symbol)
                 ok(tmW.tmLastChar == expect_last_W, "W: tmLastChar for %s got %02x expected %02x\n",
                    font_name, tmW.tmLastChar, expect_last_W);
             ok(tmW.tmBreakChar == expect_break_W, "W: tmBreakChar for %s got %02x expected %02x\n",
@@ -6136,14 +6124,11 @@ static void test_stock_fonts(void)
             }
 
             /* FIXME: Remove once Wine is fixed */
-            if (td[i][j].dpi != 96 &&
+            todo_wine_if (td[i][j].dpi != 96 &&
                 /* MS Sans Serif for 120 dpi and higher should include 12 pixel bitmap set */
                 ((!strcmp(td[i][j].face_name, "MS Sans Serif") && td[i][j].height == 12) ||
                 /* System for 120 dpi and higher should include 20 pixel bitmap set */
                 (!strcmp(td[i][j].face_name, "System") && td[i][j].height > 16)))
-            todo_wine
-            ok(height == td[i][j].height_pixels, "%d(%d): expected height %d, got %d\n", i, j, td[i][j].height_pixels, height);
-            else
             ok(height == td[i][j].height_pixels, "%d(%d): expected height %d, got %d\n", i, j, td[i][j].height_pixels, height);
 
             ok(td[i][j].weight == lf.lfWeight, "%d(%d): expected lfWeight %d, got %d\n", i, j, td[i][j].weight, lf.lfWeight);
diff --git a/dlls/gdi32/tests/path.c b/dlls/gdi32/tests/path.c
index 0b350bc..223a027 100644
--- a/dlls/gdi32/tests/path.c
+++ b/dlls/gdi32/tests/path.c
@@ -390,9 +390,7 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected,
     size = GetPath(hdc, pnt, types, size);
     assert(size > 0);
 
-    if (todo_size) todo_wine
-        ok(size == expected_size, "Path size %d does not match expected size %d\n", size, expected_size);
-    else
+    todo_wine_if (todo_size)
         ok(size == expected_size, "Path size %d does not match expected size %d\n", size, expected_size);
 
     if (winetest_debug > 2)
@@ -407,11 +405,7 @@ static void ok_path(HDC hdc, const char *path_name, const path_test_t *expected,
             (pnt[idx].x >= expected[eidx].x-2 && pnt[idx].x <= expected[eidx].x+2) &&
             (pnt[idx].y >= expected[eidx].y-2 && pnt[idx].y <= expected[eidx].y+2);
 
-        if (expected[eidx].todo || numskip) todo_wine
-            ok(match, "Expected #%d: %s (%d,%d) but got %s (%d,%d)\n", eidx,
-               type_string[expected[eidx].type], expected[eidx].x, expected[eidx].y,
-               type_string[types[idx]], pnt[idx].x, pnt[idx].y);
-        else
+        todo_wine_if (expected[eidx].todo || numskip)
             ok(match, "Expected #%d: %s (%d,%d) but got %s (%d,%d)\n", eidx,
                type_string[expected[eidx].type], expected[eidx].x, expected[eidx].y,
                type_string[types[idx]], pnt[idx].x, pnt[idx].y);
-- 
2.7.0




More information about the wine-patches mailing list