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

2022-12-21 Thread Xisco Fauli (via logerrit)
 include/test/unoapi_test.hxx   |2 
 sc/qa/unit/bugfix-test.cxx |   24 +-
 sc/qa/unit/helper/qahelper.hxx |2 
 sc/qa/unit/scshapetest.cxx |   92 -
 svx/qa/unit/customshapes.cxx   |   16 +++
 5 files changed, 68 insertions(+), 68 deletions(-)

New commits:
commit 179f50f810dfa1779de5c1f212f3887031e5567d
Author: Xisco Fauli 
AuthorDate: Wed Dec 21 16:43:18 2022 +0100
Commit: Xisco Fauli 
CommitDate: Wed Dec 21 19:09:46 2022 +

qa: hint about tolerance in names

As suggested by Mike in https://gerrit.libreoffice.org/c/core/+/144171

Change-Id: I653118985b781ebb1eed71587ae19efe45e1c800
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144691
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx
index e008b11ca2f0..e329168dfe7b 100644
--- a/include/test/unoapi_test.hxx
+++ b/include/test/unoapi_test.hxx
@@ -97,7 +97,7 @@ inline void assertRectangleEqual(const tools::Rectangle& 
rExpected, const tools:
rSourceLine, "different Height");
 }
 
-#define CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aActual, aTolerance) 
\
+#define CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aExpected, aActual, 
aTolerance)  \
 assertRectangleEqual(aExpected, aActual, aTolerance, CPPUNIT_SOURCELINE())
 
 #endif // INCLUDED_TEST_UNOAPI_TEST_HXX
diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index 4c7137d39ab2..af5bd91fc27b 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -106,9 +106,9 @@ void ScFiltersTest::testTdf137576_Measureline()
 
 // Check start and end point of measureline
 const Point aStart = pObj->GetPoint(0);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(4800, 1500), aStart, 1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(4800, 1500), aStart, 1);
 const Point aEnd = pObj->GetPoint(1);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(4800, 5200), aEnd, 1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(4800, 5200), aEnd, 1);
 
 // Save and reload
 saveAndReload("calc8");
@@ -124,9 +124,9 @@ void ScFiltersTest::testTdf137576_Measureline()
 
 // Check start and end point of measureline, should be unchanged
 const Point aStart2 = pObj->GetPoint(0);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(4800, 1500), aStart2, 1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(4800, 1500), aStart2, 1);
 const Point aEnd2 = pObj->GetPoint(1);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(4800, 5200), aEnd2, 1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(4800, 5200), aEnd2, 1);
 }
 
 void ScFiltersTest::testTdf137216_HideCol()
@@ -173,9 +173,9 @@ void ScFiltersTest::testTdf137044_CoverHiddenRows()
 // Get original object values
 tools::Rectangle aSnapRectOrig = pObj->GetSnapRect();
 Point aOriginalEndOffset = ScDrawLayer::GetObjData(pObj)->maEndOffset;
-CPPUNIT_ASSERT_RECTANGLE_EQUAL(tools::Rectangle(Point(500, 3500), 
Size(1501, 11001)),
-   aSnapRectOrig, 1);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(2000, 2499), aOriginalEndOffset, 1);
+CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(
+tools::Rectangle(Point(500, 3500), Size(1501, 11001)), aSnapRectOrig, 
1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(2000, 2499), 
aOriginalEndOffset, 1);
 
 // Hide rows 5 and 6 in UI = row index 4 to 5.
 pDoc->SetRowHidden(4, 5, 0, true);
@@ -195,9 +195,9 @@ void ScFiltersTest::testTdf137044_CoverHiddenRows()
 // Get new values and compare. End offset should be the same, height 
should be 6000 smaller.
 tools::Rectangle aSnapRectReload = pObj->GetSnapRect();
 Point aReloadEndOffset = ScDrawLayer::GetObjData(pObj)->maEndOffset;
-CPPUNIT_ASSERT_RECTANGLE_EQUAL(tools::Rectangle(Point(500, 3500), 
Size(1501, 5001)),
-   aSnapRectReload, 1);
-CPPUNIT_ASSERT_POINT_EQUAL(Point(2000, 2499), aReloadEndOffset, 1);
+CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(
+tools::Rectangle(Point(500, 3500), Size(1501, 5001)), aSnapRectReload, 
1);
+CPPUNIT_ASSERT_POINT_EQUAL_WITH_TOLERANCE(Point(2000, 2499), 
aReloadEndOffset, 1);
 }
 
 void ScFiltersTest::testTdf137020_FlipVertical()
@@ -219,7 +219,7 @@ void ScFiltersTest::testTdf137020_FlipVertical()
 // Vertical mirror on center should not change the snap rect.
 pObj->Mirror(aSnapRectOrig.LeftCenter(), aSnapRectOrig.RightCenter());
 const tools::Rectangle aSnapRectFlip = pObj->GetSnapRect();
-CPPUNIT_ASSERT_RECTANGLE_EQUAL(aSnapRectOrig, aSnapRectFlip, 1);
+CPPUNIT_ASSERT_RECTANGLE_EQUAL_WITH_TOLERANCE(aSnapRectOrig, 
aSnapRectFlip, 1);
 
 // Save and reload
 saveAndReload("calc8");
@@ -235,7 +235,7 @@ void ScFiltersTest::testTdf137020_FlipVertical()
 
 // Check pos and size of shape again, should be unchanged
 const 

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

