sw/qa/extras/uiwriter/uiwriter3.cxx | 102 ++++++++++++++++++++++++++++++++ sw/qa/uitest/writer_tests7/tdf143244.py | 46 -------------- 2 files changed, 102 insertions(+), 46 deletions(-)
New commits: commit 5b7e88d007173e9567299226371a8efda23e7dd9 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Oct 27 00:36:59 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Oct 27 08:18:27 2021 +0200 tdf#143244: sw: move UItest to CppUnittest Change-Id: If1a897270f2fc43cdd5b2a4560bc5d1ce4fdba35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124247 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/uitest/data/tdf143244.odt b/sw/qa/extras/uiwriter/data/tdf143244.odt similarity index 100% rename from sw/qa/uitest/data/tdf143244.odt rename to sw/qa/extras/uiwriter/data/tdf143244.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index e06ce707a52e..8c22759ca415 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -2641,6 +2641,108 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf137964) CPPUNIT_ASSERT_EQUAL(sal_Int32(3090), xShape->getPosition().Y); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf143244) +{ + createSwDoc(DATA_DIRECTORY, "tdf143244.odt"); + + 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(6), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + + uno::Reference<text::XTextRange> xCell(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0x009353), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xdddddd), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A5"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xdddddd), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A6"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xbee3d3), getProperty<Color>(xCell, "BackColor")); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + dispatchCommand(mxComponent, ".uno:Cut", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xIndexAccess->getCount()); + + dispatchCommand(mxComponent, ".uno:Paste", {}); + + xTextTable.set(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + + dispatchCommand(mxComponent, ".uno:GoUp", {}); + + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + for (sal_Int32 i = 0; i < 6; ++i) + { + pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_TAB); + Scheduler::ProcessEventsToIdle(); + } + + for (sal_Int32 i = 0; i < 5; ++i) + { + dispatchCommand(mxComponent, ".uno:Undo", {}); + Scheduler::ProcessEventsToIdle(); + } + + xTextTable.set(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + + for (sal_Int32 i = 0; i < 5; ++i) + { + dispatchCommand(mxComponent, ".uno:Redo", {}); + Scheduler::ProcessEventsToIdle(); + } + + xTextTable.set(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(9), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + + xCell.set(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0x009353), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xdddddd), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A5"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xdddddd), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A6"), uno::UNO_QUERY); + + // Without the fix in place, this test would have failed with + // - Expected: Color: R:255 G:255 B:255 A:255 + // - Actual : Color: R:190 G:227 B:211 A:0 + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A7"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xdddddd), getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A8"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<Color>(xCell, "BackColor")); + + xCell.set(xTextTable->getCellByName("A9"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(Color(0xbee3d3), getProperty<Color>(xCell, "BackColor")); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf136715) { createSwDoc(DATA_DIRECTORY, "tdf136715.odt"); diff --git a/sw/qa/uitest/writer_tests7/tdf143244.py b/sw/qa/uitest/writer_tests7/tdf143244.py deleted file mode 100644 index 20c70d6cd0d6..000000000000 --- a/sw/qa/uitest/writer_tests7/tdf143244.py +++ /dev/null @@ -1,46 +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 libreoffice.uno.propertyvalue import mkPropertyValues -from uitest.uihelper.common import select_pos - -# Bug 143244 - Redo of adding table rows breaks table style after cut/paste action - - -class tdf143244(UITestCase): - def test_tdf143244(self): - with self.ui_test.load_file(get_url_for_data_file("tdf143244.odt")) as writer_doc: - self.xUITest.executeCommand(".uno:SelectAll") - self.xUITest.executeCommand(".uno:Cut") - self.xUITest.executeCommand(".uno:Paste") - self.xUITest.executeCommand(".uno:GoUp") - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - for i in range(0,6): - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - for i in range(0,4): - self.xUITest.executeCommand(".uno:Undo") - for i in range(0,4): - self.xUITest.executeCommand(".uno:Redo") - for i in range (0,3): - self.xUITest.executeCommand(".uno:GoUp") - with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "4") #tab Background - btncolor = xDialog.getChild("btncolor") - btncolor.executeAction("CLICK", tuple()) - hex_custom = xDialog.getChild("hex_custom") - if i == 0: - self.assertEqual(get_state_as_dict(hex_custom)["Text"], "bee3d3") - if i == 1: - # Without the fix in place, this test would have failed with - # AssertionError: 'bee3d3' != 'ffffff' - self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ffffff") - if i == 2: - self.assertEqual(get_state_as_dict(hex_custom)["Text"], "dddddd") -# vim: set shiftwidth=4 softtabstop=4 expandtab: