include/test/bootstrapfixture.hxx |    1 +
 sd/qa/unit/PNGExportTests.cxx     |   10 ++++++++--
 test/source/bootstrapfixture.cxx  |    6 ++++++
 3 files changed, 15 insertions(+), 2 deletions(-)

New commits:
commit a144acfdf6a4be6654c6bdac4de954b91c577831
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Mar 7 12:17:46 2022 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Mon Mar 7 12:53:27 2022 +0100

    Fix some DPI-dependent tests
    
    Change-Id: I3c669802ac558379498c877c8ac4796bbff80f82
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131096
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/include/test/bootstrapfixture.hxx 
b/include/test/bootstrapfixture.hxx
index b3463ae223d5..438bba58a431 100644
--- a/include/test/bootstrapfixture.hxx
+++ b/include/test/bootstrapfixture.hxx
@@ -53,6 +53,7 @@ protected:
     // until a proper fix is implemented that either considers the DPI 
properly in the test, or
     // makes the invariants that test uses independent of DPI.
     static bool IsDefaultDPI();
+    static std::pair<double, double> getDPIScaling();
 
 public:
     DECL_DLLPRIVATE_STATIC_LINK(BootstrapFixture, ImplInitFilterHdl, 
ConvertData&, bool);
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index f3ab40228953..44a282f94a97 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -83,7 +83,11 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf105998)
 
     // make sure only the shape is exported
     Size aSize = aBMPEx.GetSizePixel();
-    CPPUNIT_ASSERT_EQUAL(Size(193, 193), aSize);
+    const auto[scalingX, scalingY] = getDPIScaling();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(193 * scalingX, aSize.getWidth(), 1.0);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(193 * scalingY, aSize.getHeight(), 1.0);
+    if (!IsDefaultDPI())
+        return;
 
     // Check all borders are red
     // use assertColorsAreSimilar since the color might differ a little bit on 
mac
@@ -144,7 +148,9 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf126319)
 
     // make sure only the shape is exported
     Size aSize = aBMPEx.GetSizePixel();
-    CPPUNIT_ASSERT_EQUAL(Size(295, 134), aSize);
+    const auto[scalingX, scalingY] = getDPIScaling();
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(295 * scalingX, aSize.getWidth(), 1.0);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(134 * scalingY, aSize.getHeight(), 1.0);
 
     // Check all borders are red or similar. Ignore the corners
     Bitmap aBMP = aBMPEx.GetBitmap();
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index 4d933a3fc5d2..c13caf807d1e 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -264,6 +264,12 @@ bool test::BootstrapFixture::IsDefaultDPI()
             && Application::GetDefaultDevice()->GetDPIY() == 96);
 }
 
+std::pair<double, double> test::BootstrapFixture::getDPIScaling()
+{
+    return { Application::GetDefaultDevice()->GetDPIX() / 96.0,
+             Application::GetDefaultDevice()->GetDPIY() / 96.0 };
+}
+
 sal_uInt16 test::BootstrapFixture::getDefaultDeviceBitCount()
 {
     ScopedVclPtr<VirtualDevice> device

Reply via email to