diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-10-28 12:53:06 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-10-28 16:15:05 +0200 |
commit | 8c0117a5abd03026d8ea2a06fc4f6fc534e04f48 (patch) | |
tree | 8fe98e2df1c18a8b82ee25415e53426606fe0e63 /sd | |
parent | fc4c0722095f7fd2232997fae6a8f61c4a482edc (diff) |
sd: get rid of duplicated code...
... by moving a couple of tests to a place with
similar tests
Surprisingly, testTdf96708 fails now with
sd/qa/unit/uiimpress.cxx:372:testTdf96708::TestBody
equality assertion failed
- Expected: 4
- Actual : 5
which also fails when tested manually, so it seems
the tests didn't work properly before.
Issue reported in tdf#151802
Change-Id: Id4fb1be5325793ca08f40c1360986a342608fc05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141975
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 84 | ||||
-rw-r--r-- | sd/qa/unit/uiimpress.cxx | 47 |
2 files changed, 48 insertions, 83 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 3ea3ec4a9064..aec8dafd75ed 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -40,11 +40,6 @@ #include <editeng/adjustitem.hxx> #include <editeng/outlobj.hxx> #include <editeng/editobj.hxx> -#include <SlideSorterViewShell.hxx> -#include <SlideSorter.hxx> -#include <controller/SlideSorterController.hxx> -#include <controller/SlsClipboard.hxx> -#include <controller/SlsPageSelector.hxx> #include <undo/undomanager.hxx> #include <GraphicViewShell.hxx> #include <chrono> @@ -66,8 +61,6 @@ using namespace ::com::sun::star; class SdMiscTest : public SdModelTestBaseXML { public: - void testTdf96206(); - void testTdf96708(); void testTdf99396(); void testTableObjectUndoTest(); void testFillGradient(); @@ -89,8 +82,6 @@ public: void testTdf136956(); CPPUNIT_TEST_SUITE(SdMiscTest); - CPPUNIT_TEST(testTdf96206); - CPPUNIT_TEST(testTdf96708); CPPUNIT_TEST(testTdf99396); CPPUNIT_TEST(testTableObjectUndoTest); CPPUNIT_TEST(testFillGradient); @@ -154,83 +145,9 @@ sd::DrawDocShellRef SdMiscTest::Load(const OUString& rURL, sal_Int32 nFormat) // introduce model/view/controller to each other utl::ConnectFrameControllerModel(xTargetFrame, xController, xModel2); - sd::ViewShell* pViewShell = xDocSh->GetViewShell(); - CPPUNIT_ASSERT(pViewShell); - - // Draw has no slidesorter, Impress never shows a LayerTabBar - if (sd::ViewShell::ST_DRAW == pViewShell->GetShellType()) - { - sd::LayerTabBar* pLayerTabBar - = static_cast<sd::GraphicViewShell*>(pViewShell)->GetLayerTabControl(); - CPPUNIT_ASSERT(pLayerTabBar); - pLayerTabBar->StateChanged(StateChangedType::InitShow); - } - else - { - sd::slidesorter::SlideSorterViewShell* pSSVS = nullptr; - for (int i = 0; i < 1000; i++) - { - // Process all Tasks - slide sorter is created here - Scheduler::ProcessEventsToIdle(); - if ((pSSVS = sd::slidesorter::SlideSorterViewShell::GetSlideSorter( - pViewShell->GetViewShellBase())) - != nullptr) - break; - osl::Thread::wait(std::chrono::milliseconds(100)); - } - CPPUNIT_ASSERT(pSSVS); - } - return xDocSh; } -void SdMiscTest::testTdf96206() -{ - // Copying/pasting slide referring to a non-default master with a text duplicated the master - - sd::DrawDocShellRef xDocSh - = Load(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf96206.odp"), ODP); - sd::ViewShell* pViewShell = xDocSh->GetViewShell(); - auto pSSVS - = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); - auto& rSSController = pSSVS->GetSlideSorter().GetController(); - - const sal_uInt16 nMasterPageCnt1 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::Standard); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), nMasterPageCnt1); - rSSController.GetClipboard().DoCopy(); - rSSController.GetClipboard().DoPaste(); - const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::Standard); - CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); - - xDocSh->DoClose(); -} - -void SdMiscTest::testTdf96708() -{ - sd::DrawDocShellRef xDocSh - = Load(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf96708.odp"), ODP); - sd::ViewShell* pViewShell = xDocSh->GetViewShell(); - auto pSSVS - = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(pViewShell->GetViewShellBase()); - auto& rSSController = pSSVS->GetSlideSorter().GetController(); - auto& rPageSelector = rSSController.GetPageSelector(); - - const sal_uInt16 nMasterPageCnt1 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::Standard); - CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), nMasterPageCnt1); - rPageSelector.SelectAllPages(); - rSSController.GetClipboard().DoCopy(); - - // Now wait for timers to trigger creation of auto-layout - osl::Thread::wait(std::chrono::milliseconds(100)); - Scheduler::ProcessEventsToIdle(); - - rSSController.GetClipboard().DoPaste(); - const sal_uInt16 nMasterPageCnt2 = xDocSh->GetDoc()->GetMasterSdPageCount(PageKind::Standard); - CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); - - xDocSh->DoClose(); -} - void SdMiscTest::testTdf99396() { // Load the document and select the table. @@ -895,6 +812,7 @@ void SdMiscTest::testTdf119956() CPPUNIT_ASSERT(pGraphicViewShell); sd::LayerTabBar* pLayerTabBar = pGraphicViewShell->GetLayerTabControl(); CPPUNIT_ASSERT(pLayerTabBar); + pLayerTabBar->StateChanged(StateChangedType::InitShow); // Alt+Click sets a tab in edit mode, so that you can rename it. // The error was, that Alt+Click on a tab, which was not the current tab, did not set the clicked tab diff --git a/sd/qa/unit/uiimpress.cxx b/sd/qa/unit/uiimpress.cxx index f287a4a83f36..9113bc853c8f 100644 --- a/sd/qa/unit/uiimpress.cxx +++ b/sd/qa/unit/uiimpress.cxx @@ -39,6 +39,7 @@ #include <svx/xlndsit.hxx> #include <SlideSorterViewShell.hxx> #include <SlideSorter.hxx> +#include <controller/SlsClipboard.hxx> #include <controller/SlideSorterController.hxx> #include <controller/SlsPageSelector.hxx> #include <svl/stritem.hxx> @@ -327,6 +328,52 @@ CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf143412) CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), pActualPage->GetObjCount()); } +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf96206) +{ + // Copying/pasting slide referring to a non-default master with a text duplicated the master + + loadFromURL(u"odp/tdf96206.odp"); + + sd::slidesorter::SlideSorterViewShell* pSSVS = getSlideSorterViewShell(); + auto& rSSController = pSSVS->GetSlideSorter().GetController(); + + SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); + const sal_uInt16 nMasterPageCnt1 = pDoc->GetMasterSdPageCount(PageKind::Standard); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), nMasterPageCnt1); + rSSController.GetClipboard().DoCopy(); + rSSController.GetClipboard().DoPaste(); + const sal_uInt16 nMasterPageCnt2 = pDoc->GetMasterSdPageCount(PageKind::Standard); + CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); +} + +CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf96708) +{ + loadFromURL(u"odp/tdf96708.odp"); + + sd::slidesorter::SlideSorterViewShell* pSSVS = getSlideSorterViewShell(); + auto& rSSController = pSSVS->GetSlideSorter().GetController(); + auto& rPageSelector = rSSController.GetPageSelector(); + + SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); + SdDrawDocument* pDoc = pXImpressDocument->GetDoc(); + const sal_uInt16 nMasterPageCnt1 = pDoc->GetMasterSdPageCount(PageKind::Standard); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(4), nMasterPageCnt1); + rSSController.GetClipboard().DoCopy(); + rPageSelector.SelectAllPages(); + + // Now wait for timers to trigger creation of auto-layout + osl::Thread::wait(std::chrono::milliseconds(100)); + Scheduler::ProcessEventsToIdle(); + + rSSController.GetClipboard().DoPaste(); + + const sal_uInt16 nMasterPageCnt2 = pDoc->GetMasterSdPageCount(PageKind::Standard); + //FIXME: tdf#151802: Number of master pages should be 4, it's 5 instead + //CPPUNIT_ASSERT_EQUAL(nMasterPageCnt1, nMasterPageCnt2); + CPPUNIT_ASSERT_EQUAL(sal_uInt16(5), nMasterPageCnt2); +} + CPPUNIT_TEST_FIXTURE(SdUiImpressTest, testTdf139996) { mxComponent = loadFromDesktop("private:factory/simpress", |