[Libreoffice-commits] core.git: sc/qa

Zdeněk Crhonek zcrhonek at gmail.com
Thu May 10 14:50:05 UTC 2018


 sc/qa/uitest/calc_tests/columns.py |  228 +++++++++++++++++++++++++++++++++++++
 1 file changed, 228 insertions(+)

New commits:
commit 8a8fa23a37aa5b2d0b061ec34dd8058493e813b5
Author: Zdeněk Crhonek <zcrhonek at gmail.com>
Date:   Wed May 9 22:51:22 2018 +0200

    uitest - Calc-Format-Columns
    
    Change-Id: Ie9375a9c464b658abf5a8f85ae76cc460ed4b9cf
    Reviewed-on: https://gerrit.libreoffice.org/54056
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Zdenek Crhonek <zcrhonek at gmail.com>

diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py
new file mode 100644
index 000000000000..56b2adbfb1b3
--- /dev/null
+++ b/sc/qa/uitest/calc_tests/columns.py
@@ -0,0 +1,228 @@
+# -*- 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.debug import sleep
+
+class CalcColumns(UITestCase):
+    def test_column_width(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        #Make sure that tools-options-StarOffice Calc-General
+        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
+        xDialogOpt = self.xUITest.getTopFocusWindow()
+
+        xPages = xDialogOpt.getChild("pages")
+        xWriterEntry = xPages.getChild('3')                 # Calc
+        xWriterEntry.executeAction("EXPAND", tuple())
+        xWriterGeneralEntry = xWriterEntry.getChild('0')
+        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General /cm
+        xunitlb = xDialogOpt.getChild("unitlb")
+        props = {"TEXT": "Centimeter"}
+        actionProps = mkPropertyValues(props)
+        xunitlb.executeAction("SELECT", actionProps)
+        xOKBtn = xDialogOpt.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOKBtn)
+        #select A1
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+        #column width
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        xdefault = xDialog.getChild("default")
+        self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true")  #default selected
+        heightStrOrig = get_state_as_dict(xvalue)["Text"]
+        heightVal = heightStrOrig[:4]  #default 2.26 cm
+        xvalue.executeAction("UP", tuple())  #2.36 cm
+        heightStr = get_state_as_dict(xvalue)["Text"]
+        heightValNew = heightStr[:4]
+        self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false")  #default not selected
+        self.assertEqual(heightValNew > heightVal, True)  #new value is bigger
+        xdefault.executeAction("CLICK", tuple())  #click default
+        self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True)  #default value set
+        #write your own value
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+        # Click Ok
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+        #verify
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+
+        self.ui_test.close_doc()
+
+    def test_column_width_two_columns(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        #Make sure that tools-options-StarOffice Calc-General
+        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
+        xDialogOpt = self.xUITest.getTopFocusWindow()
+
+        xPages = xDialogOpt.getChild("pages")
+        xWriterEntry = xPages.getChild('3')                 # Calc
+        xWriterEntry.executeAction("EXPAND", tuple())
+        xWriterGeneralEntry = xWriterEntry.getChild('0')
+        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General /cm
+        xunitlb = xDialogOpt.getChild("unitlb")
+        props = {"TEXT": "Centimeter"}
+        actionProps = mkPropertyValues(props)
+        xunitlb.executeAction("SELECT", actionProps)
+        xOKBtn = xDialogOpt.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOKBtn)
+
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"}))
+
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        xdefault = xDialog.getChild("default")
+        #write your own value
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+        # Click Ok
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+        #verify
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+
+        self.ui_test.close_doc()
+
+    def test_column_width_copy(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+
+        #Make sure that tools-options-StarOffice Calc-General
+        self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog")  #optionsdialog
+        xDialogOpt = self.xUITest.getTopFocusWindow()
+
+        xPages = xDialogOpt.getChild("pages")
+        xWriterEntry = xPages.getChild('3')                 # Calc
+        xWriterEntry.executeAction("EXPAND", tuple())
+        xWriterGeneralEntry = xWriterEntry.getChild('0')
+        xWriterGeneralEntry.executeAction("SELECT", tuple())          #General /cm
+        xunitlb = xDialogOpt.getChild("unitlb")
+        props = {"TEXT": "Centimeter"}
+        actionProps = mkPropertyValues(props)
+        xunitlb.executeAction("SELECT", actionProps)
+        xOKBtn = xDialogOpt.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOKBtn)
+        #select A1
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
+        #column width
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
+        xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"}))
+        # Click Ok
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+        #select column 1
+        self.xUITest.executeCommand(".uno:SelectColumn")
+        #copy
+        self.xUITest.executeCommand(".uno:Copy")
+        #select C1
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
+        #paste
+        self.xUITest.executeCommand(".uno:Paste")
+        #verify
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
+        self.ui_test.execute_dialog_through_command(".uno:ColumnWidth")
+        xDialog = self.xUITest.getTopFocusWindow()
+        xvalue = xDialog.getChild("value")
+        self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm")
+        xOK = xDialog.getChild("ok")
+        self.ui_test.close_dialog_through_button(xOK)
+
+        self.ui_test.close_doc()
+
+    def test_column_hide_show(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+        #select A3
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
+        self.xUITest.executeCommand(".uno:HideColumn") #uno command moves focus one cell down
+        #verify D1
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "3")
+        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"}))
+        #verify B (column C is hidden)
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "1")
+        #Show hidden column: select B1:D1
+        gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:D1"}))
+        self.xUITest.executeCommand(".uno:ShowColumn")
+        #verify
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"}))
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "3")
+        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"}))
+        #verify C1 (COlumn C is not hidden)
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "2")
+
+        self.ui_test.close_doc()
+
+    def test_column_test_move(self):
+        calc_doc = self.ui_test.create_doc_in_start_center("calc")
+        xCalcDoc = self.xUITest.getTopFocusWindow()
+        gridwin = xCalcDoc.getChild("grid_window")
+        document = self.ui_test.get_component()
+        #select C1
+        gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"}))
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "2")
+        #right
+        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"}))
+        #verify D1
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "3")
+        gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"}))
+        #verify C1
+        gridWinState = get_state_as_dict(gridwin)
+        self.assertEqual(gridWinState["CurrentColumn"], "2")
+
+        self.ui_test.close_doc()
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file


More information about the Libreoffice-commits mailing list