diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-10-26 22:27:09 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-10-27 00:39:10 +0200 |
commit | f222340085ee08e929efb957b0fc532c5b288fae (patch) | |
tree | 8dcab3d8d3d41fb81d6cb8f269c91f1e09f4cc8e /sw | |
parent | 179e0c0cc5d3fd9610574e45a5204584f0e39176 (diff) |
tdf#136715: move UItest to CppUnittest
Change-Id: I322b2cc0bae0889e5f3aaaf0542320c9dda82079
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124243
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/uiwriter/data/tdf136715.odt (renamed from sw/qa/uitest/data/tdf136715.odt) | bin | 11499 -> 11499 bytes | |||
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter3.cxx | 91 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests7/tdf136715.py | 28 |
3 files changed, 91 insertions, 28 deletions
diff --git a/sw/qa/uitest/data/tdf136715.odt b/sw/qa/extras/uiwriter/data/tdf136715.odt Binary files differindex ca5c89ce427c..ca5c89ce427c 100644 --- a/sw/qa/uitest/data/tdf136715.odt +++ b/sw/qa/extras/uiwriter/data/tdf136715.odt diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index d6aec38d1d11..e06ce707a52e 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -11,6 +11,7 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <vcl/scheduler.hxx> #include <vcl/TypeSerializer.hxx> +#include <com/sun/star/awt/FontWeight.hpp> #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <IDocumentDrawModelAccess.hxx> #include <com/sun/star/table/TableBorder2.hpp> @@ -2640,6 +2641,96 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf137964) CPPUNIT_ASSERT_EQUAL(sal_Int32(3090), xShape->getPosition().Y); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf136715) +{ + createSwDoc(DATA_DIRECTORY, "tdf136715.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(4), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTextTable->getColumns()->getCount()); + + uno::Reference<text::XTextRange> xCell(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); + + dispatchCommand(mxComponent, ".uno:GoDown", {}); + dispatchCommand(mxComponent, ".uno:GoDown", {}); + dispatchCommand(mxComponent, ".uno:LineDownSel", {}); + dispatchCommand(mxComponent, ".uno:DeleteRows", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTextTable->getColumns()->getCount()); + + xCell.set(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTextTable->getRows()->getCount()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTextTable->getColumns()->getCount()); + + xCell.set(xTextTable->getCellByName("A1"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A2"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + + // Without the fix in place, this test would have failed with + // - Expected: 100 + // - Actual : 150 + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A3"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::NORMAL, getProperty<float>(xPara, "CharWeight")); + + xCell.set(xTextTable->getCellByName("A4"), uno::UNO_QUERY); + xParaEnumAccess.set(xCell->getText(), uno::UNO_QUERY); + xParaEnum.set(xParaEnumAccess->createEnumeration()); + xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(xPara, "CharWeight")); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf138897) { createSwDoc(DATA_DIRECTORY, "tdf100018-1.odt"); diff --git a/sw/qa/uitest/writer_tests7/tdf136715.py b/sw/qa/uitest/writer_tests7/tdf136715.py deleted file mode 100644 index acd89808179d..000000000000 --- a/sw/qa/uitest/writer_tests7/tdf136715.py +++ /dev/null @@ -1,28 +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 136715 - Undoing table rows caused inconsistent table look when using table styles - -class tdf136715(UITestCase): - def test_tdf136715(self): - with self.ui_test.load_file(get_url_for_data_file("tdf136715.odt")) as writer_doc: - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:LineDownSel") - self.xUITest.executeCommand(".uno:DeleteRows") - self.xUITest.executeCommand(".uno:Undo") - with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylebcjk = xDialog.getChild("weststylelb-cjk") - #without the fix in place, the row would have bold character formatting - self.assertEqual(get_state_as_dict(xweststylebcjk)["Text"], "Regular") -# vim: set shiftwidth=4 softtabstop=4 expandtab: |