sw/qa/extras/tiledrendering/tiledrendering.cxx | 100 +++++++++++++++++++++++++ 1 file changed, 100 insertions(+)
New commits: commit 3a597235ea95621d386bf85d747f763bda275837 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Aug 16 15:14:56 2024 +0200 test(invert): ensure background-invert separation I0aed702185e642f631854b1f8234355c9e69ff6e made inverted backgrounds separated by view. This change adds a test to make sure that it really works, based on the work in I05486860c5f562c3cfa59b4a7fc492d48913a181 to allow a specific theme to be stated on a per-view basis Change-Id: I3d0c4814cde5cafe069f984fe7904080660f10d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171953 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 cba5c265c864..6c0ddb77be62 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1860,6 +1860,106 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); } +// Test that changing the theme in one view doesn't change it in the other view +CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testInvertBackgroundViewSeparation) +{ + Color aDarkColor(0x1c, 0x1c, 0x1c); + addDarkLightThemes(aDarkColor, COL_WHITE); + SwXTextDocument* pXTextDocument = createDoc(); + int nFirstViewId = SfxLokHelper::getView(); + ViewCallback aView1; + // Set view to dark scheme + { + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Dark")) }, + } + ); + comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); + } + // First view is in dark scheme + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + // Create second view + SfxLokHelper::createView(); + int nSecondViewId = SfxLokHelper::getView(); + ViewCallback aView2; + // Set second view to dark scheme + { + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Dark")) }, + } + ); + comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); + } + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + // Set view 1 to invert document background + SfxLokHelper::setView(nFirstViewId); + { + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Light")) }, + } + ); + comphelper::dispatchCommand(".uno:InvertBackground", xFrame, aPropertyValues); + } + // First view has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nSecondViewId); + // Second view still has regular background + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + // Set view 2 to invert document background + { + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Light")) }, + } + ); + comphelper::dispatchCommand(".uno:InvertBackground", xFrame, aPropertyValues); + } + // Second view has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nFirstViewId); + // First view still has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nSecondViewId); + // Set view 2 to regular document background + { + SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc(); + SwView* pView = pDoc->GetDocShell()->GetView(); + uno::Reference<frame::XFrame> xFrame = pView->GetViewFrame().GetFrame().GetFrameInterface(); + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Dark")) }, + } + ); + comphelper::dispatchCommand(".uno:InvertBackground", xFrame, aPropertyValues); + } + // Second view has regular background + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nFirstViewId); + // First view still has inverted background + 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 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeChangeBackgroundCallback) {