diff options
-rw-r--r-- | include/test/unoapi_test.hxx | 3 | ||||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 34 | ||||
-rw-r--r-- | test/source/unoapi_test.cxx | 6 |
3 files changed, 43 insertions, 0 deletions
diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx index ece36abdb149..1f14f6a21f77 100644 --- a/include/test/unoapi_test.hxx +++ b/include/test/unoapi_test.hxx @@ -60,6 +60,9 @@ protected: // reference to document component that we are testing css::uno::Reference<css::lang::XComponent> mxComponent; + // In case the test needs to work with two documents at the same time + css::uno::Reference<css::lang::XComponent> mxComponent2; + utl::TempFileNamed maTempFile; SvMemoryStream maMemory; // Underlying memory for parsed PDF files. diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 518a219e3a92..4976c19c17f0 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -2903,6 +2903,40 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149378) CPPUNIT_ASSERT_EQUAL(OUString("{=ABS({-1;-2})}"), pDoc->GetFormula(8, 0, 0)); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf152014) +{ + createScDoc(); + + insertStringToCell("A1", u"=MATCH(1,A2,0)"); + insertStringToCell("A2", u"1"); + + ScDocument* pDoc = getScDoc(); + CPPUNIT_ASSERT_EQUAL(OUString("1"), pDoc->GetString(ScAddress(0, 0, 0))); + + goToCell("A1"); + + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + // Create a second document + mxComponent2 = loadFromDesktop("private:factory/scalc"); + + uno::Reference<frame::XFrames> xFrames = mxDesktop->getFrames(); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xFrames->getCount()); + + dispatchCommand(mxComponent2, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + ScModelObj* pModelObj2 = dynamic_cast<ScModelObj*>(mxComponent2.get()); + CPPUNIT_ASSERT(pModelObj2); + ScDocument* pDoc2 = pModelObj2->GetDocument(); + + // Without the fix in place, this test would have failed with + // - Expected: #N/A + // - Actual : 1 + CPPUNIT_ASSERT_EQUAL(OUString("#N/A"), pDoc2->GetString(ScAddress(0, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126926) { createScDoc(); diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx index a1c0580cfd61..ff566c8ffa10 100644 --- a/test/source/unoapi_test.cxx +++ b/test/source/unoapi_test.cxx @@ -43,6 +43,12 @@ void UnoApiTest::setUp() void UnoApiTest::tearDown() { + if (mxComponent2.is()) + { + mxComponent2->dispose(); + mxComponent2.clear(); + } + if (mxComponent.is()) { mxComponent->dispose(); |