sc/qa/extras/anchor.cxx          |   51 ++++++++++++++++++++-------------------
 sc/qa/unit/cond_format_merge.cxx |   16 +++++++++---
 2 files changed, 39 insertions(+), 28 deletions(-)

New commits:
commit 6ca3ac3f3b3007d25c5ea68f67536c5e63fbb4e9
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Oct 14 09:38:36 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Oct 14 14:30:34 2022 +0200

    sc: add tearDown to these test classes
    
    Same as the rest of CalcUnoApiTest tests
    
    Change-Id: I55294231fd11fd31ed6f57459b2f0292ddb23635
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141358
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/extras/anchor.cxx b/sc/qa/extras/anchor.cxx
index d00b7a3f91b5..880f6ae57be9 100644
--- a/sc/qa/extras/anchor.cxx
+++ b/sc/qa/extras/anchor.cxx
@@ -35,6 +35,8 @@ class ScAnchorTest : public CalcUnoApiTest
 public:
     ScAnchorTest();
 
+    virtual void tearDown() override;
+
     void testUndoAnchor();
     void testTdf76183();
     void testODFAnchorTypes();
@@ -56,6 +58,9 @@ public:
     CPPUNIT_TEST(testTdf130556);
     CPPUNIT_TEST(testTdf134161);
     CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> mxComponent;
 };
 
 ScAnchorTest::ScAnchorTest()
@@ -63,15 +68,21 @@ ScAnchorTest::ScAnchorTest()
 {
 }
 
+void ScAnchorTest::tearDown()
+{
+    closeDocument(mxComponent);
+    CalcUnoApiTest::tearDown();
+}
+
 void ScAnchorTest::testUndoAnchor()
 {
     OUString aFileURL;
     createFileURL(u"document_with_linked_graphic.ods", aFileURL);
     // open the document with graphic included
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Get the document model
-    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
     CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
 
     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
@@ -159,13 +170,13 @@ void ScAnchorTest::testUndoAnchor()
     CPPUNIT_ASSERT_EQUAL(int(GraphicType::Bitmap), 
int(rGraphicObj.GetGraphic().GetType()));
     CPPUNIT_ASSERT_EQUAL(sal_uLong(864900), 
rGraphicObj.GetGraphic().GetSizeBytes());
 
-    xComponent->dispose();
+    pDocSh->DoClose();
 }
 
 void ScAnchorTest::testTdf76183()
 {
-    uno::Reference<lang::XComponent> xComponent = 
loadFromDesktop("private:factory/scalc");
-    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+    mxComponent = loadFromDesktop("private:factory/scalc");
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
     ScDocument& rDoc = pDocSh->GetDocument();
     ScDrawLayer* pDrawLayer = rDoc.GetDrawLayer();
@@ -182,7 +193,7 @@ void ScAnchorTest::testTdf76183()
     // Set word wrap to true
     rDoc.ApplyAttr(0, 0, 0, ScLineBreakCell(true));
     // Add multi-line text to cell to initiate optimal height change
-    uno::Reference<sheet::XSpreadsheetDocument> xDoc(xComponent, 
uno::UNO_QUERY_THROW);
+    uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
     uno::Reference<container::XIndexAccess> xIA(xDoc->getSheets(), 
uno::UNO_QUERY_THROW);
     uno::Reference<sheet::XSpreadsheet> xSheet(xIA->getByIndex(0), 
uno::UNO_QUERY_THROW);
     uno::Reference<text::XText> xText(xSheet->getCellByPosition(0, 0), 
uno::UNO_QUERY_THROW);
@@ -200,10 +211,10 @@ void ScAnchorTest::testODFAnchorTypes()
     OUString aFileURL;
     createFileURL(u"3AnchorTypes.ods", aFileURL);
     // open the document with graphic included
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Get the document model
-    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
     CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
 
     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
@@ -244,10 +255,10 @@ void ScAnchorTest::testCopyColumnWithImages()
     OUString aFileURL;
     createFileURL(u"3AnchorTypes.ods", aFileURL);
     // open the document with graphic included
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Get the document model
-    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
     CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
 
     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
@@ -315,10 +326,10 @@ void ScAnchorTest::testCutWithImages()
     OUString aFileURL;
     createFileURL(u"3AnchorTypes.ods", aFileURL);
     // open the document with graphic included
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Get the document model
-    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(xComponent);
+    SfxObjectShell* pFoundShell = 
SfxObjectShell::GetShellFromComponent(mxComponent);
     CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell);
 
     ScDocShell* pDocSh = dynamic_cast<ScDocShell*>(pFoundShell);
