From dd0b559d6aac5bf09566af735bd00b28c00fb2e4 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Fri, 4 Jan 2019 11:23:59 +0100 Subject: Unfloat: Test layout change of unfloat operation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I75298a392de6a10861ac96e1bc58a30173cd2dd2 Reviewed-on: https://gerrit.libreoffice.org/65823 Tested-by: Jenkins Reviewed-by: Tamás Zolnai --- sw/qa/extras/uiwriter/uiwriter2.cxx | 52 +++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'sw/qa') diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 3f49e4c591f8..74a8a7593a82 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -27,8 +27,7 @@ #include #include #include -#include -#include +#include namespace { @@ -54,6 +53,7 @@ public: void testUnfloatButtonSmallTable(); void testUnfloatButton(); void testUnfloatButtonReadOnlyMode(); + void testUnfloating(); CPPUNIT_TEST_SUITE(SwUiWriterTest2); CPPUNIT_TEST(testRedlineMoveInsertInDelete); @@ -70,6 +70,7 @@ public: CPPUNIT_TEST(testUnfloatButtonSmallTable); CPPUNIT_TEST(testUnfloatButton); CPPUNIT_TEST(testUnfloatButtonReadOnlyMode); + CPPUNIT_TEST(testUnfloating); CPPUNIT_TEST_SUITE_END(); private: @@ -635,6 +636,53 @@ void SwUiWriterTest2::testUnfloatButtonReadOnlyMode() CPPUNIT_ASSERT(!pFlyFrame->IsShowUnfloatButton(pWrtShell)); } +void SwUiWriterTest2::testUnfloating() +{ + // Test what happens when pushing the unfloat button + load(FLOATING_TABLE_DATA_DIRECTORY, "unfloatable_floating_table.odt"); + SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + SwFlyFrame* pFlyFrame; + + // Before unfloating we have only one page with a fly frame + { + CPPUNIT_ASSERT_EQUAL(SwFrameType::Page, pWrtShell->GetLayout()->GetLower()->GetType()); + CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext()); + CPPUNIT_ASSERT_EQUAL(SwFrameType::Txt, + pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType()); + const SwSortedObjs* pAnchored + = pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetDrawObjs(); + CPPUNIT_ASSERT(pAnchored); + CPPUNIT_ASSERT_EQUAL(static_cast(1), pAnchored->size()); + SwAnchoredObject* pAnchoredObj = (*pAnchored)[0]; + pFlyFrame = dynamic_cast(pAnchoredObj); + CPPUNIT_ASSERT(pFlyFrame); + } + + // Select the floating table + SdrObject* pObj = pFlyFrame->GetFormat()->FindRealSdrObject(); + CPPUNIT_ASSERT(pObj); + pWrtShell->SelectObj(Point(), 0, pObj); + CPPUNIT_ASSERT(pFlyFrame->IsShowUnfloatButton(pWrtShell)); + + // Push the unfloat button + pFlyFrame->ActiveUnfloatButton(pWrtShell); + + // After unfloating we have two pages with one tablre frame on each page + CPPUNIT_ASSERT(pWrtShell->GetLayout()->GetLower()->GetNext()); + CPPUNIT_ASSERT_EQUAL(SwFrameType::Page, + pWrtShell->GetLayout()->GetLower()->GetNext()->GetType()); + CPPUNIT_ASSERT(!pWrtShell->GetLayout()->GetLower()->GetNext()->GetNext()); + CPPUNIT_ASSERT_EQUAL(SwFrameType::Tab, + pWrtShell->GetLayout()->GetLower()->GetLower()->GetLower()->GetType()); + CPPUNIT_ASSERT_EQUAL( + SwFrameType::Tab, + pWrtShell->GetLayout()->GetLower()->GetNext()->GetLower()->GetLower()->GetType()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit