[Libreoffice-commits] core.git: basegfx/test

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 2 06:13:07 UTC 2020


 basegfx/test/B2DHomMatrixTest.cxx |   32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

New commits:
commit b5dee02018f9f7cd8d9afc6e8991e6e20ebb0e81
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Wed May 27 12:50:14 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 2 08:12:25 2020 +0200

    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 at gmail.com>

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


More information about the Libreoffice-commits mailing list