[Libreoffice-commits] core.git: sd/Module_sd.mk sd/qa sd/UITest_findReplace.mk

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Jan 31 15:32:02 UTC 2019


 sd/Module_sd.mk                                 |    1 
 sd/UITest_findReplace.mk                        |   16 +++
 sd/qa/uitest/findReplace/findReplace.py         |  109 ++++++++++++++++++++++++
 sd/qa/uitest/impress_tests/data/findReplace.odp |binary
 4 files changed, 126 insertions(+)

New commits:
commit e364c8c3e7352c10ec39538e3726e2a84ebfa388
Author:     Zdeněk Crhonek <zcrhonek at gmail.com>
AuthorDate: Thu Jan 31 14:50:58 2019 +0100
Commit:     Zdenek Crhonek <zcrhonek at gmail.com>
CommitDate: Thu Jan 31 16:31:24 2019 +0100

    uitest add test for Impress / find and replace dialog
    
    Change-Id: Id3479e790c9a1faf7ce3e0b542900c8875aac653
    Reviewed-on: https://gerrit.libreoffice.org/67213
    Tested-by: Jenkins
    Reviewed-by: Zdenek Crhonek <zcrhonek at gmail.com>

diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index e1ead370b2e3..22f6fa17c194 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -61,5 +61,6 @@ $(eval $(call gb_Module_add_subsequentcheck_targets,sd,\
 
 $(eval $(call gb_Module_add_uicheck_targets,sd,\
 	UITest_impress_tests \
+	UITest_findReplace \
 ))
 # vim: set noet sw=4 ts=4:
diff --git a/sd/UITest_findReplace.mk b/sd/UITest_findReplace.mk
new file mode 100644
index 000000000000..245468975771
--- /dev/null
+++ b/sd/UITest_findReplace.mk
@@ -0,0 +1,16 @@
+# 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/.
+#
+
+$(eval $(call 	gb_UITest_UITest,findReplace))
+
+$(eval $(call gb_UITest_add_modules,findReplace,$(SRCDIR)/sd/qa/uitest,\
+	findReplace/ \
+))
+
+$(eval $(call gb_UITest_set_defs,findReplace, \
+    TDOC="$(SRCDIR)/sd/qa/uitest/impress_tests/data" \
+))
diff --git a/sd/qa/uitest/findReplace/findReplace.py b/sd/qa/uitest/findReplace/findReplace.py
new file mode 100644
index 000000000000..8e5cde3446ed
--- /dev/null
+++ b/sd/qa/uitest/findReplace/findReplace.py
@@ -0,0 +1,109 @@
+# -*- 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
+from uitest.uihelper.common import select_pos
+from uitest.uihelper.calc import enter_text_to_cell
+from libreoffice.calc.document import get_cell_by_position
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.debug import sleep
+import org.libreoffice.unotest
+import pathlib
+
+def get_url_for_data_file(file_name):
+    return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri()
+
+#Find and replace
+
+class findReplace(UITestCase):
+    def test_find_impress(self):
+        impress_doc = self.ui_test.load_file(get_url_for_data_file("findReplace.odp"))
+        document = self.ui_test.get_component()
+        # print(dir(document))
+        # xPages= document.CurrentController.getCurrentPage().Number
+        # print(xPages)
+        self.assertEqual(document.CurrentController.getCurrentPage().Number, 1)
+        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+        xDialog = self.xUITest.getTopFocusWindow()
+        searchterm = xDialog.getChild("searchterm")
+        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"second"}))  #2nd slide
+        xsearch = xDialog.getChild("search")
+        xsearch.executeAction("CLICK", tuple())
+        #verify
+        self.assertEqual(document.CurrentController.getCurrentPage().Number, 2)
+
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"third"}))
+        xsearch.executeAction("CLICK", tuple())
+        #verify
+        self.assertEqual(document.CurrentController.getCurrentPage().Number, 3)  #3rd slide
+
+        xcloseBtn = xDialog.getChild("close")
+        self.ui_test.close_dialog_through_button(xcloseBtn)
+
+        #now open dialog and verify find="third" (remember last value); replace value with "First" ( click match case) with word "Replace" - click twice Replace button, check "Replace first first"
+        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+        xDialog = self.xUITest.getTopFocusWindow()
+        searchterm = xDialog.getChild("searchterm")
+        self.assertEqual(get_state_as_dict(searchterm)["Text"], "third")
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"First"}))
+        matchcase = xDialog.getChild("matchcase")
+        matchcase.executeAction("CLICK", tuple())  #click match case
+        replaceterm = xDialog.getChild("replaceterm")
+        replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Replace"})) #replace textbox
+        replace = xDialog.getChild("replace")
+        replace.executeAction("CLICK", tuple())
+        replace.executeAction("CLICK", tuple())   #click twice Replace button
+        #close and reopen the dialog, because of bug  122788
+        xcloseBtn = xDialog.getChild("close")
+        self.ui_test.close_dialog_through_button(xcloseBtn)
+        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+        xDialog = self.xUITest.getTopFocusWindow()
+        replaceterm = xDialog.getChild("replaceterm")
+        matchcase = xDialog.getChild("matchcase")
+        #now replace first (uncheck match case) with word "aaa" - click once Replace All button, check "Replace aaa aaa"
+        replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        replaceterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"aaa"}))
+        matchcase.executeAction("CLICK", tuple())  #uncheck match case
+        replaceall = xDialog.getChild("replaceall")
+        replaceall.executeAction("CLICK", tuple())
+        xcloseBtn = xDialog.getChild("close")
+        self.ui_test.close_dialog_through_button(xcloseBtn)
+
+        #go to second page
+        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+        xDialog = self.xUITest.getTopFocusWindow()
+        searchterm = xDialog.getChild("searchterm")
+        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"second"}))  #2nd slide
+        xsearch = xDialog.getChild("search")
+        xsearch.executeAction("CLICK", tuple())
+        xcloseBtn = xDialog.getChild("close")
+        self.ui_test.close_dialog_through_button(xcloseBtn)
+        self.assertEqual(document.CurrentController.getCurrentPage().Number, 2)
+        #now check if text "Replace aaa aaa" is on first slide
+        self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog")
+        xDialog = self.xUITest.getTopFocusWindow()
+        searchterm = xDialog.getChild("searchterm")
+        backsearch = xDialog.getChild("backsearch")
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Replace aaa aaa"}))
+        backsearch.executeAction("CLICK", tuple())
+        #verify
+        self.assertEqual(document.CurrentController.getCurrentPage().Number, 1)  #1st slide
+
+        xcloseBtn = xDialog.getChild("close")
+        self.ui_test.close_dialog_through_button(xcloseBtn)
+
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sd/qa/uitest/impress_tests/data/findReplace.odp b/sd/qa/uitest/impress_tests/data/findReplace.odp
new file mode 100644
index 000000000000..6ccbfcfed742
Binary files /dev/null and b/sd/qa/uitest/impress_tests/data/findReplace.odp differ


More information about the Libreoffice-commits mailing list