From ab27a77aa82bd0bcad59652b76a5c65e5e946cea Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 12 Mar 2015 10:18:48 +0100 Subject: Add SwXTextDocument::setGraphicSelection() testcase Change-Id: I172ef9f5cfdae8cbff88419171c5b8ad55fb194c --- .../tiledrendering/data/reset-selection.fodt | 17 ------------- sw/qa/extras/tiledrendering/data/shape.fodt | 17 +++++++++++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 28 +++++++++++++++++++++- 3 files changed, 44 insertions(+), 18 deletions(-) delete mode 100644 sw/qa/extras/tiledrendering/data/reset-selection.fodt create mode 100644 sw/qa/extras/tiledrendering/data/shape.fodt (limited to 'sw/qa') diff --git a/sw/qa/extras/tiledrendering/data/reset-selection.fodt b/sw/qa/extras/tiledrendering/data/reset-selection.fodt deleted file mode 100644 index feefe48bcde3..000000000000 --- a/sw/qa/extras/tiledrendering/data/reset-selection.fodt +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - Hello. - - - diff --git a/sw/qa/extras/tiledrendering/data/shape.fodt b/sw/qa/extras/tiledrendering/data/shape.fodt new file mode 100644 index 000000000000..feefe48bcde3 --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/shape.fodt @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + Hello. + + + diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index de23c69ace9c..f67f6218b339 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -21,9 +22,11 @@ class SwTiledRenderingTest : public SwModelTestBase { public: + void testSetGraphicSelection(); void testResetSelection(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); + CPPUNIT_TEST(testSetGraphicSelection); CPPUNIT_TEST(testResetSelection); CPPUNIT_TEST_SUITE_END(); @@ -37,12 +40,35 @@ SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName) SwXTextDocument* pTextDocument = dynamic_cast(mxComponent.get()); CPPUNIT_ASSERT(pTextDocument); + pTextDocument->initializeForTiledRendering(); return pTextDocument; } +void SwTiledRenderingTest::testSetGraphicSelection() +{ + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + pWrtShell->SelectObj(Point(), 0, pObject); + // Make sure the rectangle has 8 handles: at each corner and at the center of each edge. + CPPUNIT_ASSERT_EQUAL(static_cast(8), pObject->GetHdlCount()); + // Take the bottom center one. + SdrHdl* pHdl = pObject->GetHdl(6); + CPPUNIT_ASSERT_EQUAL(HDL_LOWER, pHdl->GetKind()); + Rectangle aShapeBefore = pObject->GetSnapRect(); + // Resize. + pXTextDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, pHdl->GetPos().getX(), pHdl->GetPos().getY()); + pXTextDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, pHdl->GetPos().getX(), pHdl->GetPos().getY() + 1000); + Rectangle aShapeAfter = pObject->GetSnapRect(); + // Check that a resize happened, but aspect ratio is not kept. + CPPUNIT_ASSERT_EQUAL(aShapeBefore.getWidth(), aShapeAfter.getWidth()); + CPPUNIT_ASSERT_EQUAL(aShapeBefore.getHeight() + 1000, aShapeAfter.getHeight()); +} + void SwTiledRenderingTest::testResetSelection() { - SwXTextDocument* pXTextDocument = createDoc("reset-selection.fodt"); + SwXTextDocument* pXTextDocument = createDoc("shape.fodt"); SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); // Select one character. pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false); -- cgit