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@libreoffice.org>
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 0a7d616..49e60f6 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 @@
//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 60d4279..ff9e334 100644
--- a/uitest/writer_tests4/insertTableDialog.py
+++ b/uitest/writer_tests4/insertTableDialog.py
@@ -44,41 +44,6 @@
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)