sw/qa/extras/tiledrendering/tiledrendering.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
New commits: commit 784a1468354c3ed8a8bdee216771aa234ab38407 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Aug 8 08:41:04 2024 +0200 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/+/171593 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 163dd4751ace..e7e309f67e50 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1769,12 +1769,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) @@ -1820,7 +1820,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, 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(); @@ -1837,13 +1837,13 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) ); comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, 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(); @@ -1857,7 +1857,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, 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