summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-03-12 10:18:48 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-03-16 09:38:08 +0100
commitab27a77aa82bd0bcad59652b76a5c65e5e946cea (patch)
tree1d17afcd3bb20c9fc41302c6f333c6db68007077
parenta1ae91f00fd909a2ba31bb08116baf84f9881a36 (diff)
Add SwXTextDocument::setGraphicSelection() testcase
Change-Id: I172ef9f5cfdae8cbff88419171c5b8ad55fb194c
-rw-r--r--sw/qa/extras/tiledrendering/data/shape.fodt (renamed from sw/qa/extras/tiledrendering/data/reset-selection.fodt)0
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx28
2 files changed, 27 insertions, 1 deletions
diff --git a/sw/qa/extras/tiledrendering/data/reset-selection.fodt b/sw/qa/extras/tiledrendering/data/shape.fodt
index feefe48bcde3..feefe48bcde3 100644
--- a/sw/qa/extras/tiledrendering/data/reset-selection.fodt
+++ b/sw/qa/extras/tiledrendering/data/shape.fodt
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 <swmodeltestbase.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <svx/svdpage.hxx>
#include <svx/svdview.hxx>
#include <crsskip.hxx>
@@ -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<SwXTextDocument*>(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<sal_uInt32>(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);