summaryrefslogtreecommitdiff
path: root/svx/qa
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2023-03-04 17:14:01 +0900
committerTomaž Vajngerl <quikee@gmail.com>2023-03-05 01:40:15 +0000
commite74c6e8550ae2644e30752e1fa91005c2a412ec7 (patch)
tree2d0824c5b37ebb3f9ea6f402c66edefa8d127275 /svx/qa
parentd2e757b9c6fbf7c205a7229f06e559e85bd8ead9 (diff)
svx: SdrRectObj move, rotate tests
Change-Id: I448f82d87be34c58d0abf4f6a0c1e6192567b807 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148234 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/qa')
-rw-r--r--svx/qa/unit/svdraw.cxx87
1 files changed, 87 insertions, 0 deletions
diff --git a/svx/qa/unit/svdraw.cxx b/svx/qa/unit/svdraw.cxx
index 7bf1ceb9d4a1..fc1a884c4b74 100644
--- a/svx/qa/unit/svdraw.cxx
+++ b/svx/qa/unit/svdraw.cxx
@@ -24,6 +24,7 @@
#include <svx/sdr/contact/displayinfo.hxx>
#include <svx/sdr/contact/viewcontact.hxx>
#include <svx/sdr/contact/viewobjectcontact.hxx>
+#include <svx/svdtrans.hxx>
#include <svx/svdorect.hxx>
#include <svx/unopage.hxx>
#include <svx/svdview.hxx>
@@ -549,6 +550,92 @@ CPPUNIT_TEST_FIXTURE(SvdrawTest, testPageViewDrawLayerClip)
// i.e. the 2nd page had a line shape from the first page's footer.
CPPUNIT_ASSERT_EQUAL(2, pPage2->getObjectCount());
}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectMove)
+{
+ std::unique_ptr<SdrModel> pModel(new SdrModel(nullptr, nullptr, true));
+ pModel->GetItemPool().FreezeIdRanges();
+
+ rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false));
+ pPage->SetSize(Size(50000, 50000));
+ pModel->InsertPage(pPage.get(), 0);
+
+ tools::Rectangle aRect(Point(), Size(100, 100));
+ rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, aRect);
+ pPage->NbcInsertObject(pRectangleObject.get());
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+ pRectangleObject->NbcMove({ 100, 100 });
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(100, 100), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+
+ pPage->RemoveObject(0);
+}
+
+CPPUNIT_TEST_FIXTURE(SvdrawTest, testRectangleObjectRotate)
+{
+ std::unique_ptr<SdrModel> pModel(new SdrModel(nullptr, nullptr, true));
+ pModel->GetItemPool().FreezeIdRanges();
+
+ rtl::Reference<SdrPage> pPage(new SdrPage(*pModel, false));
+ pPage->SetSize(Size(50000, 50000));
+ pModel->InsertPage(pPage.get(), 0);
+
+ {
+ tools::Rectangle aObjectSize(Point(), Size(100, 100));
+ rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, aObjectSize);
+ pPage->NbcInsertObject(pRectangleObject.get());
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+ pRectangleObject->GetSnapRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -1), Size(102, 102)),
+ pRectangleObject->GetCurrentBoundRect());
+
+ auto angle = 9000_deg100;
+ double angleRadians = toRadians(angle);
+ pRectangleObject->NbcRotate(aObjectSize.Center(), angle, std::sin(angleRadians),
+ std::cos(angleRadians));
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 98), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, -1), Size(100, 100)),
+ pRectangleObject->GetSnapRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -2), Size(102, 102)),
+ pRectangleObject->GetCurrentBoundRect());
+
+ pPage->RemoveObject(0);
+ }
+
+ {
+ tools::Rectangle aObjectSize(Point(), Size(100, 100));
+ rtl::Reference<SdrRectObj> pRectangleObject = new SdrRectObj(*pModel, aObjectSize);
+ pPage->NbcInsertObject(pRectangleObject.get());
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(100, 100)),
+ pRectangleObject->GetSnapRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-1, -1), Size(102, 102)),
+ pRectangleObject->GetCurrentBoundRect());
+
+ auto angle = -4500_deg100;
+ double angleRadians = toRadians(angle);
+ pRectangleObject->NbcRotate(aObjectSize.Center(), angle, std::sin(angleRadians),
+ std::cos(angleRadians));
+
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(49, -20), Size(100, 100)),
+ pRectangleObject->GetLogicRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-21, -20), Size(141, 141)),
+ pRectangleObject->GetSnapRect());
+ CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(-22, -21), Size(143, 143)),
+ pRectangleObject->GetCurrentBoundRect());
+
+ pPage->RemoveObject(0);
+ }
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */