sc/qa/uitest/autofilter/autofilter.py | 47 -- sc/qa/uitest/calc_tests/fillRandomNumber.py | 44 +- sc/qa/uitest/calc_tests/printRange.py | 113 ++--- sc/qa/uitest/calc_tests2/consolidate.py | 91 ++-- sc/qa/uitest/calc_tests2/standardFilter.py | 450 +++++++++-------------- sc/qa/uitest/calc_tests2/tdf104117.py | 31 - sc/qa/uitest/calc_tests3/tdf77509.py | 38 - sc/qa/uitest/calc_tests3/tdf80693.py | 37 - sc/qa/uitest/calc_tests4/tdf138089.py | 9 sc/qa/uitest/calc_tests4/tdf141547.py | 15 sc/qa/uitest/calc_tests4/tdf89958.py | 17 sc/qa/uitest/calc_tests4/trackedChanges.py | 322 +++++++--------- sc/qa/uitest/calc_tests6/multipleOperations.py | 30 - sc/qa/uitest/calc_tests9/forms.py | 6 sc/qa/uitest/conditional_format/tdf105351.py | 54 +- sc/qa/uitest/conditional_format/tdf105411.py | 22 - sc/qa/uitest/conditional_format/tdf105466.py | 14 sc/qa/uitest/function_wizard/function_wizard.py | 9 sc/qa/uitest/function_wizard/tdf123479.py | 19 sc/qa/uitest/function_wizard/tdf132173.py | 11 sc/qa/uitest/goalSeek/goalSeek.py | 19 sc/qa/uitest/goalSeek/tdf37341.py | 19 sc/qa/uitest/goalSeek/tdf43693.py | 19 sc/qa/uitest/manual_tests/calc.py | 44 -- sc/qa/uitest/range_name/create_range_name.py | 22 - sc/qa/uitest/range_name/tdf119954.py | 43 -- sc/qa/uitest/range_name/tdf138822.py | 23 - sc/qa/uitest/range_name/tdf86214.py | 52 +- sc/qa/uitest/search_replace/replace.py | 51 +- sc/qa/uitest/search_replace/tdf132097.py | 27 - sc/qa/uitest/search_replace/tdf132783.py | 13 sc/qa/uitest/search_replace/tdf143759.py | 49 +- sc/qa/uitest/search_replace/tdf35020.py | 29 - sc/qa/uitest/search_replace/tdf39917.py | 23 - sc/qa/uitest/search_replace/tdf39959.py | 27 - sc/qa/uitest/search_replace/tdf44398.py | 56 +- sc/qa/uitest/search_replace/tdf44861.py | 27 - sc/qa/uitest/search_replace/tdf57523.py | 37 - sc/qa/uitest/solver/solver.py | 43 +- sc/qa/uitest/statistics/anova.py | 45 +- sc/qa/uitest/statistics/chiSquare.py | 34 - sc/qa/uitest/statistics/correlation.py | 67 +-- sc/qa/uitest/statistics/covariance.py | 65 +-- sc/qa/uitest/statistics/descriptiveStatistics.py | 35 - sc/qa/uitest/statistics/exponentialSmoothing.py | 74 +-- sc/qa/uitest/statistics/fTest.py | 42 -- sc/qa/uitest/statistics/movingAverage.py | 78 +-- sc/qa/uitest/statistics/regression.py | 114 ++--- sc/qa/uitest/statistics/sampling.py | 39 - sc/qa/uitest/statistics/tTest.py | 42 -- sc/qa/uitest/statistics/tdf76731.py | 33 - sc/qa/uitest/statistics/zTest.py | 42 -- 52 files changed, 1198 insertions(+), 1514 deletions(-)
New commits: commit 47847b879bf6b5bb6e0f6117e0f9683b3a932a08 Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Fri Sep 10 17:45:55 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Sep 13 10:36:51 2021 +0200 uitest: guard execute_modeless_dialog_through_command in sc Change-Id: Ifd03ae26659ff56d36bfe8d4938d690ada761d5f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121912 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py index 4c1b8194fb06..3765640ff7e9 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -443,14 +443,11 @@ class AutofilterTest(UITestCase): xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xval1 = xDialog.getChild("val1") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xval1 = xDialog.getChild("val1") - select_by_text(xval1, "0.365") + select_by_text(xval1, "0.365") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertFalse(is_row_hidden(doc, 0)) self.assertFalse(is_row_hidden(doc, 1)) @@ -467,19 +464,16 @@ class AutofilterTest(UITestCase): #Test '<' condition xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") - select_by_text(xfield1, "Values") - select_by_text(xcond1, "<") - select_by_text(xval1, "0.365") + select_by_text(xfield1, "Values") + select_by_text(xcond1, "<") + select_by_text(xval1, "0.365") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertFalse(is_row_hidden(doc, 0)) self.assertTrue(is_row_hidden(doc, 1)) @@ -492,18 +486,15 @@ class AutofilterTest(UITestCase): #Test '>=' condition xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "Values") - select_by_text(xcond1, ">=") - select_by_text(xval1, "0.046") - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "Values") + select_by_text(xcond1, ">=") + select_by_text(xval1, "0.046") + self.assertFalse(is_row_hidden(doc, 0)) self.assertFalse(is_row_hidden(doc, 1)) diff --git a/sc/qa/uitest/calc_tests/fillRandomNumber.py b/sc/qa/uitest/calc_tests/fillRandomNumber.py index 34927bf98099..ac325e5303fc 100644 --- a/sc/qa/uitest/calc_tests/fillRandomNumber.py +++ b/sc/qa/uitest/calc_tests/fillRandomNumber.py @@ -16,29 +16,26 @@ class fillRandomNumber(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcellrangeedit = xDialog.getChild("cell-range-edit") - xdistributioncombo = xDialog.getChild("distribution-combo") - xparameter1spin = xDialog.getChild("parameter1-spin") - xparameter2spin = xDialog.getChild("parameter2-spin") - xenableseedcheck = xDialog.getChild("enable-seed-check") - xseedspin = xDialog.getChild("seed-spin") - xenableroundingcheck = xDialog.getChild("enable-rounding-check") - xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") - xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) - select_by_text(xdistributioncombo, "Uniform Integer") + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform Integer") - xparameter1spin.executeAction("UP", tuple()) - xparameter2spin.executeAction("UP", tuple()) - xenableseedcheck.executeAction("CLICK", tuple()) - xseedspin.executeAction("UP", tuple()) - xenableroundingcheck.executeAction("CLICK", tuple()) - xdecimalplacesspin.executeAction("UP", tuple()) + xparameter1spin.executeAction("UP", tuple()) + xparameter2spin.executeAction("UP", tuple()) + xenableseedcheck.executeAction("CLICK", tuple()) + xseedspin.executeAction("UP", tuple()) + xenableroundingcheck.executeAction("CLICK", tuple()) + xdecimalplacesspin.executeAction("UP", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #Verify self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) @@ -47,10 +44,9 @@ class fillRandomNumber(UITestCase): self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) #close dialog without doing anything - self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xCloseBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:RandomNumberGeneratorDialog", close_button="close"): + pass + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/printRange.py b/sc/qa/uitest/calc_tests/printRange.py index 1082e10de3fc..6334153fdd9e 100644 --- a/sc/qa/uitest/calc_tests/printRange.py +++ b/sc/qa/uitest/calc_tests/printRange.py @@ -18,50 +18,41 @@ class printRange(UITestCase): #Set print range self.xUITest.executeCommand(".uno:DefinePrintArea") # Print Range dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") - xDialog = self.xUITest.getTopFocusWindow() - xlbprintarea = xDialog.getChild("lbprintarea") - xedprintarea = xDialog.getChild("edprintarea") - #verify range - self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") - self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") - #set Row - xedrepeatrow = xDialog.getChild("edrepeatrow") - xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) - #set Column - xedrepeatcol = xDialog.getChild("edrepeatcol") - xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:EditPrintArea") as xDialog: + xlbprintarea = xDialog.getChild("lbprintarea") + xedprintarea = xDialog.getChild("edprintarea") + #verify range + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + #set Row + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) + #set Column + xedrepeatcol = xDialog.getChild("edrepeatcol") + xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) + # Click Ok #Verify Print Range dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") - xDialog = self.xUITest.getTopFocusWindow() - xedprintarea = xDialog.getChild("edprintarea") - xedrepeatrow = xDialog.getChild("edrepeatrow") - xedrepeatcol = xDialog.getChild("edrepeatcol") - self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") - self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") - self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") - xCancel = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancel) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:EditPrintArea", close_button="cancel") as xDialog: + xedprintarea = xDialog.getChild("edprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") #delete print ranges self.xUITest.executeCommand(".uno:DeletePrintArea") #Verify Print Range dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") - xDialog = self.xUITest.getTopFocusWindow() - xedprintarea = xDialog.getChild("edprintarea") - xlbprintarea = xDialog.getChild("lbprintarea") - xedrepeatrow = xDialog.getChild("edrepeatrow") - xedrepeatcol = xDialog.getChild("edrepeatcol") - self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "") - self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- entire sheet -") - self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") - self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:EditPrintArea") as xDialog: + xedprintarea = xDialog.getChild("edprintarea") + xlbprintarea = xDialog.getChild("lbprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "") + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- entire sheet -") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") def test_tdf33341_copy_sheet_with_print_range(self): with self.ui_test.create_doc_in_start_center("calc"): @@ -72,37 +63,31 @@ class printRange(UITestCase): #Set print range self.xUITest.executeCommand(".uno:DefinePrintArea") # Print Range dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") - xDialog = self.xUITest.getTopFocusWindow() - xlbprintarea = xDialog.getChild("lbprintarea") - xedprintarea = xDialog.getChild("edprintarea") - #verify range - self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") - self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") - #set Row - xedrepeatrow = xDialog.getChild("edrepeatrow") - xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) - #set Column - xedrepeatcol = xDialog.getChild("edrepeatcol") - xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) - # Click Ok - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:EditPrintArea") as xDialog: + xlbprintarea = xDialog.getChild("lbprintarea") + xedprintarea = xDialog.getChild("edprintarea") + #verify range + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + #set Row + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) + #set Column + xedrepeatcol = xDialog.getChild("edrepeatcol") + xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) + # Click Ok #Copy sheet with self.ui_test.execute_dialog_through_command(".uno:Move"): pass #Verify Print Range dialog on new sheet - self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") - xDialog = self.xUITest.getTopFocusWindow() - xedprintarea = xDialog.getChild("edprintarea") - xedrepeatrow = xDialog.getChild("edrepeatrow") - xedrepeatcol = xDialog.getChild("edrepeatcol") - self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") - self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") - self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") - xOK = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOK) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:EditPrintArea") as xDialog: + xedprintarea = xDialog.getChild("edprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/consolidate.py b/sc/qa/uitest/calc_tests2/consolidate.py index 83ed3587dad1..91bc581250ae 100644 --- a/sc/qa/uitest/calc_tests2/consolidate.py +++ b/sc/qa/uitest/calc_tests2/consolidate.py @@ -16,32 +16,30 @@ class consolidate(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xfunc = xDialog.getChild("func") - xlbdataarea = xDialog.getChild("lbdataarea") - xadd = xDialog.getChild("add") - xbyrow = xDialog.getChild("byrow") - xbycol = xDialog.getChild("bycol") - xeddestarea = xDialog.getChild("eddestarea") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") - select_by_text(xfunc, "Sum") + select_by_text(xfunc, "Sum") + + select_by_text(xlbdataarea, "range1") + xadd.executeAction("CLICK", tuple()) + select_by_text(xlbdataarea, "range2") + xadd.executeAction("CLICK", tuple()) + propsC = {"TEXT": "range3"} + actionPropsC = mkPropertyValues(propsC) + xlbdataarea.executeAction("SELECT", actionPropsC) + xadd.executeAction("CLICK", tuple()) + xbyrow.executeAction("CLICK", tuple()) + xbycol.executeAction("CLICK", tuple()) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) - select_by_text(xlbdataarea, "range1") - xadd.executeAction("CLICK", tuple()) - select_by_text(xlbdataarea, "range2") - xadd.executeAction("CLICK", tuple()) - propsC = {"TEXT": "range3"} - actionPropsC = mkPropertyValues(propsC) - xlbdataarea.executeAction("SELECT", actionPropsC) - xadd.executeAction("CLICK", tuple()) - xbyrow.executeAction("CLICK", tuple()) - xbycol.executeAction("CLICK", tuple()) - xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 300) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 303) @@ -63,27 +61,24 @@ class consolidate(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 4).getValue(), 315) self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 318) #verify dialog - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xfunc = xDialog.getChild("func") - xlbdataarea = xDialog.getChild("lbdataarea") - xdelete = xDialog.getChild("delete") - xbyrow = xDialog.getChild("byrow") - xbycol = xDialog.getChild("bycol") - xeddestarea = xDialog.getChild("eddestarea") - xconsareas = xDialog.getChild("consareas") - self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") - self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") - self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") - self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") - self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") - #delete first range - xFirstEntry = xconsareas.getChild("0") - xFirstEntry.executeAction("SELECT", tuple()) - xdelete.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xdelete = xDialog.getChild("delete") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + xconsareas = xDialog.getChild("consareas") + self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") + self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") + self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") + self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") + #delete first range + xFirstEntry = xconsareas.getChild("0") + xFirstEntry.executeAction("SELECT", tuple()) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 200) self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 202) @@ -106,9 +101,7 @@ class consolidate(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 212) # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate", close_button="cancel"): + pass # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/standardFilter.py b/sc/qa/uitest/calc_tests2/standardFilter.py index 008edc521e9b..5f6c456977f3 100644 --- a/sc/qa/uitest/calc_tests2/standardFilter.py +++ b/sc/qa/uitest/calc_tests2/standardFilter.py @@ -20,21 +20,18 @@ class standardFilter(UITestCase): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xconnect2 = xDialog.getChild("connect2") - xfield2 = xDialog.getChild("field2") - xval2 = xDialog.getChild("val2") - - select_by_text(xfield1, "a") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - select_by_text(xconnect2, "OR") - select_by_text(xfield2, "b") - xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) #3x down - should be on row 9 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) @@ -46,21 +43,18 @@ class standardFilter(UITestCase): gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xconnect2 = xDialog.getChild("connect2") - xfield2 = xDialog.getChild("field2") - xval2 = xDialog.getChild("val2") - - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "a") - self.assertEqual(get_state_as_dict(xfield2)["SelectEntryText"], "b") - self.assertEqual(get_state_as_dict(xconnect2)["SelectEntryText"], "OR") - self.assertEqual(get_state_as_dict(xval1)["Text"], "1") - self.assertEqual(get_state_as_dict(xval2)["Text"], "3") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "a") + self.assertEqual(get_state_as_dict(xfield2)["SelectEntryText"], "b") + self.assertEqual(get_state_as_dict(xconnect2)["SelectEntryText"], "OR") + self.assertEqual(get_state_as_dict(xval1)["Text"], "1") + self.assertEqual(get_state_as_dict(xval2)["Text"], "3") def test_standard_filter_copy_result(self): with self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) as calc_doc: @@ -68,24 +62,21 @@ class standardFilter(UITestCase): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xconnect2 = xDialog.getChild("connect2") - xfield2 = xDialog.getChild("field2") - xval2 = xDialog.getChild("val2") - xcopyresult = xDialog.getChild("copyresult") - xedcopyarea = xDialog.getChild("edcopyarea") - select_by_text(xfield1, "a") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - select_by_text(xconnect2, "OR") - select_by_text(xfield2, "b") - xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) - xcopyresult.executeAction("CLICK", tuple()) - xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) #verify self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 0).getString(), "a") self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 0).getString(), "b") @@ -103,24 +94,21 @@ class standardFilter(UITestCase): gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xconnect2 = xDialog.getChild("connect2") - xfield2 = xDialog.getChild("field2") - xval2 = xDialog.getChild("val2") - xcopyresult = xDialog.getChild("copyresult") - xedcopyarea = xDialog.getChild("edcopyarea") - select_by_text(xfield1, "a") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - select_by_text(xconnect2, "OR") - select_by_text(xfield2, "b") - xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) - xcopyresult.executeAction("CLICK", tuple()) - xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet2.$F$1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet2.$F$1"})) #verify self.assertEqual(get_cell_by_position(calc_doc, 1, 5, 0).getString(), "a") self.assertEqual(get_cell_by_position(calc_doc, 1, 6, 0).getString(), "b") @@ -146,17 +134,14 @@ class standardFilter(UITestCase): enter_text_to_cell(gridwin, "B3", "5") enter_text_to_cell(gridwin, "B4", "6") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcase = xDialog.getChild("case") - - select_by_text(xfield1, "first") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a1"})) - xcase.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a1"})) + xcase.executeAction("CLICK", tuple()) #2x down - should be on row 5 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) @@ -166,17 +151,14 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcase = xDialog.getChild("case") - - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") - self.assertEqual(get_state_as_dict(xval1)["Text"], "a1") - self.assertEqual(get_state_as_dict(xcase)["Selected"], "true") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a1") + self.assertEqual(get_state_as_dict(xcase)["Selected"], "true") def test_standard_filter_regular_expression(self): with self.ui_test.create_doc_in_start_center("calc"): @@ -196,17 +178,14 @@ class standardFilter(UITestCase): enter_text_to_cell(gridwin, "B5", "4") enter_text_to_cell(gridwin, "B6", "5") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xregexp = xDialog.getChild("regexp") - - select_by_text(xfield1, "first") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) - xregexp.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) #3x down - should be on row 7 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) @@ -218,17 +197,14 @@ class standardFilter(UITestCase): gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xregexp = xDialog.getChild("regexp") - - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") - self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") - self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") def test_standard_filter_condition_contains(self): with self.ui_test.create_doc_in_start_center("calc"): @@ -248,17 +224,14 @@ class standardFilter(UITestCase): enter_text_to_cell(gridwin, "B5", "4") enter_text_to_cell(gridwin, "B6", "5") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xregexp = xDialog.getChild("regexp") - - select_by_text(xfield1, "first") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) - xregexp.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) #3x down - should be on row 7 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) @@ -270,17 +243,14 @@ class standardFilter(UITestCase): gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xregexp = xDialog.getChild("regexp") - - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") - self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") - self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") #from testcasespecification OOo def test_standard_filter_condition_contains2(self): @@ -312,17 +282,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Contains"/Enter value "cio"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Contains") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Contains") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) #Verify that row 1,3, 4 are visible (2 and 5 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -335,16 +302,13 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Contains") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Contains") def test_standard_filter_condition_does_not_contains(self): with self.ui_test.create_doc_in_start_center("calc"): @@ -375,17 +339,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Does not contain") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not contain") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) #Verify that row 1,2, 5 are visible (3 and 4 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -398,16 +359,13 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not contain") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not contain") def test_standard_filter_condition_Begins_with(self): @@ -439,17 +397,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Begins with") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Begins with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) #Verify that row 1,3, 4 are visible (2 and 5 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -462,16 +417,13 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "so") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Begins with") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Begins with") def test_standard_filter_condition_Does_not_begin_with(self): @@ -503,17 +455,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Does not begin with") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not begin with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) #Verify that row 1,2, 5 are visible (3 and 4 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -526,16 +475,13 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "so") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not begin with") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not begin with") def test_standard_filter_condition_Ends_with(self): @@ -567,17 +513,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Ends with") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Ends with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) #Verify that row 1,2, 5 are visible (3 and 4 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -590,16 +533,13 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "s") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Ends with") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Ends with") def test_standard_filter_condition_Does_not_end_with(self): @@ -631,17 +571,14 @@ class standardFilter(UITestCase): gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) #Choose DATA-FILTER-STANDARDFILTER #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, "Does not end with") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not end with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) #Verify that row 1,3, 4 are visible (2 and 5 are hidden) gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) @@ -654,15 +591,12 @@ class standardFilter(UITestCase): #reopen filter and verify gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") - self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") - self.assertEqual(get_state_as_dict(xval1)["Text"], "s") - self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf104117.py b/sc/qa/uitest/calc_tests2/tdf104117.py index c58d68bd7432..b1ef140b73a7 100644 --- a/sc/qa/uitest/calc_tests2/tdf104117.py +++ b/sc/qa/uitest/calc_tests2/tdf104117.py @@ -16,25 +16,22 @@ class tdf104117(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcellrangeedit = xDialog.getChild("cell-range-edit") - xdistributioncombo = xDialog.getChild("distribution-combo") - xparameter1spin = xDialog.getChild("parameter1-spin") - xparameter2spin = xDialog.getChild("parameter2-spin") - xenableseedcheck = xDialog.getChild("enable-seed-check") - xseedspin = xDialog.getChild("seed-spin") - xenableroundingcheck = xDialog.getChild("enable-rounding-check") - xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") - xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) - select_by_text(xdistributioncombo, "Uniform Integer") - xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"1000000000000000000000000000000000000000000000"})) + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform Integer") + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"1000000000000000000000000000000000000000000000"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #Verify self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) diff --git a/sc/qa/uitest/calc_tests3/tdf77509.py b/sc/qa/uitest/calc_tests3/tdf77509.py index 40e741a7dd42..a63d9c98183a 100644 --- a/sc/qa/uitest/calc_tests3/tdf77509.py +++ b/sc/qa/uitest/calc_tests3/tdf77509.py @@ -20,30 +20,28 @@ class tdf77509(UITestCase): #2. Select any empty cell, eg. cell D1 gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) #3. Tab: Data > Consolidate - self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") - xDialog = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataConsolidate") as xDialog: - xfunc = xDialog.getChild("func") - xeddataarea = xDialog.getChild("eddataarea") - xadd = xDialog.getChild("add") - xbyrow = xDialog.getChild("byrow") - xbycol = xDialog.getChild("bycol") - xeddestarea = xDialog.getChild("eddestarea") + xfunc = xDialog.getChild("func") + xeddataarea = xDialog.getChild("eddataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") - select_by_text(xfunc, "Sum") - #4. Source data ranges: $Sheet1.$A$1:$B$7 - #5. Click 'Add' so that ranges appear in "Consolidation ranges" - xeddataarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$7"})) - xadd.executeAction("CLICK", tuple()) + select_by_text(xfunc, "Sum") + #4. Source data ranges: $Sheet1.$A$1:$B$7 + #5. Click 'Add' so that ranges appear in "Consolidation ranges" + xeddataarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$7"})) + xadd.executeAction("CLICK", tuple()) - xConsAreas = xDialog.getChild("consareas") - self.assertEqual(1, len(xConsAreas.getChildren())) - self.assertEqual("$Sheet1.$A$1:$B$7", get_state_as_dict(xConsAreas.getChild("0"))['Text']) + xConsAreas = xDialog.getChild("consareas") + self.assertEqual(1, len(xConsAreas.getChildren())) + self.assertEqual("$Sheet1.$A$1:$B$7", get_state_as_dict(xConsAreas.getChild("0"))['Text']) + + #6. Click 'Options' > check 'Row labels' > click OK + xbyrow.executeAction("CLICK", tuple()) - #6. Click 'Options' > check 'Row labels' > click OK - xbyrow.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #verify self.assertEqual("A 1", get_cell_by_position(calc_doc, 0, 3, 0).getString()) self.assertEqual("AB 1", get_cell_by_position(calc_doc, 0, 3, 1).getString()) diff --git a/sc/qa/uitest/calc_tests3/tdf80693.py b/sc/qa/uitest/calc_tests3/tdf80693.py index 6345c53f91a8..5e97df56d7a1 100644 --- a/sc/qa/uitest/calc_tests3/tdf80693.py +++ b/sc/qa/uitest/calc_tests3/tdf80693.py @@ -16,29 +16,26 @@ class tdf80693(UITestCase): xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcellrangeedit = xDialog.getChild("cell-range-edit") - xdistributioncombo = xDialog.getChild("distribution-combo") - xparameter1spin = xDialog.getChild("parameter1-spin") - xparameter2spin = xDialog.getChild("parameter2-spin") - xenableseedcheck = xDialog.getChild("enable-seed-check") - xseedspin = xDialog.getChild("seed-spin") - xenableroundingcheck = xDialog.getChild("enable-rounding-check") - xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") - xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) - select_by_text(xdistributioncombo, "Uniform") + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform") - xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xparameter1spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) #Verify self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 2) self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 2) diff --git a/sc/qa/uitest/calc_tests4/tdf138089.py b/sc/qa/uitest/calc_tests4/tdf138089.py index c59838df86db..a59b7ce29798 100644 --- a/sc/qa/uitest/calc_tests4/tdf138089.py +++ b/sc/qa/uitest/calc_tests4/tdf138089.py @@ -27,13 +27,10 @@ class tdf138089(UITestCase): self.assertFalse(is_row_hidden(calc_doc, 6)) # Without the fix in place, this test would have crashed here - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual("2017-12-01", get_state_as_dict(xDialog.getChild("val1"))['Text']) - self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("2017-12-01", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) self.assertFalse(is_row_hidden(calc_doc, 0)) self.assertTrue(is_row_hidden(calc_doc, 1)) diff --git a/sc/qa/uitest/calc_tests4/tdf141547.py b/sc/qa/uitest/calc_tests4/tdf141547.py index cfe8e1d33cb0..e0203847e30c 100644 --- a/sc/qa/uitest/calc_tests4/tdf141547.py +++ b/sc/qa/uitest/calc_tests4/tdf141547.py @@ -23,15 +23,12 @@ class tdf141547(UITestCase): self.assertTrue(is_row_hidden(calc_doc, i)) # Without the fix in place, this test would have crashed here - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - self.assertEqual("0", get_state_as_dict(xDialog.getChild("val1"))['Text']) - self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) - self.assertEqual("Empty", get_state_as_dict(xDialog.getChild("val2"))['Text']) - self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field2"))["DisplayText"]) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("0", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + self.assertEqual("Empty", get_state_as_dict(xDialog.getChild("val2"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field2"))["DisplayText"]) + self.assertFalse(is_row_hidden(calc_doc, 0)) for i in range(1, 7): diff --git a/sc/qa/uitest/calc_tests4/tdf89958.py b/sc/qa/uitest/calc_tests4/tdf89958.py index 1f97bc57ceca..1e36bb48fd54 100644 --- a/sc/qa/uitest/calc_tests4/tdf89958.py +++ b/sc/qa/uitest/calc_tests4/tdf89958.py @@ -22,17 +22,14 @@ class tdf89958(UITestCase): #Menu: Data->Filter->Standard Filter ... #Field Name "Column A", Condition "Does not end with", Value: "CTORS" - self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xval1 = xDialog.getChild("val1") - xcond1 = xDialog.getChild("cond1") + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") - select_by_text(xfield1, "Column A") - select_by_text(xcond1, "Does not end with") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + select_by_text(xfield1, "Column A") + select_by_text(xcond1, "Does not end with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"})) #Expected behaviours: A2 is not filtered as it does not end with "CTORS". gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py index e4f06577aa9c..07c1c8db768e 100644 --- a/sc/qa/uitest/calc_tests4/trackedChanges.py +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -17,27 +17,24 @@ class CalcTrackedChanges(UITestCase): def test_tdf131907(self): with self.ui_test.load_file(get_url_for_data_file("tdf131907.ods")) as calc_doc: xCalcDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:AcceptChanges", close_button="close") as xTrackDlg: - xChangesList = xTrackDlg.getChild("calcchanges") - self.assertEqual(1, len(xChangesList.getChildren())) + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) - textStart = "Row inserted \tSheet1.1:1\t \t" - textEnd = "(Row 1:1 inserted)" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + textStart = "Row inserted \tSheet1.1:1\t \t" + textEnd = "(Row 1:1 inserted)" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) - #it would crash here - xRejBtn = xTrackDlg.getChild("reject") - xRejBtn.executeAction("CLICK", tuple()) + #it would crash here + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) - self.assertEqual(2, len(xChangesList.getChildren())) - self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") - self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) def test_tdf66263_Protect_Records(self): with self.ui_test.create_doc_in_start_center("calc") as document: @@ -68,45 +65,42 @@ class CalcTrackedChanges(UITestCase): enter_text_to_cell(gridwin, "A1", "Test LibreOffice") enter_text_to_cell(gridwin, "A2", "Test LibreOffice") #accept tracked changes - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:AcceptChanges", close_button="close") as xTrackDlg: - xChangesList = xTrackDlg.getChild("calcchanges") - self.assertEqual(2, len(xChangesList.getChildren())) + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) - textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" - textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) - xAccBtn = xTrackDlg.getChild("accept") - xAccBtn.executeAction("CLICK", tuple()) + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) - self.assertEqual(2, len(xChangesList.getChildren())) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) - self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") - xAccBtn = xTrackDlg.getChild("accept") - xAccBtn.executeAction("CLICK", tuple()) + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) - self.assertEqual(1, len(xChangesList.getChildren())) - self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") - xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") @@ -121,37 +115,34 @@ class CalcTrackedChanges(UITestCase): enter_text_to_cell(gridwin, "A1", "Test LibreOffice") enter_text_to_cell(gridwin, "A2", "Test LibreOffice") #accept All tracked changes - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:AcceptChanges", close_button="close") as xTrackDlg: - xChangesList = xTrackDlg.getChild("calcchanges") - self.assertEqual(2, len(xChangesList.getChildren())) + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) - textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" - textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) - xAccBtn = xTrackDlg.getChild("acceptall") - xAccBtn.executeAction("CLICK", tuple()) + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) - self.assertEqual(1, len(xChangesList.getChildren())) - self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") - xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") @@ -166,57 +157,54 @@ class CalcTrackedChanges(UITestCase): enter_text_to_cell(gridwin, "A1", "Test LibreOffice") enter_text_to_cell(gridwin, "A2", "Test LibreOffice") #accept tracked changes - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() - - xChangesList = xTrackDlg.getChild("calcchanges") - self.assertEqual(2, len(xChangesList.getChildren())) - - textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" - textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) - - xRejBtn = xTrackDlg.getChild("reject") - xRejBtn.executeAction("CLICK", tuple()) - - self.assertEqual(3, len(xChangesList.getChildren())) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) - self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") - self.assertEqual(get_state_as_dict(xChangesList.getChild('2'))["Text"], "Rejected") - - xAccBtn = xTrackDlg.getChild("reject") - xAccBtn.executeAction("CLICK", tuple()) - - self.assertEqual(2, len(xChangesList.getChildren())) - self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") - self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") - - xChangesList.getChild('0').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) - - textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" - textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd3)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd4)) - - xChangesList.getChild('1').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) - - self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) - - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(3, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('2'))["Text"], "Rejected") + + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd3)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd4)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") @@ -231,48 +219,45 @@ class CalcTrackedChanges(UITestCase): enter_text_to_cell(gridwin, "A1", "Test LibreOffice") enter_text_to_cell(gridwin, "A2", "Test LibreOffice") #accept tracked changes - self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") - xTrackDlg = self.xUITest.getTopFocusWindow() + with self.ui_test.execute_modeless_dialog_through_command_guarded(".uno:AcceptChanges", close_button="close") as xTrackDlg: - xChangesList = xTrackDlg.getChild("calcchanges") - self.assertEqual(2, len(xChangesList.getChildren())) + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) - textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" - textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") - textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) - xAccBtn = xTrackDlg.getChild("rejectall") - xAccBtn.executeAction("CLICK", tuple()) + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) - self.assertEqual(2, len(xChangesList.getChildren())) - self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") - self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") - xChangesList.getChild('0').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) - textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" - textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart2)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd4)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart)) - self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd3)) + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd4)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd3)) - xChangesList.getChild('1').executeAction("EXPAND", tuple()) - self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) ... etc. - the rest is truncated