diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2019-07-29 19:17:40 +0200 |
---|---|---|
committer | Xisco Faulí <xiscofauli@libreoffice.org> | 2019-07-30 00:59:10 +0200 |
commit | 6f8a1b6736b4a79778fd222c7adabb2f6a12ca0a (patch) | |
tree | 075b7639b25eb5b66e55f90a231d66944ad555a1 | |
parent | 41d3be4a48ea2abe019cd4f9b51bef703a2dc454 (diff) |
tdf#126306: Add UItest
this is possible after Jim Raykowski added accessible
support to the autofilter popup ( tdf#122774 )
Change-Id: I9b503f8260fd914e7b5794b837d2661c63c7d21b
Reviewed-on: https://gerrit.libreoffice.org/76563
Tested-by: Jenkins
Reviewed-by: Xisco Faulí <xiscofauli@libreoffice.org>
-rw-r--r-- | sc/qa/uitest/autofilter/tdf126306.py | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/sc/qa/uitest/autofilter/tdf126306.py b/sc/qa/uitest/autofilter/tdf126306.py new file mode 100644 index 000000000000..5446d3337049 --- /dev/null +++ b/sc/qa/uitest/autofilter/tdf126306.py @@ -0,0 +1,140 @@ +# -*- 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.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from libreoffice.calc.document import get_row + +class tdf126306(UITestCase): + def check_values(self, document, results): + for i, value in enumerate(results, start=1): + self.assertEqual(get_cell_by_position(document, 0, 0, i).getValue(), value) + + def check_row_hidden(self, document, results = [True] * 14): + for i, value in enumerate(results, start=1): + row = get_row(document, i) + bVisible = row.getPropertyValue("IsVisible") + self.assertEqual(bVisible, value) + + def test_run(self): + self.ui_test.create_doc_in_start_center("calc") + document = self.ui_test.get_component() + calcDoc = self.xUITest.getTopFocusWindow() + xGridWin = calcDoc.getChild("grid_window") + + default_values = [25, 1023, 17, 9, 19, 0, 107, 89, 8, 453, 33, 3, 25, 204] + document = self.ui_test.get_component() + + for i, value in enumerate(default_values, start=2): + enter_text_to_cell(xGridWin, "A" + str(i), str(value)) + + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"})) + + self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter") + xDialog = self.xUITest.getTopFocusWindow() + xYesBtn = xDialog.getChild("yes") + self.ui_test.close_dialog_through_button(xYesBtn) + + self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) + + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Sort ascending button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+TAB"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + sort_asc_values = [0, 3, 8, 9, 17, 19, 25, 25, 33, 89, 107, 204, 453, 1023] + self.check_values(document, sort_asc_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Sort descending button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+TAB"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + sort_des_values = [1023, 453, 204, 107, 89, 33, 25, 25, 19, 17, 9, 8, 3, 0] + self.check_values(document, sort_des_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Top 10 button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+TAB"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + top10_hidden_values = [True, True, True, False, True, False, True, + True, False, True, True, False, True, True] + + #Values are the same + self.check_values(document, default_values) + self.check_row_hidden(document, top10_hidden_values) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+TAB"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + empty_values = [False] * 14 + #Values are the same + self.check_values(document, default_values) + self.check_row_hidden(document, empty_values) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Not Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+TAB"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xFloatWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + #Nothing should change + self.check_values(document, default_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # finish + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |