sw/qa/extras/uiwriter/uiwriter3.cxx     |   91 ++++++++++++++++++++++++++++++++
 sw/qa/uitest/writer_tests7/tdf136715.py |   28 ---------
 2 files changed, 91 insertions(+), 28 deletions(-)

New commits:
commit f222340085ee08e929efb957b0fc532c5b288fae
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Oct 26 22:27:09 2021 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Oct 27 00:39:10 2021 +0200

    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 <xiscofa...@libreoffice.org>

diff --git a/sw/qa/uitest/data/tdf136715.odt 
b/sw/qa/extras/uiwriter/data/tdf136715.odt
similarity index 100%
rename from sw/qa/uitest/data/tdf136715.odt
rename to 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:

Reply via email to