From 66617557476e7275fdb5ef3a7f46df89027cda4e Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Thu, 24 Jun 2021 12:29:20 +0200 Subject: uitest: sc: move csv dialog tests to their own module Change-Id: Ib8456cb77b1c147856f378eb6198f69d380e18c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117775 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sc/Module_sc.mk | 1 + sc/UITest_csv_dialog.mk | 20 ++++++++++++ sc/qa/uitest/calc_tests9/tdf142395.py | 53 -------------------------------- sc/qa/uitest/calc_tests9/tdf57841.py | 51 ------------------------------ sc/qa/uitest/calc_tests9/tdf60468.py | 58 ----------------------------------- sc/qa/uitest/csv_dialog/tdf142395.py | 53 ++++++++++++++++++++++++++++++++ sc/qa/uitest/csv_dialog/tdf57841.py | 51 ++++++++++++++++++++++++++++++ sc/qa/uitest/csv_dialog/tdf60468.py | 58 +++++++++++++++++++++++++++++++++++ 8 files changed, 183 insertions(+), 162 deletions(-) create mode 100644 sc/UITest_csv_dialog.mk delete mode 100644 sc/qa/uitest/calc_tests9/tdf142395.py delete mode 100644 sc/qa/uitest/calc_tests9/tdf57841.py delete mode 100644 sc/qa/uitest/calc_tests9/tdf60468.py create mode 100644 sc/qa/uitest/csv_dialog/tdf142395.py create mode 100644 sc/qa/uitest/csv_dialog/tdf57841.py create mode 100644 sc/qa/uitest/csv_dialog/tdf60468.py diff --git a/sc/Module_sc.mk b/sc/Module_sc.mk index a75da398136f..23f87316b79c 100644 --- a/sc/Module_sc.mk +++ b/sc/Module_sc.mk @@ -249,6 +249,7 @@ $(eval $(call gb_Module_add_uicheck_targets,sc,\ UITest_calc_tests3 \ UITest_calc_tests4 \ UITest_calc_tests6 \ + UITest_csv_dialog \ UITest_statistics \ UITest_solver \ UITest_goalSeek \ diff --git a/sc/UITest_csv_dialog.mk b/sc/UITest_csv_dialog.mk new file mode 100644 index 000000000000..9e1ac6ab9d08 --- /dev/null +++ b/sc/UITest_csv_dialog.mk @@ -0,0 +1,20 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# 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,csv_dialog)) + +$(eval $(call gb_UITest_add_modules,csv_dialog,$(SRCDIR)/sc/qa/uitest,\ + csv_dialog/ \ +)) + +$(eval $(call gb_UITest_set_defs,csv_dialog, \ + TDOC="$(SRCDIR)/sc/qa/uitest/data" \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/sc/qa/uitest/calc_tests9/tdf142395.py b/sc/qa/uitest/calc_tests9/tdf142395.py deleted file mode 100644 index 874313afecf9..000000000000 --- a/sc/qa/uitest/calc_tests9/tdf142395.py +++ /dev/null @@ -1,53 +0,0 @@ -# -*- 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 -from libreoffice.calc.document import get_cell_by_position - -class Tdf142395(UITestCase): - - def test_tdf142395(self): - - # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") - - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf142395.csv")})) - - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) - - # Remove the text delimiter - xTextDelimiter = self.ui_test.wait_until_child_is_available('textdelimiter') - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - - xDialog = self.xUITest.getTopFocusWindow() - xOK = xDialog.getChild('ok') - with self.ui_test.wait_until_component_loaded(): - self.ui_test.close_dialog_through_button(xOK) - - document = self.ui_test.get_component() - - self.assertEqual("a", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual(" b", get_cell_by_position(document, 0, 1, 0).getString()) - self.assertEqual(" c", get_cell_by_position(document, 0, 2, 0).getString()) - - # Without the fix in place, this test would have failed with - # AssertionError: ' ' != '晦餪' - self.assertEqual(" ", get_cell_by_position(document, 0, 3, 0).getString()) - - self.assertEqual("e", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual(" f", get_cell_by_position(document, 0, 1, 1).getString()) - self.assertEqual(" g", get_cell_by_position(document, 0, 2, 1).getString()) - self.assertEqual(" ", get_cell_by_position(document, 0, 3, 1).getString()) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf57841.py b/sc/qa/uitest/calc_tests9/tdf57841.py deleted file mode 100644 index 995fab2647de..000000000000 --- a/sc/qa/uitest/calc_tests9/tdf57841.py +++ /dev/null @@ -1,51 +0,0 @@ -# -*- 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 -from libreoffice.calc.document import get_cell_by_position - -class Tdf57841(UITestCase): - - def test_tdf57841(self): - - # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") - - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf57841.csv")})) - - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) - - xDialog = self.ui_test.wait_for_top_focus_window('TextImportCsvDialog') - self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild("comma"))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild("semicolon"))['Selected']) - self.assertEqual('1', get_state_as_dict(xDialog.getChild("fromrow"))['Text']) - - # Set text delimiter in case it's changed by another test - xTextDelimiter = xDialog.getChild("textdelimiter") - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"TEXT": "\""})) - - xOK = xDialog.getChild('ok') - with self.ui_test.wait_until_component_loaded(): - self.ui_test.close_dialog_through_button(xOK) - - document = self.ui_test.get_component() - - # Without the fix in place, this test would have failed with - # AssertionError: '2' != '' - for i in range(4): - self.assertEqual(str(i + 1), get_cell_by_position(document, 0, i, 0).getString()) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf60468.py b/sc/qa/uitest/calc_tests9/tdf60468.py deleted file mode 100644 index 48af292df505..000000000000 --- a/sc/qa/uitest/calc_tests9/tdf60468.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- 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 -from libreoffice.calc.document import get_cell_by_position - -class Tdf60468(UITestCase): - - def test_tdf60468(self): - - # Load file from Open dialog - self.ui_test.execute_dialog_through_command(".uno:Open") - - xOpenDialog = self.xUITest.getTopFocusWindow() - xFileName = xOpenDialog.getChild("file_name") - xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf60468.csv")})) - - xOpenBtn = xOpenDialog.getChild("open") - xOpenBtn.executeAction("CLICK", tuple()) - - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild("comma"))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild("semicolon"))['Selected']) - self.assertEqual('1', get_state_as_dict(xDialog.getChild("fromrow"))['Text']) - - # Set text delimiter in case it's changed by another test - xTextDelimiter = xDialog.getChild("textdelimiter") - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xTextDelimiter.executeAction("TYPE", mkPropertyValues({"TEXT": "\""})) - - xOK = xDialog.getChild('ok') - with self.ui_test.wait_until_component_loaded(): - self.ui_test.close_dialog_through_button(xOK) - - document = self.ui_test.get_component() - - # tdf#142040: Without the fix in place, this test would have failed with - # AssertionError: 'head1' != '' - for i in range(3): - self.assertEqual("head" + str(i + 1), get_cell_by_position(document, 0, i, 0).getString()) - - self.assertEqual("value1.1\nvalue1.2", get_cell_by_position(document, 0, 0, 1).getString()) - - # Without the fix in place, this test would have failed with - # AssertionError: 'value2.1\n\tvalue2.2\nvalue2.3' != 'value2.1\n\tvalue2.2' - self.assertEqual("value2.1\n\tvalue2.2\nvalue2.3", get_cell_by_position(document, 0, 1, 1).getString()) - self.assertEqual("value3", get_cell_by_position(document, 0, 2, 1).getString()) - - self.ui_test.close_doc() - -# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf142395.py b/sc/qa/uitest/csv_dialog/tdf142395.py new file mode 100644 index 000000000000..874313afecf9 --- /dev/null +++ b/sc/qa/uitest/csv_dialog/tdf142395.py @@ -0,0 +1,53 @@ +# -*- 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 +from libreoffice.calc.document import get_cell_by_position + +class Tdf142395(UITestCase): + + def test_tdf142395(self): + + # Load file from Open dialog + self.ui_test.execute_dialog_through_command(".uno:Open") + + xOpenDialog = self.xUITest.getTopFocusWindow() + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf142395.csv")})) + + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) + + # Remove the text delimiter + xTextDelimiter = self.ui_test.wait_until_child_is_available('textdelimiter') + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild('ok') + with self.ui_test.wait_until_component_loaded(): + self.ui_test.close_dialog_through_button(xOK) + + document = self.ui_test.get_component() + + self.assertEqual("a", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual(" b", get_cell_by_position(document, 0, 1, 0).getString()) + self.assertEqual(" c", get_cell_by_position(document, 0, 2, 0).getString()) + + # Without the fix in place, this test would have failed with + # AssertionError: ' ' != '晦餪' + self.assertEqual(" ", get_cell_by_position(document, 0, 3, 0).getString()) + + self.assertEqual("e", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual(" f", get_cell_by_position(document, 0, 1, 1).getString()) + self.assertEqual(" g", get_cell_by_position(document, 0, 2, 1).getString()) + self.assertEqual(" ", get_cell_by_position(document, 0, 3, 1).getString()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf57841.py b/sc/qa/uitest/csv_dialog/tdf57841.py new file mode 100644 index 000000000000..995fab2647de --- /dev/null +++ b/sc/qa/uitest/csv_dialog/tdf57841.py @@ -0,0 +1,51 @@ +# -*- 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 +from libreoffice.calc.document import get_cell_by_position + +class Tdf57841(UITestCase): + + def test_tdf57841(self): + + # Load file from Open dialog + self.ui_test.execute_dialog_through_command(".uno:Open") + + xOpenDialog = self.xUITest.getTopFocusWindow() + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf57841.csv")})) + + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) + + xDialog = self.ui_test.wait_for_top_focus_window('TextImportCsvDialog') + self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild("comma"))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild("semicolon"))['Selected']) + self.assertEqual('1', get_state_as_dict(xDialog.getChild("fromrow"))['Text']) + + # Set text delimiter in case it's changed by another test + xTextDelimiter = xDialog.getChild("textdelimiter") + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"TEXT": "\""})) + + xOK = xDialog.getChild('ok') + with self.ui_test.wait_until_component_loaded(): + self.ui_test.close_dialog_through_button(xOK) + + document = self.ui_test.get_component() + + # Without the fix in place, this test would have failed with + # AssertionError: '2' != '' + for i in range(4): + self.assertEqual(str(i + 1), get_cell_by_position(document, 0, i, 0).getString()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf60468.py b/sc/qa/uitest/csv_dialog/tdf60468.py new file mode 100644 index 000000000000..48af292df505 --- /dev/null +++ b/sc/qa/uitest/csv_dialog/tdf60468.py @@ -0,0 +1,58 @@ +# -*- 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 +from libreoffice.calc.document import get_cell_by_position + +class Tdf60468(UITestCase): + + def test_tdf60468(self): + + # Load file from Open dialog + self.ui_test.execute_dialog_through_command(".uno:Open") + + xOpenDialog = self.xUITest.getTopFocusWindow() + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf60468.csv")})) + + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) + + xDialog = self.xUITest.getTopFocusWindow() + self.assertEqual('true', get_state_as_dict(xDialog.getChild("tab"))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild("comma"))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild("semicolon"))['Selected']) + self.assertEqual('1', get_state_as_dict(xDialog.getChild("fromrow"))['Text']) + + # Set text delimiter in case it's changed by another test + xTextDelimiter = xDialog.getChild("textdelimiter") + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xTextDelimiter.executeAction("TYPE", mkPropertyValues({"TEXT": "\""})) + + xOK = xDialog.getChild('ok') + with self.ui_test.wait_until_component_loaded(): + self.ui_test.close_dialog_through_button(xOK) + + document = self.ui_test.get_component() + + # tdf#142040: Without the fix in place, this test would have failed with + # AssertionError: 'head1' != '' + for i in range(3): + self.assertEqual("head" + str(i + 1), get_cell_by_position(document, 0, i, 0).getString()) + + self.assertEqual("value1.1\nvalue1.2", get_cell_by_position(document, 0, 0, 1).getString()) + + # Without the fix in place, this test would have failed with + # AssertionError: 'value2.1\n\tvalue2.2\nvalue2.3' != 'value2.1\n\tvalue2.2' + self.assertEqual("value2.1\n\tvalue2.2\nvalue2.3", get_cell_by_position(document, 0, 1, 1).getString()) + self.assertEqual("value3", get_cell_by_position(document, 0, 2, 1).getString()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: -- cgit