summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2022-09-08 13:59:32 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2022-09-08 14:39:21 +0200
commit09e499e64ec4acb24c9524c8aacabc6182124442 (patch)
treeb2ccb167ca8828cb42da04983874cb9de3219aaa /chart2
parent707b0c328a282d993fa33b618083d20b6c521de6 (diff)
Fix CppunitTest_chart2_import on non-default DPI
It is really unfortunate that so much of our code depends on the DPI, that should not. Change-Id: Id1916677add508171490591a234f07a82a8e3f5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139648 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/qa/extras/chart2import.cxx27
-rw-r--r--chart2/qa/extras/xshape/chart2xshape.cxx15
2 files changed, 31 insertions, 11 deletions
diff --git a/chart2/qa/extras/chart2import.cxx b/chart2/qa/extras/chart2import.cxx
index 4e5b3a83130e..40a56d7535f1 100644
--- a/chart2/qa/extras/chart2import.cxx
+++ b/chart2/qa/extras/chart2import.cxx
@@ -2183,19 +2183,23 @@ void Chart2ImportTest::testFixedSizeBarChartVeryLongLabel()
uno::Reference<container::XIndexAccess> xIndexAccess(xXAxis, UNO_QUERY_THROW);
- // Check text is actually cropped
- uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL(OUString("Very very very very very very..."), xLabel->getString());
+ // Check text is actually cropped. Depending on DPI,
+ // it may be "Very very very very very very..." or "Very very very very very ver..."
+ uno::Reference<text::XTextRange> xLabel(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
+ const OUString aLabelString = xLabel->getString();
+ CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(32), aLabelString.getLength());
+ CPPUNIT_ASSERT(aLabelString.endsWith(u"..."));
uno::Reference<drawing::XShape> xChartWall = getShapeByName(xShapes, "CID/DiagramWall=");
CPPUNIT_ASSERT(xChartWall.is());
// The text shape width should be smaller than the chart wall
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5085), xChartWall->getSize().Width);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(7113), xChartWall->getSize().Height);
+ // The specific numbers unfortunately vary depending on DPI - allow 1 mm
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5085, xChartWall->getSize().Width, 100);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(7113, xChartWall->getSize().Height, 100);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(4870), xXAxis->getSize().Width);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(398), xXAxis->getSize().Height);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(4800, xXAxis->getSize().Width, 100);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(398, xXAxis->getSize().Height, 100);
}
void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel()
@@ -2260,11 +2264,12 @@ void Chart2ImportTest::testAutomaticSizeBarChartVeryLongLabel()
CPPUNIT_ASSERT(xChartWall.is());
// The text shape width should be smaller than the chart wall
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5761), xChartWall->getSize().Width);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(7200), xChartWall->getSize().Height);
+ // The specific numbers unfortunately vary depending on DPI - allow 1 mm
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5761, xChartWall->getSize().Width, 100);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(7200, xChartWall->getSize().Height, 100);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(5320), xXAxis->getSize().Width);
- CPPUNIT_ASSERT_EQUAL(sal_Int32(1192), xXAxis->getSize().Height);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5320, xXAxis->getSize().Width, 100);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1192, xXAxis->getSize().Height, 100);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ImportTest);
diff --git a/chart2/qa/extras/xshape/chart2xshape.cxx b/chart2/qa/extras/xshape/chart2xshape.cxx
index 45d92e58187b..2814dfcce46c 100644
--- a/chart2/qa/extras/xshape/chart2xshape.cxx
+++ b/chart2/qa/extras/xshape/chart2xshape.cxx
@@ -95,12 +95,22 @@ void Chart2XShapeTest::compareAgainstReference(std::u16string_view rReferenceFil
void Chart2XShapeTest::testFdo75075()
{
+ // 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(u"chart2/qa/extras/xshape/data/ods/", u"fdo75075.ods");
compareAgainstReference(u"fdo75075.xml");
}
void Chart2XShapeTest::testPropertyMappingBarChart()
{
+ // 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(u"chart2/qa/extras/xshape/data/ods/", u"property-mapping-bar.ods");
compareAgainstReference(u"property-mapping-bar.xml");
}
@@ -155,6 +165,11 @@ void Chart2XShapeTest::testPieChartLabels4()
void Chart2XShapeTest::testChart()
{
+ // 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(u"chart2/qa/extras/xshape/data/ods/", u"testChart.ods");
compareAgainstReference(u"testChart.xml");
}