2022-12-14 Thread Xisco Fauli (via logerrit)
 include/test/unoapi_test.hxx |   16 +++
 sc/qa/unit/bugfix-test.cxx   |   44 ++---
 sc/qa/unit/scshapetest.cxx   |   89 +++
 svx/qa/unit/customshapes.cxx |   46 +++---
 4 files changed, 54 insertions(+), 141 deletions(-)

New commits:
commit 15df8e5422010e0806eb9e93bd8822519c1ab989
Author: Xisco Fauli 
AuthorDate: Wed Dec 14 18:46:19 2022 +0100
Commit: Xisco Fauli 
CommitDate: Thu Dec 15 07:43:49 2022 +

UnoApiTest: introduce CPPUNIT_ASSERT_RECTANGLE_EQUAL

and get rid of duplicated code

Change-Id: Iccbd3147fab71b43b1725af308df8ed37c807b7e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144173
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx
index f228f70e21ca..e008b11ca2f0 100644
--- a/include/test/unoapi_test.hxx
+++ b/include/test/unoapi_test.hxx
@@ -84,6 +84,22 @@ private:
 OUString maImportFilterName;
 };
 
+inline void assertRectangleEqual(const tools::Rectangle& rExpected, const 
tools::Rectangle& rActual,
+ const sal_Int32 nTolerance, const 
CppUnit::SourceLine& rSourceLine)
+{
+CPPUNIT_NS::assertDoubleEquals(rExpected.Top(), rActual.Top(), nTolerance, 
rSourceLine,
+   "different Top");
+CPPUNIT_NS::assertDoubleEquals(rExpected.Left(), rActual.Left(), 
nTolerance, rSourceLine,
+   "different Left");
+CPPUNIT_NS::assertDoubleEquals(rExpected.GetWidth(), rActual.GetWidth(), 
nTolerance,
+   rSourceLine, "different Width");
+CPPUNIT_NS::assertDoubleEquals(rExpected.GetHeight(), rActual.GetHeight(), 
nTolerance,
+   rSourceLine, "different Height");
+}
+
+#define CPPUNIT_ASSERT_RECTANGLE_EQUAL(aExpected, aActual, aTolerance) 
\
+assertRectangleEqual(aExpected, aActual, aTolerance, CPPUNIT_SOURCELINE())
+
 #endif // INCLUDED_TEST_UNOAPI_TEST_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/bugfix-test.cxx b/sc/qa/unit/bugfix-test.cxx
index cc7673c72b8a..4c7137d39ab2 100644
--- a/sc/qa/unit/bugfix-test.cxx
+++ b/sc/qa/unit/bugfix-test.cxx
@@ -87,38 +87,6 @@ public:
 CPPUNIT_TEST_SUITE_END();
 };
 
-static void lcl_AssertRectEqualWithTolerance(std::string_view sInfo,
- const tools::Rectangle& rExpected,
- const tools::Rectangle& rActual,
- const sal_Int32 nTolerance)
-{
-// Left
-OString sMsg = OString::Concat(sInfo) + " Left expected " + 
OString::number(rExpected.Left())
-   + " actual " + OString::number(rActual.Left()) + " 
Tolerance "
-   + OString::number(nTolerance);
-CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-   std::abs(rExpected.Left() - rActual.Left()) <= 
nTolerance);
-
-// Top
-sMsg = OString::Concat(sInfo) + " Top expected " + 
OString::number(rExpected.Top()) + " actual "
-   + OString::number(rActual.Top()) + " Tolerance " + 
OString::number(nTolerance);
-CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(), std::abs(rExpected.Top() - 
rActual.Top()) <= nTolerance);
-
-// Width
-sMsg = OString::Concat(sInfo) + " Width expected " + 
OString::number(rExpected.GetWidth())
-   + " actual " + OString::number(rActual.GetWidth()) + " Tolerance "
-   + OString::number(nTolerance);
-CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-   std::abs(rExpected.GetWidth() - rActual.GetWidth()) 
<= nTolerance);
-
-// Height
-sMsg = OString::Concat(sInfo) + " Height expected " + 
OString::number(rExpected.GetHeight())
-   + " actual " + OString::number(rActual.GetHeight()) + " Tolerance "
-   + OString::number(nTolerance);
-CPPUNIT_ASSERT_MESSAGE(sMsg.getStr(),
-   std::abs(rExpected.GetHeight() - 
rActual.GetHeight()) <= nTolerance);
-}
-
 void ScFiltersTest::testTdf137576_Measureline()
 {
 // The document contains a vertical measure line, anchored "To Cell 
(resize with cell)" with
@@ -205,8 +173,8 @@ void ScFiltersTest::testTdf137044_CoverHiddenRows()
 // Get original object values
 tools::Rectangle aSnapRectOrig = pObj->GetSnapRect();
 Point aOriginalEndOffset = ScDrawLayer::GetObjData(pObj)->maEndOffset;
-lcl_AssertRectEqualWithTolerance("Load:", tools::Rectangle(Point(500, 
3500), Size(1501, 11001)),
- aSnapRectOrig, 1);
+CPPUNIT_ASSERT_RECTANGLE_EQUAL(tools::Rectangle(Point(500, 3500), 
Size(1501, 11001)),
+   aSnapRectOrig, 1);
 CPPUNIT_ASSERT_POINT_EQUAL(Point(2000, 2499), aOriginalEndOffset, 1);
 
 // Hide rows 5 and 6 in UI = row index 4 to 5.
@@ -227,8 +195,8 @@ void