diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-03-05 22:15:23 +0100 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2020-03-06 15:27:09 +0100 |
commit | bdbb63abd40b55e696856a53a959b69215a56d54 (patch) | |
tree | 3889af478b4d9d004ad42c5600f7844d8d6a7098 | |
parent | 4c009d523f1017def872f0c69caafd7d1826c263 (diff) |
tdf#76636: move UItest to CppunitTest
Change-Id: I81caa059084bbe21d112c4ca49ef5d3275356cce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90087
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r-- | sw/qa/extras/uiwriter/data3/tdf76636.doc (renamed from sw/qa/uitest/writer_tests/data/tdf76636.doc) | bin | 13824 -> 13824 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 79 | ||||
-rw-r--r-- | sw/qa/uitest/table/tdf76636.py | 77 |
3 files changed, 79 insertions, 77 deletions
diff --git a/sw/qa/uitest/writer_tests/data/tdf76636.doc b/sw/qa/extras/uiwriter/data3/tdf76636.doc Binary files differindex 2d94868da586..2d94868da586 100644 --- a/sw/qa/uitest/writer_tests/data/tdf76636.doc +++ b/sw/qa/extras/uiwriter/data3/tdf76636.doc diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 4d89873629d7..d9450881c47f 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -8,6 +8,8 @@ */ #include <swmodeltestbase.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> +#include <vcl/scheduler.hxx> namespace { @@ -110,6 +112,83 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf125261) getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636) +{ + load(DATA_DIRECTORY, "tdf76636.doc"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTextTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount()); + + //go to middle row + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); + Scheduler::ProcessEventsToIdle(); + + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_LEFT | KEY_SHIFT); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:MergeCells", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTextTable->getColumns()->getCount()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount()); +} + +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf76636_2) +{ + load(DATA_DIRECTORY, "tdf76636.doc"); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTextTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount()); + + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_DOWN); + Scheduler::ProcessEventsToIdle(); + + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_RIGHT | KEY_SHIFT); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:MergeCells", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xTextTable->getColumns()->getCount()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getColumns()->getCount()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf126340) { load(DATA_DIRECTORY, "tdf126340.odt"); diff --git a/sw/qa/uitest/table/tdf76636.py b/sw/qa/uitest/table/tdf76636.py deleted file mode 100644 index 274a7b8d08ce..000000000000 --- a/sw/qa/uitest/table/tdf76636.py +++ /dev/null @@ -1,77 +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 libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.debug import sleep -# import org.libreoffice.unotest -# import pathlib -from uitest.path import get_srcdir_url - -def get_url_for_data_file(file_name): -# return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() - return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name - -#Bug 76636 - Crash in .doc when trying to merge cells - -class tdf76636(UITestCase): - - def test_tdf76636_merge_cells_doc(self): - - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf76636.doc")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - #* open Writer - #* merge the three top cells on the right - #--> crash - - self.assertEqual(document.TextTables.getCount(), 1) - #go to middle row - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+LEFT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+LEFT"})) - - #merge - self.xUITest.executeCommand(".uno:MergeCells") - self.assertEqual(document.TextTables.getCount(), 1) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) - self.ui_test.close_doc() - - def test_tdf76636_merge_cells_doc_undo(self): - - writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf76636.doc")) - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - # 1) open crash.doc - # 2) merge the cell with 'punteggio per corso (valutazione singola)' in it with the empty cell to its right - # 3) press undo - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+RIGHT"})) - #merge - self.xUITest.executeCommand(".uno:MergeCells") - self.assertEqual(document.TextTables.getCount(), 1) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 1) - - self.ui_test.close_doc() -# vim: set shiftwidth=4 softtabstop=4 expandtab: |