summaryrefslogtreecommitdiff
path: root/basegfx
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-27 12:50:14 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-06-09 13:54:39 +0200
commit2ea69ca9ef6160535b5d5ed3d437b767085d7493 (patch)
tree648ce3e197024cddb09d5fb4af76ccacb160e7e0 /basegfx
parent37543a1bad3122461fd7b2ebe61f4a60e16a4ba4 (diff)
basegfx: test of coordinate system conversion
Change-Id: I059d1f272f0633c450287f272083bb09732357b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95304 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit b5dee02018f9f7cd8d9afc6e8991e6e20ebb0e81) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95915 Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'basegfx')
-rw-r--r--basegfx/test/B2DHomMatrixTest.cxx32
1 files changed, 32 insertions, 0 deletions
diff --git a/basegfx/test/B2DHomMatrixTest.cxx b/basegfx/test/B2DHomMatrixTest.cxx
index 8063587ac2dd..e5b923e6dd82 100644
--- a/basegfx/test/B2DHomMatrixTest.cxx
+++ b/basegfx/test/B2DHomMatrixTest.cxx
@@ -503,6 +503,36 @@ public:
CPPUNIT_ASSERT_DOUBLES_EQUAL(26, aRange.getMaxY(), 1E-12);
}
+ void testCoordinateSystemConversion()
+ {
+ // Use case when we convert
+
+ B2DRange aWindow(50, 50, 150, 150);
+
+ B2DRange aSubPage(0, 0, 2000, 2000);
+
+ B2DHomMatrix aB2DMatrix;
+ aB2DMatrix.scale(aWindow.getWidth() / aSubPage.getWidth(),
+ aWindow.getHeight() / aSubPage.getHeight());
+ aB2DMatrix.translate(aWindow.getMinX(), aWindow.getMinY());
+
+ B2DPoint aPoint1(0, 0);
+ aPoint1 *= aB2DMatrix;
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(50, aPoint1.getY(), 1E-12);
+
+ B2DPoint aPoint2(1000, 1000);
+ aPoint2 *= aB2DMatrix;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(100, aPoint2.getY(), 1E-12);
+
+ B2DPoint aPoint3(2000, 2000);
+ aPoint3 *= aB2DMatrix;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getX(), 1E-12);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(150, aPoint3.getY(), 1E-12);
+ }
+
// Change the following lines only, if you add, remove or rename
// member functions of the current class,
// because these macros are need by auto register mechanism.
@@ -520,6 +550,8 @@ public:
CPPUNIT_TEST(testMultiplyWithAnotherMatrix);
CPPUNIT_TEST(testTransformPoint);
CPPUNIT_TEST(testTransformRange);
+ CPPUNIT_TEST(testCoordinateSystemConversion);
+
CPPUNIT_TEST_SUITE_END();
}; // class b2dhommatrix