[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Thu Mar 12 02:23:02 PDT 2015
sw/qa/extras/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(-)
New commits:
commit 5729574929ca82cdf0b7b472cfea1b211a981fa2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Thu Mar 12 10:18:48 2015 +0100
Add SwXTextDocument::setGraphicSelection() testcase
Change-Id: I172ef9f5cfdae8cbff88419171c5b8ad55fb194c
diff --git a/sw/qa/extras/tiledrendering/data/reset-selection.fodt b/sw/qa/extras/tiledrendering/data/shape.fodt
similarity index 100%
rename from sw/qa/extras/tiledrendering/data/reset-selection.fodt
rename to sw/qa/extras/tiledrendering/data/shape.fodt
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index de23c69..f67f621 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);
More information about the Libreoffice-commits
mailing list