diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-11-10 17:11:43 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-11-10 20:39:55 +0100 |
commit | b9a04e8a2352d2e6290299fb6416f0bdc0c90756 (patch) | |
tree | 0ef7a0d2c39ee9889af1f07037307dfda7de5951 /sc | |
parent | 7930ad202edb8e7af2946fc428268b000edae23e (diff) |
tdf#119162: sc: move UItest to CppUnittest
Change-Id: I2e5467e92a4ebbaf2d028dd733d2f4a75eb03bb0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125003
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/uitest/data/tdf119162.xls | bin | 5632 -> 0 bytes | |||
-rw-r--r-- | sc/qa/uitest/textCase/textCase.py | 14 | ||||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 65 |
3 files changed, 54 insertions, 25 deletions
diff --git a/sc/qa/uitest/data/tdf119162.xls b/sc/qa/uitest/data/tdf119162.xls Binary files differdeleted file mode 100644 index 42765fbe9000..000000000000 --- a/sc/qa/uitest/data/tdf119162.xls +++ /dev/null diff --git a/sc/qa/uitest/textCase/textCase.py b/sc/qa/uitest/textCase/textCase.py index 7dbb6d2a41d5..b2235a5f7ce0 100644 --- a/sc/qa/uitest/textCase/textCase.py +++ b/sc/qa/uitest/textCase/textCase.py @@ -123,18 +123,4 @@ class textCase(UITestCase): self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") - def test_tdf119162_Cycle_Case(self): - #Bug 119162 - Format > Text > Cycle Case on attached example file hangs Calc reproducibly - with self.ui_test.load_file(get_url_for_data_file("tdf119162.xls")) as calc_doc: - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - #1.Open the attached .xls file - #2. Select column A - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #3. Select [Format] > [Text] > [Cycle Case] - self.xUITest.executeCommand(".uno:ChangeCaseRotateCase") - self.xUITest.executeCommand(".uno:ChangeCaseToLower") - #Actual Results:Freezes LibreOffice - self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getString(), "test\n") - # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index ef3b8dd24959..ea44aaa3cd40 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -49,7 +49,8 @@ public: const OUString& rFilter); void goToCell(const OUString& rCell); void insertStringToCell(ScModelObj& rModelObj, const OUString& rCell, const std::string& rStr, - bool bIsArray = false); + bool bUseReturn = true); + void insertArrayToCell(ScModelObj& rModelObj, const OUString& rCell, const std::string& rStr); void insertNewSheet(ScDocument& rDoc); protected: @@ -98,7 +99,7 @@ void ScUiCalcTest::goToCell(const OUString& rCell) } void ScUiCalcTest::insertStringToCell(ScModelObj& rModelObj, const OUString& rCell, - const std::string& rStr, bool bIsArray) + const std::string& rStr, bool bUseReturn) { goToCell(rCell); @@ -109,13 +110,7 @@ void ScUiCalcTest::insertStringToCell(ScModelObj& rModelObj, const OUString& rCe Scheduler::ProcessEventsToIdle(); } - if (bIsArray) - { - rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); - rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); - Scheduler::ProcessEventsToIdle(); - } - else + if (bUseReturn) { rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); @@ -123,6 +118,16 @@ void ScUiCalcTest::insertStringToCell(ScModelObj& rModelObj, const OUString& rCe } } +void ScUiCalcTest::insertArrayToCell(ScModelObj& rModelObj, const OUString& rCell, + const std::string& rStr) +{ + insertStringToCell(rModelObj, rCell, rStr, false); + + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); + rModelObj.postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | KEY_SHIFT | awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); +} + void ScUiCalcTest::insertNewSheet(ScDocument& rDoc) { sal_Int32 nTabs = static_cast<sal_Int32>(rDoc.GetTableCount()); @@ -166,6 +171,44 @@ ScModelObj* ScUiCalcTest::saveAndReload(css::uno::Reference<css::lang::XComponen return pModelObj; } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf119162) +{ + mxComponent = loadFromDesktop("private:factory/scalc"); + ScModelObj* pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get()); + CPPUNIT_ASSERT(pModelObj); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + insertStringToCell(*pModelObj, "A1", "Test", /*bUseReturn*/ false); + + // Insert Newline + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_MOD1 | awt::Key::RETURN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, KEY_MOD1 | awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::RETURN); + pModelObj->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::RETURN); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"Test" + OUStringChar(u'\xA')), + pDoc->GetString(ScAddress(0, 0, 0))); + + goToCell("A1"); + + // Without the fix in place, this test would have hung here + dispatchCommand(mxComponent, ".uno:ChangeCaseRotateCase", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"Test" + OUStringChar(u'\xA')), + pDoc->GetString(ScAddress(0, 0, 0))); + + dispatchCommand(mxComponent, ".uno:ChangeCaseToLower", {}); + Scheduler::ProcessEventsToIdle(); + + CPPUNIT_ASSERT_EQUAL(OUString(u"test" + OUStringChar(u'\xA')), + pDoc->GetString(ScAddress(0, 0, 0))); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf119155) { ScModelObj* pModelObj = createDoc("tdf119155.xlsx"); @@ -257,7 +300,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf145085) ScDocument* pDoc = pModelObj->GetDocument(); CPPUNIT_ASSERT(pDoc); - insertStringToCell(*pModelObj, "A1", "=HYPERLINK(\"a\";\"b\")", true); + insertArrayToCell(*pModelObj, "A1", "=HYPERLINK(\"a\";\"b\")"); CPPUNIT_ASSERT_EQUAL(OUString("b"), pDoc->GetString(ScAddress(0, 0, 0))); @@ -738,7 +781,7 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf131442) ScDocument* pDoc = pModelObj->GetDocument(); CPPUNIT_ASSERT(pDoc); - insertStringToCell(*pModelObj, "A1:A5", "={6;4;2;5;3}", true); + insertArrayToCell(*pModelObj, "A1:A5", "={6;4;2;5;3}"); CPPUNIT_ASSERT_EQUAL(OUString("6"), pDoc->GetString(ScAddress(0, 0, 0))); CPPUNIT_ASSERT_EQUAL(OUString("4"), pDoc->GetString(ScAddress(0, 1, 0))); |