diff options
author | Skyler Grey <skyler.grey@collabora.com> | 2024-07-25 12:34:34 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-07-31 12:51:20 +0200 |
commit | b96920054754bf14eb6acb5086dd517f0986e213 (patch) | |
tree | d010aba4520a230957985f7d44afb9d24667eccd /sw | |
parent | 3b5738ab1a646d089fa7cc59ffaeda7d011c1e07 (diff) |
test: Refactor pixel assertion
When a test fails, the line the assertion failed on is printed.
Unfortunately, in the case of this assertion, it was always inside the
same function.
If we instead change the function to only return the pixel color, and
perform the assertion inside the test, assertion failure error messages
are more helpful
Change-Id: Ia56da1b245882c8ddbf21ad98f69facc36d3ec3a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171205
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 471f4183388b..a01622eae018 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1794,12 +1794,12 @@ static Bitmap getTile(SwXTextDocument* pXTextDocument) } // Helper function to get a tile to a bitmap and check the pixel color -static void assertTilePixelColor(SwXTextDocument* pXTextDocument, int nPixelX, int nPixelY, Color aColor) +static Color getTilePixelColor(SwXTextDocument* pXTextDocument, int nPixelX, int nPixelY) { Bitmap aBitmap = getTile(pXTextDocument); BitmapScopedReadAccess pAccess(aBitmap); Color aActualColor(pAccess->GetPixel(nPixelX, nPixelY)); - CPPUNIT_ASSERT_EQUAL(aColor, aActualColor); + return aActualColor; } static void addDarkLightThemes(const Color& rDarkColor, const Color& rLightColor) @@ -1845,7 +1845,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); } // First view is in light scheme - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); // Create second view SfxLokHelper::createView(); int nSecondViewId = SfxLokHelper::getView(); @@ -1862,13 +1862,13 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) ); comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); } - assertTilePixelColor(pXTextDocument, 255, 255, aDarkColor); + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); // First view still in light scheme SfxLokHelper::setView(nFirstViewId); - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); // Second view still in dark scheme SfxLokHelper::setView(nSecondViewId); - assertTilePixelColor(pXTextDocument, 255, 255, aDarkColor); + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); // Switch second view back to light scheme { SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); @@ -1882,7 +1882,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); } // Now in light scheme - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); } // Test that changing the theme sends the document background color as LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR |