include/test/calc_unoapi_test.hxx | 4 -- sc/qa/extras/macros-test.cxx | 76 -------------------------------------- sc/qa/extras/vba-macro-test.cxx | 45 +--------------------- sc/qa/unit/scshapetest.cxx | 47 ----------------------- sc/qa/unit/uicalc/uicalc.cxx | 6 +++ test/source/calc_unoapi_test.cxx | 26 ++++--------- 6 files changed, 17 insertions(+), 187 deletions(-)
New commits: commit 03d6d07d8c1be4f0123f1f9b05b4e5f0f92eabf6 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Oct 21 14:12:29 2022 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Oct 21 18:59:47 2022 +0200 CalcUnoApiTest: work with mxComponent directly Change-Id: If6f2104ef3136952341c9d5d59a1f9784d0fe4b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141628 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/include/test/calc_unoapi_test.hxx b/include/test/calc_unoapi_test.hxx index 5bca2c150f93..a34418876bf3 100644 --- a/include/test/calc_unoapi_test.hxx +++ b/include/test/calc_unoapi_test.hxx @@ -20,7 +20,6 @@ class OOO_DLLPUBLIC_TEST CalcUnoApiTest : public UnoApiTest public: CalcUnoApiTest(const OUString& path); - virtual void setUp() override; virtual void tearDown() override; css::uno::Any executeMacro(const OUString& rScriptURL, @@ -32,9 +31,6 @@ public: protected: // reference to document component that we are testing css::uno::Reference<css::lang::XComponent> mxComponent; - -private: - css::uno::Reference<css::uno::XInterface> m_xCalcComponent; }; #endif // INCLUDED_TEST_CALC_UNOAPI_TEST_HXX diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index c14490473124..886548317942 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -136,9 +136,6 @@ void ScMacrosTest::testMSP() SAL_INFO("sc.qa", "Result is " << sResult ); CPPUNIT_ASSERT_EQUAL_MESSAGE("TestMSP ( for fdo#67547) failed", OUString("OK"), sResult); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testPasswordProtectedStarBasic() @@ -173,8 +170,6 @@ void ScMacrosTest::testPasswordProtectedStarBasic() aValue = rDoc.GetString(2,0,0); CPPUNIT_ASSERT_EQUAL_MESSAGE("Far Method script did not change the value of Sheet1.C1", OUString("success"), aValue); - - pDocSh->DoClose(); } void ScMacrosTest::testStarBasic() @@ -192,7 +187,6 @@ void ScMacrosTest::testStarBasic() executeMacro("vnd.sun.Star.script:Standard.Module1.Macro1?language=Basic&location=document"); double aValue = rDoc.GetValue(0,0,0); CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("script did not change the value of Sheet1.A1",2.0, aValue, 0.00001); - pDocSh->DoClose(); } void ScMacrosTest::testRowColumn() @@ -215,8 +209,6 @@ void ScMacrosTest::testRowColumn() executeMacro("vnd.sun.Star.script:Standard.Module1.Macro_ColumnWidth?language=Basic&location=document"); sal_uInt16 nWidth = o3tl::convert(rDoc.GetColWidth(0, 0), o3tl::Length::twip, o3tl::Length::mm100); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(4001), nWidth); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf146742() @@ -241,8 +233,6 @@ void ScMacrosTest::testTdf146742() // - Expected: FALSE // - Actual : TRUE CPPUNIT_ASSERT_EQUAL(OUString("FALSE"), rDoc.GetString(ScAddress(1,1,0))); - - pDocSh->DoClose(); } void ScMacrosTest::testMacroButtonFormControlXlsxExport() @@ -294,8 +284,6 @@ void ScMacrosTest::testTdf104902() // newlines // - Actual : string withnewlines CPPUNIT_ASSERT_EQUAL(OUString(u"string with" + OUStringChar(u'\xA') + u"newlines"), rDoc.GetString(ScAddress(0, 1, 0))); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf64639() @@ -327,8 +315,6 @@ void ScMacrosTest::testTdf64639() CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), pPage->GetObjCount()); } - - pDocSh->DoClose(); } void ScMacrosTest::testTdf142033() @@ -357,8 +343,6 @@ void ScMacrosTest::testTdf142033() // - Actual : string withnewlines CPPUNIT_ASSERT_EQUAL(OUString(u"string with" + OUStringChar(u'\xA') + u"newlines"), rDoc.GetString(ScAddress(1,0,0))); CPPUNIT_ASSERT_EQUAL(OUString(u"string with" + OUStringChar(u'\xA') + u"newlines"), rDoc.GetString(ScAddress(1,1,0))); - - pDocSh->DoClose(); } void ScMacrosTest::testPasswordProtectedUnicodeString() @@ -402,9 +386,6 @@ void ScMacrosTest::testPasswordProtectedUnicodeString() aRet >>= aReturnValue; CPPUNIT_ASSERT_EQUAL(sCorrectString, aReturnValue); } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testPasswordProtectedArrayInUserType() @@ -447,9 +428,6 @@ void ScMacrosTest::testPasswordProtectedArrayInUserType() aRet >>= nReturnValue; CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nReturnValue); } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf114427() @@ -474,8 +452,6 @@ void ScMacrosTest::testTdf114427() executeMacro("vnd.sun.Star.script:Standard.Module1.DeletingFrame?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDraws->getCount()); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf131296_legacy() @@ -503,9 +479,6 @@ void ScMacrosTest::testTdf131296_legacy() CPPUNIT_ASSERT_EQUAL_MESSAGE(sTestName.toUtf8().getStr(), sExpected, aReturnValue); } } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf131296_new() @@ -534,9 +507,6 @@ void ScMacrosTest::testTdf131296_new() CPPUNIT_ASSERT_EQUAL_MESSAGE(sTestName.toUtf8().getStr(), sExpected, aReturnValue); } } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf46119() @@ -567,8 +537,6 @@ void ScMacrosTest::testTdf46119() CPPUNIT_ASSERT_EQUAL(OUString("0.134"), rDoc.GetString(ScAddress(4, 25, 0))); CPPUNIT_ASSERT_EQUAL(OUString("0.386"), rDoc.GetString(ScAddress(4, 26, 0))); CPPUNIT_ASSERT_EQUAL(OUString("0.366"), rDoc.GetString(ScAddress(4, 27, 0))); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf128218() @@ -587,9 +555,6 @@ void ScMacrosTest::testTdf128218() // - Actual : Object() CPPUNIT_ASSERT_EQUAL(OUString("Double"), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf71271() @@ -616,9 +581,6 @@ void ScMacrosTest::testTdf71271() xProps->getPropertyValue("CodeName") >>= sCodeName; CPPUNIT_ASSERT_EQUAL(OUString("NewCodeName"), sCodeName); } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf43003() @@ -639,9 +601,6 @@ void ScMacrosTest::testTdf43003() rDoc.SetValue(ScAddress(0, 0, 0), 2); CPPUNIT_ASSERT_EQUAL(3.0, rDoc.GetValue(ScAddress(1, 0, 0))); CPPUNIT_ASSERT_EQUAL(4.0, rDoc.GetValue(ScAddress(2, 0, 0))); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } @@ -676,9 +635,6 @@ void ScMacrosTest::testTdf75263() // - Actual : ????? CPPUNIT_ASSERT_EQUAL(OUString(u"проба"), rDoc.GetString(ScAddress(0, 0, 0))); } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf133887() @@ -705,9 +661,6 @@ void ScMacrosTest::testTdf133887() // - Actual : 7 CPPUNIT_ASSERT_EQUAL(6.75, aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf133889() @@ -734,9 +687,6 @@ void ScMacrosTest::testTdf133889() // - Actual : 0 CPPUNIT_ASSERT_EQUAL(sal_Int32(100000), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf143582() @@ -754,9 +704,6 @@ void ScMacrosTest::testTdf143582() // - Expected: Test6 // - Actual : TeTest8 CPPUNIT_ASSERT_EQUAL(OUString("Test6"), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf144085() @@ -774,9 +721,6 @@ void ScMacrosTest::testTdf144085() // - Expected: $Sheet1.$B$5:$E$17 // - Actual : $Sheet1.$B$5:$C$10 CPPUNIT_ASSERT_EQUAL(OUString("$Sheet1.$B$5:$E$17"), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf125800() @@ -811,8 +755,6 @@ void ScMacrosTest::testTdf125800() const ScCondFormatEntry* pCondition = static_cast<const ScCondFormatEntry*>(pEntry); CPPUNIT_ASSERT_EQUAL(ScConditionMode::Direct, pCondition->GetOperation()); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf130307() @@ -828,9 +770,6 @@ void ScMacrosTest::testTdf130307() // Without the fix in place, this test would have crashed here CPPUNIT_ASSERT_EQUAL(OUString("Sheet1Sheet2"), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf144970() @@ -861,8 +800,6 @@ void ScMacrosTest::testTdf144970() executeMacro("vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document"); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); - - pDocSh->DoClose(); } void ScMacrosTest::testTdf138646() @@ -899,8 +836,6 @@ void ScMacrosTest::testTdf138646() CPPUNIT_ASSERT_EQUAL_MESSAGE(sTestName.toUtf8().getStr(), sExpected, aReturnValue); } } - - pDocSh->DoClose(); } void ScMacrosTest::testTdf105558() @@ -920,9 +855,6 @@ void ScMacrosTest::testTdf105558() // - Expected: 5.5 // - Actual : 0 CPPUNIT_ASSERT_EQUAL(5.5, rDoc.GetValue(ScAddress(0, 0, 0))); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testTdf107572() @@ -976,8 +908,6 @@ void ScMacrosTest::testTdf107572() CPPUNIT_ASSERT_EQUAL(Color(0xcc, 0xcc, 0xcc), rColor2); } - - pDocSh->DoClose(); } void ScMacrosTest::testShapeLayerId() @@ -1012,9 +942,6 @@ void ScMacrosTest::testShapeLayerId() // The LayerID property of com.sun.star.drawing.Shape service has 'short' IDL type. // The expected run-time error is because there are only 5 layers there. CPPUNIT_ASSERT_EQUAL(Any(OUString("0 Expected runtime error happened")), aRet); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void ScMacrosTest::testFunctionAccessIndirect() @@ -1033,9 +960,6 @@ void ScMacrosTest::testFunctionAccessIndirect() // because of disallowed external link update (needed to obtain the cell value). css::uno::Any aResult = xFunc->callFunction("INDIRECT", {css::uno::Any(aReference)}); CPPUNIT_ASSERT_EQUAL(css::uno::Any(OUString("a1")), aResult); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } ScMacrosTest::ScMacrosTest() diff --git a/sc/qa/extras/vba-macro-test.cxx b/sc/qa/extras/vba-macro-test.cxx index a54c4bdfd57e..1441933439ec 100644 --- a/sc/qa/extras/vba-macro-test.cxx +++ b/sc/qa/extras/vba-macro-test.cxx @@ -125,8 +125,6 @@ void VBAMacroTest::testSimpleCopyAndPaste() CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(1, 3, 0))); CPPUNIT_ASSERT_EQUAL(20.0, rDoc.GetValue(ScAddress(1, 4, 0))); CPPUNIT_ASSERT_EQUAL(30.0, rDoc.GetValue(ScAddress(1, 5, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testMultiDocumentCopyAndPaste() @@ -164,8 +162,6 @@ void VBAMacroTest::testMultiDocumentCopyAndPaste() CPPUNIT_ASSERT_EQUAL(200.0, rDoc.GetValue(ScAddress(1, 1, 0))); CPPUNIT_ASSERT_EQUAL(100.0, rDoc.GetValue(ScAddress(1, 2, 0))); CPPUNIT_ASSERT_EQUAL(0.0, rDoc.GetValue(ScAddress(1, 3, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testSheetAndColumnSelectAndHide() @@ -229,8 +225,6 @@ void VBAMacroTest::testSheetAndColumnSelectAndHide() CPPUNIT_ASSERT(!rDoc.ColHidden(4, 2)); CPPUNIT_ASSERT_EQUAL(SCTAB(0), rViewData.GetTabNo()); - - pDocSh->DoClose(); } void VBAMacroTest::testPrintArea() @@ -259,9 +253,6 @@ void VBAMacroTest::testPrintArea() const uno::Sequence<table::CellRangeAddress> aSequence = xPrintAreas->getPrintAreas(); CPPUNIT_ASSERT_EQUAL(true, aSequence.hasElements()); } - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void VBAMacroTest::testSelectAllChaged() @@ -287,8 +278,6 @@ void VBAMacroTest::testSelectAllChaged() // A1:E1048576 CPPUNIT_ASSERT_EQUAL(ScRange(0, 0, 0, 4, MAXROW, 0), pViewData.GetMarkData().GetMarkArea()); - - pDocSh->DoClose(); } void VBAMacroTest::testRangeSelect() @@ -314,8 +303,6 @@ void VBAMacroTest::testRangeSelect() // B2:E5 CPPUNIT_ASSERT_EQUAL(ScRange(1, 1, 0, 4, 1, 0), pViewData.GetMarkData().GetMarkArea()); - - pDocSh->DoClose(); } void VBAMacroTest::testWindowState() @@ -330,9 +317,6 @@ void VBAMacroTest::testWindowState() executeMacro("vnd.sun.Star.script:VBAProject.ThisWorkbook.testWindowState?language=Basic&" "location=document"); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void VBAMacroTest::testScroll() @@ -362,8 +346,6 @@ void VBAMacroTest::testScroll() CPPUNIT_ASSERT_EQUAL(ScSplitPos::SC_SPLIT_BOTTOMLEFT, rViewData.GetActivePart()); CPPUNIT_ASSERT_EQUAL(SCCOL(29), rViewData.GetPosX(ScHSplitPos::SC_SPLIT_LEFT)); CPPUNIT_ASSERT_EQUAL(SCROW(99), rViewData.GetPosY(ScVSplitPos::SC_SPLIT_BOTTOM)); - - pDocSh->DoClose(); } void VBAMacroTest::testMacroKeyBinding() @@ -402,9 +384,6 @@ void VBAMacroTest::testMacroKeyBinding() OUString( "vnd.sun.star.script:VBAProject.ThisWorkbook.key_T?language=Basic&location=document"), xAccelerator->getCommandByKeyEvent(aCtrlT)); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void VBAMacroTest::testVba() @@ -541,9 +520,8 @@ void VBAMacroTest::testVba() .getStr(), OUString("OK"), aStringRes); - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, - css::uno::UNO_QUERY_THROW); - xCloseable->close(true); + mxComponent->dispose(); + mxComponent.clear(); if (bWorkbooksHandling) { @@ -587,8 +565,6 @@ void VBAMacroTest::testTdf149579() CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 0, 0))); CPPUNIT_ASSERT_EQUAL(5.0, rDoc.GetValue(ScAddress(0, 1, 0))); CPPUNIT_ASSERT_EQUAL(10.0, rDoc.GetValue(ScAddress(0, 2, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testVbaRangeSort() @@ -637,8 +613,6 @@ void VBAMacroTest::testVbaRangeSort() CPPUNIT_ASSERT_EQUAL(2.0, rDoc.GetValue(ScAddress(0, 0, 0))); CPPUNIT_ASSERT_EQUAL(1.0, rDoc.GetValue(ScAddress(0, 1, 0))); CPPUNIT_ASSERT_EQUAL(0.5, rDoc.GetValue(ScAddress(0, 2, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf107885() @@ -676,8 +650,6 @@ void VBAMacroTest::testTdf107885() CPPUNIT_ASSERT(rDoc.RowHidden(2, 0)); CPPUNIT_ASSERT(!rDoc.RowHidden(3, 0)); CPPUNIT_ASSERT(!rDoc.RowHidden(4, 0)); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf131562() @@ -701,8 +673,6 @@ void VBAMacroTest::testTdf131562() //Without the fix in place, the macro wouldn't have concatenated 1 and " ." CPPUNIT_ASSERT_EQUAL(OUString("1 ."), rDoc.GetString(ScAddress(0, 2, 0))); CPPUNIT_ASSERT_EQUAL(OUString("1 .cat"), rDoc.GetString(ScAddress(0, 3, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf52602() @@ -733,8 +703,6 @@ void VBAMacroTest::testTdf52602() CPPUNIT_ASSERT_EQUAL(OUString("1/ March 2012"), rDoc.GetString(ScAddress(4, 1, 0))); CPPUNIT_ASSERT_EQUAL(OUString("1/ Mar 2012"), rDoc.GetString(ScAddress(5, 0, 0))); CPPUNIT_ASSERT_EQUAL(OUString("1/ Mar 2012"), rDoc.GetString(ScAddress(5, 1, 0))); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf107902() { @@ -764,8 +732,6 @@ void VBAMacroTest::testTdf107902() CPPUNIT_ASSERT(!rDoc.RowHidden(2, 0)); CPPUNIT_ASSERT(!rDoc.RowHidden(3, 0)); CPPUNIT_ASSERT(rDoc.RowHidden(4, 0)); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf90278() @@ -783,9 +749,6 @@ void VBAMacroTest::testTdf90278() sal_Int32 aReturnValue; aRet >>= aReturnValue; CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aReturnValue); - - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } void VBAMacroTest::testTdf149531() @@ -811,8 +774,6 @@ void VBAMacroTest::testTdf149531() sal_uInt16 nWidth = o3tl::convert(rDoc.GetColWidth(0, 0), o3tl::Length::twip, o3tl::Length::mm100); CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(25749), nWidth); - - pDocSh->DoClose(); } void VBAMacroTest::testTdf118247() @@ -845,8 +806,6 @@ void VBAMacroTest::testTdf118247() aRet >>= aReturnValue; CPPUNIT_ASSERT_EQUAL(sRange, aReturnValue); } - css::uno::Reference<css::util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); } CPPUNIT_TEST_SUITE_REGISTRATION(VBAMacroTest); diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx index 364209883709..963b1d6a7b51 100644 --- a/sc/qa/unit/scshapetest.cxx +++ b/sc/qa/unit/scshapetest.cxx @@ -222,8 +222,6 @@ void ScShapeTest::testTdf144242_OpenBezier_noSwapWH() tools::Rectangle aSnapRect(pObj->GetSnapRect()); // Without fix in place width and height were swapped lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", aExpectRect, aSnapRect, 40); - - pDocSh->DoClose(); } void ScShapeTest::testTdf144242_Line_noSwapWH() @@ -262,8 +260,6 @@ void ScShapeTest::testTdf144242_Line_noSwapWH() tools::Rectangle aSnapRect(pObj->GetSnapRect()); // Without fix in place width and height were swapped lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", aExpectRect, aSnapRect, 40); - - pDocSh->DoClose(); } void ScShapeTest::testTdf143619_validation_circle_pos() @@ -294,8 +290,6 @@ void ScShapeTest::testTdf143619_validation_circle_pos() // Without fix in place the position was (2007, 833) Point aPos = pObj->GetSnapRect().TopLeft(); lcl_AssertPointEqualWithTolerance("after row and col delete", Point(6523, 1736), aPos, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf140252_DragCreateFormControl() @@ -344,8 +338,6 @@ void ScShapeTest::testTdf140252_DragCreateFormControl() sal_Int16 nExpectedID = SC_LAYER_CONTROLS.get(); sal_Int16 nActualID = pObj->GetLayer().get(); CPPUNIT_ASSERT_EQUAL(nExpectedID, nActualID); - - pDocSh->DoClose(); } void ScShapeTest::testTdf134355_DragCreateCustomShape() @@ -389,8 +381,6 @@ void ScShapeTest::testTdf134355_DragCreateCustomShape() sal_Int16 nExpectedID = SC_LAYER_FRONT.get(); sal_Int16 nActualID = pObj->GetLayer().get(); CPPUNIT_ASSERT_EQUAL(nExpectedID, nActualID); - - pDocSh->DoClose(); } void ScShapeTest::testTdf140252_LayerOfControl() @@ -423,8 +413,6 @@ void ScShapeTest::testTdf140252_LayerOfControl() sal_Int16 nExpectedID = SC_LAYER_CONTROLS.get(); sal_Int16 nActualID = pObj->GetLayer().get(); CPPUNIT_ASSERT_EQUAL(nExpectedID, nActualID); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137082_LTR_to_RTL() @@ -460,8 +448,6 @@ void ScShapeTest::testTdf137082_LTR_to_RTL() const Degree100 nRotateRTLActual = pObjCS->GetRotateAngle(); CPPUNIT_ASSERT_EQUAL_MESSAGE("custom shape should be mirrored", nRotateRTLExpected.get(), nRotateRTLActual.get()); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137082_RTL_cell_anchored() @@ -502,8 +488,6 @@ void ScShapeTest::testTdf137082_RTL_cell_anchored() lcl_AssertRectEqualWithTolerance("reload shape A: ", aSnapRectA, pObj->GetSnapRect(), 1); pObj = lcl_getSdrObjectWithAssert(rDoc2, 1); lcl_AssertRectEqualWithTolerance("reload shape B: ", aSnapRectB, pObj->GetSnapRect(), 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137081_RTL_page_anchored() @@ -569,8 +553,6 @@ void ScShapeTest::testTdf137081_RTL_page_anchored() CPPUNIT_ASSERT(!pObjCS->IsMirroredX()); lcl_AssertPointEqualWithTolerance("custom shape top left: ", aTopLeft, pObjCS->GetLogicRect().TopLeft(), 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf139583_Rotate180deg() @@ -644,8 +626,6 @@ void ScShapeTest::testTdf137033_FlipHori_Resize() // Check shape has the original geometry, besides rounding and unit conversion errors aSnapRect = pObj->GetSnapRect(); lcl_AssertRectEqualWithTolerance("Reload, wrong pos or size: ", aExpectRect, aSnapRect, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137033_RotShear_ResizeHide() @@ -703,8 +683,6 @@ void ScShapeTest::testTdf137033_RotShear_ResizeHide() CPPUNIT_ASSERT_MESSAGE("Reload, rotate angle: ", abs(aRotateAngle - aExpectRotateAngle) <= 3_deg100); lcl_AssertRectEqualWithTolerance("Reload: wrong pos or size", aExpectRect, aSnapRect, 7); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137033_RotShear_Hide() @@ -743,8 +721,6 @@ void ScShapeTest::testTdf137033_RotShear_Hide() const tools::Rectangle aExpectRect(Point(4500, 3500), Size(15143, 5187)); const tools::Rectangle aSnapRect = pObj->GetSnapRect(); lcl_AssertRectEqualWithTolerance("Reload: wrong pos and size", aExpectRect, aSnapRect, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline() @@ -798,8 +774,6 @@ void ScShapeTest::testTdf137576_LogicRectInDefaultMeasureline() // Assert object position is unchanged, besides Twips<->Hmm inaccuracy. Point aNewPos = pObj->GetRelativePos(); lcl_AssertPointEqualWithTolerance("after reload", aOldPos, aNewPos, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137576_LogicRectInNewMeasureline() @@ -837,7 +811,6 @@ void ScShapeTest::testTdf137576_LogicRectInNewMeasureline() CPPUNIT_ASSERT_EQUAL(SCROW(2), pNData->maEnd.Row()); pObj.clear(); - pDocSh->DoClose(); } void ScShapeTest::testMeasurelineHideColSave() @@ -881,8 +854,6 @@ void ScShapeTest::testMeasurelineHideColSave() // Check that start and end point are unchanged besides rounding and unit conversion errors lcl_AssertPointEqualWithTolerance("Reload start: ", aStartPoint, pObj->GetPoint(0), 2); lcl_AssertPointEqualWithTolerance("Reload end: ", aEndPoint, pObj->GetPoint(1), 2); - - pDocSh->DoClose(); } void ScShapeTest::testHideColsShow() @@ -927,8 +898,6 @@ void ScShapeTest::testHideColsShow() tools::Rectangle aSnapRectShow(pObj->GetSnapRect()); lcl_AssertRectEqualWithTolerance("Show: Object geometry should not change", aSnapRectOrig, aSnapRectShow, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf138138_MoveCellWithRotatedShape() @@ -975,8 +944,6 @@ void ScShapeTest::testTdf138138_MoveCellWithRotatedShape() aSnapRect = pObj->GetSnapRect(); lcl_AssertRectEqualWithTolerance("Reload: Shape geometry has changed.", aExpectedRect, aSnapRect, 1); - - pDocSh->DoClose(); } void ScShapeTest::testLoadVerticalFlip() @@ -994,8 +961,6 @@ void ScShapeTest::testLoadVerticalFlip() // Check that shape is flipped CPPUNIT_ASSERT_MESSAGE("Load: Object should be vertically flipped", pObj->IsMirroredY()); - - pDocSh->DoClose(); } void ScShapeTest::testTdf117948_CollapseBeforeShape() @@ -1047,8 +1012,6 @@ void ScShapeTest::testTdf117948_CollapseBeforeShape() tools::Rectangle aSnapRect1Reload = pObj1->GetSnapRect(); lcl_AssertRectEqualWithTolerance("Reload: Line geometry has changed.", aExpectedRect1, aSnapRect1Reload, 2); - - pDocSh->DoClose(); } void ScShapeTest::testTdf137355_UndoHideRows() @@ -1089,8 +1052,6 @@ void ScShapeTest::testTdf137355_UndoHideRows() tools::Rectangle aSnapRectUndo(pObj->GetSnapRect()); lcl_AssertRectEqualWithTolerance("Undo: Object geometry should not change", aSnapRectOrig, aSnapRectUndo, 1); - - pDocSh->DoClose(); } void ScShapeTest::testTdf115655_HideDetail() @@ -1139,8 +1100,6 @@ void ScShapeTest::testTdf115655_HideDetail() tools::Rectangle aSnapRectReload = pObj->GetSnapRect(); lcl_AssertRectEqualWithTolerance("Reload: Object geometry has changed.", aSnapRectOrig, aSnapRectReload, 1); - - pDocSh->DoClose(); } void ScShapeTest::testFitToCellSize() @@ -1172,8 +1131,6 @@ void ScShapeTest::testFitToCellSize() const tools::Rectangle& rShapeRect(pObj->GetSnapRect()); const tools::Rectangle aCellRect = rDoc.GetMMRect(1, 1, 1, 1, 0); lcl_AssertRectEqualWithTolerance("Cell and SnapRect should be equal", aCellRect, rShapeRect, 2); - - pDocSh->DoClose(); } void ScShapeTest::testCustomShapeCellAnchoredRotatedShape() @@ -1205,8 +1162,6 @@ void ScShapeTest::testCustomShapeCellAnchoredRotatedShape() + OUString::number(pData->maEnd.Col()) + " row " + OUString::number(pData->maEnd.Row())); CPPUNIT_ASSERT_EQUAL(OUString("start col 1 row 1 end col 2 row 8"), sActual); - - pDocSh->DoClose(); } void ScShapeTest::testLargeAnchorOffset() @@ -1237,8 +1192,6 @@ void ScShapeTest::testLargeAnchorOffset() // - after reload Y expected 9089 actual 9643 Tolerance 1 const Point aNewPos = pObj->GetRelativePos(); lcl_AssertPointEqualWithTolerance("after reload", aOldPos, aNewPos, 1); - - pDocSh->DoClose(); } CPPUNIT_TEST_SUITE_REGISTRATION(ScShapeTest); diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 28c46538030f..bc7bb42609b3 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -1401,6 +1401,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf117706) dispatchCommand(mxComponent, ".uno:Copy", {}); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); @@ -1486,6 +1487,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108292) Scheduler::ProcessEventsToIdle(); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); @@ -1529,6 +1531,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testMultiRangeCol) dispatchCommand(mxComponent, ".uno:Copy", {}); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); @@ -1578,6 +1581,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testPasteTransposed) dispatchCommand(mxComponent, ".uno:Copy", {}); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); @@ -2292,6 +2296,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf118189) dispatchCommand(mxComponent, ".uno:Copy", {}); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); @@ -2511,6 +2516,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf130614) Scheduler::ProcessEventsToIdle(); mxComponent->dispose(); + mxComponent.clear(); // Open a new document mxComponent = loadFromDesktop("private:factory/scalc"); diff --git a/test/source/calc_unoapi_test.cxx b/test/source/calc_unoapi_test.cxx index fc8cae982bea..a0423cbc7e67 100644 --- a/test/source/calc_unoapi_test.cxx +++ b/test/source/calc_unoapi_test.cxx @@ -11,7 +11,6 @@ #include <sfx2/objsh.hxx> #include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/util/XCloseable.hpp> #include <comphelper/propertyvalue.hxx> using namespace css; @@ -22,22 +21,15 @@ CalcUnoApiTest::CalcUnoApiTest(const OUString& path) { } -void CalcUnoApiTest::setUp() -{ - UnoApiTest::setUp(); - - // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure, - // which is a private symbol to us, gets called - m_xCalcComponent = - getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument"); - CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is()); -} - void CalcUnoApiTest::tearDown() { - closeDocument(mxComponent); - uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose(); - UnoApiTest::tearDown(); + if (mxComponent.is()) + { + mxComponent->dispose(); + mxComponent.clear(); + } + + test::BootstrapFixture::tearDown(); } uno::Any CalcUnoApiTest::executeMacro(const OUString& rScriptURL, const uno::Sequence<uno::Any>& rParams) @@ -61,8 +53,8 @@ utl::TempFileNamed CalcUnoApiTest::save(const OUString& rFilter) uno::Sequence aArgs{ comphelper::makePropertyValue("FilterName", rFilter) }; css::uno::Reference<frame::XStorable> xStorable(mxComponent, css::uno::UNO_QUERY_THROW); xStorable->storeAsURL(aTempFile.GetURL(), aArgs); - css::uno::Reference<util::XCloseable> xCloseable(mxComponent, css::uno::UNO_QUERY_THROW); - xCloseable->close(true); + mxComponent->dispose(); + mxComponent.clear(); return aTempFile; }