sw/qa/extras/uiwriter/uiwriter8.cxx     |   54 ++++++++++++++++++++++++++++++++
 sw/qa/uitest/writer_tests7/tdf152964.py |   50 -----------------------------
 2 files changed, 54 insertions(+), 50 deletions(-)

New commits:
commit 6732191ebf8a559b272238c03af679263abf86ef
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Mon Feb 13 13:39:29 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Feb 13 14:26:19 2023 +0000

    tdf#152964: sw: move UItest to CppUnittest
    
    Change-Id: I9470bce1350a87d5773674b55148b64b02997210
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146902
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter8.cxx 
b/sw/qa/extras/uiwriter/uiwriter8.cxx
index 18d390ef64ce..43d21e1bfb24 100644
--- a/sw/qa/extras/uiwriter/uiwriter8.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter8.cxx
@@ -842,6 +842,60 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf146248)
     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf152964)
+{
+    createSwDoc();
+
+    dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    Scheduler::ProcessEventsToIdle();
+    dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+    Scheduler::ProcessEventsToIdle();
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Rows", uno::Any(sal_Int32(2)) }, { "Columns", 
uno::Any(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());
+
+    SwDoc* pDoc = getSwDoc();
+    SwEditShell* const pEditShell(pDoc->GetEditShell());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), 
pEditShell->GetRedlineCount());
+    dispatchCommand(mxComponent, ".uno:GoDown", {});
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), 
pEditShell->GetRedlineCount());
+
+    // Without the fix in place, this test would have crashed here
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), 
pEditShell->GetRedlineCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), 
pEditShell->GetRedlineCount());
+
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(1), 
pEditShell->GetRedlineCount());
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(2), 
pEditShell->GetRedlineCount());
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest8, testTdf107427)
 {
     createSwDoc();
diff --git a/sw/qa/uitest/writer_tests7/tdf152964.py 
b/sw/qa/uitest/writer_tests7/tdf152964.py
deleted file mode 100644
index abbf25434668..000000000000
--- a/sw/qa/uitest/writer_tests7/tdf152964.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# This file is part of the LibreOffice project.
-#
-# 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
-from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import select_pos
-
-# Bug 152964 - Undo of tracked deletion of an empty table row crashed Writer
-
-
-class tdf152964(UITestCase):
-    def test_tdf152964(self):
-        with self.ui_test.create_doc_in_start_center("writer"):
-
-            # redlining should be on
-            self.xUITest.executeCommand(".uno:TrackChanges")
-            # hide changes
-            self.xUITest.executeCommand(".uno:ShowTrackedChanges")
-
-            # insert a table
-            xWriterDoc = self.xUITest.getTopFocusWindow()
-            xWriterEdit = xWriterDoc.getChild("writer_edit")
-            xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": 
"RETURN"}))
-            with 
self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog:
-                formatlbinstable = xDialog.getChild("formatlbinstable")
-                entry = formatlbinstable.getChild("1")
-                entry.executeAction("SELECT", tuple())
-
-            # delete its second and first rows
-            self.xUITest.executeCommand(".uno:GoDown")
-            self.xUITest.executeCommand(".uno:DeleteRows")
-            self.xUITest.executeCommand(".uno:DeleteRows")
-
-            # This crashed Writer
-            self.xUITest.executeCommand(".uno:Undo")
-
-            # test other Undos and Redos
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Undo")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.xUITest.executeCommand(".uno:Redo")
-            self.xUITest.executeCommand(".uno:Redo")
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to