diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-22 14:13:04 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-22 17:54:00 +0100 |
commit | 6bda2e11c553b4032a33b95dd89e762db23e60f3 (patch) | |
tree | 2ffbb7ad57bcebb0283b505f0a48ac62e3b523a1 /sc/qa | |
parent | 6907cbb8973c9637a07032ad1b885280e91f4d4c (diff) |
tdf#130614, tdf#108887: sc_uicalc: Add unittest
Change-Id: Ib0e7e1656dfb631e6cc8a897d376c783455483d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109817
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf130614.ods | bin | 0 -> 11466 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 46 |
2 files changed, 46 insertions, 0 deletions
diff --git a/sc/qa/unit/uicalc/data/tdf130614.ods b/sc/qa/unit/uicalc/data/tdf130614.ods Binary files differnew file mode 100644 index 000000000000..7f66dff55b98 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf130614.ods diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 3b93128415ab..0c067c5d7e99 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -10,6 +10,7 @@ #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <svx/svdpage.hxx> #include <vcl/keycodes.hxx> #include <vcl/scheduler.hxx> @@ -20,9 +21,11 @@ #include <document.hxx> #include <docuno.hxx> #include <docsh.hxx> +#include <drwlayer.hxx> #include <inputopt.hxx> #include <rangeutl.hxx> #include <scmod.hxx> +#include <tabvwsh.hxx> #include <viewdata.hxx> using namespace ::com::sun::star; @@ -71,6 +74,19 @@ static void lcl_SelectRangeFromString(const ScDocument& rDoc, const OUString& rS ScDocShell::GetViewData()->GetMarkData().SetMarkArea(aRange); } +static void lcl_SelectObjectByName(std::u16string_view rObjName) +{ + ScTabViewShell* pViewShell = ScDocShell::GetViewData()->GetViewShell(); + CPPUNIT_ASSERT(pViewShell); + + bool bFound = pViewShell->SelectObject(rObjName); + CPPUNIT_ASSERT_MESSAGE( + OString(OUStringToOString(rObjName, RTL_TEXTENCODING_UTF8) + " not found.").getStr(), + bFound); + + CPPUNIT_ASSERT(ScDocShell::GetViewData()->GetScDrawView()->AreObjectsMarked()); +} + constexpr OUStringLiteral DATA_DIRECTORY = u"/sc/qa/unit/uicalc/data/"; ScModelObj* ScUiCalcTest::createDoc(const char* pName) @@ -613,6 +629,36 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138428) CPPUNIT_ASSERT_MESSAGE("There should be a note on B1", pDoc->HasNote(ScAddress(1, 0, 0))); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf130614) +{ + ScModelObj* pModelObj = createDoc("tdf130614.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + lcl_SelectObjectByName(u"Object 1"); + + // FIXME: The OLE object is not copied/pasted if using CopyToClip/PasteToClip + dispatchCommand(mxComponent, ".uno:Copy", {}); + Scheduler::ProcessEventsToIdle(); + + mxComponent->dispose(); + + // Open a new document + mxComponent = loadFromDesktop("private:factory/scalc"); + pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer(); + SdrPage* pPage = pDrawLayer->GetPage(0); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133342) { ScModelObj* pModelObj = createDoc("tdf133342.ods"); |