@@ -372,52 +383,44 @@ void ScAnchorTest::testTdf121963()
 {
     OUString aFileURL;
     createFileURL(u"tdf121963.ods", aFileURL);
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Without the accompanying fix in place, this test would have never 
returned due to an infinite
     // invalidation loop, where ScGridWindow::Paint() invalidated itself.
     Scheduler::ProcessEventsToIdle();
-
-    xComponent->dispose();
 }
 
 void ScAnchorTest::testTdf129552()
 {
     OUString aFileURL;
     createFileURL(u"tdf129552.fods", aFileURL);
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Without the accompanying fix in place, this test would have never 
returned due to an infinite
     // invalidation loop, where ScGridWindow::Paint() invalidated itself.
     Scheduler::ProcessEventsToIdle();
-
-    xComponent->dispose();
 }
 
 void ScAnchorTest::testTdf130556()
 {
     OUString aFileURL;
     createFileURL(u"tdf130556.ods", aFileURL);
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Without the accompanying fix in place, this test would have never 
returned due to an infinite
     // invalidation loop, where ScGridWindow::Paint() invalidated itself.
     Scheduler::ProcessEventsToIdle();
-
-    xComponent->dispose();
 }
 
 void ScAnchorTest::testTdf134161()
 {
     OUString aFileURL;
     createFileURL(u"tdf134161.ods", aFileURL);
-    uno::Reference<css::lang::XComponent> xComponent = 
loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // Without the accompanying fix in place, this test would have never 
returned due to an infinite
     // invalidation loop
     Scheduler::ProcessEventsToIdle();
-
-    xComponent->dispose();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScAnchorTest);
diff --git a/sc/qa/unit/cond_format_merge.cxx b/sc/qa/unit/cond_format_merge.cxx
index 01cbde7359a6..a0413fa1c3d1 100644
--- a/sc/qa/unit/cond_format_merge.cxx
+++ b/sc/qa/unit/cond_format_merge.cxx
@@ -27,11 +27,16 @@ class ScCondFormatMergeTest : public CalcUnoApiTest
 public:
     ScCondFormatMergeTest();
 
+    virtual void tearDown() override;
+
     void testCondFormatMerge();
 
     CPPUNIT_TEST_SUITE(ScCondFormatMergeTest);
     CPPUNIT_TEST(testCondFormatMerge);
     CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<lang::XComponent> mxComponent;
 };
 
 ScCondFormatMergeTest::ScCondFormatMergeTest()
@@ -39,11 +44,17 @@ ScCondFormatMergeTest::ScCondFormatMergeTest()
 {
 }
 
+void ScCondFormatMergeTest::tearDown()
+{
+    closeDocument(mxComponent);
+    CalcUnoApiTest::tearDown();
+}
+
 void ScCondFormatMergeTest::testCondFormatMerge()
 {
     OUString aFileURL;
     createFileURL(u"cond_format_merge.ods", aFileURL);
-    uno::Reference<lang::XComponent> mxComponent = loadFromDesktop(aFileURL);
+    mxComponent = loadFromDesktop(aFileURL);
 
     // get the first sheet
     uno::Reference<sheet::XSpreadsheetDocument> xDoc(mxComponent, 
uno::UNO_QUERY_THROW);
@@ -140,9 +151,6 @@ void ScCondFormatMergeTest::testCondFormatMerge()
     }
 
     CPPUNIT_ASSERT_EQUAL(5, nRanges);
-
-    closeDocument(mxComponent);
-    mxComponent.clear();
 }
 
 CPPUNIT_TEST_SUITE_REGISTRATION(ScCondFormatMergeTest);

Reply via email to