[Libreoffice-commits] core.git: sw/Module_sw.mk sw/qa sw/UITest_sw_sidebar.mk

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Mon Jan 18 22:36:03 UTC 2021


 sw/Module_sw.mk                            |    1 
 sw/UITest_sw_sidebar.mk                    |   16 +++++
 sw/qa/uitest/data/customStyles.odt         |binary
 sw/qa/uitest/sidebar/stylesSidebar.py      |   78 +++++++++++++++++++++++++++++
 sw/qa/uitest/writer_dialogs/openDialogs.py |    3 -
 5 files changed, 97 insertions(+), 1 deletion(-)

New commits:
commit 708ac46fa50de19878446571a5930e2e2d4a36a5
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Mon Jan 18 17:52:19 2021 +0100
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Mon Jan 18 23:35:23 2021 +0100

    uitest: sw: test load styles from template
    
    Also add a new module for sidebar tests
    Change-Id: Iba823907f2a71d590152c17855355ed5a0a44326
    
    Change-Id: I41a023468a90ca7d79822b6a1c78bf24ee971bc8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109566
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk
index 85a0a7a23e13..4a56c8602d25 100644
--- a/sw/Module_sw.mk
+++ b/sw/Module_sw.mk
@@ -179,6 +179,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sw,\
 	UITest_chapterNumbering \
 	UITest_sw_navigator \
 	UITest_sw_options \
+	UITest_sw_sidebar \
 	UITest_sw_styleInspector \
 	UITest_sw_ui_fmtui \
 	UITest_classification \
diff --git a/sw/UITest_sw_sidebar.mk b/sw/UITest_sw_sidebar.mk
new file mode 100644
index 000000000000..8a087e14fa43
--- /dev/null
+++ b/sw/UITest_sw_sidebar.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,sw_sidebar))
+
+$(eval $(call gb_UITest_add_modules,sw_sidebar,$(SRCDIR)/sw/qa/uitest,\
+	sidebar/ \
+))
+
+$(eval $(call gb_UITest_set_defs,sw_sidebar, \
+    TDOC="$(SRCDIR)/sw/qa/uitest/data" \
+))
diff --git a/sw/qa/uitest/data/customStyles.odt b/sw/qa/uitest/data/customStyles.odt
new file mode 100644
index 000000000000..2cf4bbbb1e98
Binary files /dev/null and b/sw/qa/uitest/data/customStyles.odt differ
diff --git a/sw/qa/uitest/sidebar/stylesSidebar.py b/sw/qa/uitest/sidebar/stylesSidebar.py
new file mode 100644
index 000000000000..db625be6f006
--- /dev/null
+++ b/sw/qa/uitest/sidebar/stylesSidebar.py
@@ -0,0 +1,78 @@
+# -*- 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, get_url_for_data_file
+from libreoffice.uno.propertyvalue import mkPropertyValues
+
+class StylesSidebar(UITestCase):
+
+   def test_load_styles_from_template(self):
+        self.ui_test.create_doc_in_start_center("writer")
+
+        self.ui_test.execute_dialog_through_command(".uno:LoadStyles")
+
+        xDialog = self.xUITest.getTopFocusWindow()
+
+        xText = xDialog.getChild("text")
+        xNumbering = xDialog.getChild("numbering")
+        xFrame = xDialog.getChild("frame")
+        xPages = xDialog.getChild("pages")
+
+        self.assertEqual('true', get_state_as_dict(xText)['Selected'])
+        self.assertEqual('false', get_state_as_dict(xNumbering)['Selected'])
+        self.assertEqual('false', get_state_as_dict(xFrame)['Selected'])
+        self.assertEqual('false', get_state_as_dict(xPages)['Selected'])
+
+        xNumbering.executeAction("CLICK", tuple())
+        xFrame.executeAction("CLICK", tuple())
+        xPages.executeAction("CLICK", tuple())
+
+        self.assertEqual('true', get_state_as_dict(xText)['Selected'])
+        self.assertEqual('true', get_state_as_dict(xNumbering)['Selected'])
+        self.assertEqual('true', get_state_as_dict(xFrame)['Selected'])
+        self.assertEqual('true', get_state_as_dict(xPages)['Selected'])
+
+        xFileName = xDialog.getChild("fromfile")
+        xFileName.executeAction("CLICK", tuple())
+
+        xOpenDialog = self.xUITest.getTopFocusWindow()
+        xFileName = xOpenDialog.getChild("file_name")
+        xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("customStyles.odt")}))
+
+        xOpenBtn = xOpenDialog.getChild("open")
+        xOpenBtn.executeAction("CLICK", tuple())
+
+        xWriterDoc = self.xUITest.getTopFocusWindow()
+        xWriterEdit = xWriterDoc.getChild("writer_edit")
+
+        self.xUITest.executeCommand(".uno:Sidebar")
+        xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"}))
+
+        xFilter = xWriterEdit.getChild('filter')
+        xFilter.executeAction("SELECT", mkPropertyValues({"TEXT": "Custom Styles"}))
+
+        expectedResults = ["customParagraphStyle", "customCharacterStyle", "customFrameStyle",
+                "customPageStyle", "customNumberingStyle"]
+
+        for i in range(5):
+            xLeft = xWriterEdit.getChild('left')
+
+            #change to another style type
+            xLeft.executeAction("CLICK", mkPropertyValues({"POS": str( i + 1 )}))
+
+            xFlatView = xWriterEdit.getChild("flatview")
+
+            self.assertEqual(1, len(xFlatView.getChildren()))
+
+            xFlatView.getChild('0').executeAction("SELECT", tuple())
+            self.assertEqual(expectedResults[i], get_state_as_dict(xFlatView)['SelectEntryText'])
+
+        self.xUITest.executeCommand(".uno:Sidebar")
+
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/writer_tests7/tdf133189.py b/sw/qa/uitest/sidebar/tdf133189.py
similarity index 100%
rename from sw/qa/uitest/writer_tests7/tdf133189.py
rename to sw/qa/uitest/sidebar/tdf133189.py
diff --git a/sw/qa/uitest/writer_tests7/tdf99711.py b/sw/qa/uitest/sidebar/tdf99711.py
similarity index 100%
rename from sw/qa/uitest/writer_tests7/tdf99711.py
rename to sw/qa/uitest/sidebar/tdf99711.py
diff --git a/sw/qa/uitest/writer_dialogs/openDialogs.py b/sw/qa/uitest/writer_dialogs/openDialogs.py
index 07f127830404..6c8cb699a7a6 100644
--- a/sw/qa/uitest/writer_dialogs/openDialogs.py
+++ b/sw/qa/uitest/writer_dialogs/openDialogs.py
@@ -79,7 +79,8 @@ dialogs = [
         # tested in sw/qa/uitest/writer_tests/watermark.py
     # {"command": ".uno:EditStyle", "closeButton": "cancel"},
         # tested in sw/qa/uitest/writer_tests2/horizontalLine.py
-    {"command": ".uno:LoadStyles", "closeButton": "cancel"},
+    #{"command": ".uno:LoadStyles", "closeButton": "cancel"},
+        # tested in sw/qa/uitest/sidebar/stylesSidebar.py
     # {"command": ".uno:InsertTable", "closeButton": "cancel"},
         # tested in uitest/writer_tests/insertTableDialog.py
     # {"command": ".uno:SpellDialog", "closeButton": "close"},


More information about the Libreoffice-commits mailing list