sc/qa/uitest/calc_dialogs/openDialogs.py | 4 sc/qa/uitest/chart/chartAxes.py | 2 sc/qa/uitest/chart/chartDataLabels.py | 2 sc/qa/uitest/chart/chartGrid.py | 2 sc/qa/uitest/chart/chartGrids.py | 2 sc/qa/uitest/chart/chartLegend.py | 2 sc/qa/uitest/chart/chartTitles.py | 2 sc/qa/uitest/chart/openDialogs.py | 125 +++++++++++++++++++++++++++++ sw/qa/uitest/writer_dialogs/openDialogs.py | 4 uitest/uitest/uihelper/testDialog.py | 41 ++++++++- 10 files changed, 173 insertions(+), 13 deletions(-)
New commits: commit 22e97c90cb6334fd58bc856ab025291cb32b48d1 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Mar 6 13:06:45 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Mar 6 16:50:25 2024 +0100 related: tdf#159879: test chart dialogs Change-Id: I91d5f4572edff99deb21dd2507c3216ef0d9e4c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164465 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/calc_dialogs/openDialogs.py b/sc/qa/uitest/calc_dialogs/openDialogs.py index f559ceec6a2e..9f26dc91f50b 100644 --- a/sc/qa/uitest/calc_dialogs/openDialogs.py +++ b/sc/qa/uitest/calc_dialogs/openDialogs.py @@ -9,7 +9,7 @@ from uitest.framework import UITestCase import unittest -from uitest.uihelper.testDialog import testDialog +from uitest.uihelper.testDialog import testAppDialog dialogs = [ {"command": ".uno:OpenRemote", "closeButton": "cancel"}, @@ -177,7 +177,7 @@ def load_tests(loader, tests, pattern): # the test only checks if calc crashes by opening the dialog, see e.g. tdf#120227, tdf#125985, tdf#125982 class openDialogs(UITestCase): def check(self, dialog): - testDialog(self, "calc", dialog) + testAppDialog(self, "calc", dialog) dialogCount = 0 for dialog in dialogs: diff --git a/sc/qa/uitest/chart/openDialogs.py b/sc/qa/uitest/chart/openDialogs.py new file mode 100644 index 000000000000..923564072405 --- /dev/null +++ b/sc/qa/uitest/chart/openDialogs.py @@ -0,0 +1,125 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# + +from uitest.framework import UITestCase +import unittest +from uitest.uihelper.testDialog import testChartDialog + +dialogs = [ + {"command": "AllTitles", "closeButton": "cancel"}, + # {"command": "DataRanges", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/tdf99069.py + # {"command": "DiagramArea", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartArea.py + # {"command": "DiagramAxisA", "closeButton": "cancel"}, + {"command": "DiagramAxisAll", "closeButton": "cancel"}, + # {"command": "DiagramAxisB", "closeButton": "cancel"}, + #{"command": "DiagramAxisX", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartXAxis.py + #{"command": "DiagramAxisY", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartYAxis.py + # {"command": "DiagramAxisZ", "closeButton": "cancel"}, + {"command": "DiagramData", "closeButton": "close", "skipTestOK": True}, + {"command": "DiagramFloor", "closeButton": "cancel"}, + # {"command": "DiagramGridAll", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrid.py + # {"command": "DiagramGridXHelp", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrid.py + # {"command": "DiagramGridXMain", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrid.py + # {"command": "DiagramGridYHelp", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrid.py + # {"command": "DiagramGridYMain", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrid.py + # {"command": "DiagramGridZHelp", "closeButton": "cancel"}, + # {"command": "DiagramGridZMain", "closeButton": "cancel"}, + {"command": "DiagramType", "closeButton": "cancel"}, + # {"command": "DiagramWall", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartWall.py + # {"command": "FormatAxis", "closeButton": "cancel"}, + {"command": "FormatChartArea", "closeButton": "cancel"}, + # {"command": "FormatDataLabel", "closeButton": "cancel"}, + # {"command": "FormatDataLabels", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartDataLabels.py + {"command": "FormatDataPoint", "closeButton": "cancel"}, + # {"command": "FormatDataSeries", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/formatDataSeries.py + {"command": "FormatFloor", "closeButton": "cancel"}, + {"command": "FormatLegend", "closeButton": "cancel"}, + # {"command": "FormatMajorGrid", "closeButton": "cancel"}, + # {"command": "FormatMeanValue", "closeButton": "cancel"}, + # {"command": "FormatMinorGrid", "closeButton": "cancel"}, + {"command": "FormatSelection", "closeButton": "cancel"}, + # {"command": "FormatStockGain", "closeButton": "cancel"}, + # {"command": "FormatStockLoss", "closeButton": "cancel"}, + # {"command": "FormatTitle", "closeButton": "cancel"}, + # {"command": "FormatTrendline", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/tdf93506_trendline.py + # {"command": "FormatTrendlineEquation", "closeButton": "cancel"}, + {"command": "FormatWall", "closeButton": "cancel"}, + # {"command": "FormatXErrorBars", "closeButton": "cancel"}, + # {"command": "FormatYErrorBars", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/tdf96432.py + # {"command": "InsertMenuAxes", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartAxes.py + # {"command": "InsertMenuDataLabels", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartDataLabels.py + {"command": "InsertMenuDataTable", "closeButton": "cancel"}, + # {"command": "InsertMenuGrids", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartGrids.py + # {"command": "InsertMenuLegend", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartLegend.py + # {"command": "InsertMenuTitles", "closeButton": "cancel"}, + # Tested in sc/qa/uitest/chart/chartTitles.py + # {"command": "InsertMenuTrendlines", "closeButton": "cancel"}, + {"command": "InsertMenuXErrorBars", "closeButton": "cancel"}, + {"command": "InsertMenuYErrorBars", "closeButton": "cancel"}, + # {"command": "InsertMinorGrid", "closeButton": "cancel"}, + # {"command": "InsertR2Value", "closeButton": "cancel"}, + {"command": "InsertRemoveAxes", "closeButton": "cancel"}, + {"command": "InsertTitles", "closeButton": "cancel"}, + # {"command": "InsertTrendline", "closeButton": "cancel"}, + {"command": "InsertXErrorBars", "closeButton": "cancel"}, + {"command": "InsertYErrorBars", "closeButton": "cancel"}, + {"command": "Legend", "closeButton": "cancel"}, + # {"command": "MainTitle", "closeButton": "cancel"}, + # {"command": "ObjectTitleDescription", "closeButton": "cancel"}, + # {"command": "RenameObject", "closeButton": "cancel"}, + # {"command": "SecondaryXTitle", "closeButton": "cancel"}, + # {"command": "SecondaryYTitle", "closeButton": "cancel"}, + # {"command": "SubTitle", "closeButton": "cancel"}, + {"command": "View3D", "closeButton": "cancel"}, + # {"command": "XTitle", "closeButton": "cancel"}, + # {"command": "YTitle", "closeButton": "cancel"}, + # {"command": "ZTitle", "closeButton": "cancel"}, +] + + +def load_tests(loader, tests, pattern): + return unittest.TestSuite(openDialogs(dialog) + for dialog in dialogs) + +# Test to open all listed dialogs one by one, close it with the given close button +# and if there is an "OK" button open the dialog again and close it by using the OK button +# the test only checks if calc crashes by opening the dialog, see e.g. tdf#159879 +class openDialogs(UITestCase): + def check(self, dialog): + testChartDialog(self, dialog) + +dialogCount = 0 +for dialog in dialogs: + dialogCount = dialogCount + 1 + + + def ch(dialog): + return lambda self: self.check(dialog) + + + setattr(openDialogs, "test_%02d_%s" % (dialogCount, dialog["command"]), ch(dialog)) +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_dialogs/openDialogs.py b/sw/qa/uitest/writer_dialogs/openDialogs.py index 1e58c5acccd9..b3b2ffcd7bad 100644 --- a/sw/qa/uitest/writer_dialogs/openDialogs.py +++ b/sw/qa/uitest/writer_dialogs/openDialogs.py @@ -9,7 +9,7 @@ from uitest.framework import UITestCase import unittest -from uitest.uihelper.testDialog import testDialog +from uitest.uihelper.testDialog import testAppDialog dialogs = [ {"command": ".uno:OpenRemote", "closeButton": "cancel"}, @@ -131,7 +131,7 @@ def load_tests(loader, tests, pattern): # the test only checks if writer crashes by opening the dialog class openDialogs(UITestCase): def check(self, dialog): - testDialog(self, "writer", dialog) + testAppDialog(self, "writer", dialog) dialogCount = 0 for dialog in dialogs: diff --git a/uitest/uitest/uihelper/testDialog.py b/uitest/uitest/uihelper/testDialog.py index 488b202f60ae..d5691522f3c0 100644 --- a/uitest/uitest/uihelper/testDialog.py +++ b/uitest/uitest/uihelper/testDialog.py @@ -6,14 +6,16 @@ # from uitest.uihelper.common import get_state_as_dict - +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues # opens the dialogs, closes it with the given close button # and if there is an "OK" button open the dialog again and close it by using the OK button # the test only checks if LibreOffice crashes by opening the dialog -def testDialog(UITestCase, app, dialog): +def testAppDialog(UITestCase, app, dialog): with UITestCase.ui_test.create_doc_in_start_center(app): - with UITestCase.ui_test.execute_dialog_through_command(dialog['command'], close_button=dialog['closeButton']) as xDialog: + with UITestCase.ui_test.execute_dialog_through_command( + dialog['command'], close_button=dialog['closeButton']) as xDialog: if 'skipTestOK' in dialog and dialog['skipTestOK'] == True: xOKBtn = None else: @@ -29,4 +31,37 @@ def testDialog(UITestCase, app, dialog): with UITestCase.ui_test.execute_dialog_through_command(dialog['command']): pass +# opens the dialogs, closes it with the given close button +# and if there is an "OK" button open the dialog again and close it by using the OK button +# the test only checks if LibreOffice crashes by opening the dialog +def testChartDialog(UITestCase, dialog): + with UITestCase.ui_test.load_file(get_url_for_data_file("chart.ods")): + xCalcDoc = UITestCase.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + xGridWin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) + xGridWin.executeAction("ACTIVATE", tuple()) + xChartMainTop = UITestCase.xUITest.getTopFocusWindow() + xChartMain = xChartMainTop.getChild("chart_window") + xObj = xChartMain.getChild("CID/D=0") + with UITestCase.ui_test.execute_dialog_through_action( + xObj, "COMMAND", + mkPropertyValues({"COMMAND": dialog['command']}), + close_button=dialog['closeButton']) as xDialog: + if 'skipTestOK' in dialog and dialog['skipTestOK'] == True: + xOKBtn = None + else: + try: + xOKBtn = xDialog.getChild("ok") + if (get_state_as_dict(xOKBtn)["Enabled"] != "true"): + xOKBtn = None + except: + xOKBtn = None + + if (xOKBtn != None): + print("check also OK button") + with UITestCase.ui_test.execute_dialog_through_action( + xObj, "COMMAND", + mkPropertyValues({"COMMAND": dialog['command']})): + pass + # vim: set shiftwidth=4 softtabstop=4 expandtab: commit 97497ff3b2b578f987af087b60df143ed0a4fb87 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Wed Mar 6 10:54:09 2024 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Mar 6 16:50:19 2024 +0100 uitest: rename testfile To be used in a follow-up commit Change-Id: Ie6c74ebb0f91ec24e6ed3ec973bc47685cd9e91f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164452 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/chart/chartAxes.py b/sc/qa/uitest/chart/chartAxes.py index 4a5cbab2e5ef..13a556e9b0f6 100644 --- a/sc/qa/uitest/chart/chartAxes.py +++ b/sc/qa/uitest/chart/chartAxes.py @@ -16,7 +16,7 @@ from uitest.uihelper.common import select_pos # Chart Enable Axes dialog class chartAxes(UITestCase): def test_chart_enable_grids_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")): + with self.ui_test.load_file(get_url_for_data_file("chart.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/chart/chartDataLabels.py b/sc/qa/uitest/chart/chartDataLabels.py index b20180353472..e619f0e6625b 100644 --- a/sc/qa/uitest/chart/chartDataLabels.py +++ b/sc/qa/uitest/chart/chartDataLabels.py @@ -19,7 +19,7 @@ from com.sun.star.lang import Locale # Chart Display Data Labels dialog class chartDataLabels(UITestCase): def test_chart_data_labels_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("chart.ods")) as calc_doc: xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/chart/chartGrid.py b/sc/qa/uitest/chart/chartGrid.py index bd017248adeb..fc1b705e6cd0 100644 --- a/sc/qa/uitest/chart/chartGrid.py +++ b/sc/qa/uitest/chart/chartGrid.py @@ -16,7 +16,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues # Bug 98390 - Crash when modifying minor grid class chartGrid(UITestCase): def test_tdf98390_chart_grid_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")): + with self.ui_test.load_file(get_url_for_data_file("chart.ods")): with change_measurement_unit(self, "Centimeter"): xCalcDoc = self.xUITest.getTopFocusWindow() diff --git a/sc/qa/uitest/chart/chartGrids.py b/sc/qa/uitest/chart/chartGrids.py index 781486b15db4..327da2933651 100644 --- a/sc/qa/uitest/chart/chartGrids.py +++ b/sc/qa/uitest/chart/chartGrids.py @@ -15,7 +15,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues # Chart Enable Grids dialog class chartGrids(UITestCase): def test_chart_enable_grids_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")): + with self.ui_test.load_file(get_url_for_data_file("chart.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/chart/chartLegend.py b/sc/qa/uitest/chart/chartLegend.py index a1cf40f44e2f..cf13dc97f5ce 100644 --- a/sc/qa/uitest/chart/chartLegend.py +++ b/sc/qa/uitest/chart/chartLegend.py @@ -16,7 +16,7 @@ from libreoffice.uno.propertyvalue import mkPropertyValues # Chart Display Legend dialog class chartLegend(UITestCase): def test_chart_display_legend_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")): + with self.ui_test.load_file(get_url_for_data_file("chart.ods")): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/chart/chartTitles.py b/sc/qa/uitest/chart/chartTitles.py index 793b634922a6..ff68f39ed930 100644 --- a/sc/qa/uitest/chart/chartTitles.py +++ b/sc/qa/uitest/chart/chartTitles.py @@ -18,7 +18,7 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class chartTitles(UITestCase): def test_chart_display_titles_dialog(self): - with self.ui_test.load_file(get_url_for_data_file("tdf98390.ods")) as calc_doc: + with self.ui_test.load_file(get_url_for_data_file("chart.ods")) as calc_doc: xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") diff --git a/sc/qa/uitest/data/tdf98390.ods b/sc/qa/uitest/data/chart.ods similarity index 100% rename from sc/qa/uitest/data/tdf98390.ods rename to sc/qa/uitest/data/chart.ods