diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-01-04 11:23:59 +0100 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-01-04 13:08:55 +0100 |
commit | dd0b559d6aac5bf09566af735bd00b28c00fb2e4 (patch) | |
tree | aeb56b0bdbb77f5f145b8b94c006bc31d36140d1 /sw/qa | |
parent | ba60204055823bce27a51078d7170e0ff9836636 (diff) |
Unfloat: Test layout change of unfloat operation
Change-Id: I75298a392de6a10861ac96e1bc58a30173cd2dd2
Reviewed-on: https://gerrit.libreoffice.org/65823
Tested-by: Jenkins
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 52 |
1 files changed, 50 insertions, 2 deletions
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 <view.hxx> #include <sortedobjs.hxx> #include <anchoredobject.hxx> -#include <FrameControlsManager.hxx> -#include <FloatingTableButton.hxx> +#include <swtypes.hxx> 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<SwXTextDocument*>(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<size_t>(1), pAnchored->size()); + SwAnchoredObject* pAnchoredObj = (*pAnchored)[0]; + pFlyFrame = dynamic_cast<SwFlyFrame*>(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: */ |