[Libreoffice-commits] core.git: sw/qa uitest/writer_tests4

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Fri Apr 3 18:00:23 UTC 2020


 sw/qa/extras/uiwriter/uiwriter3.cxx       |   75 ++++++++++++++++++++++++++++++
 uitest/writer_tests4/insertTableDialog.py |   35 --------------
 2 files changed, 75 insertions(+), 35 deletions(-)

New commits:
commit 820a5155973fef28891c7cc9f9547c21b0f2bf1a
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Fri Apr 3 13:12:51 2020 +0200
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Fri Apr 3 19:59:47 2020 +0200

    tdf#80663, tdf#96067: move UItest to CppunitTest
    
    Change-Id: I1af2de672db7124faec473202ce858ec292a2c6f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91654
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 0a7d61695821..49e60f6bc0d9 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 <com/sun/star/text/TextContentAnchorType.hpp>
+#include <comphelper/propertysequence.hxx>
 
 namespace
 {
@@ -342,4 +343,78 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf130680)
     //dispatchCommand(mxComponent, ".uno:Undo", {});
     //CPPUNIT_ASSERT_EQUAL(sal_Int32(23), xIndexAccess->getCount());
 }
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf80663)
+{
+    mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Rows", uno::makeAny(sal_Int32(2)) }, { "Columns", uno::makeAny(sal_Int32(2)) } }));
+
+    dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    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(2), xTextTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount());
+
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTextTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount());
+}
+
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf96067)
+{
+    mxComponent = loadFromDesktop("private:factory/swriter", "com.sun.star.text.TextDocument");
+
+    SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Rows", uno::makeAny(sal_Int32(3)) }, { "Columns", uno::makeAny(sal_Int32(3)) } }));
+
+    dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+    Scheduler::ProcessEventsToIdle();
+
+    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(3), xTextTable->getColumns()->getCount());
+
+    dispatchCommand(mxComponent, ".uno:SelectTable", {});
+    dispatchCommand(mxComponent, ".uno:InsertRowsBefore", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xTextTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getRows()->getCount());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/uitest/writer_tests4/insertTableDialog.py b/uitest/writer_tests4/insertTableDialog.py
index 60d427954a4c..ff9e3349943a 100644
--- a/uitest/writer_tests4/insertTableDialog.py
+++ b/uitest/writer_tests4/insertTableDialog.py
@@ -44,41 +44,6 @@ class WriterInsertTableDialog(UITestCase):
         tableText = table.getCellByName( cellName )
         tableText.setString( text )
 
-    def test_tdf80663(self):
-
-        self.insert_table("Test1", 2, 2)
-
-        document = self.ui_test.get_component()
-
-        tables = document.getTextTables()
-        self.xUITest.executeCommand(".uno:DeleteRows")
-
-        self.assertEqual(len(tables[0].getRows()), 1)
-        self.assertEqual(len(tables[0].getColumns()), 2)
-
-        self.xUITest.executeCommand(".uno:Undo")
-
-        self.assertEqual(len(tables[0].getRows()), 2)
-        self.assertEqual(len(tables[0].getColumns()), 2)
-
-        self.ui_test.close_doc()
-
-    def test_tdf96067(self):
-
-        self.insert_table("Test2", 3, 3)
-
-        self.xUITest.executeCommand(".uno:SelectTable")
-        self.xUITest.executeCommand(".uno:InsertRowsBefore")
-
-        document = self.ui_test.get_component()
-        tables = document.getTextTables()
-        self.assertEqual(len(tables[0].getRows()), 6)
-        self.assertEqual(len(tables[0].getColumns()), 3)
-
-        self.xUITest.executeCommand(".uno:Undo")
-
-        self.ui_test.close_doc()
-
     def test_tdf104158(self):
 
         self.insert_table("Test3", 2, 2)


More information about the Libreoffice-commits mailing list