diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-07-09 23:08:23 +1000 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-07-10 01:04:21 +0200 |
commit | 691e9427117f909273f648d167465802580ec770 (patch) | |
tree | c46d4354e53a761e27a0a5868f6f5e0a89b82553 | |
parent | a9359cf49ad9367d536d239187d7ef615709ea53 (diff) |
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@fbihome.de>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 38 |
1 files changed, 29 insertions, 9 deletions
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") |