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

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jul 9 23:05:33 UTC 2019


 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   38 ++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 9 deletions(-)

New commits:
commit 691e9427117f909273f648d167465802580ec770
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Jul 9 23:08:23 2019 +1000
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Wed Jul 10 01:04:21 2019 +0200

    Fix CppunitTest_sw_ooxmlexport3 on systems with DPI scaling
    
    ... after commit 3f7e8ddea89f6340cd18b5b34f5a7c5f503962be
    
    The tests are DPI-dependent, and failed on systems with DPI other
    than 96, so take that into account.
    
    Change-Id: I0297aab7988c3b78cbd3132f21e5a101bc32c1f6
    Reviewed-on: https://gerrit.libreoffice.org/75302
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index bddb9323ac2f..405cba6c78a4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -573,9 +573,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf106974_int32Crop, "tdf106974_int32Crop.docx")
 
     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
 
+    // The crop is constructed in GraphicProperties::pushToPropMap, where
+    // GraphicHelper::getOriginalSize tries to get graphic size in mm, then falls back to pixels,
+    // which are then converted to mm taking screen DPI scaling into account. Thus, the resulting
+    // values are DPI-dependent.
+    const double fXScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIX();
+
     CPPUNIT_ASSERT_MESSAGE(
         OString::number(aGraphicCropStruct.Right).getStr(),
-        sal_Int32( 40470 ) < aGraphicCropStruct.Right );
+        40470 * fXScaleFactor < aGraphicCropStruct.Right);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testLineSpacingexport, "test_line_spacing.docx")
@@ -701,10 +707,17 @@ DECLARE_OOXMLEXPORT_TEST(testGIFImageCrop, "test_GIF_ImageCrop.docx")
 
     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
 
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1085 ), aGraphicCropStruct.Left );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 3651 ), aGraphicCropStruct.Right );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 953 ), aGraphicCropStruct.Top );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1244 ), aGraphicCropStruct.Bottom );
+    // The crop is constructed in GraphicProperties::pushToPropMap, where
+    // GraphicHelper::getOriginalSize tries to get graphic size in mm, then falls back to pixels,
+    // which are then converted to mm taking screen DPI scaling into account. Thus, the resulting
+    // values are DPI-dependent.
+    const double fXScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIX();
+    const double fYScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIY();
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1085 * fXScaleFactor, aGraphicCropStruct.Left, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(3651 * fXScaleFactor, aGraphicCropStruct.Right, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(953 * fYScaleFactor, aGraphicCropStruct.Top, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1244 * fYScaleFactor, aGraphicCropStruct.Bottom, 1);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx")
@@ -719,10 +732,17 @@ DECLARE_OOXMLEXPORT_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx")
 
     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
 
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1058 ), aGraphicCropStruct.Left );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1111 ), aGraphicCropStruct.Right );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 1164 ), aGraphicCropStruct.Top );
-    CPPUNIT_ASSERT_EQUAL( sal_Int32( 635 ), aGraphicCropStruct.Bottom );
+    // The crop is constructed in GraphicProperties::pushToPropMap, where
+    // GraphicHelper::getOriginalSize tries to get graphic size in mm, then falls back to pixels,
+    // which are then converted to mm taking screen DPI scaling into account. Thus, the resulting
+    // values are DPI-dependent.
+    const double fXScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIX();
+    const double fYScaleFactor = 96.0 / Application::GetDefaultDevice()->GetDPIY();
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1058 * fXScaleFactor, aGraphicCropStruct.Left, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1111 * fXScaleFactor, aGraphicCropStruct.Right, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(1164 * fYScaleFactor, aGraphicCropStruct.Top, 1);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(635 * fYScaleFactor, aGraphicCropStruct.Bottom, 1);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf41542_imagePadding, "tdf41542_imagePadding.odt")


More information about the Libreoffice-commits mailing list