[Libreoffice-commits] core.git: chart2/qa include/test sc/qa test/source

Mike Kaganski (via logerrit) logerrit at kemper.freedesktop.org
Thu Nov 26 10:00:08 UTC 2020


 chart2/qa/extras/chart2import.cxx        |    5 +++++
 chart2/qa/extras/xshape/chart2xshape.cxx |   14 ++++----------
 include/test/bootstrapfixture.hxx        |    6 ++++++
 sc/qa/unit/subsequent_filters-test.cxx   |    6 ++----
 test/source/bootstrapfixture.cxx         |    7 +++++++
 5 files changed, 24 insertions(+), 14 deletions(-)

New commits:
commit 269e36ece4ff720e10c83126d7c553c7287645c6
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Thu Nov 26 11:41:18 2020 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Thu Nov 26 10:59:15 2020 +0100

    Introduce BootstrapFixture::IsDefaultDPI convenience function
    
    It should be used to conditionally disable tests that are unreliable
    in non-default-DPI environments. The workaround implemented by use
    of the function should be temporary, until a proper fix is found.
    
    Change-Id: Ie236226fcfd0ffb054149efc2b7a1727506c4ad0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106661
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index a0b9c00dd24d..490b2ce2698d 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -2563,6 +2563,11 @@ void Chart2ImportTest::testStockChartShiftedCategoryPosition()
 
 void Chart2ImportTest::testTdf133376()
 {
+    // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
+    // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
+    if (!IsDefaultDPI())
+        return;
+
     load("/chart2/qa/extras/data/xlsx/", "tdf133376.xlsx");
     Reference<chart::XChartDocument> xChartDoc(getChartDocFromSheet(0, mxComponent),
         UNO_QUERY_THROW);
diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx
index 68dcc1e7e030..a1a0032effc3 100644
--- a/chart2/qa/extras/xshape/chart2xshape.cxx
+++ b/chart2/qa/extras/xshape/chart2xshape.cxx
@@ -14,8 +14,6 @@
 
 #include <test/xmldiff.hxx>
 #include <test/xmltesttools.hxx>
-#include <vcl/outdev.hxx>
-#include <vcl/svapp.hxx>
 
 #include <fstream>
 
@@ -117,8 +115,7 @@ void Chart2XShapeTest::testPieChartLabels1()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     // inside placement for the best fit case
@@ -130,8 +127,7 @@ void Chart2XShapeTest::testPieChartLabels2()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     // text wrap: wrap all text labels except one
@@ -143,8 +139,7 @@ void Chart2XShapeTest::testPieChartLabels3()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     // text wrap: wrap no text label except one
@@ -156,8 +151,7 @@ void Chart2XShapeTest::testPieChartLabels4()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     // data value and percent value are centered horizontally
diff --git a/include/test/bootstrapfixture.hxx b/include/test/bootstrapfixture.hxx
index 052e3a8e229d..3a0cc1da7119 100644
--- a/include/test/bootstrapfixture.hxx
+++ b/include/test/bootstrapfixture.hxx
@@ -48,6 +48,12 @@ class OOO_DLLPUBLIC_TEST BootstrapFixture : public BootstrapFixtureBase
 protected:
     css::uno::Reference<css::uno::XComponentContext> mxComponentContext;
 
+    // A convenience function to be used to conditionally exclude tests not behaving properly
+    // on UI scaling other than 1:1. Using this should be considered a temporary workaround,
+    // 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();
+
 public:
     DECL_STATIC_LINK(BootstrapFixture, ImplInitFilterHdl, ConvertData&, bool);
 
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 23a2c27faa48..8bc5ff722b8b 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -2882,8 +2882,7 @@ void ScFiltersTest::testMiscRowHeights()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     static const TestParam::RowData DfltRowData[] =
@@ -2926,8 +2925,7 @@ void ScFiltersTest::testOptimalHeightReset()
 {
     // FIXME: the DPI check should be removed when either (1) the test is fixed to work with
     // non-default DPI; or (2) unit tests on Windows are made to use svp VCL plugin.
-    if (Application::GetDefaultDevice()->GetDPIX() != 96
-        || Application::GetDefaultDevice()->GetDPIY() != 96)
+    if (!IsDefaultDPI())
         return;
 
     ScDocShellRef xDocSh = loadDoc("multilineoptimal.", FORMAT_ODS, true);
diff --git a/test/source/bootstrapfixture.cxx b/test/source/bootstrapfixture.cxx
index 4d6b54a8f879..d05ae03d39e9 100644
--- a/test/source/bootstrapfixture.cxx
+++ b/test/source/bootstrapfixture.cxx
@@ -18,6 +18,7 @@
 #include <com/sun/star/ucb/XContentProvider.hpp>
 #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
 
+#include <vcl/outdev.hxx>
 #include <vcl/svapp.hxx>
 #include <tools/link.hxx>
 #include <vcl/graphicfilter.hxx>
@@ -237,4 +238,10 @@ IMPL_STATIC_LINK(
     return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( rData );
 }
 
+bool test::BootstrapFixture::IsDefaultDPI()
+{
+    return (Application::GetDefaultDevice()->GetDPIX() == 96
+            && Application::GetDefaultDevice()->GetDPIY() == 96);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list