diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-27 21:01:11 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-01-28 01:02:30 +0100 |
commit | 7eb289c49cc7245ef3001a39be0c15d06bbe875b (patch) | |
tree | 7ba1bff454e29c30af66c928ace91a4aa6c51383 | |
parent | bf72c4b4f84d6cd3322d4107e5b7b8bbc7911485 (diff) |
tdf#108654: sc: Move UItest to CppUnitTest
While at it, reduce the size of the file a bit
Change-Id: I84b81515a908aa5fb4e5a1688964829b17868e43
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110033
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/uitest/calc_tests6/tdf108654.py | 43 | ||||
-rw-r--r-- | sc/qa/uitest/data/tdf108654.ods | bin | 221086 -> 0 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf108654.ods | bin | 0 -> 32714 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 55 |
4 files changed, 49 insertions, 49 deletions
diff --git a/sc/qa/uitest/calc_tests6/tdf108654.py b/sc/qa/uitest/calc_tests6/tdf108654.py deleted file mode 100644 index 3f806b7024b1..000000000000 --- a/sc/qa/uitest/calc_tests6/tdf108654.py +++ /dev/null @@ -1,43 +0,0 @@ -# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -from uitest.framework import UITestCase -from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file -from uitest.uihelper.common import select_pos -from uitest.uihelper.calc import enter_text_to_cell -from libreoffice.calc.document import get_cell_by_position -from libreoffice.uno.propertyvalue import mkPropertyValues - -#Bug 108654 - CRASH while undoing paste on a new sheet -class tdf108654(UITestCase): - def test_tdf108654_Undo_paste_crash(self): - calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf108654.ods")) - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #Sheet3 - CTRL+A & CTRL+C - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Copy") - #Create a new sheet & paste (CTRL-V) - self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet - xDialog = self.xUITest.getTopFocusWindow() - xOKButton = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKButton) - - self.assertEqual(document.Sheets.getCount(), 4) - - self.xUITest.executeCommand(".uno:Paste") - #Undo the action twice - self.xUITest.executeCommand(".uno:Undo") - self.xUITest.executeCommand(".uno:Undo") - - #-> CRASH - self.assertEqual(document.Sheets.getCount(), 3) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/data/tdf108654.ods b/sc/qa/uitest/data/tdf108654.ods Binary files differdeleted file mode 100644 index e7feec567f71..000000000000 --- a/sc/qa/uitest/data/tdf108654.ods +++ /dev/null diff --git a/sc/qa/unit/uicalc/data/tdf108654.ods b/sc/qa/unit/uicalc/data/tdf108654.ods Binary files differnew file mode 100644 index 000000000000..761e8cf2a39e --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf108654.ods diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 283ec027fbee..2d8d6389f907 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -42,6 +42,7 @@ public: void goToCell(const OUString& rCell); void insertStringToCell(ScModelObj& rModelObj, const OUString& rCell, const std::string& rStr, bool bIsArray = false); + void insertNewSheet(ScDocument& rDoc); protected: uno::Reference<lang::XComponent> mxComponent; @@ -114,6 +115,17 @@ void ScUiCalcTest::insertStringToCell(ScModelObj& rModelObj, const OUString& rCe } } +void ScUiCalcTest::insertNewSheet(ScDocument& rDoc) +{ + sal_Int32 nTabs = static_cast<sal_Int32>(rDoc.GetTableCount()); + + uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( + { { "Name", uno::Any(OUString("NewTab")) }, { "Index", uno::Any(nTabs + 1) } })); + dispatchCommand(mxComponent, ".uno:Insert", aArgs); + + CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(nTabs + 1), rDoc.GetTableCount()); +} + constexpr OUStringLiteral DATA_DIRECTORY = u"/sc/qa/unit/uicalc/data/"; ScModelObj* ScUiCalcTest::createDoc(const char* pName) @@ -374,9 +386,9 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf138710) CPPUNIT_ASSERT_EQUAL(OUString("Total"), pDoc->GetString(ScAddress(0, 0, 1))); } -CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108654) { - ScModelObj* pModelObj = createDoc("tdf133326.ods"); + ScModelObj* pModelObj = createDoc("tdf108654.ods"); ScDocument* pDoc = pModelObj->GetDocument(); CPPUNIT_ASSERT(pDoc); @@ -387,16 +399,47 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false); Scheduler::ProcessEventsToIdle(); + insertNewSheet(*pDoc); + + // .uno:Paste without touching shared clipboard + ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); + Scheduler::ProcessEventsToIdle(); + + OUString aFormula; + pDoc->GetFormula(3, 126, 1, aFormula); + CPPUNIT_ASSERT_EQUAL(OUString("=VLOOKUP(C127,#REF!,D$1,0)"), aFormula); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + + pDoc->GetFormula(3, 126, 1, aFormula); + CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); + CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount()); +} - uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( - { { "Name", uno::Any(OUString("")) }, { "Index", uno::Any(sal_Int32(2)) } })); - dispatchCommand(mxComponent, ".uno:Insert", aArgs); +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326) +{ + ScModelObj* pModelObj = createDoc("tdf133326.ods"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + + // .uno:Copy without touching shared clipboard + ScDocument aClipDoc(SCDOCMODE_CLIP); + ScDocShell::GetViewData()->GetView()->CopyToClip(&aClipDoc, false, false, false, false); + Scheduler::ProcessEventsToIdle(); + + insertNewSheet(*pDoc); OUString aFormula; pDoc->GetFormula(0, 0, 1, aFormula); CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula); - CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount()); // .uno:Paste without touching shared clipboard ScDocShell::GetViewData()->GetView()->PasteFromClip(InsertDeleteFlags::ALL, &aClipDoc); |