sw/qa/extras/uiwriter/uiwriter3.cxx     |   72 ++++++++++++++++++++++++++++++++
 sw/qa/uitest/writer_tests7/tdf140731.py |   53 -----------------------
 2 files changed, 72 insertions(+), 53 deletions(-)

New commits:
commit b438a4502d2b388012b0744374e86d1ff0543e8d
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Jan 20 21:07:19 2022 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Jan 21 08:48:33 2022 +0100

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

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 19945bfb7ae1..8ad4a66cb4e3 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1995,6 +1995,78 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf145584)
     CPPUNIT_ASSERT_EQUAL(OUString("World"), sText);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf140731)
+{
+    SwDoc* const pDoc = createSwDoc();
+    SwWrtShell* const pWrtSh = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtSh);
+
+    pWrtSh->Insert("Lorem");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+
+    pTextDoc->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, KEY_F3);
+    Scheduler::ProcessEventsToIdle();
+
+    // generating a big text with ~60k words and several paragraphs
+    for (sal_Int32 i = 0; i < 8; ++i)
+    {
+        dispatchCommand(mxComponent, ".uno:SelectAll", {});
+        Scheduler::ProcessEventsToIdle();
+
+        dispatchCommand(mxComponent, ".uno:Copy", {});
+        Scheduler::ProcessEventsToIdle();
+
+        dispatchCommand(mxComponent, ".uno:Paste", {});
+        Scheduler::ProcessEventsToIdle();
+
+        dispatchCommand(mxComponent, ".uno:Paste", {});
+        Scheduler::ProcessEventsToIdle();
+    }
+
+    dispatchCommand(mxComponent, ".uno:GoToStartOfDoc", {});
+    Scheduler::ProcessEventsToIdle();
+
+    // Format->Text operations on small selections (which would generate <~500 
redlines)
+    // changetracking still working
+    dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    Scheduler::ProcessEventsToIdle();
+
+    SwCursorShell* pShell(pDoc->GetEditShell());
+
+    pShell->SelectText(1, 500);
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseToTitleCase", {});
+    Scheduler::ProcessEventsToIdle();
+
+    SwEditShell* const pEditShell(pDoc->GetEditShell());
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(118),
+                         pEditShell->GetRedlineCount());
+
+    //Removing all the redlines.
+    dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), 
pEditShell->GetRedlineCount());
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    Scheduler::ProcessEventsToIdle();
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseToTitleCase", {});
+    Scheduler::ProcessEventsToIdle();
+
+    // Without the fix in place, on big selections writer would freeze. Now it 
ignores change tracking.
+    CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(0), 
pEditShell->GetRedlineCount());
+
+    // The patch has no effects on the Format->Text operations
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("Lorem Ipsum Dolor 
Sit Amet"));
+
+    dispatchCommand(mxComponent, ".uno:ChangeCaseToUpper", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT(getParagraph(1)->getString().startsWith("LOREM IPSUM DOLOR 
SIT AMET"));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf116315)
 {
     SwDoc* const pDoc = createSwDoc();
diff --git a/sw/qa/uitest/writer_tests7/tdf140731.py 
b/sw/qa/uitest/writer_tests7/tdf140731.py
deleted file mode 100644
index 74d479bf004c..000000000000
--- a/sw/qa/uitest/writer_tests7/tdf140731.py
+++ /dev/null
@@ -1,53 +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, get_url_for_data_file
-from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import type_text
-
-class tdf140731(UITestCase):
-    def test_tdf140731(self):
-        with self.ui_test.create_doc_in_start_center("writer") as document:
-            xWriterDoc = self.xUITest.getTopFocusWindow()
-            xWriterEdit = xWriterDoc.getChild("writer_edit")
-            type_text(xWriterEdit, 'Lorem')
-            xWriterEdit.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"F3"}))
-            xWriterEdit.executeAction("TYPE", 
mkPropertyValues({"KEYCODE":"RETURN"}))
-
-            #generating a big text with ~60k words and several paragraphs
-            for i in range(0,8):
-                self.xUITest.executeCommand(".uno:SelectAll")
-                self.xUITest.executeCommand(".uno:Copy")
-                self.xUITest.executeCommand(".uno:Paste")
-                self.xUITest.executeCommand(".uno:Paste")
-            xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"}))
-
-            #Format->Text operations on small selections (which would generate 
<~500 redlines), changetracking still working
-            self.xUITest.executeCommand(".uno:TrackChanges")
-            xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": 
"1", "END_POS": "1000"}))
-            self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
-            
self.assertTrue(document.Redlines.createEnumeration().hasMoreElements())
-
-            #Removing all the redlines.
-            with 
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges",
 close_button="close") as xTrackDlg:
-                xAccBtn = xTrackDlg.getChild("rejectall")
-                xAccBtn.executeAction("CLICK", tuple())
-
-            #Without the fix in place, on big selections writer would freeze. 
Now it ignores change tracking.
-            self.xUITest.executeCommand(".uno:SelectAll")
-            self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase")
-            
self.assertFalse(document.Redlines.createEnumeration().hasMoreElements())
-
-            #The patch has no effects on the Format->Text operations
-            self.assertEqual(document.Text.String[0:26], "Lorem Ipsum Dolor 
Sit Amet")
-            self.xUITest.executeCommand(".uno:SelectAll")
-            self.xUITest.executeCommand(".uno:ChangeCaseToUpper")
-            self.assertEqual(document.Text.String[0:26], "LOREM IPSUM DOLOR 
SIT AMET")
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab:

Reply via email to