[Libreoffice-commits] core.git: sd/qa

Miklos Vajna vmiklos at collabora.co.uk
Tue Apr 14 05:02:22 PDT 2015


 sd/qa/unit/tiledrendering/data/shape.odp     |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   24 ++++++++++++++++++++++++
 2 files changed, 24 insertions(+)

New commits:
commit 87b682500f481b61399609b24a4a695fda93f552
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Apr 14 12:44:29 2015 +0200

    Add SdXImpressDocument::setGraphicSelection() testcase.
    
    Change-Id: Ifdf3ef84cd886b338536629fb36ebba694916d6a

diff --git a/sd/qa/unit/tiledrendering/data/shape.odp b/sd/qa/unit/tiledrendering/data/shape.odp
new file mode 100644
index 0000000..f734761
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/shape.odp differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 1b87768..16ec351 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -43,6 +43,7 @@ public:
     void testPostKeyEvent();
     void testPostMouseEvent();
     void testSetTextSelection();
+    void testSetGraphicSelection();
 #endif
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
@@ -51,6 +52,7 @@ public:
     CPPUNIT_TEST(testPostKeyEvent);
     CPPUNIT_TEST(testPostMouseEvent);
     CPPUNIT_TEST(testSetTextSelection);
+    CPPUNIT_TEST(testSetGraphicSelection);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -219,6 +221,28 @@ void SdTiledRenderingTest::testSetTextSelection()
     // The new selection must include the ending dot, too -- but not the first word.
     CPPUNIT_ASSERT_EQUAL(OUString("bbb."), rEditView.GetSelected());
 }
+
+void SdTiledRenderingTest::testSetGraphicSelection()
+{
+    SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pPage = pViewShell->GetActualPage();
+    SdrObject* pObject = pPage->GetObj(0);
+    // 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.
+    pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_START, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(pHdl->GetPos().getY()));
+    pXImpressDocument->setGraphicSelection(LOK_SETGRAPHICSELECTION_END, convertMm100ToTwip(pHdl->GetPos().getX()), convertMm100ToTwip(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(aShapeBefore.getHeight() < aShapeAfter.getHeight());
+}
+
 #endif
 
 CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);


More information about the Libreoffice-commits mailing list