diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-30 11:01:58 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-30 13:17:54 +0200 |
commit | 57e8d25a40d7c053fef8ecb452e159264c659604 (patch) | |
tree | 9b7ca9fc7cbe8972d1caba9e583fc77f6c5a91b1 /sc/qa | |
parent | adf59322c651e8e6740a8d97d963dcf0972bdc54 (diff) |
uitest: guard create_doc_in_start_center in sc
Mostly done by a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I9392c56e6efccde958f0cdd497376b3939b75be4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118152
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc/qa')
125 files changed, 7216 insertions, 7593 deletions
diff --git a/sc/qa/uitest/autofilter/autofilter.py b/sc/qa/uitest/autofilter/autofilter.py index 1b5bcb1f113f..82e45d08254f 100644 --- a/sc/qa/uitest/autofilter/autofilter.py +++ b/sc/qa/uitest/autofilter/autofilter.py @@ -126,101 +126,97 @@ class AutofilterTest(UITestCase): self.assertFalse(is_row_hidden(doc, 4)) def test_differentSearches(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = calcDoc.getChild("grid_window") - enter_text_to_cell(xGridWindow, "A1", "X") - enter_text_to_cell(xGridWindow, "A2", "11") - enter_text_to_cell(xGridWindow, "A3", "22") - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + xGridWindow = calcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "A1", "X") + enter_text_to_cell(xGridWindow, "A2", "11") + enter_text_to_cell(xGridWindow, "A3", "22") + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") + xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(2, len(xList.getChildren())) - self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) - self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) + self.assertEqual(2, len(xList.getChildren())) + self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) - xSearchEdit = xFloatWindow.getChild("search_edit") - xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : "11"})) + xSearchEdit = xFloatWindow.getChild("search_edit") + xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : "11"})) - self.assertEqual(1, len(xList.getChildren())) - self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual(1, len(xList.getChildren())) + self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) - xOkBtn = xFloatWindow.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.assertFalse(is_row_hidden(document, 0)) - self.assertFalse(is_row_hidden(document, 1)) - self.assertTrue(is_row_hidden(document, 2)) + self.assertFalse(is_row_hidden(document, 0)) + self.assertFalse(is_row_hidden(document, 1)) + self.assertTrue(is_row_hidden(document, 2)) - xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") + xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(2, len(xList.getChildren())) - self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) - self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) + self.assertEqual(2, len(xList.getChildren())) + self.assertEqual("11", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual("22", get_state_as_dict(xList.getChild('1'))['Text']) - xSearchEdit = xFloatWindow.getChild("search_edit") - xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : "22"})) + xSearchEdit = xFloatWindow.getChild("search_edit") + xSearchEdit.executeAction("TYPE", mkPropertyValues({"TEXT" : "22"})) - self.assertEqual(1, len(xList.getChildren())) - self.assertEqual("22", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual(1, len(xList.getChildren())) + self.assertEqual("22", get_state_as_dict(xList.getChild('0'))['Text']) - xOkBtn = xFloatWindow.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.assertFalse(is_row_hidden(document, 0)) - self.assertTrue(is_row_hidden(document, 1)) - self.assertFalse(is_row_hidden(document, 2)) + self.assertFalse(is_row_hidden(document, 0)) + self.assertTrue(is_row_hidden(document, 1)) + self.assertFalse(is_row_hidden(document, 2)) - self.ui_test.close_doc() def test_tdf89244(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "AAA") - enter_text_to_cell(gridwin, "A3", "BBB") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A3", "BBB") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.xUITest.executeCommand(".uno:MergeCells") + self.xUITest.executeCommand(".uno:MergeCells") - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() + xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") + xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(2, len(xList.getChildren())) - self.assertEqual("(empty)", get_state_as_dict(xList.getChild('0'))['Text']) - self.assertEqual("BBB", get_state_as_dict(xList.getChild('1'))['Text']) + self.assertEqual(2, len(xList.getChildren())) + self.assertEqual("(empty)", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual("BBB", get_state_as_dict(xList.getChild('1'))['Text']) - xOkBtn = xFloatWindow.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() def test_tdf116818(self): with self.ui_test.load_file(get_url_for_data_file("tdf116818.xlsx")) as doc: @@ -372,54 +368,51 @@ class AutofilterTest(UITestCase): self.assertFalse(is_row_hidden(doc, 7)) def test_tdf142350(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "A2", "0") - enter_text_to_cell(gridwin, "A3", "") - enter_text_to_cell(gridwin, "A4", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - - # tdf140745 show (empty) entry on top of the checkbox list - self.assertEqual(3, len(xList.getChildren())) - self.assertEqual("(empty)", get_state_as_dict(xList.getChild('0'))['Text']) - self.assertEqual("0", get_state_as_dict(xList.getChild('1'))['Text']) - self.assertEqual("1", get_state_as_dict(xList.getChild('2'))['Text']) - - xEntry = xList.getChild("0") - xEntry.executeAction("CLICK", tuple()) - - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) - - self.assertFalse(is_row_hidden(document, 1)) - self.assertTrue(is_row_hidden(document, 2)) - self.assertFalse(is_row_hidden(document, 3)) - - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(3, len(xList.getChildren())) - self.assertEqual('false', get_state_as_dict(xList.getChild('0'))['IsChecked']) - self.assertEqual('true', get_state_as_dict(xList.getChild('1'))['IsChecked']) - self.assertEqual('true', get_state_as_dict(xList.getChild('2'))['IsChecked']) - xCloseButton = xFloatWindow.getChild("cancel") - xCloseButton.executeAction("CLICK", tuple()) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "") + enter_text_to_cell(gridwin, "A4", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + + # tdf140745 show (empty) entry on top of the checkbox list + self.assertEqual(3, len(xList.getChildren())) + self.assertEqual("(empty)", get_state_as_dict(xList.getChild('0'))['Text']) + self.assertEqual("0", get_state_as_dict(xList.getChild('1'))['Text']) + self.assertEqual("1", get_state_as_dict(xList.getChild('2'))['Text']) + + xEntry = xList.getChild("0") + xEntry.executeAction("CLICK", tuple()) + + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) + + self.assertFalse(is_row_hidden(document, 1)) + self.assertTrue(is_row_hidden(document, 2)) + self.assertFalse(is_row_hidden(document, 3)) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xList.getChildren())) + self.assertEqual('false', get_state_as_dict(xList.getChild('0'))['IsChecked']) + self.assertEqual('true', get_state_as_dict(xList.getChild('1'))['IsChecked']) + self.assertEqual('true', get_state_as_dict(xList.getChild('2'))['IsChecked']) + xCloseButton = xFloatWindow.getChild("cancel") + xCloseButton.executeAction("CLICK", tuple()) + def test_tdf138438(self): with self.ui_test.load_file(get_url_for_data_file("tdf138438.ods")) as doc: diff --git a/sc/qa/uitest/autofilter/autofilterBugs.py b/sc/qa/uitest/autofilter/autofilterBugs.py index 8a5250ae62c0..0b058da8c2b2 100644 --- a/sc/qa/uitest/autofilter/autofilterBugs.py +++ b/sc/qa/uitest/autofilter/autofilterBugs.py @@ -23,31 +23,29 @@ class autofilter(UITestCase): self.assertEqual(calc_doc.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) def test_tdf94055(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = calcDoc.getChild("grid_window") - enter_text_to_cell(xGridWindow, "A1", "X") - enter_text_to_cell(xGridWindow, "B1", "Y") - enter_text_to_cell(xGridWindow, "A2", "a") - enter_text_to_cell(xGridWindow, "B2", "b") - enter_text_to_cell(xGridWindow, "A3", "c") - enter_text_to_cell(xGridWindow, "B3", "d") - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"})) - - with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): - pass - - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) - self.xUITest.executeCommand(".uno:SelectRow") #select two rows - - with self.ui_test.execute_dialog_through_command(".uno:DataSort"): - pass - - #autofilter still exist - self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = calcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "A1", "X") + enter_text_to_cell(xGridWindow, "B1", "Y") + enter_text_to_cell(xGridWindow, "A2", "a") + enter_text_to_cell(xGridWindow, "B2", "b") + enter_text_to_cell(xGridWindow, "A3", "c") + enter_text_to_cell(xGridWindow, "B3", "d") + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): + pass + + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) + self.xUITest.executeCommand(".uno:SelectRow") #select two rows + + with self.ui_test.execute_dialog_through_command(".uno:DataSort"): + pass + + #autofilter still exist + self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) + #tdf77479.ods def test_tdf77479(self): diff --git a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py index a266925f1c00..5e2cd379fbd1 100644 --- a/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py +++ b/sc/qa/uitest/autofilter/tdf117276_autofilter_reset.py @@ -49,128 +49,126 @@ class tdf117276_autofilter_reset(UITestCase): self.assertEqual(2, self.get_values_count_in_AutoFilter(xGridWindow, "1")) def test_run(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = calcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = calcDoc.getChild("grid_window") # self.ui_test.execute_dialog_through_command(".uno:Insert") # insert sheet # xDialog = self.xUITest.getTopFocusWindow() # xOKButton = xDialog.getChild("ok") # xOKButton.executeAction("CLICK", tuple()) - # 1. prepare document - # | A | B | - # ----------------------------------------- - # 1 | HEADER-A | HEADER-B | - # ----------------------------------------- - # 2 | Unique a2 | common value for B2:B4 | - # 3 | Unique a3 | common value for B2:B4 | - # 4 | Unique a4 | common value for B2:B4 | - # 5 | Unique a5 | Unique b5 | - # 6 | Unique a6 | Unique b6 | - # - # row-1 - enter_text_to_cell(xGridWindow, "A1", "HEADER-A") - enter_text_to_cell(xGridWindow, "B1", "HEADER-B") - - # row-1 - enter_text_to_cell(xGridWindow, "A2", "Unique a2") - enter_text_to_cell(xGridWindow, "B2", "common value for B2:B4") - - # row-2 - enter_text_to_cell(xGridWindow, "A3", "Unique a3") - enter_text_to_cell(xGridWindow, "B3", "common value for B2:B4") - - # row-3 - enter_text_to_cell(xGridWindow, "A4", "Unique a4") - enter_text_to_cell(xGridWindow, "B4", "common value for B2:B4") - - # row-4 - enter_text_to_cell(xGridWindow, "A5", "Unique a5") - enter_text_to_cell(xGridWindow, "B5", "Unique b5") - - # row-5 - enter_text_to_cell(xGridWindow, "A6", "Unique a6") - enter_text_to_cell(xGridWindow, "B6", "Unique b6") - - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) - - # 2. switch on auto-filter - with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): - pass - - # autofilter still exist - self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) - - # 3. open filter of column A and deselect first 3 entries (Unique a2, Unique a3, Unique a4) - xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xTreeList = xCheckListMenu.getChild("check_list_box") - - xEntry1 = xTreeList.getChild("0") - xEntry1.executeAction("CLICK", tuple()) # Unique a2 - xEntry2 = xTreeList.getChild("1") - xEntry2.executeAction("CLICK", tuple()) # Unique a3 - xEntry3 = xTreeList.getChild("2") - xEntry3.executeAction("CLICK", tuple()) # Unique a4 - - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) - - # check filtering - # | A | B | - # ----------------------------------------- - # 1 | HEADER-A | HEADER-B | - # ----------------------------------------- - # 5 | Unique a5 | Unique b5 | - # 6 | Unique a6 | Unique b6 | - self.assertFalse(is_row_hidden(document, 0)) # column headers - self.assertTrue(is_row_hidden(document, 1)) - self.assertTrue(is_row_hidden(document, 2)) - self.assertTrue(is_row_hidden(document, 3)) - self.assertFalse(is_row_hidden(document, 4)) - self.assertFalse(is_row_hidden(document, 5)) - - self.assertEqual(5, self.get_values_count_in_AutoFilter(xGridWindow, "0")) - self.assertEqual(2, self.get_values_count_in_AutoFilter(xGridWindow, "1")) - - # 4. open filter of column B and deselect "Unique b5" - xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xTreeList = xCheckListMenu.getChild("check_list_box") - - xEntry = xTreeList.getChild("0") - xEntry.executeAction("CLICK", tuple()) # Unique b5 - - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) - - # check filtering - # | A | B | - # ----------------------------------------- - # 1 | HEADER-A | HEADER-B | - # ----------------------------------------- - # 6 | Unique a6 | Unique b6 | - self.check_state(document, xGridWindow) - - # 4. open filters of column A, B and close it using different buttons - self.openAutoFilterAndCloseIt(xGridWindow, "1", "ok") - self.check_state(document, xGridWindow) - - self.openAutoFilterAndCloseIt(xGridWindow, "1", "cancel") - self.check_state(document, xGridWindow) - - self.openAutoFilterAndCloseIt(xGridWindow, "0", "cancel") - self.check_state(document, xGridWindow) - - self.openAutoFilterAndCloseIt(xGridWindow, "0", "ok") - self.check_state(document, xGridWindow) - - # finish - self.ui_test.close_doc() + # 1. prepare document + # | A | B | + # ----------------------------------------- + # 1 | HEADER-A | HEADER-B | + # ----------------------------------------- + # 2 | Unique a2 | common value for B2:B4 | + # 3 | Unique a3 | common value for B2:B4 | + # 4 | Unique a4 | common value for B2:B4 | + # 5 | Unique a5 | Unique b5 | + # 6 | Unique a6 | Unique b6 | + # + # row-1 + enter_text_to_cell(xGridWindow, "A1", "HEADER-A") + enter_text_to_cell(xGridWindow, "B1", "HEADER-B") + + # row-1 + enter_text_to_cell(xGridWindow, "A2", "Unique a2") + enter_text_to_cell(xGridWindow, "B2", "common value for B2:B4") + + # row-2 + enter_text_to_cell(xGridWindow, "A3", "Unique a3") + enter_text_to_cell(xGridWindow, "B3", "common value for B2:B4") + + # row-3 + enter_text_to_cell(xGridWindow, "A4", "Unique a4") + enter_text_to_cell(xGridWindow, "B4", "common value for B2:B4") + + # row-4 + enter_text_to_cell(xGridWindow, "A5", "Unique a5") + enter_text_to_cell(xGridWindow, "B5", "Unique b5") + + # row-5 + enter_text_to_cell(xGridWindow, "A6", "Unique a6") + enter_text_to_cell(xGridWindow, "B6", "Unique b6") + + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) + + # 2. switch on auto-filter + with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): + pass + + # autofilter still exist + self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) + + # 3. open filter of column A and deselect first 3 entries (Unique a2, Unique a3, Unique a4) + xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + + xEntry1 = xTreeList.getChild("0") + xEntry1.executeAction("CLICK", tuple()) # Unique a2 + xEntry2 = xTreeList.getChild("1") + xEntry2.executeAction("CLICK", tuple()) # Unique a3 + xEntry3 = xTreeList.getChild("2") + xEntry3.executeAction("CLICK", tuple()) # Unique a4 + + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) + + # check filtering + # | A | B | + # ----------------------------------------- + # 1 | HEADER-A | HEADER-B | + # ----------------------------------------- + # 5 | Unique a5 | Unique b5 | + # 6 | Unique a6 | Unique b6 | + self.assertFalse(is_row_hidden(document, 0)) # column headers + self.assertTrue(is_row_hidden(document, 1)) + self.assertTrue(is_row_hidden(document, 2)) + self.assertTrue(is_row_hidden(document, 3)) + self.assertFalse(is_row_hidden(document, 4)) + self.assertFalse(is_row_hidden(document, 5)) + + self.assertEqual(5, self.get_values_count_in_AutoFilter(xGridWindow, "0")) + self.assertEqual(2, self.get_values_count_in_AutoFilter(xGridWindow, "1")) + + # 4. open filter of column B and deselect "Unique b5" + xGridWindow.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + + xEntry = xTreeList.getChild("0") + xEntry.executeAction("CLICK", tuple()) # Unique b5 + + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) + + # check filtering + # | A | B | + # ----------------------------------------- + # 1 | HEADER-A | HEADER-B | + # ----------------------------------------- + # 6 | Unique a6 | Unique b6 | + self.check_state(document, xGridWindow) + + # 4. open filters of column A, B and close it using different buttons + self.openAutoFilterAndCloseIt(xGridWindow, "1", "ok") + self.check_state(document, xGridWindow) + + self.openAutoFilterAndCloseIt(xGridWindow, "1", "cancel") + self.check_state(document, xGridWindow) + + self.openAutoFilterAndCloseIt(xGridWindow, "0", "cancel") + self.check_state(document, xGridWindow) + + self.openAutoFilterAndCloseIt(xGridWindow, "0", "ok") + self.check_state(document, xGridWindow) + + # finish # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf126306.py b/sc/qa/uitest/autofilter/tdf126306.py index 6423760d2a60..e0a895ba5cce 100644 --- a/sc/qa/uitest/autofilter/tdf126306.py +++ b/sc/qa/uitest/autofilter/tdf126306.py @@ -21,118 +21,115 @@ class tdf126306(UITestCase): self.assertEqual(bVisible, value) def test_run(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - xGridWin = calcDoc.getChild("grid_window") - - default_values = [25, 1023, 17, 9, 19, 0, 107, 89, 8, 453, 33, 3, 25, 204] - document = self.ui_test.get_component() - - for i, value in enumerate(default_values, start=2): - enter_text_to_cell(xGridWin, "A" + str(i), str(value)) - - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"})) - - with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): - pass - - self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) - - self.check_values(document, default_values) - self.check_row_hidden(document) - - # Sort ascending button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SPACE"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - sort_asc_values = [0, 3, 8, 9, 17, 19, 25, 25, 33, 89, 107, 204, 453, 1023] - self.check_values(document, sort_asc_values) - self.check_row_hidden(document) - - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.check_values(document, default_values) - self.check_row_hidden(document) - - # Sort descending button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - sort_des_values = [1023, 453, 204, 107, 89, 33, 25, 25, 19, 17, 9, 8, 3, 0] - self.check_values(document, sort_des_values) - self.check_row_hidden(document) - - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.check_values(document, default_values) - self.check_row_hidden(document) - - # Top 10 button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - top10_hidden_values = [True, True, True, False, True, False, True, - True, False, True, True, False, True, True] - - #Values are the same - self.check_values(document, default_values) - self.check_row_hidden(document, top10_hidden_values) - - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.check_values(document, default_values) - self.check_row_hidden(document) - - # Empty button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - empty_values = [False] * 14 - #Values are the same - self.check_values(document, default_values) - self.check_row_hidden(document, empty_values) - - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.check_values(document, default_values) - self.check_row_hidden(document) - - # Not Empty button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - #Nothing should change - self.check_values(document, default_values) - self.check_row_hidden(document) - - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.check_values(document, default_values) - self.check_row_hidden(document) - - # finish - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + xGridWin = calcDoc.getChild("grid_window") + + default_values = [25, 1023, 17, 9, 19, 0, 107, 89, 8, 453, 33, 3, 25, 204] + + for i, value in enumerate(default_values, start=2): + enter_text_to_cell(xGridWin, "A" + str(i), str(value)) + + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A15"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): + pass + + self.assertEqual(document.getPropertyValue("UnnamedDatabaseRanges").getByTable(0).AutoFilter, True) + + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Sort ascending button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SPACE"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + sort_asc_values = [0, 3, 8, 9, 17, 19, 25, 25, 33, 89, 107, 204, 453, 1023] + self.check_values(document, sort_asc_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Sort descending button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + sort_des_values = [1023, 453, 204, 107, 89, 33, 25, 25, 19, 17, 9, 8, 3, 0] + self.check_values(document, sort_des_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Top 10 button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + top10_hidden_values = [True, True, True, False, True, False, True, + True, False, True, True, False, True, True] + + #Values are the same + self.check_values(document, default_values) + self.check_row_hidden(document, top10_hidden_values) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + empty_values = [False] * 14 + #Values are the same + self.check_values(document, default_values) + self.check_row_hidden(document, empty_values) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # Not Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + #Nothing should change + self.check_values(document, default_values) + self.check_row_hidden(document) + + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.check_values(document, default_values) + self.check_row_hidden(document) + + # finish # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf141559.py b/sc/qa/uitest/autofilter/tdf141559.py index 6bce18852ff3..7c727bd1669a 100644 --- a/sc/qa/uitest/autofilter/tdf141559.py +++ b/sc/qa/uitest/autofilter/tdf141559.py @@ -15,79 +15,76 @@ from uitest.uihelper.common import get_state_as_dict class tdf141559(UITestCase): def test_tdf141559_clear_filter(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "A2", "1") - enter_text_to_cell(gridwin, "A3", "2") - enter_text_to_cell(gridwin, "A4", "3") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - #Choose Standard Filter... button - xMenu = xFloatWindow.getChild("menu") - - # check last item: 'Standard Filter...' (new menu item 'Clear Filter' is optional) - nLastIdx = int(get_state_as_dict(xMenu)['Children']) - 1 - self.assertEqual(10, nLastIdx) - self.assertEqual('Standard Filter...', get_state_as_dict(xMenu.getChild(str(nLastIdx)))['Text']) - - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - self.assertEqual("Standard Filter...", get_state_as_dict(xMenu)['SelectEntryText']) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - xDialog = self.xUITest.getTopFocusWindow() - xfield1 = xDialog.getChild("field1") - xcond1 = xDialog.getChild("cond1") - xval1 = xDialog.getChild("val1") - - select_by_text(xfield1, "A") - select_by_text(xcond1, ">") - xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - row = get_row(document, 1) - self.assertFalse(row.getPropertyValue("IsVisible")) - - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - #Choose Clear Filter button - xMenu = xFloatWindow.getChild("menu") - - # check last item: 'Clear Filter' - nLastIdx = int(get_state_as_dict(xMenu)['Children']) - 1 - self.assertEqual(11, nLastIdx) - self.assertEqual('Clear Filter', get_state_as_dict(xMenu.getChild(str(nLastIdx)))['Text']) - - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - # Use new menu item "Clear Filter" to remove the standard filter condition - self.assertEqual("Clear Filter", get_state_as_dict(xMenu)['SelectEntryText']) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - - self.assertTrue(row.getPropertyValue("IsVisible")) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "2") + enter_text_to_cell(gridwin, "A4", "3") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + #Choose Standard Filter... button + xMenu = xFloatWindow.getChild("menu") + + # check last item: 'Standard Filter...' (new menu item 'Clear Filter' is optional) + nLastIdx = int(get_state_as_dict(xMenu)['Children']) - 1 + self.assertEqual(10, nLastIdx) + self.assertEqual('Standard Filter...', get_state_as_dict(xMenu.getChild(str(nLastIdx)))['Text']) + + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + self.assertEqual("Standard Filter...", get_state_as_dict(xMenu)['SelectEntryText']) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xcond1 = xDialog.getChild("cond1") + xval1 = xDialog.getChild("val1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, ">") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + row = get_row(document, 1) + self.assertFalse(row.getPropertyValue("IsVisible")) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + #Choose Clear Filter button + xMenu = xFloatWindow.getChild("menu") + + # check last item: 'Clear Filter' + nLastIdx = int(get_state_as_dict(xMenu)['Children']) - 1 + self.assertEqual(11, nLastIdx) + self.assertEqual('Clear Filter', get_state_as_dict(xMenu.getChild(str(nLastIdx)))['Text']) + + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + # Use new menu item "Clear Filter" to remove the standard filter condition + self.assertEqual("Clear Filter", get_state_as_dict(xMenu)['SelectEntryText']) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + self.assertTrue(row.getPropertyValue("IsVisible")) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf141946.py b/sc/qa/uitest/autofilter/tdf141946.py index 4e45ecfb7d5a..7e53dd1c879d 100644 --- a/sc/qa/uitest/autofilter/tdf141946.py +++ b/sc/qa/uitest/autofilter/tdf141946.py @@ -12,64 +12,61 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf141946(UITestCase): def test_tdf141946_inserted_column(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "A2", "1") - enter_text_to_cell(gridwin, "A3", "2") - enter_text_to_cell(gridwin, "A4", "3") + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "2") + enter_text_to_cell(gridwin, "A4", "3") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "B2", "4") - enter_text_to_cell(gridwin, "B3", "5") - enter_text_to_cell(gridwin, "B4", "6") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "B2", "4") + enter_text_to_cell(gridwin, "B3", "5") + enter_text_to_cell(gridwin, "B4", "6") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - xEntry = xList.getChild("1") - xEntry.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + xEntry = xList.getChild("1") + xEntry.executeAction("CLICK", tuple()) - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - self.xUITest.executeCommand(".uno:InsertColumnsBefore") + self.xUITest.executeCommand(".uno:InsertColumnsBefore") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(2, len(xList.getChildren())) - xCloseBtn = xFloatWindow.getChild("cancel") - xCloseBtn.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(2, len(xList.getChildren())) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(1, len(xList.getChildren())) - xCloseBtn = xFloatWindow.getChild("cancel") - xCloseBtn.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(1, len(xList.getChildren())) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "2", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(3, len(xList.getChildren())) - xCloseBtn = xFloatWindow.getChild("cancel") - xCloseBtn.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "2", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xList.getChildren())) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf36383.py b/sc/qa/uitest/autofilter/tdf36383.py index 26003ebcf9fb..a36001cfcab2 100644 --- a/sc/qa/uitest/autofilter/tdf36383.py +++ b/sc/qa/uitest/autofilter/tdf36383.py @@ -13,50 +13,47 @@ from libreoffice.calc.document import get_row class tdf36383(UITestCase): def test_tdf36383_row_height(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "A2", "1") - enter_text_to_cell(gridwin, "A3", "2") - enter_text_to_cell(gridwin, "A4", "3") + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "2") + enter_text_to_cell(gridwin, "A4", "3") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - xEntry = xList.getChild("1") - xEntry.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + xEntry = xList.getChild("1") + xEntry.executeAction("CLICK", tuple()) - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) - row = get_row(document, 2) - self.assertFalse(row.getPropertyValue("IsVisible")) + row = get_row(document, 2) + self.assertFalse(row.getPropertyValue("IsVisible")) - #row height - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - self.assertFalse(row.getPropertyValue("IsVisible")) + self.assertFalse(row.getPropertyValue("IsVisible")) - #optimal row height - with self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight"): - pass + #optimal row height + with self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight"): + pass - self.assertFalse(row.getPropertyValue("IsVisible")) + self.assertFalse(row.getPropertyValue("IsVisible")) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf46062.py b/sc/qa/uitest/autofilter/tdf46062.py index 065279e686ab..6d3f9655991e 100644 --- a/sc/qa/uitest/autofilter/tdf46062.py +++ b/sc/qa/uitest/autofilter/tdf46062.py @@ -13,35 +13,34 @@ class tdf46062(UITestCase): def test_tdf46062(self): - self.ui_test.create_doc_in_start_center("calc") - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "spaces") - enter_text_to_cell(gridwin, "A2", " ") - enter_text_to_cell(gridwin, "A3", " ") - enter_text_to_cell(gridwin, "A4", " ") + enter_text_to_cell(gridwin, "A1", "spaces") + enter_text_to_cell(gridwin, "A2", " ") + enter_text_to_cell(gridwin, "A3", " ") + enter_text_to_cell(gridwin, "A4", " ") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command(".uno:DataFilterAutoFilter", close_button="yes"): + pass - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(3, len(xList.getChildren())) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xList.getChildren())) - # Without the fix in place, this test would have failed with - # AssertionError: '" "' != ' ' - self.assertEqual('" "', get_state_as_dict(xList.getChild("0"))['Text']) - self.assertEqual('" "', get_state_as_dict(xList.getChild("1"))['Text']) - self.assertEqual('" "', get_state_as_dict(xList.getChild("2"))['Text']) + # Without the fix in place, this test would have failed with + # AssertionError: '" "' != ' ' + self.assertEqual('" "', get_state_as_dict(xList.getChild("0"))['Text']) + self.assertEqual('" "', get_state_as_dict(xList.getChild("1"))['Text']) + self.assertEqual('" "', get_state_as_dict(xList.getChild("2"))['Text']) - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf48025.py b/sc/qa/uitest/autofilter/tdf48025.py index c5d5c711da5f..ac90453e8951 100644 --- a/sc/qa/uitest/autofilter/tdf48025.py +++ b/sc/qa/uitest/autofilter/tdf48025.py @@ -12,61 +12,58 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf48025(UITestCase): def test_tdf48025_deleted_columns(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "A2", "1") - enter_text_to_cell(gridwin, "A3", "2") - enter_text_to_cell(gridwin, "A4", "3") + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "2") + enter_text_to_cell(gridwin, "A4", "3") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "B2", "4") - enter_text_to_cell(gridwin, "B3", "5") - enter_text_to_cell(gridwin, "B4", "6") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "B2", "4") + enter_text_to_cell(gridwin, "B3", "5") + enter_text_to_cell(gridwin, "B4", "6") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "C2", "7") - enter_text_to_cell(gridwin, "C3", "8") - enter_text_to_cell(gridwin, "C4", "9") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "C2", "7") + enter_text_to_cell(gridwin, "C3", "8") + enter_text_to_cell(gridwin, "C4", "9") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C4"})) - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - xEntry = xList.getChild("1") - xEntry.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + xEntry = xList.getChild("1") + xEntry.executeAction("CLICK", tuple()) - xOkButton = xFloatWindow.getChild("ok") - xOkButton.executeAction("CLICK", tuple()) + xOkButton = xFloatWindow.getChild("ok") + xOkButton.executeAction("CLICK", tuple()) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:DeleteColumns") + self.xUITest.executeCommand(".uno:DeleteColumns") - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(3, len(xList.getChildren())) - xCloseBtn = xFloatWindow.getChild("cancel") - xCloseBtn.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(3, len(xList.getChildren())) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) - gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(2, len(xList.getChildren())) - xCloseBtn = xFloatWindow.getChild("cancel") - xCloseBtn.executeAction("CLICK", tuple()) + gridwin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "1", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(2, len(xList.getChildren())) + xCloseBtn = xFloatWindow.getChild("cancel") + xCloseBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/autofilter/tdf68113.py b/sc/qa/uitest/autofilter/tdf68113.py index f62ac9ce95c0..6f6b4e97f52b 100644 --- a/sc/qa/uitest/autofilter/tdf68113.py +++ b/sc/qa/uitest/autofilter/tdf68113.py @@ -13,65 +13,62 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf68113(UITestCase): def test_tdf68113_empty_notempty_button(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() - calcDoc = self.xUITest.getTopFocusWindow() - xGridWin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + calcDoc = self.xUITest.getTopFocusWindow() + xGridWin = calcDoc.getChild("grid_window") - enter_text_to_cell(xGridWin, "A1", "A") - enter_text_to_cell(xGridWin, "A2", "1") - enter_text_to_cell(xGridWin, "A3", "2") - enter_text_to_cell(xGridWin, "A5", "4") - enter_text_to_cell(xGridWin, "A7", "6") + enter_text_to_cell(xGridWin, "A1", "A") + enter_text_to_cell(xGridWin, "A2", "1") + enter_text_to_cell(xGridWin, "A3", "2") + enter_text_to_cell(xGridWin, "A5", "4") + enter_text_to_cell(xGridWin, "A7", "6") - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A7"})) + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A7"})) - self.xUITest.executeCommand(".uno:DataFilterAutoFilter") + self.xUITest.executeCommand(".uno:DataFilterAutoFilter") - # Empty button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + # Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - # Checkbox elements - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xTreeList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(5, len(xTreeList.getChildren())) - self.assertEqual('true', get_state_as_dict(xTreeList.getChild('0'))['IsChecked']) - self.assertEqual('false', get_state_as_dict(xTreeList.getChild('2'))['IsChecked']) - self.assertEqual('false', get_state_as_dict(xTreeList.getChild('4'))['IsChecked']) - xCancelBtn = xFloatWindow.getChild("cancel") - xCancelBtn.executeAction("CLICK", tuple()) + # Checkbox elements + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(5, len(xTreeList.getChildren())) + self.assertEqual('true', get_state_as_dict(xTreeList.getChild('0'))['IsChecked']) + self.assertEqual('false', get_state_as_dict(xTreeList.getChild('2'))['IsChecked']) + self.assertEqual('false', get_state_as_dict(xTreeList.getChild('4'))['IsChecked']) + xCancelBtn = xFloatWindow.getChild("cancel") + xCancelBtn.executeAction("CLICK", tuple()) - # Not Empty button - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xMenu = xFloatWindow.getChild("menu") - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + # Not Empty button + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xMenu = xFloatWindow.getChild("menu") + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + xMenu.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - # Checkbox elements - xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) - xFloatWindow = self.xUITest.getFloatWindow() - xCheckListMenu = xFloatWindow.getChild("check_list_menu") - xTreeList = xCheckListMenu.getChild("check_list_box") - self.assertEqual(5, len(xTreeList.getChildren())) - self.assertEqual('false', get_state_as_dict(xTreeList.getChild('0'))['IsChecked']) - self.assertEqual('true', get_state_as_dict(xTreeList.getChild('2'))['IsChecked']) - self.assertEqual('true', get_state_as_dict(xTreeList.getChild('4'))['IsChecked']) - xCancelBtn = xFloatWindow.getChild("cancel") - xCancelBtn.executeAction("CLICK", tuple()) + # Checkbox elements + xGridWin.executeAction("LAUNCH", mkPropertyValues({"AUTOFILTER": "", "COL": "0", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("check_list_menu") + xTreeList = xCheckListMenu.getChild("check_list_box") + self.assertEqual(5, len(xTreeList.getChildren())) + self.assertEqual('false', get_state_as_dict(xTreeList.getChild('0'))['IsChecked']) + self.assertEqual('true', get_state_as_dict(xTreeList.getChild('2'))['IsChecked']) + self.assertEqual('true', get_state_as_dict(xTreeList.getChild('4'))['IsChecked']) + xCancelBtn = xFloatWindow.getChild("cancel") + xCancelBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/CalcPasteOnly.py b/sc/qa/uitest/calc_tests/CalcPasteOnly.py index 414f58230a51..de52826d121e 100644 --- a/sc/qa/uitest/calc_tests/CalcPasteOnly.py +++ b/sc/qa/uitest/calc_tests/CalcPasteOnly.py @@ -13,29 +13,27 @@ from uitest.uihelper.calc import enter_text_to_cell class CalcPasteOnly(UITestCase): def test_paste_only(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xTopWindow = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - gridwin = xTopWindow.getChild("grid_window") - - enter_text_to_cell(gridwin, "A1", "=SUM(A2:A3)") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:Copy") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.xUITest.executeCommand(".uno:PasteOnlyText") - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - self.xUITest.executeCommand(".uno:PasteOnlyValue") - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "0") - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 0) - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) - self.xUITest.executeCommand(".uno:PasteOnlyFormula") - self.assertEqual(get_cell_by_position(document, 0, 4, 0).getString(), "0") - self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 4, 0).getFormula(), "=SUM(E2:E3)") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "=SUM(A2:A3)") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:PasteOnlyText") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:PasteOnlyValue") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 0) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:PasteOnlyFormula") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getFormula(), "=SUM(E2:E3)") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py b/sc/qa/uitest/calc_tests/CellDropDownItems.py index ce443cda3283..b81589daccec 100644 --- a/sc/qa/uitest/calc_tests/CellDropDownItems.py +++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py @@ -13,71 +13,69 @@ class CellDropDownItems(UITestCase): def test_dropdownitems(self): #This is to test Dropdown items in grid window - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #select cell C10 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"})) - - #Open Validation Dialog - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - - #Select List option - xallow = xDialog.getChild("allow") - xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"})) - - #Add items to the List - xminlist = xDialog.getChild("minlist") - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"})) - xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"})) - - #Close the dialog - - #Launch the Select Menu to view the list ans select first item in the list - gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) - - #Select the TreeList UI Object - xWin = self.xUITest.getTopFocusWindow() - xlist = xWin.getChild("list") - - xListItem = xlist.getChild('0') - xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) - self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item1") - - #Launch the Select Menu to view the list ans select Third item in the list - gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) - - #Select the TreeList UI Object - xWin = self.xUITest.getTopFocusWindow() - xlist = xWin.getChild("list") - - xListItem = xlist.getChild('2') - xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) - self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item3") - - #Launch the Select Menu to view the list ans select Fifth item in the list - gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) - - #Select the TreeList UI Object - xWin = self.xUITest.getTopFocusWindow() - xlist = xWin.getChild("list") - - xListItem = xlist.getChild('4') - xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) - self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item5") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #select cell C10 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"})) + + #Open Validation Dialog + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + + #Select List option + xallow = xDialog.getChild("allow") + xallow.executeAction("SELECT", mkPropertyValues({"POS": "6"})) + + #Add items to the List + xminlist = xDialog.getChild("minlist") + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"})) + + #Close the dialog + + #Launch the Select Menu to view the list ans select first item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('0') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item1") + + #Launch the Select Menu to view the list ans select Third item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('2') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item3") + + #Launch the Select Menu to view the list ans select Fifth item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('4') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item5") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/Comments.py b/sc/qa/uitest/calc_tests/Comments.py index 3841686d99f5..2bfce36a6ba9 100644 --- a/sc/qa/uitest/calc_tests/Comments.py +++ b/sc/qa/uitest/calc_tests/Comments.py @@ -10,39 +10,37 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class Comments(UITestCase): def test_comment(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # Select Cell D8 - gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D8"})) + # Select Cell D8 + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D8"})) - # Create comment and open it's window - gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) + # Create comment and open it's window + gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) - # Write text in the Comment Window - gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "First Comment"})) + # Write text in the Comment Window + gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "First Comment"})) - # Close Comment Window - gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) + # Close Comment Window + gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) - # Check on the comment text - self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "First Comment") + # Check on the comment text + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "First Comment") - # Check on comment in another cell - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) - gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "Second Comment"})) - gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) - self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Second Comment") + # Check on comment in another cell + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) + gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "Second Comment"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Second Comment") - # Write Comment without opening Comment window - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B5"})) - gridwin.executeAction("COMMENT", mkPropertyValues({"SETTEXT": "Third Comment"})) - self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Third Comment") + # Write Comment without opening Comment window + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B5"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"SETTEXT": "Third Comment"})) + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Third Comment") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/autofill.py b/sc/qa/uitest/calc_tests/autofill.py index 665410da2d48..c81d1549a8c7 100644 --- a/sc/qa/uitest/calc_tests/autofill.py +++ b/sc/qa/uitest/calc_tests/autofill.py @@ -107,19 +107,17 @@ class CalcAutofill(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 11).getString(), "10.64.127.7") def test_autofill_with_suffix(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "1st") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: - xautofill = xDialog.getChild("autofill") - xautofill.executeAction("CLICK", tuple()) - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1st") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/calcSheetDelete.py b/sc/qa/uitest/calc_tests/calcSheetDelete.py index c3e28bee2d0c..3a93f2a69034 100644 --- a/sc/qa/uitest/calc_tests/calcSheetDelete.py +++ b/sc/qa/uitest/calc_tests/calcSheetDelete.py @@ -13,127 +13,119 @@ class calcSheetDelete(UITestCase): def test_tdf114228_insert_and_delete_sheet(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"})) - nrSheets = document.Sheets.getCount() #default number + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"})) + nrSheets = document.Sheets.getCount() #default number - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass - self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) - with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): - pass - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() - self.assertEqual(document.Sheets.getCount(), nrSheets) - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.Sheets.getCount(), nrSheets + 1) - self.xUITest.executeCommand(".uno:Redo") - self.assertEqual(document.Sheets.getCount(), nrSheets) + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) - self.ui_test.close_doc() def test_tdf43078_insert_and_delete_sheet_insert_text(self): - self.ui_test.create_doc_in_start_center("calc") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - nrSheets = document.Sheets.getCount() #default number of sheets + nrSheets = document.Sheets.getCount() #default number of sheets - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() - self.assertEqual(document.Sheets.getCount(), nrSheets + 2) - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - enter_text_to_cell(xGridWindow, "B2", "abcd") + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "B2", "abcd") - with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass - self.assertEqual(document.Sheets.getCount(), nrSheets + 1) - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.Sheets.getCount(), nrSheets + 2) - self.xUITest.executeCommand(".uno:Redo") - self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) - self.ui_test.close_doc() def test_delete_more_sheets_at_once(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - nrSheets = document.Sheets.getCount() #default number - i = 0 - while i < 6: - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass - i = i + 1 - self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 6: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + i = i + 1 + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) - i = 0 - while i < 5: - self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet - i = i + 1 + i = 0 + while i < 5: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 - with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() - self.assertEqual(document.Sheets.getCount(), nrSheets) - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.Sheets.getCount(), nrSheets + 6) - self.xUITest.executeCommand(".uno:Redo") - self.assertEqual(document.Sheets.getCount(), nrSheets) + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) - self.ui_test.close_doc() def test_tdf105105_delete_lots_of_sheets_at_once(self): - self.ui_test.create_doc_in_start_center("calc") - - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - nrSheets = document.Sheets.getCount() #default number - i = 0 - while i < 100: - with self.ui_test.execute_dialog_through_command(".uno:Insert"): + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 100: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + i = i + 1 + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + + i = 0 + while i < 99: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 + + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): pass - i = i + 1 - xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') - xToolkit.processEventsToIdle() - self.assertEqual(document.Sheets.getCount(), nrSheets + 100) - - i = 0 - while i < 99: - self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet - i = i + 1 - - with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): - pass - - self.assertEqual(document.Sheets.getCount(), nrSheets) - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.Sheets.getCount(), nrSheets + 100) - self.xUITest.executeCommand(".uno:Redo") - self.assertEqual(document.Sheets.getCount(), nrSheets) - - self.ui_test.close_doc() + + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py index 129488b50feb..8487f232fe65 100644 --- a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py +++ b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py @@ -15,186 +15,182 @@ class CalcCellBackgroundColorSelector(UITestCase): def test_color_selector(self): #This is to test color selection - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - xpaletteselector = xDialog.getChild("paletteselector") - - # Now we have the ColorPage that we can get the color selector from it - xColorpage = xDialog.getChild("ColorPage") - color_selector = xColorpage.getChild("colorset") - - # For chart-palettes colors - select_by_text(xpaletteselector, "chart-palettes") - # Select Color with id 2 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)") - - # Select Color with id 5 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)") - - # For libreoffice colors - select_by_text(xpaletteselector, "libreoffice") - # Select Color with id 6 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)") - - # Select Color with id 30 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent") - self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)") - - # For html colors - select_by_text(xpaletteselector, "html") - # Select Color with id 1 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White") - # Select Color with id 120 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy") - - # For freecolour-hlc colors - select_by_text(xpaletteselector, "freecolour-hlc") - # Select Color with id 988 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10") - # Select Color with id 575 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20") - - # For tonal colors - select_by_text(xpaletteselector, "tonal") - # Select Color with id 17 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%") - # Select Color with id 13 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%") - - # For material colors - select_by_text(xpaletteselector, "material") - # Select Color with id 9 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800") - - # For standard colors - select_by_text(xpaletteselector, "standard") - # Select Color with id 3 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + xpaletteselector = xDialog.getChild("paletteselector") + + # Now we have the ColorPage that we can get the color selector from it + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)") + + # Select Color with id 5 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)") + + # For libreoffice colors + select_by_text(xpaletteselector, "libreoffice") + # Select Color with id 6 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)") + + # Select Color with id 30 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)") + + # For html colors + select_by_text(xpaletteselector, "html") + # Select Color with id 1 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White") + # Select Color with id 120 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy") + + # For freecolour-hlc colors + select_by_text(xpaletteselector, "freecolour-hlc") + # Select Color with id 988 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10") + # Select Color with id 575 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20") + + # For tonal colors + select_by_text(xpaletteselector, "tonal") + # Select Color with id 17 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%") + # Select Color with id 13 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%") + + # For material colors + select_by_text(xpaletteselector, "material") + # Select Color with id 9 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800") + + # For standard colors + select_by_text(xpaletteselector, "standard") + # Select Color with id 3 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3") + + def test_recent_color_selector(self): #This is to test recent color selection - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A5 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - - # we will select color for cell A5 to be able to predict the latest color in - # recent color selector - xpaletteselector = xDialog.getChild("paletteselector") - xColorpage = xDialog.getChild("ColorPage") - color_selector = xColorpage.getChild("colorset") - - # For chart-palettes colors - select_by_text(xpaletteselector, "chart-palettes") - # Select Color with id 2 - color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) - self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") - self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") - self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") - self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") - xrgb = get_state_as_dict(color_selector)["RGB"] - - # close the dialog after selection of the color - - #select cell D3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D3"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Numbers - # click on color btn - xbtncolor = xDialog.getChild("btncolor") - xbtncolor.executeAction("CLICK",tuple()) - - xColorpage = xDialog.getChild("ColorPage") - recent_color_selector = xColorpage.getChild("recentcolorset") - - # Select Color with id 1 - recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1") - self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0") - self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2") - self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb) - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + # we will select color for cell A5 to be able to predict the latest color in + # recent color selector + xpaletteselector = xDialog.getChild("paletteselector") + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + xrgb = get_state_as_dict(color_selector)["RGB"] + + # close the dialog after selection of the color + + #select cell D3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D3"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + xColorpage = xDialog.getChild("ColorPage") + recent_color_selector = xColorpage.getChild("recentcolorset") + + # Select Color with id 1 + recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb) + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py index 2466366762c1..5687a4887a1e 100644 --- a/sc/qa/uitest/calc_tests/columns.py +++ b/sc/qa/uitest/calc_tests/columns.py @@ -11,227 +11,215 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class CalcColumns(UITestCase): def test_column_width(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #column width - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected - heightStrOrig = get_state_as_dict(xvalue)["Text"] - heightVal = heightStrOrig[:4] #default 2.26 cm - xvalue.executeAction("UP", tuple()) #2.36 cm - heightStr = get_state_as_dict(xvalue)["Text"] - heightValNew = heightStr[:4] - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected - self.assertEqual(heightValNew > heightVal, True) #new value is bigger - xdefault.executeAction("CLICK", tuple()) #click default - self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #verify - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth", close_button="cancel") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 2.26 cm + xvalue.executeAction("UP", tuple()) #2.36 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_column_width_two_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"})) - - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"})) + + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_column_width_copy(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #column width - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #select column 1 - self.xUITest.executeCommand(".uno:SelectColumn") - #copy - self.xUITest.executeCommand(".uno:Copy") - #select C1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - #paste - self.xUITest.executeCommand(".uno:Paste") - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select column 1 + self.xUITest.executeCommand(".uno:SelectColumn") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_column_hide_show(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - self.xUITest.executeCommand(".uno:HideColumn") #uno command moves focus one cell down - #verify D1 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) - #verify B (column C is hidden) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "1") - #Show hidden column: select B1:D1 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:D1"})) - self.xUITest.executeCommand(".uno:ShowColumn") - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) - #verify C1 (COlumn C is not hidden) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "2") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:HideColumn") #uno command moves focus one cell down + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify B (column C is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "1") + #Show hidden column: select B1:D1 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:D1"})) + self.xUITest.executeCommand(".uno:ShowColumn") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 (COlumn C is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + def test_column_test_move(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select C1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "2") - #right - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) - #verify D1 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) - #verify C1 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentColumn"], "2") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + #right + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + def test_tdf117522_column_width_insert_left(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select C1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - #column width - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #select D1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - #column width - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) - # Click Ok - #select E1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) - #column width - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) - # Click Ok - #select columns C-E - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"})) - self.xUITest.executeCommand(".uno:SelectColumn") - #Insert Columns Left - self.xUITest.executeCommand(".uno:InsertColumnsBefore") - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"})) - with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) + # Click Ok + #select E1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) + # Click Ok + #select columns C-E + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #Insert Columns Left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.0003 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.0004 cm") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/fillRandomNumber.py b/sc/qa/uitest/calc_tests/fillRandomNumber.py index 800786bbbac0..5388c26aab82 100644 --- a/sc/qa/uitest/calc_tests/fillRandomNumber.py +++ b/sc/qa/uitest/calc_tests/fillRandomNumber.py @@ -12,47 +12,45 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #randomnumbergenerator.ui class fillRandomNumber(UITestCase): def test_fill_random_number(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - 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.create_doc_in_start_center_guarded("calc") as document: + 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") - 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) - #undo - self.xUITest.executeCommand(".uno:Undo") - 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) - 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) - self.ui_test.close_doc() + 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) + #undo + self.xUITest.executeCommand(".uno:Undo") + 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) + 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/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py index f0a6d7e0b0cc..ad0d4faf23b1 100644 --- a/sc/qa/uitest/calc_tests/formatCells.py +++ b/sc/qa/uitest/calc_tests/formatCells.py @@ -14,403 +14,385 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class formatCell(UITestCase): def test_format_cell_numbers_tab(self): #numberingformatpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") - #language - select_by_text(xlanguagelb, "English (USA)") - #other properties - xdecimalsed.executeAction("UP", tuple()) - xleadzerosed.executeAction("UP", tuple()) - xnegnumred.executeAction("CLICK", tuple()) - xthousands.executeAction("CLICK", tuple()) - #format #,#00.0;[RED]-#,#00.0 - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") - #save - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") - - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") - self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") - self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") - self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") - self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + #language + select_by_text(xlanguagelb, "English (USA)") + #other properties + xdecimalsed.executeAction("UP", tuple()) + xleadzerosed.executeAction("UP", tuple()) + xnegnumred.executeAction("CLICK", tuple()) + xthousands.executeAction("CLICK", tuple()) + #format #,#00.0;[RED]-#,#00.0 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + #save + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") + self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") + self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + def test_format_cell_font_tab(self): #numberingformatpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font - xSizeFont = xDialog.getChild("westsizelb-cjk") - xSizeFontEast = xDialog.getChild("eastsizelb") - xSizeFontCTL = xDialog.getChild("ctlsizelb") - xLangFont = xDialog.getChild("westlanglb-cjk") - xLangFontEast = xDialog.getChild("eastlanglb") - xLangFontCTL = xDialog.getChild("ctllanglb") - - xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 - select_pos(xLangFont, "0") - select_pos(xLangFontEast, "0") - select_pos(xLangFontCTL, "0") - - #Verify - select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font - xSizeFont = xDialog.getChild("westsizelb-cjk") - xSizeFontEast = xDialog.getChild("eastsizelb") - xSizeFontCTL = xDialog.getChild("ctlsizelb") - xLangFont = xDialog.getChild("westlanglb-cjk") - xLangFontEast = xDialog.getChild("eastlanglb") - xLangFontCTL = xDialog.getChild("ctllanglb") - - self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") - self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") - self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size - self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") - self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]") - self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + select_pos(xLangFont, "0") + select_pos(xLangFontEast, "0") + select_pos(xLangFontCTL, "0") + + #Verify - select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size + self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]") + + def test_format_cell_font_effects_tab(self): #numberingformatpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") #tab Font Effects - xRelief = xDialog.getChild("relieflb") - xOverline = xDialog.getChild("overlinelb") - xStrikeout = xDialog.getChild("strikeoutlb") - xUnderline = xDialog.getChild("underlinelb") - xEmphasis = xDialog.getChild("emphasislb") - xPosition = xDialog.getChild("positionlb") - - select_pos(xRelief, "1") - select_pos(xOverline, "1") - select_pos(xStrikeout, "1") - select_pos(xUnderline, "1") - select_pos(xEmphasis, "1") - select_pos(xPosition, "1") - - #Verify- select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - - xRelief = xDialog.getChild("relieflb") - xOverline = xDialog.getChild("overlinelb") - xStrikeout = xDialog.getChild("strikeoutlb") - xUnderline = xDialog.getChild("underlinelb") - xEmphasis = xDialog.getChild("emphasislb") - xPosition = xDialog.getChild("positionlb") - - self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") - self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") - self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") - self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Font Effects + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + select_pos(xRelief, "1") + select_pos(xOverline, "1") + select_pos(xStrikeout, "1") + select_pos(xUnderline, "1") + select_pos(xEmphasis, "1") + select_pos(xPosition, "1") + + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") + self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") + self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") + + def test_format_cell_alignment_tab(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") #tab Alignment - comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") - xspinIndentFrom = xDialog.getChild("spinIndentFrom") - xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") - xcheckVertStack = xDialog.getChild("checkVertStack") - xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") - xcheckHyphActive = xDialog.getChild("checkHyphActive") - xcomboTextDirBox = xDialog.getChild("comboTextDirBox") - - select_by_text(comboboxHorzAlign, "Left") - xspinIndentFrom.executeAction("UP", tuple()) - indentVal = get_state_as_dict(xspinIndentFrom)["Text"] - select_by_text(xcomboboxVertAlign, "Top") - xcheckVertStack.executeAction("CLICK", tuple()) - xcheckWrapTextAuto.executeAction("CLICK", tuple()) - xcheckHyphActive.executeAction("CLICK", tuple()) - select_by_text(xcomboTextDirBox, "Left-to-right (LTR)") - #Verify- select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") - comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") - xspinIndentFrom = xDialog.getChild("spinIndentFrom") - xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") - xcheckVertStack = xDialog.getChild("checkVertStack") - xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") - xcheckHyphActive = xDialog.getChild("checkHyphActive") - xcomboTextDirBox = xDialog.getChild("comboTextDirBox") - - self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") - self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) - self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") - self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") - self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + select_by_text(comboboxHorzAlign, "Left") + xspinIndentFrom.executeAction("UP", tuple()) + indentVal = get_state_as_dict(xspinIndentFrom)["Text"] + select_by_text(xcomboboxVertAlign, "Top") + xcheckVertStack.executeAction("CLICK", tuple()) + xcheckWrapTextAuto.executeAction("CLICK", tuple()) + xcheckHyphActive.executeAction("CLICK", tuple()) + select_by_text(xcomboTextDirBox, "Left-to-right (LTR)") + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") + self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) + self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") + self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") + def test_format_cell_asian_typography_tab(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "4") #tab Asian typography - xcheckForbidList = xDialog.getChild("checkForbidList") - xcheckForbidList.executeAction("CLICK", tuple()) - #Verify- select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "4") - xcheckForbidList = xDialog.getChild("checkForbidList") - self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Asian typography + xcheckForbidList = xDialog.getChild("checkForbidList") + xcheckForbidList.executeAction("CLICK", tuple()) + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + xcheckForbidList = xDialog.getChild("checkForbidList") + self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") + def test_minimal_border_width(self): #borderpage.ui, tdf#137790 - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #set points pt measurement - change_measurement_unit(self, "Point") - - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - - linewidthmf = xDialog.getChild("linewidthmf") - xLineSet = xDialog.getChild('lineset') - - # check line-width for default solid line - self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '0.75 pt') - - # set line style to "double" (minimal width is taken) - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.10 pt') - - # set line style to "solid" - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '0.75 pt') - - # make custom line width - linewidthmf.executeAction("UP", tuple()) - linewidthmf.executeAction("UP", tuple()) - linewidthmf.executeAction("UP", tuple()) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.50 pt') - - # set line style to "double" (minimal width is not taken) - xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) - widthVal = get_state_as_dict(linewidthmf)["Text"] - self.assertEqual(widthVal, '1.50 pt') - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #set points pt measurement + change_measurement_unit(self, "Point") + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + + linewidthmf = xDialog.getChild("linewidthmf") + xLineSet = xDialog.getChild('lineset') + + # check line-width for default solid line + self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # set line style to "double" (minimal width is taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.10 pt') + + # set line style to "solid" + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # make custom line width + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.50 pt') + + # set line style to "double" (minimal width is not taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.50 pt') + + def test_format_cell_borders_tab(self): #borderpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #set points pt measurement - change_measurement_unit(self, "Point") - - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - xsync = xDialog.getChild("sync") - xleftmf = xDialog.getChild("leftmf") - xrightmf = xDialog.getChild("rightmf") - xtopmf = xDialog.getChild("topmf") - xbottommf = xDialog.getChild("bottommf") - - xsync.executeAction("CLICK", tuple()) #uncheck Synchronize - xleftmf.executeAction("UP", tuple()) - xrightmf.executeAction("UP", tuple()) - xrightmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xtopmf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - xbottommf.executeAction("UP", tuple()) - - leftVal = get_state_as_dict(xleftmf)["Text"] - rightVal = get_state_as_dict(xrightmf)["Text"] - topVal = get_state_as_dict(xtopmf)["Text"] - bottomVal = get_state_as_dict(xbottommf)["Text"] - - - # Verify select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") #tab Borders - xsync = xDialog.getChild("sync") - xleftmf = xDialog.getChild("leftmf") - xrightmf = xDialog.getChild("rightmf") - xtopmf = xDialog.getChild("topmf") - xbottommf = xDialog.getChild("bottommf") - - self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") - self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) - self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) - self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) - self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #set points pt measurement + change_measurement_unit(self, "Point") + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + xsync.executeAction("CLICK", tuple()) #uncheck Synchronize + xleftmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + + leftVal = get_state_as_dict(xleftmf)["Text"] + rightVal = get_state_as_dict(xrightmf)["Text"] + topVal = get_state_as_dict(xtopmf)["Text"] + bottomVal = get_state_as_dict(xbottommf)["Text"] + + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") + self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) + self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) + self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) + self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) + + def test_format_cell_cell_protection_tab(self): #cellprotectionpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Cell protection - xcheckHideFormula = xDialog.getChild("checkHideFormula") - xcheckHideAll = xDialog.getChild("checkHideAll") - xcheckHidePrinting = xDialog.getChild("checkHidePrinting") - - xcheckHideFormula.executeAction("CLICK", tuple()) - xcheckHideAll.executeAction("CLICK", tuple()) - xcheckHidePrinting.executeAction("CLICK", tuple()) - - # Verify select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "6") #tab Borders - xcheckHideFormula = xDialog.getChild("checkHideFormula") - xcheckHideAll = xDialog.getChild("checkHideAll") - xcheckHidePrinting = xDialog.getChild("checkHidePrinting") - - self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") - self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") - self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Cell protection + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + xcheckHideFormula.executeAction("CLICK", tuple()) + xcheckHideAll.executeAction("CLICK", tuple()) + xcheckHidePrinting.executeAction("CLICK", tuple()) + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Borders + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") + + def test_tdf130762(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "3") #tab Alignment - xspinDegrees = xDialog.getChild("spinDegrees") - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") - xspinDegrees.executeAction("DOWN", tuple()) - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") - xspinDegrees.executeAction("UP", tuple()) - self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + xspinDegrees = xDialog.getChild("spinDegrees") + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + xspinDegrees.executeAction("DOWN", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") + xspinDegrees.executeAction("UP", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/mergedRowsColumns.py b/sc/qa/uitest/calc_tests/mergedRowsColumns.py index a33fb44c7580..bdb26fb5d6fd 100644 --- a/sc/qa/uitest/calc_tests/mergedRowsColumns.py +++ b/sc/qa/uitest/calc_tests/mergedRowsColumns.py @@ -160,18 +160,17 @@ class mergedRowsColumns(UITestCase): self.xUITest.executeCommand(".uno:Undo") def test_move_merged_cells(self): - self.ui_test.create_doc_in_start_center("calc") - xTopWindow = self.xUITest.getTopFocusWindow() - gridwin = xTopWindow.getChild("grid_window") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:C1"})) - self.xUITest.executeCommand(".uno:ToggleMergeCells") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) - self.xUITest.executeCommand(".uno:GoLeft") - self.xUITest.executeCommand(".uno:GoLeft") - self.assertEqual(get_state_as_dict(gridwin)["CurrentColumn"], "0") - self.assertEqual(get_state_as_dict(gridwin)["CurrentRow"], "0") #position A1 - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:C1"})) + self.xUITest.executeCommand(".uno:ToggleMergeCells") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + self.assertEqual(get_state_as_dict(gridwin)["CurrentColumn"], "0") + self.assertEqual(get_state_as_dict(gridwin)["CurrentRow"], "0") #position A1 + # 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 c58469e032e7..551a16997f6e 100644 --- a/sc/qa/uitest/calc_tests/printRange.py +++ b/sc/qa/uitest/calc_tests/printRange.py @@ -10,103 +10,99 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class printRange(UITestCase): def test_printRange(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) - #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) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #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) - #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) + #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) - #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) - self.ui_test.close_doc() + #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) def test_tdf33341_copy_sheet_with_print_range(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) - #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) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #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) - #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) + #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) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/rows.py b/sc/qa/uitest/calc_tests/rows.py index 37810b80241a..e5fd0cec18cf 100644 --- a/sc/qa/uitest/calc_tests/rows.py +++ b/sc/qa/uitest/calc_tests/rows.py @@ -11,191 +11,179 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class CalcRows(UITestCase): def test_row_height(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #row height - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected - heightStrOrig = get_state_as_dict(xvalue)["Text"] - heightVal = heightStrOrig[:4] #default 0.45 cm - xvalue.executeAction("UP", tuple()) #0.50 cm - heightStr = get_state_as_dict(xvalue)["Text"] - heightValNew = heightStr[:4] - self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected - self.assertEqual(heightValNew > heightVal, True) #new value is bigger - xdefault.executeAction("CLICK", tuple()) #click default - self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #verify - with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 0.45 cm + xvalue.executeAction("UP", tuple()) #0.50 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_row_height_two_rows(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) - - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - xdefault = xDialog.getChild("default") - #write your own value - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) + + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_tdf89140_row_height_copy(self): #Bug 89140 - Calc row paste doesn't keep row height - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #row height - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #select row 1 - self.xUITest.executeCommand(".uno:SelectRow") - #copy - self.xUITest.executeCommand(".uno:Copy") - #select A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #paste - self.xUITest.executeCommand(".uno:Paste") - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select row 1 + self.xUITest.executeCommand(".uno:SelectRow") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + def test_row_hide_show(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.xUITest.executeCommand(".uno:HideRow") #uno command moves focus one cell down - #verify A4 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) - #verify A2 (row 3 is hidden) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "1") - #Show hidden row: select A2:A4 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A4"})) - self.xUITest.executeCommand(".uno:ShowRow") - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) - #verify A3 (row 3 is not hidden) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:HideRow") #uno command moves focus one cell down + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 (row 3 is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + #Show hidden row: select A2:A4 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A4"})) + self.xUITest.executeCommand(".uno:ShowRow") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A3 (row 3 is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + def test_row_test_move(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - #down - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) - #verify A4 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) - #verify A2 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + #down + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + def test_row_height_insert_below(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - change_measurement_unit(self, "Centimeter") - - #select A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #row height - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) - # Click Ok - #select row 3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - self.xUITest.executeCommand(".uno:SelectRow") - #insert rows below - self.xUITest.executeCommand(".uno:InsertRowsAfter") - - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) - with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: - xvalue = xDialog.getChild("value") - self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select row 3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:SelectRow") + #insert rows below + self.xUITest.executeCommand(".uno:InsertRowsAfter") + + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.0001 cm") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/sheetRename.py b/sc/qa/uitest/calc_tests/sheetRename.py index 41d28583da02..3cfa751bad30 100644 --- a/sc/qa/uitest/calc_tests/sheetRename.py +++ b/sc/qa/uitest/calc_tests/sheetRename.py @@ -10,43 +10,39 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class sheetRename(UITestCase): def test_sheet_rename(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: - xname_entry = xDialog.getChild("name_entry") - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) - #Verify - with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="cancel") as xDialog: - xname_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + #Verify + with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="cancel") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") - self.ui_test.close_doc() def test_sheet_rename_invalid_sheet_name(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="") as xDialog: - xname_entry = xDialog.getChild("name_entry") - nameVal = get_state_as_dict(xname_entry)["Text"] - xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) - xOKBtn = xDialog.getChild("ok") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="") as xDialog: + xname_entry = xDialog.getChild("name_entry") + nameVal = get_state_as_dict(xname_entry)["Text"] + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) + xOKBtn = xDialog.getChild("ok") - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ())): - pass + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ())): + pass - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - #Verify - with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: - xname_entry = xDialog.getChild("name_entry") - self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) + #Verify + with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) - self.ui_test.close_doc() # def test_tdf81431_rename_sheet_clipboard_content_wiped_out(self): # calc_doc = self.ui_test.create_doc_in_start_center("calc") diff --git a/sc/qa/uitest/calc_tests/zoom.py b/sc/qa/uitest/calc_tests/zoom.py index 6a0fd1670e06..5e1e62c047ae 100644 --- a/sc/qa/uitest/calc_tests/zoom.py +++ b/sc/qa/uitest/calc_tests/zoom.py @@ -11,47 +11,46 @@ from uitest.uihelper.common import get_state_as_dict class calcZoom(UITestCase): def test_zoom_calc(self): - MainDoc = self.ui_test.create_doc_in_start_center("calc") - MainWindow = self.xUITest.getTopFocusWindow() - gridwin = MainWindow.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - #Set the Zoom to be 100% - gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "100"})) - self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") - - #dialog View-Zoom-Zoom - with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: - - #select fit weight & height - OK - open and verify - fitwandh = xDialog.getChild("fitwandh") - fitwandh.executeAction("CLICK",tuple()) - - with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: - #select fit weight - OK - open and verify - fitw = xDialog.getChild("fitw") - fitw.executeAction("CLICK",tuple()) - - with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: - #select 100% & Automatic - OK - open and verify - x100pc = xDialog.getChild("100pc") - x100pc.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") - - #Set the Zoom to be 103% - gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "103"})) - self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "103") - - with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: - #select variable option and make zoom 100% again - OK - open and verify - zoomsb = xDialog.getChild("zoomsb") - self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%") - zoomsb.executeAction("DOWN",tuple()) - zoomsb.executeAction("DOWN",tuple()) - zoomsb.executeAction("DOWN",tuple()) - self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + MainWindow = self.xUITest.getTopFocusWindow() + gridwin = MainWindow.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Set the Zoom to be 100% + gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "100"})) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + + #dialog View-Zoom-Zoom + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + + #select fit weight & height - OK - open and verify + fitwandh = xDialog.getChild("fitwandh") + fitwandh.executeAction("CLICK",tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select fit weight - OK - open and verify + fitw = xDialog.getChild("fitw") + fitw.executeAction("CLICK",tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select 100% & Automatic - OK - open and verify + x100pc = xDialog.getChild("100pc") + x100pc.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + + #Set the Zoom to be 103% + gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "103"})) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "103") + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select variable option and make zoom 100% again - OK - open and verify + zoomsb = xDialog.getChild("zoomsb") + self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%") + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/dataform.py b/sc/qa/uitest/calc_tests2/dataform.py index 617abfc73932..3c1b3d699217 100644 --- a/sc/qa/uitest/calc_tests2/dataform.py +++ b/sc/qa/uitest/calc_tests2/dataform.py @@ -9,15 +9,14 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class dataform(UITestCase): def test_dataform(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) - with self.ui_test.execute_dialog_through_command(".uno:DataForm", close_button="close"): - pass + with self.ui_test.execute_dialog_through_command(".uno:DataForm", close_button="close"): + pass - self.ui_test.close_doc() # 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 dccf669d1e39..41d481e880c0 100644 --- a/sc/qa/uitest/calc_tests2/standardFilter.py +++ b/sc/qa/uitest/calc_tests2/standardFilter.py @@ -133,554 +133,536 @@ class standardFilter(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 1, 7, 2).getValue(), 4) def test_standard_filter_case_sensitive(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "first") - enter_text_to_cell(gridwin, "B1", "second") - enter_text_to_cell(gridwin, "A2", "a1") - enter_text_to_cell(gridwin, "A3", "A1") - enter_text_to_cell(gridwin, "A4", "A1") - enter_text_to_cell(gridwin, "B2", "4") - 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) - #2x down - should be on row 5 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "4") - #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) - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "a1") + enter_text_to_cell(gridwin, "A3", "A1") + enter_text_to_cell(gridwin, "A4", "A1") + enter_text_to_cell(gridwin, "B2", "4") + 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) + #2x down - should be on row 5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #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) def test_standard_filter_regular_expression(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "first") - enter_text_to_cell(gridwin, "B1", "second") - enter_text_to_cell(gridwin, "A2", "aa") - enter_text_to_cell(gridwin, "A3", "aaa") - enter_text_to_cell(gridwin, "A4", "abbb") - enter_text_to_cell(gridwin, "A5", "accc") - enter_text_to_cell(gridwin, "A6", "a*") - enter_text_to_cell(gridwin, "B2", "1") - enter_text_to_cell(gridwin, "B3", "2") - enter_text_to_cell(gridwin, "B4", "3") - 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) - #3x down - should be on row 7 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "6") - #reopen filter and verify - 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) - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + 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) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + 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) def test_standard_filter_condition_contains(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "first") - enter_text_to_cell(gridwin, "B1", "second") - enter_text_to_cell(gridwin, "A2", "aa") - enter_text_to_cell(gridwin, "A3", "aaa") - enter_text_to_cell(gridwin, "A4", "abbb") - enter_text_to_cell(gridwin, "A5", "accc") - enter_text_to_cell(gridwin, "A6", "a*") - enter_text_to_cell(gridwin, "B2", "1") - enter_text_to_cell(gridwin, "B3", "2") - enter_text_to_cell(gridwin, "B4", "3") - 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) - #3x down - should be on row 7 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "6") - #reopen filter and verify - 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) - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + 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) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + 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) #from testcasespecification OOo def test_standard_filter_condition_contains2(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,3, 4 are visible (2 and 5 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - #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) - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #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) def test_standard_filter_condition_does_not_contains(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,2, 5 are visible (3 and 4 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "1") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "4") - #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) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #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) + def test_standard_filter_condition_Begins_with(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,3, 4 are visible (2 and 5 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - #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) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #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) + def test_standard_filter_condition_Does_not_begin_with(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,2, 5 are visible (3 and 4 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "1") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "4") - #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) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #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) + def test_standard_filter_condition_Ends_with(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,2, 5 are visible (3 and 4 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "1") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "4") - #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) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #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) + def test_standard_filter_condition_Does_not_end_with(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - enter_text_to_cell(gridwin, "C1", "C") - enter_text_to_cell(gridwin, "D1", "D") - enter_text_to_cell(gridwin, "A2", "economics") - enter_text_to_cell(gridwin, "B2", "34") - enter_text_to_cell(gridwin, "C2", "67") - enter_text_to_cell(gridwin, "D2", "122") - enter_text_to_cell(gridwin, "A3", "socioeconomic") - enter_text_to_cell(gridwin, "B3", "45") - enter_text_to_cell(gridwin, "C3", "77") - enter_text_to_cell(gridwin, "D3", "333") - enter_text_to_cell(gridwin, "A4", "sociology") - enter_text_to_cell(gridwin, "B4", "78") - enter_text_to_cell(gridwin, "C4", "89") - enter_text_to_cell(gridwin, "D4", "56") - enter_text_to_cell(gridwin, "A5", "humanities") - enter_text_to_cell(gridwin, "B5", "45") - enter_text_to_cell(gridwin, "C5", "67") - enter_text_to_cell(gridwin, "D5", "89") - #Select - 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) - - #Verify that row 1,3, 4 are visible (2 and 5 are hidden) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "2") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["CurrentRow"], "3") - #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) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + 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) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #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) + # 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 a226427311ee..fe4cfe40b056 100644 --- a/sc/qa/uitest/calc_tests2/tdf104117.py +++ b/sc/qa/uitest/calc_tests2/tdf104117.py @@ -12,36 +12,34 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #Bug 104117 - Crash in Calc when selecting "Uniform Integer" with an max value "100000000000000" in "Random Number Generator class tdf104117(UITestCase): def test_tdf104117(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - 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.create_doc_in_start_center_guarded("calc") as document: + 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") - 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) - #undo - self.xUITest.executeCommand(".uno:Undo") - 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) - self.ui_test.close_doc() + 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) + #undo + self.xUITest.executeCommand(".uno:Undo") + 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_tests2/tdf117367.py b/sc/qa/uitest/calc_tests2/tdf117367.py index 6295ce8781a7..7dec2a2005c8 100644 --- a/sc/qa/uitest/calc_tests2/tdf117367.py +++ b/sc/qa/uitest/calc_tests2/tdf117367.py @@ -12,38 +12,36 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf117367(UITestCase): def test_tdf117367_merge_cells_radio_buttons(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "AAA") - enter_text_to_cell(gridwin, "A2", "BBB") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) - - #Right-click - Merge cells /Select all three options - with self.ui_test.execute_dialog_through_command(".uno:MergeCells") as xDialog: - xmoveCellsRadio = xDialog.getChild("move-cells-radio") - xemptyCellsRadio = xDialog.getChild("empty-cells-radio") - xkeepContentRadio = xDialog.getChild("keep-content-radio") - xmoveCellsRadio.executeAction("CLICK", tuple()) - xmoveCellsRadio.executeAction("CLICK", tuple()) - #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") - - xemptyCellsRadio.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") - - xkeepContentRadio.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") - self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + + #Right-click - Merge cells /Select all three options + with self.ui_test.execute_dialog_through_command(".uno:MergeCells") as xDialog: + xmoveCellsRadio = xDialog.getChild("move-cells-radio") + xemptyCellsRadio = xDialog.getChild("empty-cells-radio") + xkeepContentRadio = xDialog.getChild("keep-content-radio") + xmoveCellsRadio.executeAction("CLICK", tuple()) + xmoveCellsRadio.executeAction("CLICK", tuple()) + #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xemptyCellsRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xkeepContentRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf120174.py b/sc/qa/uitest/calc_tests2/tdf120174.py index 752d276c5db5..31e2556141a8 100644 --- a/sc/qa/uitest/calc_tests2/tdf120174.py +++ b/sc/qa/uitest/calc_tests2/tdf120174.py @@ -11,20 +11,18 @@ from uitest.uihelper.calc import enter_text_to_cell class tdf120174(UITestCase): def test_tdf120174(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "121") - enter_text_to_cell(gridwin, "B1", "=A1") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - # Delete contents of A1 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) - # Before the fix the result would be still 121. - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) # B1 - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "121") + enter_text_to_cell(gridwin, "B1", "=A1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Delete contents of A1 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + # Before the fix the result would be still 121. + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) # B1 + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf126577.py b/sc/qa/uitest/calc_tests2/tdf126577.py index 8eef03b9c070..a579b7b24930 100644 --- a/sc/qa/uitest/calc_tests2/tdf126577.py +++ b/sc/qa/uitest/calc_tests2/tdf126577.py @@ -12,33 +12,31 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf126577(UITestCase): def test_tdf126577(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) - with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: - self.assertEqual("true", get_state_as_dict(xDialog.getChild("down"))['Checked']) - self.assertEqual("true", get_state_as_dict(xDialog.getChild("linear"))['Checked']) + self.assertEqual("true", get_state_as_dict(xDialog.getChild("down"))['Checked']) + self.assertEqual("true", get_state_as_dict(xDialog.getChild("linear"))['Checked']) - xStart = xDialog.getChild("startValue") - xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xEnd = xDialog.getChild("endValue") - xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) + xEnd = xDialog.getChild("endValue") + xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) - for i in range(10): - self.assertEqual(str(i + 1), get_cell_by_position(document, 0, 0, i).getString()) + for i in range(10): + self.assertEqual(str(i + 1), get_cell_by_position(document, 0, 0, i).getString()) - for i in range(10, 20): - # Without the fix in place, this test would have failed with - # AssertionError: '' != '#NUM!' - self.assertEqual("", get_cell_by_position(document, 0, 0, i).getString()) + for i in range(10, 20): + # Without the fix in place, this test would have failed with + # AssertionError: '' != '#NUM!' + self.assertEqual("", get_cell_by_position(document, 0, 0, i).getString()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf46138.py b/sc/qa/uitest/calc_tests2/tdf46138.py index ed05962467f6..eeb9ae33b4e2 100644 --- a/sc/qa/uitest/calc_tests2/tdf46138.py +++ b/sc/qa/uitest/calc_tests2/tdf46138.py @@ -11,21 +11,19 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf46138(UITestCase): def test_tdf46138(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #Choose a column, - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:SelectColumn") - #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", - with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: - xStart = xDialog.getChild("startValue") - xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") - #then "Ctrl+Z"/ undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #Choose a column, + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + #then "Ctrl+Z"/ undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf51700.py b/sc/qa/uitest/calc_tests2/tdf51700.py index 172705b6c57e..fda6d4eda5fb 100644 --- a/sc/qa/uitest/calc_tests2/tdf51700.py +++ b/sc/qa/uitest/calc_tests2/tdf51700.py @@ -13,39 +13,37 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf51700(UITestCase): def test_tdf51700_text_to_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #Add data - enter_text_to_cell(gridwin, "A2", "3242,43242,3242,2342") - enter_text_to_cell(gridwin, "A3", "fdsfa,afsdfa,adfdas,fsad") - enter_text_to_cell(gridwin, "A4", "21312,1111,1111,111") - #select column A - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:SelectColumn") - # Data - Text to Columns - with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: - xcomma = xDialog.getChild("comma") - if (get_state_as_dict(xcomma)["Selected"]) == "false": - xcomma.executeAction("CLICK", tuple()) - # Click Ok + #Add data + enter_text_to_cell(gridwin, "A2", "3242,43242,3242,2342") + enter_text_to_cell(gridwin, "A3", "fdsfa,afsdfa,adfdas,fsad") + enter_text_to_cell(gridwin, "A4", "21312,1111,1111,111") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + # Data - Text to Columns + with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: + xcomma = xDialog.getChild("comma") + if (get_state_as_dict(xcomma)["Selected"]) == "false": + xcomma.executeAction("CLICK", tuple()) + # Click Ok - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") - self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) - self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") - self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/clearCells.py b/sc/qa/uitest/calc_tests3/clearCells.py index 49cd1dab059c..ce5a8b984d8e 100644 --- a/sc/qa/uitest/calc_tests3/clearCells.py +++ b/sc/qa/uitest/calc_tests3/clearCells.py @@ -14,271 +14,257 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #+ Bug 101904 - Delete Contents dialog -- won't delete cell content "Date & time" class clearCells(UITestCase): def test_clear_cells_text(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "aa") - enter_text_to_cell(gridwin, "A2", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "false": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "false": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + def test_clear_cells_date_tdf101904(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "01/01/2000") - enter_text_to_cell(gridwin, "A2", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "false": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "01/01/2000") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "false": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + def test_clear_cells_number(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "aa") - enter_text_to_cell(gridwin, "A2", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "false": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "false": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0) + def test_clear_cells_formulas(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "=A1+1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "false": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "true": - xformats.executeAction("CLICK", tuple()) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "=A1+1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "false": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + def test_clear_cells_formats(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "aa") - enter_text_to_cell(gridwin, "A2", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.xUITest.executeCommand(".uno:Bold") - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "true": - xdeleteall.executeAction("CLICK", tuple()) - if (get_state_as_dict(xtext)["Selected"]) == "true": - xtext.executeAction("CLICK", tuple()) - if (get_state_as_dict(xdatetime)["Selected"]) == "true": - xdatetime.executeAction("CLICK", tuple()) - if (get_state_as_dict(xcomments)["Selected"]) == "true": - xcomments.executeAction("CLICK", tuple()) - if (get_state_as_dict(xobjects)["Selected"]) == "true": - xobjects.executeAction("CLICK", tuple()) - if (get_state_as_dict(xnumbers)["Selected"]) == "true": - xnumbers.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformulas)["Selected"]) == "true": - xformulas.executeAction("CLICK", tuple()) - if (get_state_as_dict(xformats)["Selected"]) == "false": - xformats.executeAction("CLICK", tuple()) - - #Verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") #tab Font - - xstylelb = xDialog.getChild("weststylelb-cjk") - print(get_state_as_dict(xstylelb)) - - - self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "false": + xformats.executeAction("CLICK", tuple()) + + #Verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + + xstylelb = xDialog.getChild("weststylelb-cjk") + print(get_state_as_dict(xstylelb)) + + + self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") + + def test_clear_cells_all(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "aa") - enter_text_to_cell(gridwin, "A2", "1") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - self.xUITest.executeCommand(".uno:Bold") - with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: - xdeleteall = xDialog.getChild("deleteall") - xtext = xDialog.getChild("text") - xdatetime = xDialog.getChild("datetime") - xcomments = xDialog.getChild("comments") - xobjects = xDialog.getChild("objects") - xnumbers = xDialog.getChild("numbers") - xformulas = xDialog.getChild("formulas") - xformats = xDialog.getChild("formats") - - if (get_state_as_dict(xdeleteall)["Selected"]) == "false": - xdeleteall.executeAction("CLICK", tuple()) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + def test_cancel_clear_cells_all(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "aa") - enter_text_to_cell(gridwin, "A2", "1") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Delete", close_button="cancel") as xDialog: - xdeleteall = xDialog.getChild("deleteall") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete", close_button="cancel") as xDialog: + xdeleteall = xDialog.getChild("deleteall") - if (get_state_as_dict(xdeleteall)["Selected"]) == "false": - xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "1") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py index 65aaf55b2bf2..ea5837199218 100644 --- a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py +++ b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py @@ -11,61 +11,57 @@ from com.sun.star.lang import IndexOutOfBoundsException class insertQrCode(UITestCase): def test_insert_qr_code_gen(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # cancel the dialog without doing anything - with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode", close_button="cancel") as xDialog: + # cancel the dialog without doing anything + with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode", close_button="cancel") as xDialog: - xURL = xDialog.getChild("edit_text") - type_text(xURL, "www.libreoffice.org") + xURL = xDialog.getChild("edit_text") + type_text(xURL, "www.libreoffice.org") - with self.assertRaises(IndexOutOfBoundsException): - document.Sheets.getByIndex(0).DrawPage.getByIndex(0) + with self.assertRaises(IndexOutOfBoundsException): + document.Sheets.getByIndex(0).DrawPage.getByIndex(0) - # Reopen the dialog box - with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") as xDialog: + # Reopen the dialog box + with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") as xDialog: - # Get elements in the Dialog Box - xURL = xDialog.getChild("edit_text") - xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. - xBorder = xDialog.getChild("edit_margin") + # Get elements in the Dialog Box + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. + xBorder = xDialog.getChild("edit_margin") - type_text(xURL, "www.libreoffice.org") #set the QR code - xECC_Low.executeAction("CLICK", tuple()) - xBorder.executeAction("UP", tuple()) - xBorder.executeAction("DOWN", tuple()) + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) - # check the QR code in the document - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) + # check the QR code in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) - self.ui_test.close_doc() def test_insert_qr_code_gen2(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") as xDialog: - xURL = xDialog.getChild("edit_text") - xECC_Low = xDialog.getChild("button_low") - xBorder = xDialog.getChild("edit_margin") + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") + xBorder = xDialog.getChild("edit_margin") - type_text(xURL, "www.libreoffice.org") #set the QR code - xECC_Low.executeAction("CLICK", tuple()) - xBorder.executeAction("UP", tuple()) - xBorder.executeAction("DOWN", tuple()) + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) - #check the QR Code in the document - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) + #check the QR Code in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf69450.py b/sc/qa/uitest/calc_tests3/tdf69450.py index 615aa96497a3..92c50e594dcd 100644 --- a/sc/qa/uitest/calc_tests3/tdf69450.py +++ b/sc/qa/uitest/calc_tests3/tdf69450.py @@ -12,43 +12,41 @@ from libreoffice.calc.document import get_cell_by_position class tdf69450(UITestCase): def test_tdf69450(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #add text to A1 and B1 - enter_text_to_cell(gridwin, "A1", "A") - enter_text_to_cell(gridwin, "B1", "B") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:Copy") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog: - - xtext = xDialog.getChild("text") - xnumbers = xDialog.getChild("numbers") - xdatetime = xDialog.getChild("datetime") - xformats = xDialog.getChild("formats") - - xtext.executeAction("CLICK", tuple()) - xnumbers.executeAction("CLICK", tuple()) - xdatetime.executeAction("CLICK", tuple()) - xformats.executeAction("CLICK", tuple()) - - - #check B1 text - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - self.xUITest.executeCommand(".uno:Bold") - self.xUITest.executeCommand(".uno:Copy") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial"): - pass - - #check B1 text - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #add text to A1 and B1 + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog: + + xtext = xDialog.getChild("text") + xnumbers = xDialog.getChild("numbers") + xdatetime = xDialog.getChild("datetime") + xformats = xDialog.getChild("formats") + + xtext.executeAction("CLICK", tuple()) + xnumbers.executeAction("CLICK", tuple()) + xdatetime.executeAction("CLICK", tuple()) + xformats.executeAction("CLICK", tuple()) + + + #check B1 text + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + self.xUITest.executeCommand(".uno:Bold") + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial"): + pass + + #check B1 text + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf73006.py b/sc/qa/uitest/calc_tests3/tdf73006.py index 0dfd743a24ee..33df2d49f3ef 100644 --- a/sc/qa/uitest/calc_tests3/tdf73006.py +++ b/sc/qa/uitest/calc_tests3/tdf73006.py @@ -13,27 +13,25 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf73006(UITestCase): def test_tdf73006_text_to_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #Add data - enter_text_to_cell(gridwin, "A2", "A B") - #select column A - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:SelectColumn") - # Data - Text to Columns - with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: - xspace = xDialog.getChild("space") - if (get_state_as_dict(xspace)["Selected"]) == "false": - xspace.executeAction("CLICK", tuple()) - # Click Ok + #Add data + enter_text_to_cell(gridwin, "A2", "A B") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + # Data - Text to Columns + with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: + xspace = xDialog.getChild("space") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + # Click Ok - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf79983.py b/sc/qa/uitest/calc_tests3/tdf79983.py index 347786e5a27f..28a864ac7ad8 100644 --- a/sc/qa/uitest/calc_tests3/tdf79983.py +++ b/sc/qa/uitest/calc_tests3/tdf79983.py @@ -13,54 +13,52 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf79983(UITestCase): def test_tdf79983_sort_list_case_sensitive(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "AAA") - enter_text_to_cell(gridwin, "A2", "BBB") - enter_text_to_cell(gridwin, "A3", "CCC") - enter_text_to_cell(gridwin, "A4", "DDD") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + enter_text_to_cell(gridwin, "A3", "CCC") + enter_text_to_cell(gridwin, "A4", "DDD") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - #Tools / Options / LibreOffice Calc / Sort Lists - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + #Tools / Options / LibreOffice Calc / Sort Lists + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcSortEntry = xCalcEntry.getChild('5') - xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List - #copy new list from selected cells - xcopy = xDialogOpt.getChild("copy") - xcopy.executeAction("CLICK", tuple()) + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcSortEntry = xCalcEntry.getChild('5') + xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List + #copy new list from selected cells + xcopy = xDialogOpt.getChild("copy") + xcopy.executeAction("CLICK", tuple()) - self.assertEqual("AAA\nBBB\nCCC\nDDD", get_state_as_dict(xDialogOpt.getChild("entries"))['Text']) + self.assertEqual("AAA\nBBB\nCCC\nDDD", get_state_as_dict(xDialogOpt.getChild("entries"))['Text']) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) - enter_text_to_cell(gridwin, "A1", "AAA") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - #fill down - with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: - xautofill = xDialog.getChild("autofill") - xautofill.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "CCC") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "DDD") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "") + enter_text_to_cell(gridwin, "A1", "AAA") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #fill down + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "CCC") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "DDD") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf80693.py b/sc/qa/uitest/calc_tests3/tdf80693.py index 8b16978c95f9..bf8b08d76688 100644 --- a/sc/qa/uitest/calc_tests3/tdf80693.py +++ b/sc/qa/uitest/calc_tests3/tdf80693.py @@ -12,40 +12,38 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #Bug 80693 - EDITING: fill cell with random numbers with min = max class tdf80693(UITestCase): def test_tdf80693_random_numbers_min_max(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - 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.create_doc_in_start_center_guarded("calc") as document: + 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") - 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) - #undo - self.xUITest.executeCommand(".uno:Undo") - 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) - self.ui_test.close_doc() + 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) + #undo + self.xUITest.executeCommand(".uno:Undo") + 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_tests3/tdf82398.py b/sc/qa/uitest/calc_tests3/tdf82398.py index c5d453476874..677b137ace13 100644 --- a/sc/qa/uitest/calc_tests3/tdf82398.py +++ b/sc/qa/uitest/calc_tests3/tdf82398.py @@ -13,47 +13,45 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf82398(UITestCase): def test_tdf82398_text_to_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #Add data - enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") - enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") - enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") - enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") - #select column A1:A4 / .uno:NumberFormatDate - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - self.xUITest.executeCommand(".uno:NumberFormatDate") - # Data - Text to Columns - with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") + #Add data + enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") + enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") + enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") + enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") + #select column A1:A4 / .uno:NumberFormatDate + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + self.xUITest.executeCommand(".uno:NumberFormatDate") + # Data - Text to Columns + with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) - # Click Ok + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") - self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") - self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") - self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) - self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") - self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf88999.py b/sc/qa/uitest/calc_tests4/tdf88999.py index e04957336609..7686ef9e1270 100644 --- a/sc/qa/uitest/calc_tests4/tdf88999.py +++ b/sc/qa/uitest/calc_tests4/tdf88999.py @@ -14,33 +14,31 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf88999(UITestCase): def test_tdf88999_scientific_format_decimal_value(self): #numberingformatpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "1e-2") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1e-2") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") - self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") - self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") - self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") + self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf89907.py b/sc/qa/uitest/calc_tests4/tdf89907.py index a88250a6a8a9..18e532432274 100644 --- a/sc/qa/uitest/calc_tests4/tdf89907.py +++ b/sc/qa/uitest/calc_tests4/tdf89907.py @@ -13,48 +13,46 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf89907(UITestCase): def test_tdf89907_text_to_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #Add data - enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") - enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") - enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") - enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") - #select column A - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:SelectColumn") - #Optimal Width - self.xUITest.executeCommand(".uno:SetOptimalColumnWidthDirect") - # Data - Text to Columns - with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: - xother = xDialog.getChild("other") - xinputother = xDialog.getChild("inputother") - if (get_state_as_dict(xother)["Selected"]) == "false": - xother.executeAction("CLICK", tuple()) - xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) - # Click Ok + #Add data + enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") + enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") + enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") + enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #Optimal Width + self.xUITest.executeCommand(".uno:SetOptimalColumnWidthDirect") + # Data - Text to Columns + with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") - self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") - self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") - self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) - self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") - self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf92423.py b/sc/qa/uitest/calc_tests4/tdf92423.py index c282895fd1cf..e20c4973af28 100644 --- a/sc/qa/uitest/calc_tests4/tdf92423.py +++ b/sc/qa/uitest/calc_tests4/tdf92423.py @@ -13,55 +13,53 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf92423(UITestCase): def test_tdf92423_text_to_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xWriterEntry = xPages.getChild('3') # Calc - xWriterEntry.executeAction("EXPAND", tuple()) - xWriterGeneralEntry = xWriterEntry.getChild('0') - xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb - xreplwarncb = xDialogOpt.getChild("replwarncb") - if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": - xreplwarncb.executeAction("CLICK", tuple()) - #enter data - enter_text_to_cell(gridwin, "A1", "1;2") - enter_text_to_cell(gridwin, "A2", "2;3") - enter_text_to_cell(gridwin, "A3", "3;4") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - #copy data - self.xUITest.executeCommand(".uno:Copy") - #move down - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - self.xUITest.executeCommand(".uno:GoDown") - #paste data, should be selected - self.xUITest.executeCommand(".uno:Paste") #A7:A9 - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A7:Sheet1.A9") - # Data - Text to Columns - with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: - xSemicolon = xDialog.getChild("semicolon") #check semicolon checkbox - if (get_state_as_dict(xSemicolon)["Selected"]) == "false": - xSemicolon.executeAction("CLICK", tuple()) - # Click Ok + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + #enter data + enter_text_to_cell(gridwin, "A1", "1;2") + enter_text_to_cell(gridwin, "A2", "2;3") + enter_text_to_cell(gridwin, "A3", "3;4") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + #copy data + self.xUITest.executeCommand(".uno:Copy") + #move down + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + #paste data, should be selected + self.xUITest.executeCommand(".uno:Paste") #A7:A9 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A7:Sheet1.A9") + # Data - Text to Columns + with self.ui_test.execute_dialog_through_command(".uno:TextToColumns") as xDialog: + xSemicolon = xDialog.getChild("semicolon") #check semicolon checkbox + if (get_state_as_dict(xSemicolon)["Selected"]) == "false": + xSemicolon.executeAction("CLICK", tuple()) + # Click Ok - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 2) - self.assertEqual(get_cell_by_position(document, 0, 0, 8).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 2) - self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 4) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 4) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf94208.py b/sc/qa/uitest/calc_tests4/tdf94208.py index 542b8a2daa91..cdb359fdf0bd 100644 --- a/sc/qa/uitest/calc_tests4/tdf94208.py +++ b/sc/qa/uitest/calc_tests4/tdf94208.py @@ -13,35 +13,33 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf94208(UITestCase): def test_tdf94208_Undo_fill_down_rows_selected(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - #1 - Fill data - enter_text_to_cell(gridwin, "A3", "Range") - enter_text_to_cell(gridwin, "A4", "Range") - enter_text_to_cell(gridwin, "A5", "Range") - enter_text_to_cell(gridwin, "A6", "Range") - enter_text_to_cell(gridwin, "A7", "Range") - enter_text_to_cell(gridwin, "A8", "Range") - enter_text_to_cell(gridwin, "B6", "test") - #2 - Select rows three though eight. - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:A8"})) - self.xUITest.executeCommand(".uno:SelectRow") - #3 - type Control-D/Fill Down - self.xUITest.executeCommand(".uno:FillDown") - #4 - undo. - self.xUITest.executeCommand(".uno:Undo") - #5 - Ouch! The data isn't right. - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") - self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "test") + #1 - Fill data + enter_text_to_cell(gridwin, "A3", "Range") + enter_text_to_cell(gridwin, "A4", "Range") + enter_text_to_cell(gridwin, "A5", "Range") + enter_text_to_cell(gridwin, "A6", "Range") + enter_text_to_cell(gridwin, "A7", "Range") + enter_text_to_cell(gridwin, "A8", "Range") + enter_text_to_cell(gridwin, "B6", "test") + #2 - Select rows three though eight. + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:A8"})) + self.xUITest.executeCommand(".uno:SelectRow") + #3 - type Control-D/Fill Down + self.xUITest.executeCommand(".uno:FillDown") + #4 - undo. + self.xUITest.executeCommand(".uno:Undo") + #5 - Ouch! The data isn't right. + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "test") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py index cff17b17e204..4038d4afd279 100644 --- a/sc/qa/uitest/calc_tests4/trackedChanges.py +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -40,251 +40,241 @@ class CalcTrackedChanges(UITestCase): xCancBtn.executeAction("CLICK", tuple()) def test_tdf66263_Protect_Records(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.wait_until_child_is_available("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - self.xUITest.executeCommand(".uno:TraceChangeMode") - #protect dialog - with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: - xpass = xDialog.getChild("pass1ed") - xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - xconfirm = xDialog.getChild("confirm1ed") - xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - #verify password - with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: - xpass = xDialog.getChild("pass1ed") - xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + self.xUITest.executeCommand(".uno:TraceChangeMode") + #protect dialog + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xconfirm = xDialog.getChild("confirm1ed") + xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + #verify password + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + def test_tracked_changes_accept(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.wait_until_child_is_available("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #track changes; enter text to cell - self.xUITest.executeCommand(".uno:TraceChangeMode") - 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)) - - 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") - - 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(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)) - - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + 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)) + + 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") + + 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(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)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") def test_tracked_changes_acceptall(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.wait_until_child_is_available("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #track changes; enter text to cell - self.xUITest.executeCommand(".uno:TraceChangeMode") - 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() - - 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)) - - 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(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)) - - xCancBtn = xTrackDlg.getChild("close") - xCancBtn.executeAction("CLICK", tuple()) - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + 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() + + 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)) + + 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(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)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") def test_tracked_changes_reject(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.wait_until_child_is_available("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #track changes; enter text to cell - self.xUITest.executeCommand(".uno:TraceChangeMode") - 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()) - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + 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()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") def test_tracked_changes_rejectall(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.wait_until_child_is_available("grid_window") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #track changes; enter text to cell - self.xUITest.executeCommand(".uno:TraceChangeMode") - 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)) - - 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") - - 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)) - - 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()) - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + 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)) + + 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") + + 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)) + + 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()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") def test_tdf136062(self): diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py index 5547f81956cc..17fb31049720 100644 --- a/sc/qa/uitest/calc_tests6/autoFormat.py +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -11,59 +11,57 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class autoFormat(UITestCase): def test_autoformat_styles(self): - writer_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A1:C5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) - #AutoFormat Styles - with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1:C5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) + #AutoFormat Styles + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: - formatlb = xDialog.getChild("formatlb") - numformatcb = xDialog.getChild("numformatcb") - bordercb = xDialog.getChild("bordercb") - fontcb = xDialog.getChild("fontcb") - patterncb = xDialog.getChild("patterncb") - alignmentcb = xDialog.getChild("alignmentcb") - autofitcb = xDialog.getChild("autofitcb") + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") - entry = formatlb.getChild("7") #Financial - entry.executeAction("SELECT", tuple()) - numformatcb.executeAction("CLICK", tuple()) - bordercb.executeAction("CLICK", tuple()) - fontcb.executeAction("CLICK", tuple()) - patterncb.executeAction("CLICK", tuple()) - alignmentcb.executeAction("CLICK", tuple()) - autofitcb.executeAction("CLICK", tuple()) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) - #verify - with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: + #verify + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: - formatlb = xDialog.getChild("formatlb") - numformatcb = xDialog.getChild("numformatcb") - bordercb = xDialog.getChild("bordercb") - fontcb = xDialog.getChild("fontcb") - patterncb = xDialog.getChild("patterncb") - alignmentcb = xDialog.getChild("alignmentcb") - autofitcb = xDialog.getChild("autofitcb") + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") - entry = formatlb.getChild("7") #Financial - entry.executeAction("SELECT", tuple()) - self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") - self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") - self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") - self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") - numformatcb.executeAction("CLICK", tuple()) - bordercb.executeAction("CLICK", tuple()) - fontcb.executeAction("CLICK", tuple()) - patterncb.executeAction("CLICK", tuple()) - alignmentcb.executeAction("CLICK", tuple()) - autofitcb.executeAction("CLICK", tuple()) + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") + self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") + self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/autocorrectOptions.py b/sc/qa/uitest/calc_tests6/autocorrectOptions.py index 158b738baf63..f79a07a78906 100644 --- a/sc/qa/uitest/calc_tests6/autocorrectOptions.py +++ b/sc/qa/uitest/calc_tests6/autocorrectOptions.py @@ -12,87 +12,85 @@ from uitest.uihelper.common import select_pos class autocorrectOptions(UITestCase): def test_autocorrect_options_calc(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab replace - origtext = xDialog.getChild("origtext") - newtext = xDialog.getChild("newtext") - xnew = xDialog.getChild("new") - xdelete = xDialog.getChild("delete") - xtabview = xDialog.getChild("tabview") - xreset = xDialog.getChild("reset") - nrRows = get_state_as_dict(xtabview)["VisibleCount"] - - self.assertTrue(int(nrRows) > 0) - - #add new rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xnew.executeAction("CLICK", tuple()) - nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] - nrRowsDiff = int(nrRowsNew) - int(nrRows) - self.assertEqual(nrRowsDiff, 1) #we have +1 rule - #delete rule - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) - xdelete.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules - - select_pos(xTabs, "1") #tab Exceptions - #abbreviations - abbrev = xDialog.getChild("abbrev") - newabbrev = xDialog.getChild("newabbrev") - delabbrev = xDialog.getChild("delabbrev") - abbrevlist = xDialog.getChild("abbrevlist") - - nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] - - self.assertTrue(int(nrRowsAbb) > 0) - - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) - newabbrev.executeAction("CLICK", tuple()) - nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] - nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) - self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule - delabbrev.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules - - #words with two initial capitals - double = xDialog.getChild("double") - newdouble = xDialog.getChild("newdouble") - deldouble = xDialog.getChild("deldouble") - doublelist = xDialog.getChild("doublelist") - - nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] - - self.assertTrue(int(nrRowsDouble) > 0) - - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) - newdouble.executeAction("CLICK", tuple()) - nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] - nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and - self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule - deldouble.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + xreset = xDialog.getChild("reset") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + self.assertTrue(int(nrRows) > 0) + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] + + self.assertTrue(int(nrRowsAbb) > 0) + + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] + + self.assertTrue(int(nrRowsDouble) > 0) + + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/hideShowSheet.py b/sc/qa/uitest/calc_tests6/hideShowSheet.py index 303c2cc5dce3..ec517fd3e5f2 100644 --- a/sc/qa/uitest/calc_tests6/hideShowSheet.py +++ b/sc/qa/uitest/calc_tests6/hideShowSheet.py @@ -11,35 +11,33 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class hideShowSheet(UITestCase): def test_hide_show_sheet(self): - writer_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #insert sheet - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass - #select sheet - gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"1"})) - self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") - #hide sheet - self.xUITest.executeCommand(".uno:Hide") - #show sheet Dialog - with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "1") - #insert 2nd sheet - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass - #select sheet - gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"2"})) - self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") - #hide sheet - self.xUITest.executeCommand(".uno:Hide") - #show sheet Dialog - with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "2") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #insert sheet + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + #select sheet + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"1"})) + self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "1") + #insert 2nd sheet + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + #select sheet + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"2"})) + self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py b/sc/qa/uitest/calc_tests6/moveCopySheet.py index 7b038d8d9bde..27f293755b22 100644 --- a/sc/qa/uitest/calc_tests6/moveCopySheet.py +++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py @@ -11,59 +11,57 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class moveCopySheet(UITestCase): def test_copy_move_sheet(self): - writer_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #default - 1 sheet; select the sheet (is selected), dialog move/copy sheet - with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: - #new name = newName - newName = xDialog.getChild("newName") - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) - #verify, the file has 2 sheets; first one "newName" is selected - self.assertEqual(document.Sheets.getCount(), 2) - # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName - with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: - insertBefore = xDialog.getChild("insertBefore") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #default - 1 sheet; select the sheet (is selected), dialog move/copy sheet + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + #new name = newName + newName = xDialog.getChild("newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) + #verify, the file has 2 sheets; first one "newName" is selected + self.assertEqual(document.Sheets.getCount(), 2) + # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + insertBefore = xDialog.getChild("insertBefore") - xTreeEntry = insertBefore.getChild('2') - xTreeEntry.executeAction("SELECT", tuple()) + xTreeEntry = insertBefore.getChild('2') + xTreeEntry.executeAction("SELECT", tuple()) - newName = xDialog.getChild("newName") - self.assertEqual(get_state_as_dict(newName)["Text"], "newName") - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) - # Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName" - self.assertEqual(document.Sheets.getCount(), 2) + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], "newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) + # Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName" + self.assertEqual(document.Sheets.getCount(), 2) - self.assertEqual(document.Sheets[0].Name, "Sheet1") - self.assertEqual(document.Sheets[1].Name, "moveName") + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") - # Verify that the cancel button does not do anything - with self.ui_test.execute_dialog_through_command(".uno:Move", close_button="cancel"): - pass + # Verify that the cancel button does not do anything + with self.ui_test.execute_dialog_through_command(".uno:Move", close_button="cancel"): + pass - self.assertEqual(document.Sheets.getCount(), 2) - self.assertEqual(document.Sheets[0].Name, "Sheet1") - self.assertEqual(document.Sheets[1].Name, "moveName") + self.assertEqual(document.Sheets.getCount(), 2) + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") - #Check copy option - with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: - xCopy = xDialog.getChild("copy") - xCopy.executeAction("CLICK", tuple()) - sheetName = "moveName_2" - newName = xDialog.getChild("newName") - self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) + #Check copy option + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xCopy = xDialog.getChild("copy") + xCopy.executeAction("CLICK", tuple()) + sheetName = "moveName_2" + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) - self.assertEqual(document.Sheets.getCount(), 3) - self.assertEqual(document.Sheets[0].Name, sheetName) - self.assertEqual(document.Sheets[1].Name, "Sheet1") - self.assertEqual(document.Sheets[2].Name, "moveName") + self.assertEqual(document.Sheets.getCount(), 3) + self.assertEqual(document.Sheets[0].Name, sheetName) + self.assertEqual(document.Sheets[1].Name, "Sheet1") + self.assertEqual(document.Sheets[2].Name, "moveName") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/multipleOperations.py b/sc/qa/uitest/calc_tests6/multipleOperations.py index 1f60937b056a..83868c824aa5 100644 --- a/sc/qa/uitest/calc_tests6/multipleOperations.py +++ b/sc/qa/uitest/calc_tests6/multipleOperations.py @@ -14,112 +14,108 @@ from uitest.uihelper.calc import enter_text_to_cell class multipleOperations(UITestCase): def test_multiple_operations_one_variable(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - #enter data - enter_text_to_cell(xGridWindow, "B1", "10") - enter_text_to_cell(xGridWindow, "B2", "2") - enter_text_to_cell(xGridWindow, "B3", "10000") - enter_text_to_cell(xGridWindow, "B4", "2000") - enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") - enter_text_to_cell(xGridWindow, "D2", "500") - enter_text_to_cell(xGridWindow, "D3", "1000") - enter_text_to_cell(xGridWindow, "D4", "1500") - enter_text_to_cell(xGridWindow, "D5", "2000") - enter_text_to_cell(xGridWindow, "D6", "2500") - enter_text_to_cell(xGridWindow, "D7", "3000") - enter_text_to_cell(xGridWindow, "D8", "3500") - enter_text_to_cell(xGridWindow, "D9", "4000") - enter_text_to_cell(xGridWindow, "D10", "4500") - enter_text_to_cell(xGridWindow, "D11", "5000") - #Select the range D2:E11 - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) - #Choose Data > Multiple Operations. - self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") - xDialog = self.xUITest.getTopFocusWindow() - #Formulas = B5 ; Column input cell = B4 - formulas = xDialog.getChild("formulas") - col = xDialog.getChild("col") - formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"})) - col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) - self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) - self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) - self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) - self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) - self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) - self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) - self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) - self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) - self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:E11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) + #Choose Data > Multiple Operations. + self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") + xDialog = self.xUITest.getTopFocusWindow() + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) - self.ui_test.close_doc() def test_multiple_operations_several_formulas(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - #enter data - enter_text_to_cell(xGridWindow, "B1", "10") - enter_text_to_cell(xGridWindow, "B2", "2") - enter_text_to_cell(xGridWindow, "B3", "10000") - enter_text_to_cell(xGridWindow, "B4", "2000") - enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") - enter_text_to_cell(xGridWindow, "C5", "=B5/B4") + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + enter_text_to_cell(xGridWindow, "C5", "=B5/B4") - enter_text_to_cell(xGridWindow, "D2", "500") - enter_text_to_cell(xGridWindow, "D3", "1000") - enter_text_to_cell(xGridWindow, "D4", "1500") - enter_text_to_cell(xGridWindow, "D5", "2000") - enter_text_to_cell(xGridWindow, "D6", "2500") - enter_text_to_cell(xGridWindow, "D7", "3000") - enter_text_to_cell(xGridWindow, "D8", "3500") - enter_text_to_cell(xGridWindow, "D9", "4000") - enter_text_to_cell(xGridWindow, "D10", "4500") - enter_text_to_cell(xGridWindow, "D11", "5000") - #Select the range D2:F11 - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:F11"})) - #Choose Data > Multiple Operations. - self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") - xDialog = self.xUITest.getTopFocusWindow() - #Formulas = B5 ; Column input cell = B4 - formulas = xDialog.getChild("formulas") - col = xDialog.getChild("col") - formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5:$C$5"})) - col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #verify - self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) - self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) - self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) - self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) - self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) - self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) - self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) - self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) - self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) - self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:F11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:F11"})) + #Choose Data > Multiple Operations. + self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") + xDialog = self.xUITest.getTopFocusWindow() + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5:$C$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), -12) - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), -2) - self.assertEqual(round(get_cell_by_position(document, 0, 5, 3).getValue(),2), 1.33) - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 4) - self.assertEqual(round(get_cell_by_position(document, 0, 5, 6).getValue(),2), 4.67) - self.assertEqual(round(get_cell_by_position(document, 0, 5, 7).getValue(),2), 5.14) - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 5.5) - self.assertEqual(round(get_cell_by_position(document, 0, 5, 9).getValue(),2), 5.78) - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), -12) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), -2) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 3).getValue(),2), 1.33) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 4) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 6).getValue(),2), 4.67) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 7).getValue(),2), 5.14) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 5.5) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 9).getValue(),2), 5.78) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 6) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/scenarios.py b/sc/qa/uitest/calc_tests6/scenarios.py index e4b10b449624..9063762a629b 100644 --- a/sc/qa/uitest/calc_tests6/scenarios.py +++ b/sc/qa/uitest/calc_tests6/scenarios.py @@ -13,32 +13,30 @@ from uitest.uihelper.calc import enter_text_to_cell class scenarios(UITestCase): def test_scenarios(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #fill B1:B4 with 1, select B1:B4; - enter_text_to_cell(xGridWindow, "B1", "1") - enter_text_to_cell(xGridWindow, "B2", "1") - enter_text_to_cell(xGridWindow, "B3", "1") - enter_text_to_cell(xGridWindow, "B4", "1") - xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"})) - #scenarios - scenario A1 - with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: - - name = xDialog.getChild("name") - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) - - #next scenarios - scenario B1 - with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: - - name = xDialog.getChild("name") - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + #fill B1:B4 with 1, select B1:B4; + enter_text_to_cell(xGridWindow, "B1", "1") + enter_text_to_cell(xGridWindow, "B2", "1") + enter_text_to_cell(xGridWindow, "B3", "1") + enter_text_to_cell(xGridWindow, "B4", "1") + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"})) + #scenarios - scenario A1 + with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) + + #next scenarios - scenario B1 + with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py index a7d1b762752a..21f2443db596 100644 --- a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py +++ b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py @@ -12,18 +12,16 @@ from uitest.uihelper.common import get_state_as_dict class shareSpreadsheet(UITestCase): def test_share_spreadsheet(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - #dialog shareSpreadsheet - with self.ui_test.execute_dialog_through_command(".uno:ShareDocument", close_button="cancel") as xDialog: + #dialog shareSpreadsheet + with self.ui_test.execute_dialog_through_command(".uno:ShareDocument", close_button="cancel") as xDialog: - share = xDialog.getChild("share") - share.executeAction("CLICK", tuple()) - users = xDialog.getChild("users") - self.assertEqual(get_state_as_dict(users)["Children"], "1") + share = xDialog.getChild("share") + share.executeAction("CLICK", tuple()) + users = xDialog.getChild("users") + self.assertEqual(get_state_as_dict(users)["Children"], "1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf104378.py b/sc/qa/uitest/calc_tests6/tdf104378.py index a210306f3193..99fb75ee50db 100644 --- a/sc/qa/uitest/calc_tests6/tdf104378.py +++ b/sc/qa/uitest/calc_tests6/tdf104378.py @@ -11,23 +11,21 @@ from libreoffice.calc.document import get_cell_by_position class tdf104378(UITestCase): def test_tdf104378(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "遠程MySQL連接遠程MySQL連接遠程MySQL連接") + enter_text_to_cell(gridwin, "A1", "遠程MySQL連接遠程MySQL連接遠程MySQL連接") - with self.ui_test.execute_dialog_through_command(".uno:ChineseConversion"): - pass + with self.ui_test.execute_dialog_through_command(".uno:ChineseConversion"): + pass - document = self.ui_test.get_component() - # Without the fix in place, this test would have failed with - # - 远程MySQL連接遠程MySQL連接遠程MySQL連接 - # + 远程MySQL连接远程MySQL连接远程MySQL连接 - self.assertEqual(get_cell_by_position( - document, 0, 0, 0).getString(), "远程MySQL连接远程MySQL连接远程MySQL连接") + # Without the fix in place, this test would have failed with + # - 远程MySQL連接遠程MySQL連接遠程MySQL連接 + # + 远程MySQL连接远程MySQL连接远程MySQL连接 + self.assertEqual(get_cell_by_position( + document, 0, 0, 0).getString(), "远程MySQL连接远程MySQL连接远程MySQL连接") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf116996.py b/sc/qa/uitest/calc_tests6/tdf116996.py index 9552b7ccc26a..6f28b7d9bb72 100644 --- a/sc/qa/uitest/calc_tests6/tdf116996.py +++ b/sc/qa/uitest/calc_tests6/tdf116996.py @@ -11,40 +11,38 @@ from uitest.uihelper.common import get_state_as_dict class tdf116996(UITestCase): def test_tdf116996_enable_experimental_feature(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xLOEntry = xPages.getChild('0') # Libreoffice - xLOEntry.executeAction("EXPAND", tuple()) - xAdvancedEntry = xLOEntry.getChild('10') - xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced - xexperimental = xDialogOpt.getChild("experimental") - xexperimental.executeAction("CLICK", tuple()) #enable experimental features - - xOKBtn = xDialogOpt.getChild("ok") - - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): - pass - - #reopen options dialog and verify - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xLOEntry = xPages.getChild('0') # Libreoffice - xLOEntry.executeAction("EXPAND", tuple()) - xAdvancedEntry = xLOEntry.getChild('10') - xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced - xexperimental = xDialogOpt.getChild("experimental") - - self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") - xexperimental.executeAction("CLICK", tuple()) #disable experimental features - xOKBtn = xDialogOpt.getChild("ok") - - with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): - pass - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + xexperimental.executeAction("CLICK", tuple()) #enable experimental features + + xOKBtn = xDialogOpt.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass + + #reopen options dialog and verify + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + + self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") + xexperimental.executeAction("CLICK", tuple()) #disable experimental features + xOKBtn = xDialogOpt.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf121263.py b/sc/qa/uitest/calc_tests6/tdf121263.py index 1a3776f811d9..b8db6a19811b 100644 --- a/sc/qa/uitest/calc_tests6/tdf121263.py +++ b/sc/qa/uitest/calc_tests6/tdf121263.py @@ -13,27 +13,25 @@ from uitest.uihelper.common import get_state_as_dict class tdf121263(UITestCase): def test_tdf121263_hide_more_sheets(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xTopWindow = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - gridwin = xTopWindow.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass - gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) - #select previous sheet - self.xUITest.executeCommand(".uno:JumpToPrevTableSel") + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) + #select previous sheet + self.xUITest.executeCommand(".uno:JumpToPrevTableSel") - #hide sheet - self.xUITest.executeCommand(".uno:Hide") + #hide sheet + self.xUITest.executeCommand(".uno:Hide") - #show sheet Dialog - with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: - treeview = xDialog.getChild("treeview") - self.assertEqual(get_state_as_dict(treeview)["Children"], "2") + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf91726.py b/sc/qa/uitest/calc_tests6/tdf91726.py index 4f64d9588202..a688751f6e0b 100644 --- a/sc/qa/uitest/calc_tests6/tdf91726.py +++ b/sc/qa/uitest/calc_tests6/tdf91726.py @@ -11,40 +11,38 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf91726(UITestCase): def test_tdf91726_new_style(self): - writer_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select A1:E9 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:E9"})) - #AutoFormat Styles - with self.ui_test.execute_dialog_through_command(".uno:AutoFormat", close_button="") as xDialog: - #add new style "Default" - xadd = xDialog.getChild("add") - - # Use empty close_button to open consecutive dialogs - with self.ui_test.execute_blocking_action( - xadd.executeAction, args=('CLICK', ()), close_button="") as dialog: - nameEntry = dialog.getChild("name_entry") - nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) - xOKBtn = dialog.getChild("ok") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1:E9 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:E9"})) + #AutoFormat Styles + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat", close_button="") as xDialog: + #add new style "Default" + xadd = xDialog.getChild("add") + # Use empty close_button to open consecutive dialogs with self.ui_test.execute_blocking_action( - xOKBtn.executeAction, args=('CLICK', ()), close_button="") as dialog2: - #Error message: You have entered an invalid name. - #AutoFormat could not be created. - #Try again using a different name. - xOKBtn2 = dialog2.getChild("ok") + xadd.executeAction, args=('CLICK', ()), close_button="") as dialog: + nameEntry = dialog.getChild("name_entry") + nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) + xOKBtn = dialog.getChild("ok") with self.ui_test.execute_blocking_action( - xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3: - nameEntry = dialog3.getChild("name_entry") - #back to name dialog, LO should not crash - self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") + xOKBtn.executeAction, args=('CLICK', ()), close_button="") as dialog2: + #Error message: You have entered an invalid name. + #AutoFormat could not be created. + #Try again using a different name. + xOKBtn2 = dialog2.getChild("ok") + + with self.ui_test.execute_blocking_action( + xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3: + nameEntry = dialog3.getChild("name_entry") + #back to name dialog, LO should not crash + self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") - xCanceltn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCanceltn) + xCanceltn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanceltn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf106667.py b/sc/qa/uitest/calc_tests7/tdf106667.py index 16503995f121..7792969097e6 100644 --- a/sc/qa/uitest/calc_tests7/tdf106667.py +++ b/sc/qa/uitest/calc_tests7/tdf106667.py @@ -13,22 +13,20 @@ from libreoffice.calc.document import get_cell_by_position class tdf106667(UITestCase): def test_tdf106667_about_dlg_all(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "A") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1000"})) + enter_text_to_cell(gridwin, "A1", "A") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1000"})) - self.xUITest.executeCommand(".uno:FillDown") + self.xUITest.executeCommand(".uno:FillDown") - self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:SelectAll") - with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose") as xAboutDlg: - pass + with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose") as xAboutDlg: + pass - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") - self.ui_test.close_doc() + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf117987.py b/sc/qa/uitest/calc_tests7/tdf117987.py index 3de0b176ed01..9ad154275f1b 100644 --- a/sc/qa/uitest/calc_tests7/tdf117987.py +++ b/sc/qa/uitest/calc_tests7/tdf117987.py @@ -10,16 +10,14 @@ from libreoffice.calc.document import get_cell_by_position class tdf117987(UITestCase): def test_highlight_cell_after_moving_cursor(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) - self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) - document = self.ui_test.get_component() - self.assertEqual(get_cell_by_position(document, 0, 0, 1).CellBackColor, 16776960) - self.ui_test.close_doc() + self.assertEqual(get_cell_by_position(document, 0, 0, 1).CellBackColor, 16776960) diff --git a/sc/qa/uitest/calc_tests7/tdf123122.py b/sc/qa/uitest/calc_tests7/tdf123122.py index 566ac527eef3..858ffed472c8 100644 --- a/sc/qa/uitest/calc_tests7/tdf123122.py +++ b/sc/qa/uitest/calc_tests7/tdf123122.py @@ -14,48 +14,46 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf123122(UITestCase): def test_tdf123122_format_cell_datetime(self): #numberingformatpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #select cell A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - #Format cells and enter NN MMM DD YYYY HH:MM as format code - xformatted.executeAction("CLEAR", tuple()) #clear textbox - xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) - #save - OK + #Format cells and enter NN MMM DD YYYY HH:MM as format code + xformatted.executeAction("CLEAR", tuple()) #clear textbox + xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) + #save - OK - #verify - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #format - cell - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") #tab Numbers - xliststore1 = xDialog.getChild("categorylb") #1st list / Category - xliststore2 = xDialog.getChild("formatlb") #2nd list / Format - xdecimalsed = xDialog.getChild("decimalsed") - xleadzerosed = xDialog.getChild("leadzerosed") - xnegnumred = xDialog.getChild("negnumred") - xthousands = xDialog.getChild("thousands") - xlanguagelb = xDialog.getChild("languagelb") - xformatted = xDialog.getChild("formatted") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") - self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") - self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf125030.py b/sc/qa/uitest/calc_tests7/tdf125030.py index 51d9cb292a77..485614050127 100644 --- a/sc/qa/uitest/calc_tests7/tdf125030.py +++ b/sc/qa/uitest/calc_tests7/tdf125030.py @@ -13,21 +13,19 @@ from uitest.uihelper.calc import enter_text_to_cell class tdf125030(UITestCase): def test_tdf125030_repeat_crash(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter data - enter_text_to_cell(gridwin, "A1", "aaaa") - enter_text_to_cell(gridwin, "B1", "bbbb") - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%201&FamilyName:string=CellStyles") - #focus on A2 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - #repeat (Ctrl+Shft+Y) - self.xUITest.executeCommand(".uno:Repeat") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aaaa") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "aaaa") + enter_text_to_cell(gridwin, "B1", "bbbb") + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%201&FamilyName:string=CellStyles") + #focus on A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #repeat (Ctrl+Shft+Y) + self.xUITest.executeCommand(".uno:Repeat") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aaaa") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf45020.py b/sc/qa/uitest/calc_tests7/tdf45020.py index 48ca97fe51a5..08b6de43f4a2 100644 --- a/sc/qa/uitest/calc_tests7/tdf45020.py +++ b/sc/qa/uitest/calc_tests7/tdf45020.py @@ -11,26 +11,24 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf45020(UITestCase): def test_tdf45020_hide_rows_select(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #in cell A1-A4: apple pear melon mango - enter_text_to_cell(gridwin, "A1", "apple") - enter_text_to_cell(gridwin, "A1", "pear") - enter_text_to_cell(gridwin, "A1", "melon") - enter_text_to_cell(gridwin, "A1", "mango") - #select A2 and A3 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) - #format > Row > Hide - self.ui_test._xUITest.executeCommand(".uno:HideRow") - #select A1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #press Shift+down - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+DOWN"})) - #verify A1:A4 selected - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #in cell A1-A4: apple pear melon mango + enter_text_to_cell(gridwin, "A1", "apple") + enter_text_to_cell(gridwin, "A1", "pear") + enter_text_to_cell(gridwin, "A1", "melon") + enter_text_to_cell(gridwin, "A1", "mango") + #select A2 and A3 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) + #format > Row > Hide + self.ui_test._xUITest.executeCommand(".uno:HideRow") + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #press Shift+down + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+DOWN"})) + #verify A1:A4 selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/navigator.py b/sc/qa/uitest/calc_tests8/navigator.py index 86e473dae8d6..630c1cda7ba1 100644 --- a/sc/qa/uitest/calc_tests8/navigator.py +++ b/sc/qa/uitest/calc_tests8/navigator.py @@ -111,40 +111,39 @@ class navigator(UITestCase): def test_tdf134390(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWin = xCalcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") - self.xUITest.executeCommand(".uno:Sidebar") - xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) - xCalcDoc = self.xUITest.getTopFocusWindow() - xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") - xToolBar = xNavigatorPanel.getChild("toolbox2") - xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("toolbox2") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button - xRow = xNavigatorPanel.getChild('row') - xColumn = xNavigatorPanel.getChild('column') - self.assertEqual(get_state_as_dict(xColumn)['Value'], '1') - self.assertEqual(get_state_as_dict(xRow)['Value'], '1') - self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "0") - self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "0") + xRow = xNavigatorPanel.getChild('row') + xColumn = xNavigatorPanel.getChild('column') + self.assertEqual(get_state_as_dict(xColumn)['Value'], '1') + self.assertEqual(get_state_as_dict(xRow)['Value'], '1') + self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "0") + self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "0") - xRow.executeAction("UP", tuple()) - xColumn.executeAction("UP", tuple()) + xRow.executeAction("UP", tuple()) + xColumn.executeAction("UP", tuple()) - # Use return to update the current cell - xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + # Use return to update the current cell + xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - self.assertEqual(get_state_as_dict(xColumn)['Value'], '2') - self.assertEqual(get_state_as_dict(xRow)['Value'], '2') + self.assertEqual(get_state_as_dict(xColumn)['Value'], '2') + self.assertEqual(get_state_as_dict(xRow)['Value'], '2') - self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1") - self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "1") + self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1") + self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "1") - self.xUITest.executeCommand(".uno:Sidebar") + self.xUITest.executeCommand(".uno:Sidebar") - self.ui_test.close_doc() def test_tdf141973(self): with self.ui_test.load_file(get_url_for_data_file("tdf141973.ods")): diff --git a/sc/qa/uitest/calc_tests8/tdf118308.py b/sc/qa/uitest/calc_tests8/tdf118308.py index 4160d609e263..852bb474a381 100644 --- a/sc/qa/uitest/calc_tests8/tdf118308.py +++ b/sc/qa/uitest/calc_tests8/tdf118308.py @@ -13,39 +13,38 @@ from libreoffice.calc.document import get_cell_by_position class tdf118308(UITestCase): def test_tdf118308(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - enter_text_to_cell(gridwin, "A1", "A") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:Copy") - - with self.ui_test.load_empty_file("calc") as calc_document: - + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: xCalcDoc = self.xUITest.getTopFocusWindow() gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "A") gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("calc") as calc_document: + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xDialog: - # Without the fix in place, this test would have failed here - # since a different dialog would have been opened and the children - # wouldn't have been found - xText = xDialog.getChild("text") - xNumbers = xDialog.getChild("numbers") - xDatetime = xDialog.getChild("datetime") - xFormats = xDialog.getChild("formats") + # Without the fix in place, this test would have failed here + # since a different dialog would have been opened and the children + # wouldn't have been found + xText = xDialog.getChild("text") + xNumbers = xDialog.getChild("numbers") + xDatetime = xDialog.getChild("datetime") + xFormats = xDialog.getChild("formats") - self.assertEqual("true", get_state_as_dict(xText)["Selected"]) - self.assertEqual("true", get_state_as_dict(xNumbers)["Selected"]) - self.assertEqual("true", get_state_as_dict(xDatetime)["Selected"]) - self.assertEqual("false", get_state_as_dict(xFormats)["Selected"]) + self.assertEqual("true", get_state_as_dict(xText)["Selected"]) + self.assertEqual("true", get_state_as_dict(xNumbers)["Selected"]) + self.assertEqual("true", get_state_as_dict(xDatetime)["Selected"]) + self.assertEqual("false", get_state_as_dict(xFormats)["Selected"]) - self.assertEqual("A", get_cell_by_position(calc_document, 0, 0, 0).getString()) + self.assertEqual("A", get_cell_by_position(calc_document, 0, 0, 0).getString()) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf125051.py b/sc/qa/uitest/calc_tests8/tdf125051.py index 992f3b0822e4..205038008db7 100644 --- a/sc/qa/uitest/calc_tests8/tdf125051.py +++ b/sc/qa/uitest/calc_tests8/tdf125051.py @@ -15,29 +15,27 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf125051(UITestCase): def test_tdf125051_crash_spelling_dialog(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "text") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:SpellDialog") as xDialog2: - pass + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "text") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:SpellDialog") as xDialog2: + pass - xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog - #open options - optionsBtn = xDialog.getChild("options") + xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog + #open options + optionsBtn = xDialog.getChild("options") - with self.ui_test.execute_blocking_action(optionsBtn.executeAction, args=('CLICK', ()), close_button="cancel"): - pass + with self.ui_test.execute_blocking_action(optionsBtn.executeAction, args=('CLICK', ()), close_button="cancel"): + pass - closeBtn = xDialog.getChild("close") #close Spelling dialog - self.ui_test.close_dialog_through_button(closeBtn) + closeBtn = xDialog.getChild("close") #close Spelling dialog + self.ui_test.close_dialog_through_button(closeBtn) - #verify, we didn't crash - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text") + #verify, we didn't crash + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf137726.py b/sc/qa/uitest/calc_tests8/tdf137726.py index 205f9e416854..dddc0d0799ca 100644 --- a/sc/qa/uitest/calc_tests8/tdf137726.py +++ b/sc/qa/uitest/calc_tests8/tdf137726.py @@ -9,21 +9,20 @@ from uitest.framework import UITestCase class tdf137726(UITestCase): def test_tdf137726(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # three dialogs are displayed one after the other, click OK in all of them - with self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") as xDialog: - pass + # three dialogs are displayed one after the other, click OK in all of them + with self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") as xDialog: + pass - for i in range(2): - xDialog = self.xUITest.getTopFocusWindow() - xOKBtn = xDialog.getChild('ok') - self.ui_test.close_dialog_through_button(xOKBtn) + for i in range(2): + xDialog = self.xUITest.getTopFocusWindow() + xOKBtn = xDialog.getChild('ok') + self.ui_test.close_dialog_through_button(xOKBtn) - # Without the fix in place, this test would have hung here + # Without the fix in place, this test would have hung here - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf117879.py b/sc/qa/uitest/calc_tests9/tdf117879.py index b67e27ff4c89..2245ddcdf2a0 100644 --- a/sc/qa/uitest/calc_tests9/tdf117879.py +++ b/sc/qa/uitest/calc_tests9/tdf117879.py @@ -13,32 +13,29 @@ class tdf117879(UITestCase): def test_tdf117879(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - type_text(gridwin, "=SUM({A1},2,3,4,5}") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") - # Without the fix in place, this dialog wouldn't have been displayed - with self.ui_test.execute_blocking_action(gridwin.executeAction, - args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="yes"): - pass + # Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="yes"): + pass - document = self.ui_test.get_component() - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5)") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5)") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - type_text(gridwin, "=SUM({A1},2,3,4,5}") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") - with self.ui_test.execute_blocking_action(gridwin.executeAction, - args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="no"): - pass + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="no"): + pass - document = self.ui_test.get_component() - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5})") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5})") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf121949.py b/sc/qa/uitest/calc_tests9/tdf121949.py index ec1876c4f148..3d59a0a00498 100644 --- a/sc/qa/uitest/calc_tests9/tdf121949.py +++ b/sc/qa/uitest/calc_tests9/tdf121949.py @@ -10,19 +10,18 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf121949 (UITestCase): def test_tdf121949_copy_block_with_single_cell_not_included(self): - self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # mark a range with a single cell left our and copy to clipboard - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) - with self.ui_test.execute_dialog_through_command(".uno:Copy"): - pass + # mark a range with a single cell left our and copy to clipboard + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) + with self.ui_test.execute_dialog_through_command(".uno:Copy"): + pass - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf133629.py b/sc/qa/uitest/calc_tests9/tdf133629.py index 67bead7fdec8..7d1bffbc6721 100644 --- a/sc/qa/uitest/calc_tests9/tdf133629.py +++ b/sc/qa/uitest/calc_tests9/tdf133629.py @@ -11,50 +11,48 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf133629(UITestCase): def test_tdf133629(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass - self.xUITest.executeCommand(".uno:TableSelectAll") + self.xUITest.executeCommand(".uno:TableSelectAll") - self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:SelectAll") - # Check selection - self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A1:AMJ1048576')) - self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A2:AMJ1048576')) + # Check selection + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A1:AMJ1048576')) + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A2:AMJ1048576')) - with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "5") + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") - xPresets = xDialog.getChild("presets") - xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) + xPresets = xDialog.getChild("presets") + xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) - # Change width - xLineWidth = xDialog.getChild("linewidthmf") - xLineWidth.executeAction("UP", tuple()) - xLineWidth.executeAction("UP", tuple()) - self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) + # Change width + xLineWidth = xDialog.getChild("linewidthmf") + xLineWidth.executeAction("UP", tuple()) + xLineWidth.executeAction("UP", tuple()) + self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) - # Without the fix in place, this test would have crash here + # Without the fix in place, this test would have crash here - xA1Sheet1 = document.Sheets[0].getCellRangeByName("A1") - self.assertEqual(44, xA1Sheet1.BottomBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet1.TopBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet1.LeftBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet1.RightBorder.OuterLineWidth) + xA1Sheet1 = document.Sheets[0].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet1.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.RightBorder.OuterLineWidth) - xA1Sheet2 = document.Sheets[1].getCellRangeByName("A1") - self.assertEqual(44, xA1Sheet2.BottomBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet2.TopBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet2.LeftBorder.OuterLineWidth) - self.assertEqual(44, xA1Sheet2.RightBorder.OuterLineWidth) + xA1Sheet2 = document.Sheets[1].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet2.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.RightBorder.OuterLineWidth) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf141244.py b/sc/qa/uitest/calc_tests9/tdf141244.py index ea8a467c4b66..89d21d1c5c58 100644 --- a/sc/qa/uitest/calc_tests9/tdf141244.py +++ b/sc/qa/uitest/calc_tests9/tdf141244.py @@ -13,28 +13,27 @@ class tdf141244(UITestCase): def test_tdf141244(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", '=DDE("soffice";"data1.ods";"sheet1.A1")') + enter_text_to_cell(gridwin, "A1", '=DDE("soffice";"data1.ods";"sheet1.A1")') - with self.ui_test.execute_dialog_through_command(".uno:EditLinks", close_button="close") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:EditLinks", close_button="close") as xDialog: - xLinks = xDialog.getChild("TB_LINKS") - self.assertEqual(1, len(xLinks.getChildren())) + xLinks = xDialog.getChild("TB_LINKS") + self.assertEqual(1, len(xLinks.getChildren())) - xChangeBtn = xDialog.getChild("CHANGE_SOURCE") + xChangeBtn = xDialog.getChild("CHANGE_SOURCE") - with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: - self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) - self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) - self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) + with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) + self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) + self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) - # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here + # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/chart/create_chart.py b/sc/qa/uitest/chart/create_chart.py index 878af422a581..26d1de5155ee 100644 --- a/sc/qa/uitest/chart/create_chart.py +++ b/sc/qa/uitest/chart/create_chart.py @@ -30,99 +30,93 @@ class CalcChartUIDemo(UITestCase): def test_cancel_immediately(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="cancel"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="cancel"): + pass - self.ui_test.close_doc() def test_create_from_first_page(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): + pass - self.ui_test.close_doc() def test_create_from_second_page(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) - xDataInRows = xChartDlg.getChild("RB_DATAROWS") - xDataInRows.executeAction("CLICK", tuple()) + xDataInRows = xChartDlg.getChild("RB_DATAROWS") + xDataInRows.executeAction("CLICK", tuple()) - xDataInCols = xChartDlg.getChild("RB_DATACOLS") - xDataInCols.executeAction("CLICK", tuple()) + xDataInCols = xChartDlg.getChild("RB_DATACOLS") + xDataInCols.executeAction("CLICK", tuple()) - self.ui_test.close_doc() def test_deselect_chart(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): + pass - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - time.sleep(2) + time.sleep(2) - self.ui_test.close_doc() def test_activate_chart(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): + pass - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) - xGridWindow.executeAction("ACTIVATE", tuple()) + xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) + xGridWindow.executeAction("ACTIVATE", tuple()) - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - self.ui_test.close_doc() def select_chart_element(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): + pass - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) - xGridWindow.executeAction("ACTIVATE", tuple()) + xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) + xGridWindow.executeAction("ACTIVATE", tuple()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/chart/edit_chart.py b/sc/qa/uitest/chart/edit_chart.py index 48d9149004f5..b16e2ab57963 100644 --- a/sc/qa/uitest/chart/edit_chart.py +++ b/sc/qa/uitest/chart/edit_chart.py @@ -29,34 +29,33 @@ class CalcChartEditUIDemo(UITestCase): def test_select_secondary_axis(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.fill_spreadsheet() + self.fill_spreadsheet() - xCalcDoc = self.xUITest.getTopFocusWindow() - xGridWindow = xCalcDoc.getChild("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): - pass + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish"): + pass - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"OBJECT": "Object 1"})) - xGridWindow.executeAction("ACTIVATE", tuple()) + xGridWindow.executeAction("ACTIVATE", tuple()) - xChartMainTop = self.xUITest.getTopFocusWindow() - xChartMain = xChartMainTop.getChild("chart_window") + xChartMainTop = self.xUITest.getTopFocusWindow() + xChartMain = xChartMainTop.getChild("chart_window") - xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0") + xSeriesObj = xChartMain.getChild("CID/D=0:CS=0:CT=0:Series=0") - with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataSeries"})) as xSeriesFormatDlg: + with self.ui_test.execute_dialog_through_action(xSeriesObj, "COMMAND", mkPropertyValues({"COMMAND": "FormatDataSeries"})) as xSeriesFormatDlg: - xAxis2 = xSeriesFormatDlg.getChild("RBT_OPT_AXIS_2") - xAxis2.executeAction("CLICK", tuple()) + xAxis2 = xSeriesFormatDlg.getChild("RBT_OPT_AXIS_2") + xAxis2.executeAction("CLICK", tuple()) - xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) + xGridWindow.executeAction("DESELECT", mkPropertyValues({"OBJECT": ""})) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/chart/tdf124295.py b/sc/qa/uitest/chart/tdf124295.py index 131f897c9573..24bbd14ee52e 100644 --- a/sc/qa/uitest/chart/tdf124295.py +++ b/sc/qa/uitest/chart/tdf124295.py @@ -15,19 +15,18 @@ class tdf124295(UITestCase): def test_tdf124295(self): # Open spreadsheet and insert chart - self.ui_test.create_doc_in_start_center("calc") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="cancel") as xChartDlg: + with self.ui_test.create_doc_in_start_center_guarded("calc"): + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="cancel") as xChartDlg: - # Click 3D look check button - x3DCheckBtn = xChartDlg.getChild("3dlook") - x3DCheckBtn.executeAction("CLICK", tuple()) + # Click 3D look check button + x3DCheckBtn = xChartDlg.getChild("3dlook") + x3DCheckBtn.executeAction("CLICK", tuple()) - x3DSchemeLstBox = xChartDlg.getChild("3dscheme") - # Without the fix in place, this test would have failed with: - # AssertionError: 'Realistic' != '' - self.assertEqual("Realistic", get_state_as_dict(x3DSchemeLstBox)["SelectEntryText"]) + x3DSchemeLstBox = xChartDlg.getChild("3dscheme") + # Without the fix in place, this test would have failed with: + # AssertionError: 'Realistic' != '' + self.assertEqual("Realistic", get_state_as_dict(x3DSchemeLstBox)["SelectEntryText"]) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/chart/tdf131715.py b/sc/qa/uitest/chart/tdf131715.py index d8954d9cfab6..9ad4c017e39f 100644 --- a/sc/qa/uitest/chart/tdf131715.py +++ b/sc/qa/uitest/chart/tdf131715.py @@ -10,16 +10,15 @@ from uitest.uihelper.common import select_pos class tdf131715(UITestCase): def test_tdf131715(self): - self.ui_test.create_doc_in_start_center("calc") - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + with self.ui_test.create_doc_in_start_center_guarded("calc"): + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: - xWizard = xChartDlg.getChild('Wizard') + xWizard = xChartDlg.getChild('Wizard') - for i in range(10): - #without the fix in place, it would crash here - select_pos(xWizard, "2") + for i in range(10): + #without the fix in place, it would crash here + select_pos(xWizard, "2") - self.assertEqual(get_state_as_dict(xWizard)['CurrentStep'], "2") + self.assertEqual(get_state_as_dict(xWizard)['CurrentStep'], "2") - self.ui_test.close_doc() diff --git a/sc/qa/uitest/chart/tdf46885.py b/sc/qa/uitest/chart/tdf46885.py index 637033505fd3..7d5b4e4bd6d7 100644 --- a/sc/qa/uitest/chart/tdf46885.py +++ b/sc/qa/uitest/chart/tdf46885.py @@ -15,35 +15,31 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf46885(UITestCase): def test_tdf46885_crash_chart_no_cell_selected_nextButton(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A10", "col1") - #When you start a new chart and have one empty cell selected LibO will crash when you select the Next>> button. - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A10", "col1") + #When you start a new chart and have one empty cell selected LibO will crash when you select the Next>> button. + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) - #verify, we didn't crash - self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") + #verify, we didn't crash + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") - self.ui_test.close_doc() def test_tdf46885_crash_chart_multiple_empty_cells_selected(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A10", "col1") - #If you select multiple empty cells and then start a new chart LibO will crash immediately. - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C4"})) - with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: - xNextBtn = xChartDlg.getChild("next") - xNextBtn.executeAction("CLICK", tuple()) + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A10", "col1") + #If you select multiple empty cells and then start a new chart LibO will crash immediately. + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C4"})) + with self.ui_test.execute_dialog_through_command(".uno:InsertObjectChart", close_button="finish") as xChartDlg: + xNextBtn = xChartDlg.getChild("next") + xNextBtn.executeAction("CLICK", tuple()) - #verify, we didn't crash - self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") + #verify, we didn't crash + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "col1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/conditional_format/tdf105351.py b/sc/qa/uitest/conditional_format/tdf105351.py index 53e68a343a86..dd1ac8e0e18a 100644 --- a/sc/qa/uitest/conditional_format/tdf105351.py +++ b/sc/qa/uitest/conditional_format/tdf105351.py @@ -15,50 +15,48 @@ from uitest.debug import sleep #Bug 105351 - FORMATTING: Unable to change Data Bar conditional formatting class tdf105351(UITestCase): def test_tdf105351_cond_format_data_bar(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #2. Set the value of cell A1 to 5 - enter_text_to_cell(gridwin, "A1", "5") - #3. Select cell A1, then choose from the menus Format -> Conditional Formatting -> Data Bar - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DataBarFormatDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcolscalemin = xDialog.getChild("colscalemin") - xedcolscalemin = xDialog.getChild("edcolscalemin") - xcolscalemax = xDialog.getChild("colscalemax") - xedcolscalemax = xDialog.getChild("edcolscalemax") - #4. In the conditional formatting window, select the dropdown on the left that says "Automatic" - #and change it to "Value". In the text field below it enter 0. - #5. Select the dropdown on the right that says "Automatic" and change it to "Value". In the text field below it enter 10 - select_by_text(xcolscalemin, "Value") - xedcolscalemin.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #2. Set the value of cell A1 to 5 + enter_text_to_cell(gridwin, "A1", "5") + #3. Select cell A1, then choose from the menus Format -> Conditional Formatting -> Data Bar + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataBarFormatDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcolscalemin = xDialog.getChild("colscalemin") + xedcolscalemin = xDialog.getChild("edcolscalemin") + xcolscalemax = xDialog.getChild("colscalemax") + xedcolscalemax = xDialog.getChild("edcolscalemax") + #4. In the conditional formatting window, select the dropdown on the left that says "Automatic" + #and change it to "Value". In the text field below it enter 0. + #5. Select the dropdown on the right that says "Automatic" and change it to "Value". In the text field below it enter 10 + select_by_text(xcolscalemin, "Value") + xedcolscalemin.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) - select_by_text(xcolscalemax, "Value") - xedcolscalemax.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) + select_by_text(xcolscalemax, "Value") + xedcolscalemax.executeAction("TYPE", mkPropertyValues({"TEXT":"10"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify : The conditions set for cell A1 should be shown and editable. - self.ui_test.execute_modeless_dialog_through_command(".uno:DataBarFormatDialog") - xDialog = self.xUITest.getTopFocusWindow() - xcolscalemin = xDialog.getChild("colscalemin") - xedcolscalemin = xDialog.getChild("edcolscalemin") - xcolscalemax = xDialog.getChild("colscalemax") - xedcolscalemax = xDialog.getChild("edcolscalemax") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify : The conditions set for cell A1 should be shown and editable. + self.ui_test.execute_modeless_dialog_through_command(".uno:DataBarFormatDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcolscalemin = xDialog.getChild("colscalemin") + xedcolscalemin = xDialog.getChild("edcolscalemin") + xcolscalemax = xDialog.getChild("colscalemax") + xedcolscalemax = xDialog.getChild("edcolscalemax") - self.assertEqual(get_state_as_dict(xcolscalemin)["SelectEntryText"], "Value") - self.assertEqual(get_state_as_dict(xedcolscalemin)["Text"], "0") - self.assertEqual(get_state_as_dict(xcolscalemax)["SelectEntryText"], "Value") - self.assertEqual(get_state_as_dict(xedcolscalemax)["Text"], "10") - #editable - change value and then verify - xedcolscalemax.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - self.assertEqual(get_state_as_dict(xedcolscalemax)["Text"], "110") + self.assertEqual(get_state_as_dict(xcolscalemin)["SelectEntryText"], "Value") + self.assertEqual(get_state_as_dict(xedcolscalemin)["Text"], "0") + self.assertEqual(get_state_as_dict(xcolscalemax)["SelectEntryText"], "Value") + self.assertEqual(get_state_as_dict(xedcolscalemax)["Text"], "10") + #editable - change value and then verify + xedcolscalemax.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + self.assertEqual(get_state_as_dict(xedcolscalemax)["Text"], "110") - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/conditional_format/tdf105411.py b/sc/qa/uitest/conditional_format/tdf105411.py index 8f08c2f22fb5..35a15ef3f19f 100644 --- a/sc/qa/uitest/conditional_format/tdf105411.py +++ b/sc/qa/uitest/conditional_format/tdf105411.py @@ -11,25 +11,24 @@ class tdf105411(UITestCase): def test_delete_conditional_format(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.ui_test.execute_modeless_dialog_through_command(".uno:ConditionalFormatDialog") + self.ui_test.execute_modeless_dialog_through_command(".uno:ConditionalFormatDialog") - xCondFormatDlg = self.xUITest.getTopFocusWindow() + xCondFormatDlg = self.xUITest.getTopFocusWindow() - xDeleteBtn = xCondFormatDlg.getChild("delete") - xDeleteBtn.executeAction("CLICK", tuple()) + xDeleteBtn = xCondFormatDlg.getChild("delete") + xDeleteBtn.executeAction("CLICK", tuple()) - xCondFormatDlg = self.xUITest.getTopFocusWindow() + xCondFormatDlg = self.xUITest.getTopFocusWindow() - xDeleteBtn = xCondFormatDlg.getChild("add") - xDeleteBtn.executeAction("CLICK", tuple()) + xDeleteBtn = xCondFormatDlg.getChild("add") + xDeleteBtn.executeAction("CLICK", tuple()) - xCondFormatDlg = self.xUITest.getTopFocusWindow() + xCondFormatDlg = self.xUITest.getTopFocusWindow() - xOkBtn = xCondFormatDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xOkBtn = xCondFormatDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/conditional_format/tdf105466.py b/sc/qa/uitest/conditional_format/tdf105466.py index fa7db7e49698..c087f925e3e3 100644 --- a/sc/qa/uitest/conditional_format/tdf105466.py +++ b/sc/qa/uitest/conditional_format/tdf105466.py @@ -15,21 +15,20 @@ class tdf105466(UITestCase): @unittest.skip("issue with floating windows") def test_changing_conditional_format(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.ui_test.execute_modeless_dialog_through_command(".uno:ConditionalFormatDialog") + self.ui_test.execute_modeless_dialog_through_command(".uno:ConditionalFormatDialog") - for i in range(0,4): - with self.subTest(i = i): - xCondFormatDlg = self.xUITest.getTopFocusWindow() - xTypeLstBox = xCondFormatDlg.getChild("type") - xTypeLstBox.executeAction("SELECT", mkPropertyValues({"POS": str(i)})) + for i in range(0,4): + with self.subTest(i = i): + xCondFormatDlg = self.xUITest.getTopFocusWindow() + xTypeLstBox = xCondFormatDlg.getChild("type") + xTypeLstBox.executeAction("SELECT", mkPropertyValues({"POS": str(i)})) - xCondFormatDlg = self.xUITest.getTopFocusWindow() - xOkBtn = xCondFormatDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xCondFormatDlg = self.xUITest.getTopFocusWindow() + xOkBtn = xCondFormatDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf142395.py b/sc/qa/uitest/csv_dialog/tdf142395.py index a667a886ca8d..ced11850fa05 100644 --- a/sc/qa/uitest/csv_dialog/tdf142395.py +++ b/sc/qa/uitest/csv_dialog/tdf142395.py @@ -45,6 +45,5 @@ class Tdf142395(UITestCase): self.assertEqual(" g", get_cell_by_position(document, 0, 2, 1).getString()) self.assertEqual(" ", get_cell_by_position(document, 0, 3, 1).getString()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf57841.py b/sc/qa/uitest/csv_dialog/tdf57841.py index 87c2a2b1b9f5..e098d72873a8 100644 --- a/sc/qa/uitest/csv_dialog/tdf57841.py +++ b/sc/qa/uitest/csv_dialog/tdf57841.py @@ -43,6 +43,5 @@ class Tdf57841(UITestCase): for i in range(4): self.assertEqual(str(i + 1), get_cell_by_position(document, 0, i, 0).getString()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/csv_dialog/tdf60468.py b/sc/qa/uitest/csv_dialog/tdf60468.py index bb4603de56b4..25d8b0a14e58 100644 --- a/sc/qa/uitest/csv_dialog/tdf60468.py +++ b/sc/qa/uitest/csv_dialog/tdf60468.py @@ -50,6 +50,5 @@ class Tdf60468(UITestCase): self.assertEqual("value2.1\n\tvalue2.2\nvalue2.3", get_cell_by_position(document, 0, 1, 1).getString()) self.assertEqual("value3", get_cell_by_position(document, 0, 2, 1).getString()) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/function_wizard/function_wizard.py b/sc/qa/uitest/function_wizard/function_wizard.py index 13b83350927f..0e80e6729f33 100644 --- a/sc/qa/uitest/function_wizard/function_wizard.py +++ b/sc/qa/uitest/function_wizard/function_wizard.py @@ -12,18 +12,17 @@ from uitest.framework import UITestCase class FunctionWizardTest(UITestCase): # tdf#98427 def test_open_function_wizard(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") + self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") - xFunctionDlg = self.xUITest.getTopFocusWindow() + xFunctionDlg = self.xUITest.getTopFocusWindow() - xArrayChkBox = xFunctionDlg.getChild("array") - xArrayChkBox.executeAction("CLICK", tuple()) + xArrayChkBox = xFunctionDlg.getChild("array") + xArrayChkBox.executeAction("CLICK", tuple()) - xCancelBtn = xFunctionDlg.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + xCancelBtn = xFunctionDlg.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/function_wizard/tdf132173.py b/sc/qa/uitest/function_wizard/tdf132173.py index d74f7dc744ca..0e372536206f 100644 --- a/sc/qa/uitest/function_wizard/tdf132173.py +++ b/sc/qa/uitest/function_wizard/tdf132173.py @@ -11,23 +11,21 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf132173(UITestCase): def test_tdf132173(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") - xDialog = self.xUITest.getTopFocusWindow() - xFormula = xDialog.getChild("ed_formula") - xFormula.executeAction("TYPE", mkPropertyValues({"TEXT": 'FIND({"A";"B";"C"},"SAMPLE TEXT")'})) + self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") + xDialog = self.xUITest.getTopFocusWindow() + xFormula = xDialog.getChild("ed_formula") + xFormula.executeAction("TYPE", mkPropertyValues({"TEXT": 'FIND({"A";"B";"C"},"SAMPLE TEXT")'})) - self.assertEqual(get_state_as_dict(xFormula)["Text"], '=FIND({"A";"B";"C"},"SAMPLE TEXT")') + self.assertEqual(get_state_as_dict(xFormula)["Text"], '=FIND({"A";"B";"C"},"SAMPLE TEXT")') - xOk = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOk) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) - document = self.ui_test.get_component() - #Without the fix in place, cell's value would have been #NAME? - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "2") + #Without the fix in place, cell's value would have been #NAME? + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "2") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/hide_cols/tdf95306.py b/sc/qa/uitest/hide_cols/tdf95306.py index 63f976849ee3..c53dd52b66c6 100644 --- a/sc/qa/uitest/hide_cols/tdf95306.py +++ b/sc/qa/uitest/hide_cols/tdf95306.py @@ -20,23 +20,21 @@ def get_column_hidden(doc, index): class HideDisjointColumns(UITestCase): def test_hide_columns(self): - self.ui_test.create_doc_in_start_center("calc") - xTopWindow = self.xUITest.getTopFocusWindow() - - gridwin = xTopWindow.getChild("grid_window") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1", "EXTEND":"true"})) - - doc = self.ui_test.get_component() - self.assertFalse(get_column_hidden(doc, 1)) - self.assertFalse(get_column_hidden(doc, 3)) - self.ui_test._xUITest.executeCommand(".uno:HideColumn") - self.assertTrue(get_column_hidden(doc, 1)) - self.assertTrue(get_column_hidden(doc, 3)) - self.ui_test._xUITest.executeCommand(".uno:Undo") - self.assertFalse(get_column_hidden(doc, 1)) - self.assertFalse(get_column_hidden(doc, 3)) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as doc: + xTopWindow = self.xUITest.getTopFocusWindow() + + gridwin = xTopWindow.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1", "EXTEND":"true"})) + + self.assertFalse(get_column_hidden(doc, 1)) + self.assertFalse(get_column_hidden(doc, 3)) + self.ui_test._xUITest.executeCommand(".uno:HideColumn") + self.assertTrue(get_column_hidden(doc, 1)) + self.assertTrue(get_column_hidden(doc, 3)) + self.ui_test._xUITest.executeCommand(".uno:Undo") + self.assertFalse(get_column_hidden(doc, 1)) + self.assertFalse(get_column_hidden(doc, 3)) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/inputLine/tdf54197.py b/sc/qa/uitest/inputLine/tdf54197.py index 54f2c5f56861..6ad8140b1f1e 100644 --- a/sc/qa/uitest/inputLine/tdf54197.py +++ b/sc/qa/uitest/inputLine/tdf54197.py @@ -18,21 +18,19 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf54197(UITestCase): def test_tdf54197_CTRL_D_input_line_change(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - # 1. go to cell A1 enter any text - enter_text_to_cell(gridwin, "A1", "t") - # 2. go to cell A2 press Ctrl+D - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - self.xUITest.executeCommand(".uno:FillDown") - # The same text as above is displayed at cell A2, BUT input line is still blank - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "t") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "t") - xInputWin = xCalcDoc.getChild("sc_input_window") - self.assertEqual(get_state_as_dict(xInputWin)["Text"], "t") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + # 1. go to cell A1 enter any text + enter_text_to_cell(gridwin, "A1", "t") + # 2. go to cell A2 press Ctrl+D + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + self.xUITest.executeCommand(".uno:FillDown") + # The same text as above is displayed at cell A2, BUT input line is still blank + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "t") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "t") + xInputWin = xCalcDoc.getChild("sc_input_window") + self.assertEqual(get_state_as_dict(xInputWin)["Text"], "t") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/inputLine/tdf67346.py b/sc/qa/uitest/inputLine/tdf67346.py index 324d8ca6384c..0af6e2f13204 100644 --- a/sc/qa/uitest/inputLine/tdf67346.py +++ b/sc/qa/uitest/inputLine/tdf67346.py @@ -18,28 +18,26 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf67346(UITestCase): def test_tdf67346_undo_paste_text_input_line(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - # type 'Apple' in A1 - enter_text_to_cell(gridwin, "A1", "Apple") - # input line: copy the text from there - xInputWin = xCalcDoc.getChild("sc_input_window") - xInputWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - self.xUITest.executeCommand(".uno:Copy") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - # Ctrl-V - self.xUITest.executeCommand(".uno:Paste") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Apple") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Apple") - self.assertEqual(get_state_as_dict(xInputWin)["Text"], "Apple") - #Ctrl-Z - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Apple") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") - self.assertEqual(get_state_as_dict(xInputWin)["Text"], "") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + # type 'Apple' in A1 + enter_text_to_cell(gridwin, "A1", "Apple") + # input line: copy the text from there + xInputWin = xCalcDoc.getChild("sc_input_window") + xInputWin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + # Ctrl-V + self.xUITest.executeCommand(".uno:Paste") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Apple") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Apple") + self.assertEqual(get_state_as_dict(xInputWin)["Text"], "Apple") + #Ctrl-Z + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Apple") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") + self.assertEqual(get_state_as_dict(xInputWin)["Text"], "") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/key_f4/f4.py b/sc/qa/uitest/key_f4/f4.py index e1be28dcda77..755c966daa57 100644 --- a/sc/qa/uitest/key_f4/f4.py +++ b/sc/qa/uitest/key_f4/f4.py @@ -15,115 +15,111 @@ from uitest.uihelper.calc import enter_text_to_cell class keyF4(UITestCase): def test_f4(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter data - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "2") - enter_text_to_cell(gridwin, "A3", "3") - enter_text_to_cell(gridwin, "B1", "=A1") - enter_text_to_cell(gridwin, "B2", "=A2") - enter_text_to_cell(gridwin, "B3", "=A3") - #select B1 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=$A$1") - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=A$1") - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=$A1") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "2") + enter_text_to_cell(gridwin, "A3", "3") + enter_text_to_cell(gridwin, "B1", "=A1") + enter_text_to_cell(gridwin, "B2", "=A2") + enter_text_to_cell(gridwin, "B3", "=A3") + #select B1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=$A$1") + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=A$1") + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getFormula(), "=$A1") - #non continuous select - #enter data - enter_text_to_cell(gridwin, "C1", "=A1") - enter_text_to_cell(gridwin, "C2", "=A2") - enter_text_to_cell(gridwin, "C3", "=A3") + #non continuous select + #enter data + enter_text_to_cell(gridwin, "C1", "=A1") + enter_text_to_cell(gridwin, "C2", "=A2") + enter_text_to_cell(gridwin, "C3", "=A3") - #select C1 and C3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C3", "EXTEND":"1"})) - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=$A$1") - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=$A$3") - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=A$1") - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=A$3") - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #verify - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=$A1") - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=$A3") + #select C1 and C3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C3", "EXTEND":"1"})) + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=$A$1") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=$A$3") + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=A$1") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=A$3") + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=$A1") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getFormula(), "=$A3") - self.ui_test.close_doc() def test_tdf39650_F4_R1C1(self): #Bug 39650 - Shift+F4 conversion from relative to absolute does not work for R1C1 syntax - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Excel R1C1") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Excel R1C1") - #In cell R3C3 enter "xxx". - enter_text_to_cell(gridwin, "C3", "xxx") - # In cell R2C2 type = and then click on the xxx in R3C3. - enter_text_to_cell(gridwin, "B2", "=R[1]C[1]") - # With cell R2C2 still selected, type Shift-F4. - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + #In cell R3C3 enter "xxx". + enter_text_to_cell(gridwin, "C3", "xxx") + # In cell R2C2 type = and then click on the xxx in R3C3. + enter_text_to_cell(gridwin, "B2", "=R[1]C[1]") + # With cell R2C2 still selected, type Shift-F4. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) - #F4 - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) + #F4 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "F4"})) - #This should change the formula in R2C2 from =R[1]C[1] to =R3C3. - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "xxx") - enter_text_to_cell(gridwin, "A1", "=FORMULA(R[1]C[1])") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3") + #This should change the formula in R2C2 from =R[1]C[1] to =R3C3. + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "xxx") + enter_text_to_cell(gridwin, "A1", "=FORMULA(R[1]C[1])") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=R3C3") - #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Calc A1") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Calc A1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/manual_tests/calc.py b/sc/qa/uitest/manual_tests/calc.py index 92c33e0d1803..bba77075f5bf 100644 --- a/sc/qa/uitest/manual_tests/calc.py +++ b/sc/qa/uitest/manual_tests/calc.py @@ -16,196 +16,188 @@ class ManualCalcTests(UITestCase): # http://manual-test.libreoffice.org/manage/case/189/ def test_define_database_range(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - # Select range A1:D10 - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D10"})) + # Select range A1:D10 + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D10"})) - # Execute "Define DB Range dialog" - self.ui_test.execute_modeless_dialog_through_command(".uno:DefineDBName") + # Execute "Define DB Range dialog" + self.ui_test.execute_modeless_dialog_through_command(".uno:DefineDBName") - xDefineNameDlg = self.xUITest.getTopFocusWindow() + xDefineNameDlg = self.xUITest.getTopFocusWindow() - xEntryBox = xDefineNameDlg.getChild("entry") - type_text(xEntryBox, "my_database") + xEntryBox = xDefineNameDlg.getChild("entry") + type_text(xEntryBox, "my_database") - xOkBtn = xDefineNameDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xOkBtn = xDefineNameDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) - # Deselect range - xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Deselect range + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - # Execute "Select DB Range dialog" - with self.ui_test.execute_dialog_through_command(".uno:SelectDB") as xSelectNameDlg: + # Execute "Select DB Range dialog" + with self.ui_test.execute_dialog_through_command(".uno:SelectDB") as xSelectNameDlg: - xListBox = xSelectNameDlg.getChild("treeview") - xListBoxState = get_state_as_dict(xListBox) - self.assertEqual(xListBoxState["SelectionCount"], "1") - self.assertEqual(xListBoxState["SelectEntryText"], "my_database") + xListBox = xSelectNameDlg.getChild("treeview") + xListBoxState = get_state_as_dict(xListBox) + self.assertEqual(xListBoxState["SelectionCount"], "1") + self.assertEqual(xListBoxState["SelectEntryText"], "my_database") - # Assert that the correct range has been selected - gridWinState = get_state_as_dict(xGridWin) - self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.D10") + # Assert that the correct range has been selected + gridWinState = get_state_as_dict(xGridWin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.D10") - self.ui_test.close_doc() # http://manual-test.libreoffice.org/manage/case/190/ def test_sort_data(self): - self.ui_test.create_doc_in_start_center("calc") - - # Insert data - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - enter_text_to_cell(xGridWin, "B1", "3") - enter_text_to_cell(xGridWin, "B2", "25") - enter_text_to_cell(xGridWin, "B3", "17") - enter_text_to_cell(xGridWin, "B4", "9") - enter_text_to_cell(xGridWin, "B5", "19") - enter_text_to_cell(xGridWin, "B6", "0") - enter_text_to_cell(xGridWin, "B7", "107") - enter_text_to_cell(xGridWin, "B8", "89") - enter_text_to_cell(xGridWin, "B9", "8") - enter_text_to_cell(xGridWin, "B10", "33") - - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B10"})) - - # Execute "Sort" dialog - with self.ui_test.execute_dialog_through_command(".uno:DataSort"): - pass - - document = self.ui_test.get_component() - - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 8) - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 9) - self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 17) - self.assertEqual(get_cell_by_position(document, 0, 1, 5).getValue(), 19) - self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 25) - self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 33) - self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 89) - self.assertEqual(get_cell_by_position(document, 0, 1, 9).getValue(), 107) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + + # Insert data + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + enter_text_to_cell(xGridWin, "B1", "3") + enter_text_to_cell(xGridWin, "B2", "25") + enter_text_to_cell(xGridWin, "B3", "17") + enter_text_to_cell(xGridWin, "B4", "9") + enter_text_to_cell(xGridWin, "B5", "19") + enter_text_to_cell(xGridWin, "B6", "0") + enter_text_to_cell(xGridWin, "B7", "107") + enter_text_to_cell(xGridWin, "B8", "89") + enter_text_to_cell(xGridWin, "B9", "8") + enter_text_to_cell(xGridWin, "B10", "33") + + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B10"})) + + # Execute "Sort" dialog + with self.ui_test.execute_dialog_through_command(".uno:DataSort"): + pass + + + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 8) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 9) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 17) + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getValue(), 19) + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 25) + self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 33) + self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 89) + self.assertEqual(get_cell_by_position(document, 0, 1, 9).getValue(), 107) + # http://manual-test.libreoffice.org/manage/case/191/ def test_validation(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xValidationDlg: + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xValidationDlg: - xAllowList = xValidationDlg.getChild("allow") - xAllowList.executeAction("SELECT", mkPropertyValues({"POS": "1"})) + xAllowList = xValidationDlg.getChild("allow") + xAllowList.executeAction("SELECT", mkPropertyValues({"POS": "1"})) - xData = xValidationDlg.getChild("data") - xData.executeAction("SELECT", mkPropertyValues({"POS": "5"})) + xData = xValidationDlg.getChild("data") + xData.executeAction("SELECT", mkPropertyValues({"POS": "5"})) - xVal = xValidationDlg.getChild("max") - xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) + xVal = xValidationDlg.getChild("max") + xVal.executeAction("TYPE", mkPropertyValues({"TEXT":"0"})) - def enter_text(cell, text): - enter_text_to_cell(xGridWin, cell, text) + def enter_text(cell, text): + enter_text_to_cell(xGridWin, cell, text) - with self.ui_test.execute_blocking_action(enter_text, args=("A1", "abc")): - pass - with self.ui_test.execute_blocking_action(enter_text, args=("B6", "2.18")): - pass + with self.ui_test.execute_blocking_action(enter_text, args=("A1", "abc")): + pass + with self.ui_test.execute_blocking_action(enter_text, args=("B6", "2.18")): + pass - enter_text_to_cell(xGridWin, "C2", "24") + enter_text_to_cell(xGridWin, "C2", "24") - self.ui_test.close_doc() # http://manual-test.libreoffice.org/manage/case/187/ def test_transpose(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - enter_text_to_cell(xGridWin, "B3", "abcd") - enter_text_to_cell(xGridWin, "B4", "edfg") - enter_text_to_cell(xGridWin, "C3", "35") - enter_text_to_cell(xGridWin, "C4", "5678") + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + enter_text_to_cell(xGridWin, "B3", "abcd") + enter_text_to_cell(xGridWin, "B4", "edfg") + enter_text_to_cell(xGridWin, "C3", "35") + enter_text_to_cell(xGridWin, "C4", "5678") - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C10"})) - self.xUITest.executeCommand(".uno:Cut") + self.xUITest.executeCommand(".uno:Cut") - xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xPasteSpecialDlg: + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xPasteSpecialDlg: - xAllChkBox = xPasteSpecialDlg.getChild("paste_all") - xAllChkBox.executeAction("CLICK", tuple()) + xAllChkBox = xPasteSpecialDlg.getChild("paste_all") + xAllChkBox.executeAction("CLICK", tuple()) - xTransposeChkBox = xPasteSpecialDlg.getChild("transpose") - xTransposeChkBox.executeAction("CLICK", tuple()) + xTransposeChkBox = xPasteSpecialDlg.getChild("transpose") + xTransposeChkBox.executeAction("CLICK", tuple()) - document = self.ui_test.get_component() - self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "abcd") - self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 35) - self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "edfg") - self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 5678) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "abcd") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 35) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "edfg") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 5678) - self.ui_test.close_doc() # http://manual-test.libreoffice.org/manage/case/151/ def test_cell_recalc(self): - with self.ui_test.load_file(get_url_for_data_file("cell_recalc.ods")) as doc: + with self.ui_test.load_file(get_url_for_data_file("cell_recalc.ods")) as document: xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:D9"})) self.xUITest.executeCommand(".uno:Cut") - self.assertEqual(get_cell_by_position(doc, 0, 3, 15).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 3, 15).getValue(), 0) self.xUITest.executeCommand(".uno:Undo") for i in range(1, 9): - self.assertTrue(get_cell_by_position(doc, 0, 3, i).getValue() != 0) + self.assertTrue(get_cell_by_position(document, 0, 3, i).getValue() != 0) - self.assertEqual(get_cell_by_position(doc, 0, 3, 15).getValue(), 195) + self.assertEqual(get_cell_by_position(document, 0, 3, 15).getValue(), 195) # http://manual-test.libreoffice.org/manage/case/143/ def test_random_numbers(self): - self.ui_test.create_doc_in_start_center("calc") - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A10"})) + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A10"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") - xRandomNumberDlg = self.xUITest.getTopFocusWindow() - xDistributionLstBox = xRandomNumberDlg.getChild("distribution-combo") - xDistributionLstBox.executeAction("SELECT", mkPropertyValues({"POS": "1"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") + xRandomNumberDlg = self.xUITest.getTopFocusWindow() + xDistributionLstBox = xRandomNumberDlg.getChild("distribution-combo") + xDistributionLstBox.executeAction("SELECT", mkPropertyValues({"POS": "1"})) - xMin = xRandomNumberDlg.getChild("parameter1-spin") - xMin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) - xMin.executeAction("TYPE", mkPropertyValues({"TEXT": "-2"})) - xMax = xRandomNumberDlg.getChild("parameter2-spin") - xMax.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) - xMax.executeAction("TYPE", mkPropertyValues({"TEXT": "10"})) + xMin = xRandomNumberDlg.getChild("parameter1-spin") + xMin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) + xMin.executeAction("TYPE", mkPropertyValues({"TEXT": "-2"})) + xMax = xRandomNumberDlg.getChild("parameter2-spin") + xMax.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+A"})) + xMax.executeAction("TYPE", mkPropertyValues({"TEXT": "10"})) - xApplyBtn = xRandomNumberDlg.getChild("apply") - xApplyBtn.executeAction("CLICK", tuple()) + xApplyBtn = xRandomNumberDlg.getChild("apply") + xApplyBtn.executeAction("CLICK", tuple()) - doc = self.ui_test.get_component() - def check_random_values(): - for i in range(1, 9): - val = get_cell_by_position(doc, 0, 0, i).getValue() - self.assertTrue(val <= 10 and val >= -2) + def check_random_values(): + for i in range(1, 9): + val = get_cell_by_position(document, 0, 0, i).getValue() + self.assertTrue(val <= 10 and val >= -2) - check_random_values() + check_random_values() - xOkBtn = xRandomNumberDlg.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xOkBtn = xRandomNumberDlg.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) - # we might want to check that clicking 'ok' actually changes the values - check_random_values() + # we might want to check that clicking 'ok' actually changes the values + check_random_values() - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/manual_tests/more_calc.py b/sc/qa/uitest/manual_tests/more_calc.py index 9212c2606e0e..71d913c68f37 100644 --- a/sc/qa/uitest/manual_tests/more_calc.py +++ b/sc/qa/uitest/manual_tests/more_calc.py @@ -21,29 +21,27 @@ class ManualCalcTests(UITestCase): # This test is to check that paste special combined with some options and link is ok. # Refers to tdf#84810 - self.ui_test.create_doc_in_start_center("calc") - - # Write text to cell A1 - xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") - enter_text_to_cell(xGridWin, "A1", "abcd") - - # Copy cell A1 to clipboard - xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - self.xUITest.executeCommand(".uno:Copy") - - # Set cursor to cell A3 - xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - - # Choose Paste Special Options and paste data - with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xPasteSpecialDlg: - xAllChkBox = xPasteSpecialDlg.getChild("paste_all") - xAllChkBox.executeAction("CLICK", tuple()) - xLinkChkBox = xPasteSpecialDlg.getChild("link") - xLinkChkBox.executeAction("CLICK", tuple()) - - # Assert successful paste - document = self.ui_test.get_component() - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "abcd") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + + # Write text to cell A1 + xGridWin = self.xUITest.getTopFocusWindow().getChild("grid_window") + enter_text_to_cell(xGridWin, "A1", "abcd") + + # Copy cell A1 to clipboard + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + + # Set cursor to cell A3 + xGridWin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + + # Choose Paste Special Options and paste data + with self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") as xPasteSpecialDlg: + xAllChkBox = xPasteSpecialDlg.getChild("paste_all") + xAllChkBox.executeAction("CLICK", tuple()) + xLinkChkBox = xPasteSpecialDlg.getChild("link") + xLinkChkBox.executeAction("CLICK", tuple()) + + # Assert successful paste + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "abcd") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/options/tdf122977.py b/sc/qa/uitest/options/tdf122977.py index 1ca0c1465dde..bcd97c4d3fe3 100644 --- a/sc/qa/uitest/options/tdf122977.py +++ b/sc/qa/uitest/options/tdf122977.py @@ -15,44 +15,42 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class chartDefaultColors(UITestCase): def test_tdf122977_crash_chart_default_colors_options(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #Go to Tools -> Options -> Charts -> Default Colors - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="cancel") as xDialogOpt: - - xPages = xDialogOpt.getChild("pages") - xChartEntry = xPages.getChild('5') # Charts - xChartEntry.executeAction("EXPAND", tuple()) - xChartGeneralEntry = xChartEntry.getChild('0') - xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors - xColors = xDialogOpt.getChild("colors") - xAdd = xDialogOpt.getChild("add") - xDelete = xDialogOpt.getChild("delete") - xDefault = xDialogOpt.getChild("default") - - #click Default - reset - xDefault.executeAction("CLICK", tuple()) - nrDefaultColors = get_state_as_dict(xColors)["Children"] - nrDefaultColors1 = int(nrDefaultColors) + 1 - xAdd.executeAction("CLICK", tuple()) #add new color - self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) - - #delete new color - with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"): - pass - - self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) - - xAdd.executeAction("CLICK", tuple()) #add new color - self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) - #click Default - xDefault.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #Go to Tools -> Options -> Charts -> Default Colors + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="cancel") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xChartEntry = xPages.getChild('5') # Charts + xChartEntry.executeAction("EXPAND", tuple()) + xChartGeneralEntry = xChartEntry.getChild('0') + xChartGeneralEntry.executeAction("SELECT", tuple()) #Default Colors + xColors = xDialogOpt.getChild("colors") + xAdd = xDialogOpt.getChild("add") + xDelete = xDialogOpt.getChild("delete") + xDefault = xDialogOpt.getChild("default") + + #click Default - reset + xDefault.executeAction("CLICK", tuple()) + nrDefaultColors = get_state_as_dict(xColors)["Children"] + nrDefaultColors1 = int(nrDefaultColors) + 1 + xAdd.executeAction("CLICK", tuple()) #add new color + self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) + + #delete new color + with self.ui_test.execute_blocking_action(xDelete.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) + + xAdd.executeAction("CLICK", tuple()) #add new color + self.assertEqual(get_state_as_dict(xColors)["Children"], str(nrDefaultColors1)) + #click Default + xDefault.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xColors)["Children"], nrDefaultColors) + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/protect/protectSheet.py b/sc/qa/uitest/protect/protectSheet.py index 353da927d1f6..9dc9e2accaa6 100644 --- a/sc/qa/uitest/protect/protectSheet.py +++ b/sc/qa/uitest/protect/protectSheet.py @@ -16,39 +16,37 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class protectSheet(UITestCase): def test_protect_sheet(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter password - lock - with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog: - xprotect = xDialog.getChild("protect") - xpassword1 = xDialog.getChild("password1") - xpassword2 = xDialog.getChild("password2") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter password - lock + with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog: + xprotect = xDialog.getChild("protect") + xpassword1 = xDialog.getChild("password1") + xpassword2 = xDialog.getChild("password2") - if (get_state_as_dict(xprotect)["Selected"]) == "false": - xprotect.executeAction("CLICK", tuple()) - xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + if (get_state_as_dict(xprotect)["Selected"]) == "false": + xprotect.executeAction("CLICK", tuple()) + xpassword1.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpassword2.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - #Unlock + #Unlock - with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog: - xpass1ed = xDialog.getChild("pass1ed") + with self.ui_test.execute_dialog_through_command(".uno:Protect") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - #Verify - the sheet is unlocked - enter_text_to_cell(gridwin, "B2", "A") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A") + #Verify - the sheet is unlocked + enter_text_to_cell(gridwin, "B2", "A") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "A") - # test cancel button - with self.ui_test.execute_dialog_through_command(".uno:Protect", close_button="cancel"): - pass + # test cancel button + with self.ui_test.execute_dialog_through_command(".uno:Protect", close_button="cancel"): + pass - enter_text_to_cell(gridwin, "B2", "B") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") + enter_text_to_cell(gridwin, "B2", "B") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/protect/protectSpreadsheet.py b/sc/qa/uitest/protect/protectSpreadsheet.py index 8659dc621e82..71fd6fa94da9 100644 --- a/sc/qa/uitest/protect/protectSpreadsheet.py +++ b/sc/qa/uitest/protect/protectSpreadsheet.py @@ -16,25 +16,23 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class protectSpreadsheet(UITestCase): def test_protect_spreadsheet(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter password - with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument") as xDialog: - xpass1ed = xDialog.getChild("pass1ed") - xconfirm1ed = xDialog.getChild("confirm1ed") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter password + with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") + xconfirm1ed = xDialog.getChild("confirm1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xconfirm1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - #Verify - with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument", close_button="cancel") as xDialog: - xpass1ed = xDialog.getChild("pass1ed") + #Verify + with self.ui_test.execute_dialog_through_command(".uno:ToolProtectionDocument", close_button="cancel") as xDialog: + xpass1ed = xDialog.getChild("pass1ed") - xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) + xpass1ed.executeAction("TYPE", mkPropertyValues({"TEXT":"aa"})) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/range_name/create_range_name.py b/sc/qa/uitest/range_name/create_range_name.py index 98cba79d88c2..14b4a1db3e43 100644 --- a/sc/qa/uitest/range_name/create_range_name.py +++ b/sc/qa/uitest/range_name/create_range_name.py @@ -17,155 +17,150 @@ class CreateRangeNameTest(UITestCase): def test_create_range_name(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - calcDoc = self.xUITest.getTopFocusWindow() - xPosWindow = calcDoc.getChild('pos_window') - self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) + calcDoc = self.xUITest.getTopFocusWindow() + xPosWindow = calcDoc.getChild('pos_window') + self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) - self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") + self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") - xAddNameDlg = self.xUITest.getTopFocusWindow() + xAddNameDlg = self.xUITest.getTopFocusWindow() - xEdit = xAddNameDlg.getChild("edit") - type_text(xEdit, "globalRangeName") + xEdit = xAddNameDlg.getChild("edit") + type_text(xEdit, "globalRangeName") - xAddBtn = xAddNameDlg.getChild("add") - self.ui_test.close_dialog_through_button(xAddBtn) + xAddBtn = xAddNameDlg.getChild("add") + self.ui_test.close_dialog_through_button(xAddBtn) - self.assertEqual('globalRangeName', get_state_as_dict(xPosWindow)['Text']) + self.assertEqual('globalRangeName', get_state_as_dict(xPosWindow)['Text']) - self.ui_test.close_doc() def test_create_range_name_from_ui(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "B1", "1") - enter_text_to_cell(gridwin, "C1", "1") + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "B1", "1") + enter_text_to_cell(gridwin, "C1", "1") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) - xPosWindow = calcDoc.getChild('pos_window') - self.assertEqual('A1:C1', get_state_as_dict(xPosWindow)['Text']) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) + xPosWindow = calcDoc.getChild('pos_window') + self.assertEqual('A1:C1', get_state_as_dict(xPosWindow)['Text']) - xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xPosWindow.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE1"})) - xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xPosWindow.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE1"})) + xPosWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) - self.assertEqual('RANGE1', get_state_as_dict(xPosWindow)['Text']) + self.assertEqual('RANGE1', get_state_as_dict(xPosWindow)['Text']) - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A2", "=SUM(RANGE1)") - self.assertEqual(3.0, get_cell_by_position(document, 0, 0, 1).getValue()) + enter_text_to_cell(gridwin, "A2", "=SUM(RANGE1)") + self.assertEqual(3.0, get_cell_by_position(document, 0, 0, 1).getValue()) - # Change the name - with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: - xNamesList = xDialog.getChild('names') - self.assertEqual(1, len(xNamesList.getChildren())) + # Change the name + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + xNamesList = xDialog.getChild('names') + self.assertEqual(1, len(xNamesList.getChildren())) - xName = xDialog.getChild('name') - self.assertEqual( 'RANGE1', get_state_as_dict(xName)["Text"]) + xName = xDialog.getChild('name') + self.assertEqual( 'RANGE1', get_state_as_dict(xName)["Text"]) - xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE2"})) + xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"RANGE2"})) - # tdf#87474 check the formula is updated after changing the name - self.assertEqual("=SUM(RANGE2)", get_cell_by_position(document, 0, 0, 1).getFormula()) + # tdf#87474 check the formula is updated after changing the name + self.assertEqual("=SUM(RANGE2)", get_cell_by_position(document, 0, 0, 1).getFormula()) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual("=SUM(RANGE1)", get_cell_by_position(document, 0, 0, 1).getFormula()) + self.assertEqual("=SUM(RANGE1)", get_cell_by_position(document, 0, 0, 1).getFormula()) - self.ui_test.close_doc() def test_create_local_range_name(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: - calcDoc = self.xUITest.getTopFocusWindow() - xPosWindow = calcDoc.getChild('pos_window') - self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) + calcDoc = self.xUITest.getTopFocusWindow() + xPosWindow = calcDoc.getChild('pos_window') + self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) - self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") + self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") - xAddNameDlg = self.xUITest.getTopFocusWindow() + xAddNameDlg = self.xUITest.getTopFocusWindow() - xEdit = xAddNameDlg.getChild("edit") - type_text(xEdit, "localRangeName") + xEdit = xAddNameDlg.getChild("edit") + type_text(xEdit, "localRangeName") - xScope = xAddNameDlg.getChild("scope") - select_pos(xScope, "1") + xScope = xAddNameDlg.getChild("scope") + select_pos(xScope, "1") - xAddBtn = xAddNameDlg.getChild("add") - self.ui_test.close_dialog_through_button(xAddBtn) + xAddBtn = xAddNameDlg.getChild("add") + self.ui_test.close_dialog_through_button(xAddBtn) - # tdf#67007: Without the fix in place, this test would have failed with - # AssertionError: 'localRangeName' != 'A1' - # Additionally, newly check a sheet-local scoped name has " (sheetname)" appended. - self.assertEqual('localRangeName (Sheet1)', get_state_as_dict(xPosWindow)['Text']) + # tdf#67007: Without the fix in place, this test would have failed with + # AssertionError: 'localRangeName' != 'A1' + # Additionally, newly check a sheet-local scoped name has " (sheetname)" appended. + self.assertEqual('localRangeName (Sheet1)', get_state_as_dict(xPosWindow)['Text']) - gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "1") + gridwin = calcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1") - # Use the name range in the current sheet - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + # Use the name range in the current sheet + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - with self.ui_test.execute_dialog_through_command(".uno:InsertName", close_button="paste") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:InsertName", close_button="paste") as xDialog: - xCtrl = xDialog.getChild('ctrl') - self.assertEqual(1, len(xCtrl.getChildren())) - self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) - xCtrl.getChild('0').executeAction("SELECT", tuple()) + xCtrl = xDialog.getChild('ctrl') + self.assertEqual(1, len(xCtrl.getChildren())) + self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) + xCtrl.getChild('0').executeAction("SELECT", tuple()) - # use return key to paste the name range - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + # use return key to paste the name range + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - document = self.ui_test.get_component() - self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) - self.assertEqual("=localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) + self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) + self.assertEqual("=localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) - # Insert a new sheet - with self.ui_test.execute_dialog_through_command(".uno:Insert"): - pass + # Insert a new sheet + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass - # Use the name range in the new sheet - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + # Use the name range in the new sheet + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - with self.ui_test.execute_dialog_through_command(".uno:InsertName", close_button="paste") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:InsertName", close_button="paste") as xDialog: - xCtrl = xDialog.getChild('ctrl') - self.assertEqual(1, len(xCtrl.getChildren())) - self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) - xCtrl.getChild('0').executeAction("SELECT", tuple()) + xCtrl = xDialog.getChild('ctrl') + self.assertEqual(1, len(xCtrl.getChildren())) + self.assertEqual("localRangeName\t$Sheet1.$A$1\tSheet1", get_state_as_dict(xCtrl.getChild('0'))['Text']) + xCtrl.getChild('0').executeAction("SELECT", tuple()) - # use return key to paste the name range - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + # use return key to paste the name range + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - # tdf#137896: Without the fix in place, this test would have failed with - # AssertionError: '1' != '#NAME?' - self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) + # tdf#137896: Without the fix in place, this test would have failed with + # AssertionError: '1' != '#NAME?' + self.assertEqual("1", get_cell_by_position(document, 0, 1, 0).getString()) - # and AssertionError: '=Sheet1.localRangeName' != '=localrangename' - self.assertEqual("=Sheet1.localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) + # and AssertionError: '=Sheet1.localRangeName' != '=localrangename' + self.assertEqual("=Sheet1.localRangeName", get_cell_by_position(document, 0, 1, 0).getFormula()) - with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: - # tdf#138851: Without the fix in place, this test would have failed with - # AssertionError: 'Sheet1' != 'Document (Global)' - xScope = xDialog.getChild("scope") - self.assertEqual("Sheet1", get_state_as_dict(xScope)['SelectEntryText']) + # tdf#138851: Without the fix in place, this test would have failed with + # AssertionError: 'Sheet1' != 'Document (Global)' + xScope = xDialog.getChild("scope") + self.assertEqual("Sheet1", get_state_as_dict(xScope)['SelectEntryText']) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/range_name/tdf137617.py b/sc/qa/uitest/range_name/tdf137617.py index 44410bff6de3..8e22158bb5a3 100644 --- a/sc/qa/uitest/range_name/tdf137617.py +++ b/sc/qa/uitest/range_name/tdf137617.py @@ -15,86 +15,85 @@ class tdf137617(UITestCase): def test_tdf137617(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - calcDoc = self.xUITest.getTopFocusWindow() - gridwin = calcDoc.getChild("grid_window") + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "Result1") - enter_text_to_cell(gridwin, "A2", "Result2") + enter_text_to_cell(gridwin, "A1", "Result1") + enter_text_to_cell(gridwin, "A2", "Result2") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B2"})) - with self.ui_test.execute_dialog_through_command(".uno:CreateNames") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:CreateNames") as xDialog: - # Only left is selected - self.assertEqual('true', get_state_as_dict(xDialog.getChild('left'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('top'))['Selected']) + # Only left is selected + self.assertEqual('true', get_state_as_dict(xDialog.getChild('left'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('top'))['Selected']) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) - xPosWindow = calcDoc.getChild('pos_window') - self.assertEqual('Result1', get_state_as_dict(xPosWindow)['Text']) + xPosWindow = calcDoc.getChild('pos_window') + self.assertEqual('Result1', get_state_as_dict(xPosWindow)['Text']) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) - self.assertEqual('Result2', get_state_as_dict(xPosWindow)['Text']) + self.assertEqual('Result2', get_state_as_dict(xPosWindow)['Text']) - # Change formula syntax to "Excel R1C1" - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + # Change formula syntax to "Excel R1C1" + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) - xFormulaSyntax = xDialogOpt.getChild('formulasyntax') - select_by_text(xFormulaSyntax, "Excel R1C1") + xFormulaSyntax = xDialogOpt.getChild('formulasyntax') + select_by_text(xFormulaSyntax, "Excel R1C1") - enter_text_to_cell(gridwin, "C1", "Result3") - enter_text_to_cell(gridwin, "D1", "Result4") + enter_text_to_cell(gridwin, "C1", "Result3") + enter_text_to_cell(gridwin, "D1", "Result4") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:D2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:D2"})) - with self.ui_test.execute_dialog_through_command(".uno:CreateNames") as xDialog: + with self.ui_test.execute_dialog_through_command(".uno:CreateNames") as xDialog: - # Only top is selected - self.assertEqual('false', get_state_as_dict(xDialog.getChild('left'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) - self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) - self.assertEqual('true', get_state_as_dict(xDialog.getChild('top'))['Selected']) + # Only top is selected + self.assertEqual('false', get_state_as_dict(xDialog.getChild('left'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('right'))['Selected']) + self.assertEqual('false', get_state_as_dict(xDialog.getChild('bottom'))['Selected']) + self.assertEqual('true', get_state_as_dict(xDialog.getChild('top'))['Selected']) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C2"})) - # Without the fix in place, this test would have failed with - # AssertionError: 'Result3' != 'R2C3' - self.assertEqual('Result3', get_state_as_dict(xPosWindow)['Text']) + # Without the fix in place, this test would have failed with + # AssertionError: 'Result3' != 'R2C3' + self.assertEqual('Result3', get_state_as_dict(xPosWindow)['Text']) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D2"})) - self.assertEqual('Result4', get_state_as_dict(xPosWindow)['Text']) + self.assertEqual('Result4', get_state_as_dict(xPosWindow)['Text']) - # Change formula syntax back to "Calc A1" - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + # Change formula syntax back to "Calc A1" + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) - xFormulaSyntax = xDialogOpt.getChild('formulasyntax') - select_by_text(xFormulaSyntax, "Calc A1") + xFormulaSyntax = xDialogOpt.getChild('formulasyntax') + select_by_text(xFormulaSyntax, "Calc A1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/range_name/tdf138822.py b/sc/qa/uitest/range_name/tdf138822.py index 361cc379e828..7cb8f990ed1b 100644 --- a/sc/qa/uitest/range_name/tdf138822.py +++ b/sc/qa/uitest/range_name/tdf138822.py @@ -11,53 +11,52 @@ from uitest.uihelper.common import type_text class tdf138822(UITestCase): def test_tdf138822(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - calcDoc = self.xUITest.getTopFocusWindow() - xPosWindow = calcDoc.getChild('pos_window') - self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) + calcDoc = self.xUITest.getTopFocusWindow() + xPosWindow = calcDoc.getChild('pos_window') + self.assertEqual('A1', get_state_as_dict(xPosWindow)['Text']) - self.ui_test.execute_modeless_dialog_through_command(".uno:DefineName") + self.ui_test.execute_modeless_dialog_through_command(".uno:DefineName") - xManageNamesDialog = self.xUITest.getTopFocusWindow() + xManageNamesDialog = self.xUITest.getTopFocusWindow() - xAddBtn = xManageNamesDialog.getChild("add") - self.ui_test.close_dialog_through_button(xAddBtn) + xAddBtn = xManageNamesDialog.getChild("add") + self.ui_test.close_dialog_through_button(xAddBtn) - xDefineNamesDialog = self.xUITest.getTopFocusWindow() + xDefineNamesDialog = self.xUITest.getTopFocusWindow() - xAddBtn = xDefineNamesDialog.getChild("add") - self.assertEqual("false", get_state_as_dict(xAddBtn)['Enabled']) + xAddBtn = xDefineNamesDialog.getChild("add") + self.assertEqual("false", get_state_as_dict(xAddBtn)['Enabled']) - xEdit = xDefineNamesDialog.getChild("edit") - type_text(xEdit, "rangeName") + xEdit = xDefineNamesDialog.getChild("edit") + type_text(xEdit, "rangeName") - self.assertEqual("true", get_state_as_dict(xAddBtn)['Enabled']) + self.assertEqual("true", get_state_as_dict(xAddBtn)['Enabled']) - self.ui_test.close_dialog_through_button(xAddBtn) + self.ui_test.close_dialog_through_button(xAddBtn) - xManageNamesDialog = self.xUITest.getTopFocusWindow() + xManageNamesDialog = self.xUITest.getTopFocusWindow() - xNamesList = xManageNamesDialog.getChild('names') - self.assertEqual(1, len(xNamesList.getChildren())) - self.assertEqual(get_state_as_dict(xNamesList.getChild('0'))["Text"], "rangeName\t$Sheet1.$A$1\tDocument (Global)") + xNamesList = xManageNamesDialog.getChild('names') + self.assertEqual(1, len(xNamesList.getChildren())) + self.assertEqual(get_state_as_dict(xNamesList.getChild('0'))["Text"], "rangeName\t$Sheet1.$A$1\tDocument (Global)") - xCancelBtn = xManageNamesDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + xCancelBtn = xManageNamesDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - # Open the dialog again - self.ui_test.execute_modeless_dialog_through_command(".uno:DefineName") + # Open the dialog again + self.ui_test.execute_modeless_dialog_through_command(".uno:DefineName") - xManageNamesDialog = self.xUITest.getTopFocusWindow() - xNamesList = xManageNamesDialog.getChild('names') + xManageNamesDialog = self.xUITest.getTopFocusWindow() + xNamesList = xManageNamesDialog.getChild('names') - # Without the fix in place, this test would have failed with - # AssertionError: 0 != 1 - self.assertEqual(0, len(xNamesList.getChildren())) + # Without the fix in place, this test would have failed with + # AssertionError: 0 != 1 + self.assertEqual(0, len(xNamesList.getChildren())) - xOkBtn = xManageNamesDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) + xOkBtn = xManageNamesDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/range_name/tdf86214.py b/sc/qa/uitest/range_name/tdf86214.py index 48817e0bcc64..6515ed74d97d 100644 --- a/sc/qa/uitest/range_name/tdf86214.py +++ b/sc/qa/uitest/range_name/tdf86214.py @@ -15,46 +15,45 @@ class InvalidNames(UITestCase): def test_invalid_names(self): - self.ui_test.create_doc_in_start_center("calc") + with self.ui_test.create_doc_in_start_center_guarded("calc"): - self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") + self.ui_test.execute_modeless_dialog_through_command(".uno:AddName") - xAddNameDlg = self.xUITest.getTopFocusWindow() + xAddNameDlg = self.xUITest.getTopFocusWindow() - invalid_names = ["A1", "12", "1.2", "A1:B2", "test.a", \ - "test+", "test-", "test*", "test!abc", "test#", \ - "test^", "test°", "test$", "test§", "test%", \ - "test&", "test/", "test(", "test)", "test[", "test]", \ - "test\\", "test`", "test´", "test'", "test~", "test<", \ - "tst>", "test|", "test:t", "test;z"] + invalid_names = ["A1", "12", "1.2", "A1:B2", "test.a", \ + "test+", "test-", "test*", "test!abc", "test#", \ + "test^", "test°", "test$", "test§", "test%", \ + "test&", "test/", "test(", "test)", "test[", "test]", \ + "test\\", "test`", "test´", "test'", "test~", "test<", \ + "tst>", "test|", "test:t", "test;z"] - xLabel = xAddNameDlg.getChild("label") - xAddBtn = xAddNameDlg.getChild("add") - xEdit = xAddNameDlg.getChild("edit") + xLabel = xAddNameDlg.getChild("label") + xAddBtn = xAddNameDlg.getChild("add") + xEdit = xAddNameDlg.getChild("edit") - success_text = get_state_as_dict(xLabel)["Text"] + success_text = get_state_as_dict(xLabel)["Text"] - for name in invalid_names: - with self.subTest(name = name): - select_all(xEdit) - type_text(xEdit, name) + for name in invalid_names: + with self.subTest(name = name): + select_all(xEdit) + type_text(xEdit, name) - # tdf#132869 - Without the fix in place, this test would have failed with - # - Expected: "Invalid name. Start with a letter, use only letters, numbers and underscore." - # - Actual : "" - self.assertNotEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) - self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "false") + # tdf#132869 - Without the fix in place, this test would have failed with + # - Expected: "Invalid name. Start with a letter, use only letters, numbers and underscore." + # - Actual : "" + self.assertNotEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) + self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "false") - select_all(xEdit) - type_text(xEdit, "valid_name") + select_all(xEdit) + type_text(xEdit, "valid_name") - self.assertEqual(success_text, get_state_as_dict(xLabel)["Text"]) - self.assertEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) - self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "true") + self.assertEqual(success_text, get_state_as_dict(xLabel)["Text"]) + self.assertEqual(success_text, get_state_as_dict(xEdit)["QuickHelpText"]) + self.assertEqual(get_state_as_dict(xAddBtn)["Enabled"], "true") - self.ui_test.close_dialog_through_button(xAddBtn) + self.ui_test.close_dialog_through_button(xAddBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/search_replace/tdf132097.py b/sc/qa/uitest/search_replace/tdf132097.py index 5585befb6da3..007ae4d734bc 100644 --- a/sc/qa/uitest/search_replace/tdf132097.py +++ b/sc/qa/uitest/search_replace/tdf132097.py @@ -11,29 +11,28 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf132097(UITestCase): def test_tdf132097(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCols = xDialog.getChild('cols') - xSearchTerm = xDialog.getChild("searchterm") - xBackSearch = xDialog.getChild("backsearch") - xSeachLabel = xDialog.getChild("searchlabel") + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCols = xDialog.getChild('cols') + xSearchTerm = xDialog.getChild("searchterm") + xBackSearch = xDialog.getChild("backsearch") + xSeachLabel = xDialog.getChild("searchlabel") - xCols.executeAction("CLICK", tuple()) - xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT":"TEST"})) + xCols.executeAction("CLICK", tuple()) + xSearchTerm.executeAction("TYPE", mkPropertyValues({"TEXT":"TEST"})) - for i in range(10): - # without the fix in place it would crash here. - # Sometimes it doesn't crash at first so try a few times to be sure - xBackSearch.executeAction("CLICK", tuple()) + for i in range(10): + # without the fix in place it would crash here. + # Sometimes it doesn't crash at first so try a few times to be sure + xBackSearch.executeAction("CLICK", tuple()) - self.assertEqual(get_state_as_dict(xSeachLabel)["Text"], "Search key not found") + self.assertEqual(get_state_as_dict(xSeachLabel)["Text"], "Search key not found") - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/search_replace/tdf39917.py b/sc/qa/uitest/search_replace/tdf39917.py index 3431b102af1b..74b4ec02bd6f 100644 --- a/sc/qa/uitest/search_replace/tdf39917.py +++ b/sc/qa/uitest/search_replace/tdf39917.py @@ -18,79 +18,77 @@ from uitest.debug import sleep class tdf39917(UITestCase): def test_tdf39917_find_replace_R1C1(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #* Tools --> Options --> Calc --> Formula --> Syntax = Excel R1C1 + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Excel R1C1") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Excel R1C1") - #1. Create a workbook with 3 sheets: Page1, Page2, Page3. - # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1 - # 5. Fill fields: + #1. Create a workbook with 3 sheets: Page1, Page2, Page3. + # 2. Tools -> Options -> LibreOffice Calc -> Formula: Set syntax to Excel A1 + # 5. Fill fields: - with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: - after = xDialog.getChild("after") - after.executeAction("CLICK", tuple()) - nameed = xDialog.getChild("nameed") - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) - with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: - after = xDialog.getChild("after") - after.executeAction("CLICK", tuple()) - nameed = xDialog.getChild("nameed") - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) - # 3. Type in (for example) B4: =Page2!B4 - enter_text_to_cell(gridwin, "B4", "=Page2!RC") - # 4. Edit -> Find and Replace - # Find: Page2 - # Replace: Page3 - # 6. Press Replace all - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox - replace = xDialog.getChild("replace") - replace.executeAction("CLICK", tuple()) - replace.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + nameed = xDialog.getChild("nameed") + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) + with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + nameed = xDialog.getChild("nameed") + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + nameed.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + nameed.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + # 3. Type in (for example) B4: =Page2!B4 + enter_text_to_cell(gridwin, "B4", "=Page2!RC") + # 4. Edit -> Find and Replace + # Find: Page2 + # Replace: Page3 + # 6. Press Replace all + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page2"})) + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"Page3"})) #replace textbox + replace = xDialog.getChild("replace") + replace.executeAction("CLICK", tuple()) + replace.executeAction("CLICK", tuple()) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - #verify - enter_text_to_cell(gridwin, "A1", "=FORMULA(R[3]C[1])") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=Page3!RC") - #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 - with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + #verify + enter_text_to_cell(gridwin, "A1", "=FORMULA(R[3]C[1])") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "=Page3!RC") + #Give it back Tools --> Options --> Calc --> Formula --> Syntax = Calc A1 + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: - xPages = xDialogOpt.getChild("pages") - xCalcEntry = xPages.getChild('3') # Calc - xCalcEntry.executeAction("EXPAND", tuple()) - xCalcFormulaEntry = xCalcEntry.getChild('4') - xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcFormulaEntry = xCalcEntry.getChild('4') + xCalcFormulaEntry.executeAction("SELECT", tuple()) #Formula - formulasyntax = xDialogOpt.getChild("formulasyntax") - #Excel R1C1 - select_by_text(formulasyntax, "Calc A1") + formulasyntax = xDialogOpt.getChild("formulasyntax") + #Excel R1C1 + select_by_text(formulasyntax, "Calc A1") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/search_replace/tdf44398.py b/sc/qa/uitest/search_replace/tdf44398.py index c44305cb01d1..f18f311fe989 100644 --- a/sc/qa/uitest/search_replace/tdf44398.py +++ b/sc/qa/uitest/search_replace/tdf44398.py @@ -17,77 +17,73 @@ from uitest.debug import sleep class tdf44398(UITestCase): def test_tdf44398_find_replace_regexp(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # 1. A1 => 123456 - enter_text_to_cell(gridwin, "A1", "123456") - # 2. ctrl-h, in dialog - # Search: ([0-9]) - # Replace: $1 - # check regular expression - # hit replace all + # 1. A1 => 123456 + enter_text_to_cell(gridwin, "A1", "123456") + # 2. ctrl-h, in dialog + # Search: ([0-9]) + # Replace: $1 + # check regular expression + # hit replace all - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([0-9])"})) - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) #replace textbox - regexp = xDialog.getChild("regexp") - regexp.executeAction("CLICK", tuple()) #regular expressions - replaceall = xDialog.getChild("replaceall") - replaceall.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([0-9])"})) + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) #replace textbox + regexp = xDialog.getChild("regexp") + regexp.executeAction("CLICK", tuple()) #regular expressions + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - #verify 3. A1 => 123456 - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "123456") + #verify 3. A1 => 123456 + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "123456") - self.ui_test.close_doc() def test_tdf44398_find_replace_regexp_string(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - # 1. A1 => VarNumberA - enter_text_to_cell(gridwin, "A1", "VarNumberA") - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) - # 2. ctrl-h, in dialog - # Search: ([A-Z]) - # Replace: <space>$1 - # check regular expression - # check case - # hit replace all + # 1. A1 => VarNumberA + enter_text_to_cell(gridwin, "A1", "VarNumberA") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + # 2. ctrl-h, in dialog + # Search: ([A-Z]) + # Replace: <space>$1 + # check regular expression + # check case + # hit replace all - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([A-Z])"})) - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":" $1"})) #replace textbox - regexp = xDialog.getChild("regexp") - if (get_state_as_dict(regexp)["Selected"]) == "false": - regexp.executeAction("CLICK", tuple()) #regular expressions - matchcase = xDialog.getChild("matchcase") - matchcase.executeAction("CLICK", tuple()) #case + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"([A-Z])"})) + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":" $1"})) #replace textbox + regexp = xDialog.getChild("regexp") + if (get_state_as_dict(regexp)["Selected"]) == "false": + regexp.executeAction("CLICK", tuple()) #regular expressions + matchcase = xDialog.getChild("matchcase") + matchcase.executeAction("CLICK", tuple()) #case - replaceall = xDialog.getChild("replaceall") - replaceall.executeAction("CLICK", tuple()) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - #verify A1 => ' Var Number A' - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " Var Number A") + #verify A1 => ' Var Number A' + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " Var Number A") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/search_replace/tdf57523.py b/sc/qa/uitest/search_replace/tdf57523.py index 36159dd7133a..3eb890622d2f 100644 --- a/sc/qa/uitest/search_replace/tdf57523.py +++ b/sc/qa/uitest/search_replace/tdf57523.py @@ -13,42 +13,40 @@ from uitest.uihelper.common import get_state_as_dict class tdf57523(UITestCase): def test_tdf57523(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "AAA") - enter_text_to_cell(gridwin, "A4", "AAA") + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A4", "AAA") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") - xDialog = self.xUITest.getTopFocusWindow() - searchterm = xDialog.getChild("searchterm") - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"^$"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:SearchDialog") + xDialog = self.xUITest.getTopFocusWindow() + searchterm = xDialog.getChild("searchterm") + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + searchterm.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + searchterm.executeAction("TYPE", mkPropertyValues({"TEXT":"^$"})) - replaceterm = xDialog.getChild("replaceterm") - replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"BBB"})) - regexp = xDialog.getChild("regexp") + replaceterm = xDialog.getChild("replaceterm") + replaceterm.executeAction("TYPE", mkPropertyValues({"TEXT":"BBB"})) + regexp = xDialog.getChild("regexp") - if get_state_as_dict(regexp)['Selected'] == 'false': - regexp.executeAction("CLICK", tuple()) - self.assertEqual("true", get_state_as_dict(regexp)['Selected']) + if get_state_as_dict(regexp)['Selected'] == 'false': + regexp.executeAction("CLICK", tuple()) + self.assertEqual("true", get_state_as_dict(regexp)['Selected']) - replaceall = xDialog.getChild("replaceall") - replaceall.executeAction("CLICK", tuple()) + replaceall = xDialog.getChild("replaceall") + replaceall.executeAction("CLICK", tuple()) - xcloseBtn = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xcloseBtn) + xcloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xcloseBtn) - # Without the fix in place, this test would have failed with - # AssertionError: '' != 'BBB' - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") + # Without the fix in place, this test would have failed with + # AssertionError: '' != 'BBB' + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/signatureLine/insertSignatureLine.py b/sc/qa/uitest/signatureLine/insertSignatureLine.py index 7032858ef1c6..8281e14162ef 100644 --- a/sc/qa/uitest/signatureLine/insertSignatureLine.py +++ b/sc/qa/uitest/signatureLine/insertSignatureLine.py @@ -15,76 +15,72 @@ from com.sun.star.lang import IndexOutOfBoundsException class insertSignatureLineCalc(UITestCase): def test_insert_signature_line_calc(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - # cancel the dialog without doing anything - with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine", close_button="cancel") as xDialog: - - xName = xDialog.getChild("edit_name") - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - - with self.assertRaises(IndexOutOfBoundsException): - document.Sheets.getByIndex(0).DrawPage.getByIndex(0) - - # set the signature line - with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") as xDialog: - - xName = xDialog.getChild("edit_name") - xTitle = xDialog.getChild("edit_title") - xEmail = xDialog.getChild("edit_email") - xComment = xDialog.getChild("checkbox_can_add_comments") - xInstructions = xDialog.getChild("edit_instructions") - - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) - xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) - xComment.executeAction("CLICK", tuple()) - xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) - - #check the signature Line in the document - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerEmail, "Email") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineCanAddComment, False) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineShowSignDate, True) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSigningInstructions, "Instructions") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + # cancel the dialog without doing anything + with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine", close_button="cancel") as xDialog: + + xName = xDialog.getChild("edit_name") + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + + with self.assertRaises(IndexOutOfBoundsException): + document.Sheets.getByIndex(0).DrawPage.getByIndex(0) + + # set the signature line + with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") as xDialog: + + xName = xDialog.getChild("edit_name") + xTitle = xDialog.getChild("edit_title") + xEmail = xDialog.getChild("edit_email") + xComment = xDialog.getChild("checkbox_can_add_comments") + xInstructions = xDialog.getChild("edit_instructions") + + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) + xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) + xComment.executeAction("CLICK", tuple()) + xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) + + #check the signature Line in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerEmail, "Email") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineCanAddComment, False) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineShowSignDate, True) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSigningInstructions, "Instructions") + def test_insert_signature_line2_calc(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") as xDialog: - - xName = xDialog.getChild("edit_name") - xTitle = xDialog.getChild("edit_title") - xEmail = xDialog.getChild("edit_email") - xComment = xDialog.getChild("checkbox_can_add_comments") - xDate = xDialog.getChild("checkbox_show_sign_date") - xInstructions = xDialog.getChild("edit_instructions") - - xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line - xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) - xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) - xDate.executeAction("CLICK", tuple()) - xComment.executeAction("CLICK", tuple()) - xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) - - #check the signature Line in the document - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerEmail, "Email") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineCanAddComment, False) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineShowSignDate, False) - self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSigningInstructions, "Instructions") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + with self.ui_test.execute_dialog_through_command(".uno:InsertSignatureLine") as xDialog: + + xName = xDialog.getChild("edit_name") + xTitle = xDialog.getChild("edit_title") + xEmail = xDialog.getChild("edit_email") + xComment = xDialog.getChild("checkbox_can_add_comments") + xDate = xDialog.getChild("checkbox_show_sign_date") + xInstructions = xDialog.getChild("edit_instructions") + + xName.executeAction("TYPE", mkPropertyValues({"TEXT":"Name"})) #set the signature line + xTitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Title"})) + xEmail.executeAction("TYPE", mkPropertyValues({"TEXT":"Email"})) + xDate.executeAction("CLICK", tuple()) + xComment.executeAction("CLICK", tuple()) + xInstructions.executeAction("TYPE", mkPropertyValues({"TEXT":"Instructions"})) + + #check the signature Line in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerName, "Name") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerEmail, "Email") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSuggestedSignerTitle, "Title") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineCanAddComment, False) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineShowSignDate, False) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).SignatureLineSigningInstructions, "Instructions") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/naturalSort.py b/sc/qa/uitest/sort/naturalSort.py index 373fd8bbe3c0..15b160f41eda 100644 --- a/sc/qa/uitest/sort/naturalSort.py +++ b/sc/qa/uitest/sort/naturalSort.py @@ -18,87 +18,83 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class CalcNaturalSorting(UITestCase): def test_natural_sorting_rows(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter data - enter_text_to_cell(gridwin, "A1", "MW100SSMOU456.996JIL4") - enter_text_to_cell(gridwin, "A2", "MW180SSMOU456.996JIL4") - enter_text_to_cell(gridwin, "A3", "MW110SSMOU456.993JIL4") - enter_text_to_cell(gridwin, "A4", "MW180SSMOU456.994JIL4") - enter_text_to_cell(gridwin, "A5", "MW101SSMOU456.996JIL4") - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xNatural = xDialog.getChild("naturalsort") - xNatural.executeAction("CLICK", tuple()) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW101SSMOU456.996JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW180SSMOU456.996JIL4") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW180SSMOU456.996JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW101SSMOU456.996JIL4") - #enter data - enter_text_to_cell(gridwin, "D1", "MW-2") - enter_text_to_cell(gridwin, "D2", "MW-20") - enter_text_to_cell(gridwin, "D3", "MW-1") - enter_text_to_cell(gridwin, "D4", "MW-18") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "MW100SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A2", "MW180SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A3", "MW110SSMOU456.993JIL4") + enter_text_to_cell(gridwin, "A4", "MW180SSMOU456.994JIL4") + enter_text_to_cell(gridwin, "A5", "MW101SSMOU456.996JIL4") + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW101SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW180SSMOU456.996JIL4") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW180SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW101SSMOU456.996JIL4") + #enter data + enter_text_to_cell(gridwin, "D1", "MW-2") + enter_text_to_cell(gridwin, "D2", "MW-20") + enter_text_to_cell(gridwin, "D3", "MW-1") + enter_text_to_cell(gridwin, "D4", "MW-18") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:D4"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:D4"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-1") - self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "MW-2") - self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "MW-18") - self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "MW-20") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "MW-20") - self.ui_test.close_doc() def test_natural_sorting_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter data - enter_text_to_cell(gridwin, "A1", "MW-2") - enter_text_to_cell(gridwin, "B1", "MW-20") - enter_text_to_cell(gridwin, "C1", "MW-1") - enter_text_to_cell(gridwin, "D1", "MW-18") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "MW-2") + enter_text_to_cell(gridwin, "B1", "MW-20") + enter_text_to_cell(gridwin, "C1", "MW-1") + enter_text_to_cell(gridwin, "D1", "MW-18") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - xleftright.executeAction("CLICK", tuple()) - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xleftright.executeAction("CLICK", tuple()) + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "MW-2") - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "MW-18") - self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-20") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-20") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/sorting.py b/sc/qa/uitest/sort/sorting.py index 2c2c56fc2bf7..1aae9da04de0 100644 --- a/sc/qa/uitest/sort/sorting.py +++ b/sc/qa/uitest/sort/sorting.py @@ -18,268 +18,256 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class CalcSorting(UITestCase): def test_Sortingbuttons_detect_columnheaders(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Number") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "Misc") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select cell A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Press toolbarbutton for descending sorting .uno:SortDescending - self.xUITest.executeCommand(".uno:SortDescending") - #Verify that cell A1 still contains "Number" and B1 "Misc" - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Select cell B3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - #Press toolbar button for ascending sorting - self.xUITest.executeCommand(".uno:SortAscending") - #Verify that cell A1 still contains "Number" and B1 "Misc" - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Select cell A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Open sort dialog by DATA - SORT /Switch to tabpage Options - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") - #Cancel dialog - #Select Range A1:B5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) - #Press toolbarbutton for descending sorting - self.xUITest.executeCommand(".uno:SortDescending") - #Verify that cell A1 still contains "Number" and B1 "Misc" - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Press toolbarbutton for descending sorting + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") def test_Sortingbuttons_list_has_not_columnheaders(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: 5; 3; 4; 6; 2 / In column B enter: e; s; d; f; g - enter_text_to_cell(gridwin, "A1", "5") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "e") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select cell A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Press toolbar button for ascending sorting - self.xUITest.executeCommand(".uno:SortAscending") - #Verify that cell A1 no longer contains "5" and B1 no longer contains "e" - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() != "5", True) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString() != "e", True) - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Select cell B3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - #Open sort dialog by DATA - SORT /Switch to tabpage Options - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #Verify that option "Range contains column labels" is not set - xHeader = xDialog.getChild("header") - self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") - #Cancel dialog - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: 5; 3; 4; 6; 2 / In column B enter: e; s; d; f; g + enter_text_to_cell(gridwin, "A1", "5") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "e") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 no longer contains "5" and B1 no longer contains "e" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() != "5", True) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString() != "e", True) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is not set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") + #Cancel dialog def test_Sorting_default_to_selected_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Number") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "Misc") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select cell A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Press toolbarbutton for descending sorting .uno:SortDescending - self.xUITest.executeCommand(".uno:SortDescending") - #Verify that the sortorder was determined for column A (Number;2;3;4;6) - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 6) - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 4) - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 2) - #UNDO - self.xUITest.executeCommand(".uno:Undo") - #Select cell B3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - #Press toolbar button for ascending sorting - self.xUITest.executeCommand(".uno:SortAscending") - #Verify that the sortorder was determined for column B (Misc;s;g;f;d) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") - self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 2) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;s;g;f;d) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") - self.ui_test.close_doc() def test_Sorting_default_to_selected_TAB_A_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Number") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "Misc") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select Range A1:B5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) - #Move the active cell inside the range to column A by using the TAB key - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - #Press toolbar button for ascending sorting - self.xUITest.executeCommand(".uno:SortAscending") - #Verify that the sortorder was determined for column A (Number;2;3;4;6) - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 6) + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 6) - self.ui_test.close_doc() def test_Sorting_default_to_selected_TAB_B_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Number") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "Misc") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select Range A1:B5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) - #Move the active cell inside the range to column B by using the TAB key - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - #Press toolbar button for ascending sorting - self.xUITest.executeCommand(".uno:SortAscending") - #Verify that the sortorder was determined for column B (Misc;d;f;g;s) - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") - self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") - self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") - self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") - self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;d;f;g;s) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") - self.ui_test.close_doc() def test_Sorting_sort_criteria(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Number") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "4") - enter_text_to_cell(gridwin, "A4", "6") - enter_text_to_cell(gridwin, "A5", "2") - enter_text_to_cell(gridwin, "B1", "Misc") - enter_text_to_cell(gridwin, "B2", "s") - enter_text_to_cell(gridwin, "B3", "d") - enter_text_to_cell(gridwin, "B4", "f") - enter_text_to_cell(gridwin, "B5", "g") - #Select cell A3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Number(ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - #Select cell B3 - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Misc (ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - #Select Range A1:B5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) - #Move the active cell inside the range to column A by using the TAB key - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Number(ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog - #Select Range A1:B5 - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) - #Move the active cell inside the range to column B by using the TAB key - gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - #Verify that the first sort criteria is set to "Misc (ascending)" - xSortKey1 = xDialog.getChild("sortlb") - xAsc = xDialog.getChild("up") - self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") - self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") - #Cancel dialog + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/subtotals.py b/sc/qa/uitest/sort/subtotals.py index b48079a02ec8..2ed2a60fecc2 100644 --- a/sc/qa/uitest/sort/subtotals.py +++ b/sc/qa/uitest/sort/subtotals.py @@ -17,32 +17,30 @@ from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file class Subtotals(UITestCase): def test_tdf114720(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - XcalcDoc = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() - gridwin = XcalcDoc.getChild("grid_window") - - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "1") - enter_text_to_cell(gridwin, "A3", "1") - enter_text_to_cell(gridwin, "A4", "1") - enter_text_to_cell(gridwin, "A5", "1") - enter_text_to_cell(gridwin, "A6", "1") - enter_text_to_cell(gridwin, "A7", "1") - enter_text_to_cell(gridwin, "A8", "1") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) - - with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals"): - pass - - self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "") - - # check cancel button - with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals", close_button="cancel"): - pass - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "1") + enter_text_to_cell(gridwin, "A4", "1") + enter_text_to_cell(gridwin, "A5", "1") + enter_text_to_cell(gridwin, "A6", "1") + enter_text_to_cell(gridwin, "A7", "1") + enter_text_to_cell(gridwin, "A8", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "") + + # check cancel button + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals", close_button="cancel"): + pass + def test_tdf88792(self): with self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) as calc_doc: diff --git a/sc/qa/uitest/sort/tdf100517.py b/sc/qa/uitest/sort/tdf100517.py index 350d233f12f6..c2a36be8d758 100644 --- a/sc/qa/uitest/sort/tdf100517.py +++ b/sc/qa/uitest/sort/tdf100517.py @@ -27,51 +27,49 @@ class tdf100517(UITestCase): def test_tdf100517(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "Text 2") - enter_text_to_cell(gridwin, "A2", "Text 3") - enter_text_to_cell(gridwin, "A3", "Text 1") + enter_text_to_cell(gridwin, "A1", "Text 2") + enter_text_to_cell(gridwin, "A2", "Text 3") + enter_text_to_cell(gridwin, "A3", "Text 1") - for i in ['B1', 'B2', 'B3']: - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": i})) - xArgs = mkPropertyValues({"Text": i}) + for i in ['B1', 'B2', 'B3']: + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": i})) + xArgs = mkPropertyValues({"Text": i}) - self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) + self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) - self.execute_sort_dialog(gridwin, "true") + self.execute_sort_dialog(gridwin, "true") - self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) - self.assertEqual("B3", get_cell_by_position(document, 0, 1, 0).Annotation.String) - self.assertEqual("B1", get_cell_by_position(document, 0, 1, 1).Annotation.String) - self.assertEqual("B2", get_cell_by_position(document, 0, 1, 2).Annotation.String) + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 2).Annotation.String) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 2).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 2).getString()) - self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) - self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) - self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) - self.execute_sort_dialog(gridwin, "false") + self.execute_sort_dialog(gridwin, "false") - self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) - self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) - self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) - self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) + self.assertEqual("B1", get_cell_by_position(document, 0, 1, 0).Annotation.String) + self.assertEqual("B2", get_cell_by_position(document, 0, 1, 1).Annotation.String) + self.assertEqual("B3", get_cell_by_position(document, 0, 1, 2).Annotation.String) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf126678.py b/sc/qa/uitest/sort/tdf126678.py index 1a12a8b2bc7f..11c2d9a621b6 100644 --- a/sc/qa/uitest/sort/tdf126678.py +++ b/sc/qa/uitest/sort/tdf126678.py @@ -27,46 +27,44 @@ class tdf126678(UITestCase): def test_tdf126678(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") - enter_text_to_cell(gridwin, "A1", "Text 2") - enter_text_to_cell(gridwin, "A2", "Text 3") - enter_text_to_cell(gridwin, "A3", "Text 1") + enter_text_to_cell(gridwin, "A1", "Text 2") + enter_text_to_cell(gridwin, "A2", "Text 3") + enter_text_to_cell(gridwin, "A3", "Text 1") - # Set the background of the corresponding cell - colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) - self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + # Set the background of the corresponding cell + colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) - self.execute_sort_dialog(gridwin, "false") + self.execute_sort_dialog(gridwin, "false") - self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) - # Sorting without option "including formats" does not include cells with cell formats - self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) - self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, 16776960) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, -1) + # Sorting without option "including formats" does not include cells with cell formats + self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, 16776960) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, -1) - self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") - self.execute_sort_dialog(gridwin, "true") + self.execute_sort_dialog(gridwin, "true") - self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) - self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) - self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) + self.assertEqual("Text 1", get_cell_by_position(document, 0, 0, 0).getString()) + self.assertEqual("Text 2", get_cell_by_position(document, 0, 0, 1).getString()) + self.assertEqual("Text 3", get_cell_by_position(document, 0, 0, 2).getString()) - # Sorting with option "including formats" includes all cells with visible cell formats - # tdf126678 - Without the fix in place, the test would have failed with - # AssertionError: -1 != 16776960 - self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) - self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, -1) - self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, 16776960) + # Sorting with option "including formats" includes all cells with visible cell formats + # tdf126678 - Without the fix in place, the test would have failed with + # AssertionError: -1 != 16776960 + self.assertEqual(get_cell_by_position(document, 0, 1, 0).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).CellBackColor, -1) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).CellBackColor, 16776960) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf53482.py b/sc/qa/uitest/sort/tdf53482.py index b54196e89997..fdfbe1947c78 100644 --- a/sc/qa/uitest/sort/tdf53482.py +++ b/sc/qa/uitest/sort/tdf53482.py @@ -44,39 +44,37 @@ class tdf53482(UITestCase): self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 123).getString(), "13") def test_tdf53482_Range_contains_column_headings(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter: Misc; s; d; f; g - enter_text_to_cell(gridwin, "A1", "Misc") - enter_text_to_cell(gridwin, "A2", "s") - enter_text_to_cell(gridwin, "A3", "d") - enter_text_to_cell(gridwin, "A4", "f") - enter_text_to_cell(gridwin, "A5", "g") - #1. Highlight cells to be sorted - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) - #2. Click Data menu, Sort - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - #3. On Options tab, tick 'Range contains column labels' - xHeader = xDialog.getChild("header") - xHeader.executeAction("CLICK", tuple()) - if (get_state_as_dict(xHeader)["Selected"]) == "false": + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Misc") + enter_text_to_cell(gridwin, "A2", "s") + enter_text_to_cell(gridwin, "A3", "d") + enter_text_to_cell(gridwin, "A4", "f") + enter_text_to_cell(gridwin, "A5", "g") + #1. Highlight cells to be sorted + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + #2. Click Data menu, Sort + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") xHeader.executeAction("CLICK", tuple()) - #4. On Sort Criteria tab, set appropriate criteria - select_pos(xTabs, "0") - xDown = xDialog.getChild("down") - xDown.executeAction("CLICK", tuple()) - #5. Click Ok - #6. Expected behavior: Ignore column labels when sorting - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "g") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "f") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "d") + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + #5. Click Ok + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "d") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf91305.py b/sc/qa/uitest/sort/tdf91305.py index 481d429c2531..e49cf3a6149e 100644 --- a/sc/qa/uitest/sort/tdf91305.py +++ b/sc/qa/uitest/sort/tdf91305.py @@ -18,117 +18,110 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf91305(UITestCase): def test_tdf91305_sort_text_cells_rows(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter texts - enter_text_to_cell(gridwin, "A1", "cc") - enter_text_to_cell(gridwin, "A2", "ff") - enter_text_to_cell(gridwin, "A3", "aa") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) - #Press toolbarbutton for ascending sorting .uno:SortAsc - self.xUITest.executeCommand(".uno:SortAscending") - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "ff") - #Press toolbarbutton for descending sorting .uno:SortDescending - self.xUITest.executeCommand(".uno:SortDescending") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "ff") + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") def test_tdf91305_sort_text_cells_columns(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter texts - enter_text_to_cell(gridwin, "A1", "cc") - enter_text_to_cell(gridwin, "B1", "ff") - enter_text_to_cell(gridwin, "C1", "aa") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "B1", "ff") + enter_text_to_cell(gridwin, "C1", "aa") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "ff") - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - xleftright = xDialog.getChild("leftright") - xdown = xDialog.getChild("down") - select_pos(xTabs, "1") - xleftright.executeAction("CLICK", tuple()) - select_pos(xTabs, "0") - xdown.executeAction("CLICK", tuple()) - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") - self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "aa") - self.ui_test.close_doc() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "ff") + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + xdown = xDialog.getChild("down") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "aa") #comment 6 - Additional sub-bugs: def test_tdf91305_sort_text_cells_rows(self): #Selecting some empty cells and pressing SORT causes empty cells to move below. #No matter if you sort from A to Z or from Z to A. - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter text - enter_text_to_cell(gridwin, "A5", "ff") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - #sorting - self.xUITest.executeCommand(".uno:SortAscending") - self.xUITest.executeCommand(".uno:SortDescending") - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "ff") - # Assert that the correct range has been selected - gridWinState = get_state_as_dict(gridwin) - self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter text + enter_text_to_cell(gridwin, "A5", "ff") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #sorting + self.xUITest.executeCommand(".uno:SortAscending") + self.xUITest.executeCommand(".uno:SortDescending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "ff") + # Assert that the correct range has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") - self.ui_test.close_doc() #2) Placing digit to the header position and running set of sorts will make digit to be on 2nd or last position. def test_tdf91305_sort_text_cells_1st_row_digit(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #In column A enter texts - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "ff") - enter_text_to_cell(gridwin, "A3", "aa") - enter_text_to_cell(gridwin, "A4", "cc") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") + enter_text_to_cell(gridwin, "A4", "cc") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - #Press toolbarbutton for ascending sorting .uno:SortAsc - self.xUITest.executeCommand(".uno:SortAscending") - #verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") - #Press toolbarbutton for descending sorting .uno:SortDescending - self.xUITest.executeCommand(".uno:SortDescending") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "1") - #Undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "1") + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/sort/tdf99773.py b/sc/qa/uitest/sort/tdf99773.py index 0d5f61a308ac..c56707448fb5 100644 --- a/sc/qa/uitest/sort/tdf99773.py +++ b/sc/qa/uitest/sort/tdf99773.py @@ -17,33 +17,31 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tdf99773(UITestCase): def test_tdf99773_natural_sorting_space(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #enter data - enter_text_to_cell(gridwin, "A1", "A 11") - enter_text_to_cell(gridwin, "A2", "A 2") - enter_text_to_cell(gridwin, "A3", "B 2") - enter_text_to_cell(gridwin, "A4", "A 5") - enter_text_to_cell(gridwin, "A5", "A 50") - enter_text_to_cell(gridwin, "A6", "B 20") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "A 11") + enter_text_to_cell(gridwin, "A2", "A 2") + enter_text_to_cell(gridwin, "A3", "B 2") + enter_text_to_cell(gridwin, "A4", "A 5") + enter_text_to_cell(gridwin, "A5", "A 50") + enter_text_to_cell(gridwin, "A6", "B 20") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"})) - #Open sort dialog by DATA - SORT - with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xNatural = xDialog.getChild("naturalsort") - if (get_state_as_dict(xNatural)["Selected"]) == "false": - xNatural.executeAction("CLICK", tuple()) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A 2") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A 5") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "A 11") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "A 50") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "B 2") - self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "B 20") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"})) + #Open sort dialog by DATA - SORT + with self.ui_test.execute_dialog_through_command(".uno:DataSort") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A 5") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "A 11") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "A 50") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "B 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "B 20") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/anova.py b/sc/qa/uitest/statistics/anova.py index 579b9d29014d..880e926587b3 100644 --- a/sc/qa/uitest/statistics/anova.py +++ b/sc/qa/uitest/statistics/anova.py @@ -16,132 +16,130 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class anova(UITestCase): def test_statistic_anova(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Maths") - enter_text_to_cell(gridwin, "A2", "47") - enter_text_to_cell(gridwin, "A3", "36") - enter_text_to_cell(gridwin, "A4", "40") - enter_text_to_cell(gridwin, "A5", "39") - enter_text_to_cell(gridwin, "A7", "47") - enter_text_to_cell(gridwin, "A8", "29") - enter_text_to_cell(gridwin, "A9", "27") - enter_text_to_cell(gridwin, "A10", "57") - enter_text_to_cell(gridwin, "A11", "56") - enter_text_to_cell(gridwin, "A12", "57") - enter_text_to_cell(gridwin, "A13", "26") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") - enter_text_to_cell(gridwin, "B1", "Physics") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "68") - enter_text_to_cell(gridwin, "B4", "65") - enter_text_to_cell(gridwin, "B5", "64") - enter_text_to_cell(gridwin, "B6", "38") - enter_text_to_cell(gridwin, "B7", "84") - enter_text_to_cell(gridwin, "B8", "80") - enter_text_to_cell(gridwin, "B9", "49") - enter_text_to_cell(gridwin, "B10", "49") - enter_text_to_cell(gridwin, "B11", "33") + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") - enter_text_to_cell(gridwin, "C1", "Biology") - enter_text_to_cell(gridwin, "C2", "33") - enter_text_to_cell(gridwin, "C3", "42") - enter_text_to_cell(gridwin, "C4", "44") - enter_text_to_cell(gridwin, "C5", "60") - enter_text_to_cell(gridwin, "C6", "43") - enter_text_to_cell(gridwin, "C7", "62") - enter_text_to_cell(gridwin, "C8", "51") - enter_text_to_cell(gridwin, "C9", "40") - enter_text_to_cell(gridwin, "C10", "12") - enter_text_to_cell(gridwin, "C11", "60") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:C13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xradiotwofactor = xDialog.getChild("radio-two-factor") - xradiosinglefactor = xDialog.getChild("radio-single-factor") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xalphaspin = xDialog.getChild("alpha-spin") + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:C13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xradiotwofactor = xDialog.getChild("radio-two-factor") + xradiosinglefactor = xDialog.getChild("radio-single-factor") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xalphaspin = xDialog.getChild("alpha-spin") - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$2:$C$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xradiosinglefactor.executeAction("CLICK", tuple()) - xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3") - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation") - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups") - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups") - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total") + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$2:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xradiosinglefactor.executeAction("CLICK", tuple()) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xalphaspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.05"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "ANOVA - Single Factor") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Column 3") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Source of Variation") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Between Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "Within Groups") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "Total") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Count") - self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 11) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 10) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 10) - self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "SS") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),11), 1876.56832844575) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),10), 6025.1090909091) - #bug 80583 - self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),11), 7901.67741935484) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Count") + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 11) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 10) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 10) + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "SS") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),11), 1876.56832844575) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),10), 6025.1090909091) + #bug 80583 + self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),11), 7901.67741935484) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Sum") - self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 461) - self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 597) - self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 447) - self.assertEqual(get_cell_by_position(document, 0, 7, 8).getString(), "df") - self.assertEqual(get_cell_by_position(document, 0, 7, 9).getValue(), 2) - self.assertEqual(get_cell_by_position(document, 0, 7, 10).getValue(), 28) - self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue(), 30) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Sum") + self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 461) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 597) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 447) + self.assertEqual(get_cell_by_position(document, 0, 7, 8).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 7, 9).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 7, 10).getValue(), 28) + self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue(), 30) - self.assertEqual(get_cell_by_position(document, 0, 8, 3).getString(), "Mean") - self.assertEqual(round(get_cell_by_position(document, 0, 8, 4).getValue(), 12), 41.909090909091) - self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue(), 59.7) - self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue(), 44.7) - self.assertEqual(get_cell_by_position(document, 0, 8, 8).getString(), "MS") - self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),11), 938.28416422287) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),11), 215.18246753247) + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getString(), "Mean") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 4).getValue(), 12), 41.909090909091) + self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue(), 59.7) + self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue(), 44.7) + self.assertEqual(get_cell_by_position(document, 0, 8, 8).getString(), "MS") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),11), 938.28416422287) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),11), 215.18246753247) - self.assertEqual(get_cell_by_position(document, 0, 9, 3).getString(), "Variance") - self.assertEqual(round(get_cell_by_position(document, 0, 9, 4).getValue(),11), 139.49090909091) - self.assertEqual(round(get_cell_by_position(document, 0, 9, 5).getValue(),12), 287.122222222222) - self.assertEqual(round(get_cell_by_position(document, 0, 9, 6).getValue(),12), 227.344444444444) - self.assertEqual(get_cell_by_position(document, 0, 9, 8).getString(), "F") - self.assertEqual(round(get_cell_by_position(document, 0, 9, 9).getValue(),13), 4.3604117704492) + self.assertEqual(get_cell_by_position(document, 0, 9, 3).getString(), "Variance") + self.assertEqual(round(get_cell_by_position(document, 0, 9, 4).getValue(),11), 139.49090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 9, 5).getValue(),12), 287.122222222222) + self.assertEqual(round(get_cell_by_position(document, 0, 9, 6).getValue(),12), 227.344444444444) + self.assertEqual(get_cell_by_position(document, 0, 9, 8).getString(), "F") + self.assertEqual(round(get_cell_by_position(document, 0, 9, 9).getValue(),13), 4.3604117704492) - self.assertEqual(get_cell_by_position(document, 0, 10, 8).getString(), "P-value") - self.assertEqual(round(get_cell_by_position(document, 0, 10, 9).getValue(),14), 0.02246149518798) + self.assertEqual(get_cell_by_position(document, 0, 10, 8).getString(), "P-value") + self.assertEqual(round(get_cell_by_position(document, 0, 10, 9).getValue(),14), 0.02246149518798) - self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical") - self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),13), 3.3403855582378) + self.assertEqual(get_cell_by_position(document, 0, 11, 8).getString(), "F critical") + self.assertEqual(round(get_cell_by_position(document, 0, 11, 9).getValue(),13), 3.3403855582378) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:AnalysisOfVarianceDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/chiSquare.py b/sc/qa/uitest/statistics/chiSquare.py index 5016e71f861c..be2a2f801f5f 100644 --- a/sc/qa/uitest/statistics/chiSquare.py +++ b/sc/qa/uitest/statistics/chiSquare.py @@ -16,80 +16,78 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class chiSquare(UITestCase): def test_chiSquare(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "28") - enter_text_to_cell(gridwin, "A2", "26") - enter_text_to_cell(gridwin, "A3", "31") - enter_text_to_cell(gridwin, "A4", "23") - enter_text_to_cell(gridwin, "A5", "20") - enter_text_to_cell(gridwin, "A6", "27") - enter_text_to_cell(gridwin, "A7", "28") - enter_text_to_cell(gridwin, "A8", "14") - enter_text_to_cell(gridwin, "A9", "4") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "2") - enter_text_to_cell(gridwin, "A12", "8") - enter_text_to_cell(gridwin, "A13", "9") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "28") + enter_text_to_cell(gridwin, "A2", "26") + enter_text_to_cell(gridwin, "A3", "31") + enter_text_to_cell(gridwin, "A4", "23") + enter_text_to_cell(gridwin, "A5", "20") + enter_text_to_cell(gridwin, "A6", "27") + enter_text_to_cell(gridwin, "A7", "28") + enter_text_to_cell(gridwin, "A8", "14") + enter_text_to_cell(gridwin, "A9", "4") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "2") + enter_text_to_cell(gridwin, "A12", "8") + enter_text_to_cell(gridwin, "A13", "9") - enter_text_to_cell(gridwin, "B1", "19") - enter_text_to_cell(gridwin, "B2", "13") - enter_text_to_cell(gridwin, "B3", "12") - enter_text_to_cell(gridwin, "B4", "5") - enter_text_to_cell(gridwin, "B5", "34") - enter_text_to_cell(gridwin, "B6", "31") - enter_text_to_cell(gridwin, "B7", "31") - enter_text_to_cell(gridwin, "B8", "12") - enter_text_to_cell(gridwin, "B9", "24") - enter_text_to_cell(gridwin, "B10", "23") - enter_text_to_cell(gridwin, "B11", "19") - enter_text_to_cell(gridwin, "B12", "10") - enter_text_to_cell(gridwin, "B13", "33") + enter_text_to_cell(gridwin, "B1", "19") + enter_text_to_cell(gridwin, "B2", "13") + enter_text_to_cell(gridwin, "B3", "12") + enter_text_to_cell(gridwin, "B4", "5") + enter_text_to_cell(gridwin, "B5", "34") + enter_text_to_cell(gridwin, "B6", "31") + enter_text_to_cell(gridwin, "B7", "31") + enter_text_to_cell(gridwin, "B8", "12") + enter_text_to_cell(gridwin, "B9", "24") + enter_text_to_cell(gridwin, "B10", "23") + enter_text_to_cell(gridwin, "B11", "19") + enter_text_to_cell(gridwin, "B12", "10") + enter_text_to_cell(gridwin, "B13", "33") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Test of Independence (Chi-Square)") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Test of Independence (Chi-Square)") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "df") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "P-value") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Test Statistic") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Critical Value") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "P-value") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Test Statistic") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Critical Value") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 12) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 91.687005584173) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 21.026069817483) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 91.687005584173) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 21.026069817483) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:ChiSquareTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/correlation.py b/sc/qa/uitest/statistics/correlation.py index a005e7830c40..775693a8d944 100644 --- a/sc/qa/uitest/statistics/correlation.py +++ b/sc/qa/uitest/statistics/correlation.py @@ -16,187 +16,183 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class correlation(UITestCase): def test_statistic_correlation_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Maths") - enter_text_to_cell(gridwin, "A2", "47") - enter_text_to_cell(gridwin, "A3", "36") - enter_text_to_cell(gridwin, "A4", "40") - enter_text_to_cell(gridwin, "A5", "39") - enter_text_to_cell(gridwin, "A7", "47") - enter_text_to_cell(gridwin, "A8", "29") - enter_text_to_cell(gridwin, "A9", "27") - enter_text_to_cell(gridwin, "A10", "57") - enter_text_to_cell(gridwin, "A11", "56") - enter_text_to_cell(gridwin, "A12", "57") - enter_text_to_cell(gridwin, "A13", "26") - - enter_text_to_cell(gridwin, "B1", "Physics") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "68") - enter_text_to_cell(gridwin, "B4", "65") - enter_text_to_cell(gridwin, "B5", "64") - enter_text_to_cell(gridwin, "B6", "38") - enter_text_to_cell(gridwin, "B7", "84") - enter_text_to_cell(gridwin, "B8", "80") - enter_text_to_cell(gridwin, "B9", "49") - enter_text_to_cell(gridwin, "B10", "49") - enter_text_to_cell(gridwin, "B11", "33") - - enter_text_to_cell(gridwin, "C1", "Biology") - enter_text_to_cell(gridwin, "C2", "33") - enter_text_to_cell(gridwin, "C3", "42") - enter_text_to_cell(gridwin, "C4", "44") - enter_text_to_cell(gridwin, "C5", "60") - enter_text_to_cell(gridwin, "C6", "43") - enter_text_to_cell(gridwin, "C7", "62") - enter_text_to_cell(gridwin, "C8", "51") - enter_text_to_cell(gridwin, "C9", "40") - enter_text_to_cell(gridwin, "C10", "12") - enter_text_to_cell(gridwin, "C11", "60") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Correlations") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") - - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 1) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),14), -0.40292549168204) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),14), -0.21076428363645) - - self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue(), 1) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),14), 0.23097140475091) - - self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") - self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue(), 1) - - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Correlations") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),14), -0.40292549168204) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),14), -0.21076428363645) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),14), 0.23097140475091) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue(), 1) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + def test_statistic_correlation_row(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Maths") - enter_text_to_cell(gridwin, "A2", "Physics") - enter_text_to_cell(gridwin, "A3", "Biology") - - enter_text_to_cell(gridwin, "B1", "47") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "33") - - enter_text_to_cell(gridwin, "C1", "36") - enter_text_to_cell(gridwin, "C2", "68") - enter_text_to_cell(gridwin, "C3", "42") - - enter_text_to_cell(gridwin, "D1", "40") - enter_text_to_cell(gridwin, "D2", "65") - enter_text_to_cell(gridwin, "D3", "44") - - enter_text_to_cell(gridwin, "E1", "39") - enter_text_to_cell(gridwin, "E2", "64") - enter_text_to_cell(gridwin, "E3", "60") - - enter_text_to_cell(gridwin, "F2", "38") - enter_text_to_cell(gridwin, "F3", "43") - - enter_text_to_cell(gridwin, "G1", "47") - enter_text_to_cell(gridwin, "G2", "84") - enter_text_to_cell(gridwin, "G3", "62") - - enter_text_to_cell(gridwin, "H1", "29") - enter_text_to_cell(gridwin, "H2", "80") - enter_text_to_cell(gridwin, "H3", "51") - - enter_text_to_cell(gridwin, "I1", "27") - enter_text_to_cell(gridwin, "I2", "49") - enter_text_to_cell(gridwin, "I3", "40") - - enter_text_to_cell(gridwin, "J1", "57") - enter_text_to_cell(gridwin, "J2", "49") - enter_text_to_cell(gridwin, "J3", "12") - - enter_text_to_cell(gridwin, "K1", "56") - enter_text_to_cell(gridwin, "K2", "33") - enter_text_to_cell(gridwin, "K3", "60") - - enter_text_to_cell(gridwin, "L1", "57") - - enter_text_to_cell(gridwin, "M1", "26") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Correlations") - self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") - self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") - self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") - - self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") - self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 1) - self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),15), -0.402925491682042) - self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue(),15), -0.210764283636454) - - self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") - self.assertEqual(get_cell_by_position(document, 0, 2, 8).getValue(), 1) - self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),14), 0.23097140475091) - - self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") - self.assertEqual(get_cell_by_position(document, 0, 3, 9).getValue(), 1) - - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "Physics") + enter_text_to_cell(gridwin, "A3", "Biology") + + enter_text_to_cell(gridwin, "B1", "47") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "33") + + enter_text_to_cell(gridwin, "C1", "36") + enter_text_to_cell(gridwin, "C2", "68") + enter_text_to_cell(gridwin, "C3", "42") + + enter_text_to_cell(gridwin, "D1", "40") + enter_text_to_cell(gridwin, "D2", "65") + enter_text_to_cell(gridwin, "D3", "44") + + enter_text_to_cell(gridwin, "E1", "39") + enter_text_to_cell(gridwin, "E2", "64") + enter_text_to_cell(gridwin, "E3", "60") + + enter_text_to_cell(gridwin, "F2", "38") + enter_text_to_cell(gridwin, "F3", "43") + + enter_text_to_cell(gridwin, "G1", "47") + enter_text_to_cell(gridwin, "G2", "84") + enter_text_to_cell(gridwin, "G3", "62") + + enter_text_to_cell(gridwin, "H1", "29") + enter_text_to_cell(gridwin, "H2", "80") + enter_text_to_cell(gridwin, "H3", "51") + + enter_text_to_cell(gridwin, "I1", "27") + enter_text_to_cell(gridwin, "I2", "49") + enter_text_to_cell(gridwin, "I3", "40") + + enter_text_to_cell(gridwin, "J1", "57") + enter_text_to_cell(gridwin, "J2", "49") + enter_text_to_cell(gridwin, "J3", "12") + + enter_text_to_cell(gridwin, "K1", "56") + enter_text_to_cell(gridwin, "K2", "33") + enter_text_to_cell(gridwin, "K3", "60") + + enter_text_to_cell(gridwin, "L1", "57") + + enter_text_to_cell(gridwin, "M1", "26") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:CorrelationDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Correlations") + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") + + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),15), -0.402925491682042) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue(),15), -0.210764283636454) + + self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 2, 8).getValue(), 1) + self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),14), 0.23097140475091) + + self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") + self.assertEqual(get_cell_by_position(document, 0, 3, 9).getValue(), 1) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/covariance.py b/sc/qa/uitest/statistics/covariance.py index 3787a458648e..7bf4802e954c 100644 --- a/sc/qa/uitest/statistics/covariance.py +++ b/sc/qa/uitest/statistics/covariance.py @@ -16,185 +16,181 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class covariance(UITestCase): def test_statistic_covariance_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Maths") - enter_text_to_cell(gridwin, "A2", "47") - enter_text_to_cell(gridwin, "A3", "36") - enter_text_to_cell(gridwin, "A4", "40") - enter_text_to_cell(gridwin, "A5", "39") - enter_text_to_cell(gridwin, "A7", "47") - enter_text_to_cell(gridwin, "A8", "29") - enter_text_to_cell(gridwin, "A9", "27") - enter_text_to_cell(gridwin, "A10", "57") - enter_text_to_cell(gridwin, "A11", "56") - enter_text_to_cell(gridwin, "A12", "57") - enter_text_to_cell(gridwin, "A13", "26") - - enter_text_to_cell(gridwin, "B1", "Physics") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "68") - enter_text_to_cell(gridwin, "B4", "65") - enter_text_to_cell(gridwin, "B5", "64") - enter_text_to_cell(gridwin, "B6", "38") - enter_text_to_cell(gridwin, "B7", "84") - enter_text_to_cell(gridwin, "B8", "80") - enter_text_to_cell(gridwin, "B9", "49") - enter_text_to_cell(gridwin, "B10", "49") - enter_text_to_cell(gridwin, "B11", "33") - - enter_text_to_cell(gridwin, "C1", "Biology") - enter_text_to_cell(gridwin, "C2", "33") - enter_text_to_cell(gridwin, "C3", "42") - enter_text_to_cell(gridwin, "C4", "44") - enter_text_to_cell(gridwin, "C5", "60") - enter_text_to_cell(gridwin, "C6", "43") - enter_text_to_cell(gridwin, "C7", "62") - enter_text_to_cell(gridwin, "C8", "51") - enter_text_to_cell(gridwin, "C9", "40") - enter_text_to_cell(gridwin, "C10", "12") - enter_text_to_cell(gridwin, "C11", "60") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Covariances") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") - - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),11), 126.80991735537) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),12), -61.444444444444) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue()), -32) - - self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") - self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),2), 258.41) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),2), 53.11) - - self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") - self.assertEqual(round(get_cell_by_position(document, 0, 8, 3).getValue(),2), 204.61) - - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Covariances") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Column 3") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 1") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),11), 126.80991735537) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),12), -61.444444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue()), -32) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "Column 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),2), 258.41) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),2), 53.11) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString(), "Column 3") + self.assertEqual(round(get_cell_by_position(document, 0, 8, 3).getValue(),2), 204.61) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + def test_statistic_covariance_row(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Maths") - enter_text_to_cell(gridwin, "A2", "Physics") - enter_text_to_cell(gridwin, "A3", "Biology") - - enter_text_to_cell(gridwin, "B1", "47") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "33") - - enter_text_to_cell(gridwin, "C1", "36") - enter_text_to_cell(gridwin, "C2", "68") - enter_text_to_cell(gridwin, "C3", "42") - - enter_text_to_cell(gridwin, "D1", "40") - enter_text_to_cell(gridwin, "D2", "65") - enter_text_to_cell(gridwin, "D3", "44") - - enter_text_to_cell(gridwin, "E1", "39") - enter_text_to_cell(gridwin, "E2", "64") - enter_text_to_cell(gridwin, "E3", "60") - - enter_text_to_cell(gridwin, "F2", "38") - enter_text_to_cell(gridwin, "F3", "43") - - enter_text_to_cell(gridwin, "G1", "47") - enter_text_to_cell(gridwin, "G2", "84") - enter_text_to_cell(gridwin, "G3", "62") - - enter_text_to_cell(gridwin, "H1", "29") - enter_text_to_cell(gridwin, "H2", "80") - enter_text_to_cell(gridwin, "H3", "51") - - enter_text_to_cell(gridwin, "I1", "27") - enter_text_to_cell(gridwin, "I2", "49") - enter_text_to_cell(gridwin, "I3", "40") - - enter_text_to_cell(gridwin, "J1", "57") - enter_text_to_cell(gridwin, "J2", "49") - enter_text_to_cell(gridwin, "J3", "12") - - enter_text_to_cell(gridwin, "K1", "56") - enter_text_to_cell(gridwin, "K2", "33") - enter_text_to_cell(gridwin, "K3", "60") - - enter_text_to_cell(gridwin, "L1", "57") - - enter_text_to_cell(gridwin, "M1", "26") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Covariances") - self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") - self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") - self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") - - self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") - self.assertEqual(round(get_cell_by_position(document, 0, 1, 7).getValue(),10), 126.8099173554) - self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),12), -61.444444444444) - self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue()), -32) - - self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") - self.assertEqual(round(get_cell_by_position(document, 0, 2, 8).getValue(),2), 258.41) - self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),2), 53.11) - - self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") - self.assertEqual(round(get_cell_by_position(document, 0, 3, 9).getValue(),2), 204.61) - - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Maths") + enter_text_to_cell(gridwin, "A2", "Physics") + enter_text_to_cell(gridwin, "A3", "Biology") + + enter_text_to_cell(gridwin, "B1", "47") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "33") + + enter_text_to_cell(gridwin, "C1", "36") + enter_text_to_cell(gridwin, "C2", "68") + enter_text_to_cell(gridwin, "C3", "42") + + enter_text_to_cell(gridwin, "D1", "40") + enter_text_to_cell(gridwin, "D2", "65") + enter_text_to_cell(gridwin, "D3", "44") + + enter_text_to_cell(gridwin, "E1", "39") + enter_text_to_cell(gridwin, "E2", "64") + enter_text_to_cell(gridwin, "E3", "60") + + enter_text_to_cell(gridwin, "F2", "38") + enter_text_to_cell(gridwin, "F3", "43") + + enter_text_to_cell(gridwin, "G1", "47") + enter_text_to_cell(gridwin, "G2", "84") + enter_text_to_cell(gridwin, "G3", "62") + + enter_text_to_cell(gridwin, "H1", "29") + enter_text_to_cell(gridwin, "H2", "80") + enter_text_to_cell(gridwin, "H3", "51") + + enter_text_to_cell(gridwin, "I1", "27") + enter_text_to_cell(gridwin, "I2", "49") + enter_text_to_cell(gridwin, "I3", "40") + + enter_text_to_cell(gridwin, "J1", "57") + enter_text_to_cell(gridwin, "J2", "49") + enter_text_to_cell(gridwin, "J3", "12") + + enter_text_to_cell(gridwin, "K1", "56") + enter_text_to_cell(gridwin, "K2", "33") + enter_text_to_cell(gridwin, "K3", "60") + + enter_text_to_cell(gridwin, "L1", "57") + + enter_text_to_cell(gridwin, "M1", "26") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:M3"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:CovarianceDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$M$3"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$A$7"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Covariances") + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getString(), "Row 3") + + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "Row 1") + self.assertEqual(round(get_cell_by_position(document, 0, 1, 7).getValue(),10), 126.8099173554) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 8).getValue(),12), -61.444444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 1, 9).getValue()), -32) + + self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "Row 2") + self.assertEqual(round(get_cell_by_position(document, 0, 2, 8).getValue(),2), 258.41) + self.assertEqual(round(get_cell_by_position(document, 0, 2, 9).getValue(),2), 53.11) + + self.assertEqual(get_cell_by_position(document, 0, 3, 6).getString(), "Row 3") + self.assertEqual(round(get_cell_by_position(document, 0, 3, 9).getValue(),2), 204.61) + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/descriptiveStatistics.py b/sc/qa/uitest/statistics/descriptiveStatistics.py index b0fe011fee66..db62c307cef9 100644 --- a/sc/qa/uitest/statistics/descriptiveStatistics.py +++ b/sc/qa/uitest/statistics/descriptiveStatistics.py @@ -16,148 +16,146 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class descriptiveStatistics(UITestCase): def test_descriptive_statistics(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "Math") - enter_text_to_cell(gridwin, "A2", "47") - enter_text_to_cell(gridwin, "A3", "36") - enter_text_to_cell(gridwin, "A4", "40") - enter_text_to_cell(gridwin, "A5", "39") - enter_text_to_cell(gridwin, "A7", "47") - enter_text_to_cell(gridwin, "A8", "29") - enter_text_to_cell(gridwin, "A9", "27") - enter_text_to_cell(gridwin, "A10", "57") - enter_text_to_cell(gridwin, "A11", "56") - enter_text_to_cell(gridwin, "A12", "57") - enter_text_to_cell(gridwin, "A13", "26") - - - enter_text_to_cell(gridwin, "B1", "Physics") - enter_text_to_cell(gridwin, "B2", "67") - enter_text_to_cell(gridwin, "B3", "68") - enter_text_to_cell(gridwin, "B4", "65") - enter_text_to_cell(gridwin, "B5", "64") - enter_text_to_cell(gridwin, "B6", "38") - enter_text_to_cell(gridwin, "B7", "84") - enter_text_to_cell(gridwin, "B8", "80") - enter_text_to_cell(gridwin, "B9", "49") - enter_text_to_cell(gridwin, "B10", "49") - enter_text_to_cell(gridwin, "B11", "33") - - enter_text_to_cell(gridwin, "C1", "Biology") - enter_text_to_cell(gridwin, "C2", "33") - enter_text_to_cell(gridwin, "C3", "42") - enter_text_to_cell(gridwin, "C4", "44") - enter_text_to_cell(gridwin, "C5", "60") - enter_text_to_cell(gridwin, "C6", "43") - enter_text_to_cell(gridwin, "C7", "62") - enter_text_to_cell(gridwin, "C8", "51") - enter_text_to_cell(gridwin, "C9", "40") - enter_text_to_cell(gridwin, "C10", "12") - enter_text_to_cell(gridwin, "C11", "60") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) - - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) - - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString() , "Mean") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString() , "Standard Error") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString() , "Mode") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString() , "Median") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString() , "First Quartile") - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString() , "Third Quartile") - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString() , "Variance") - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString() , "Standard Deviation") - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString() , "Kurtosis") - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString() , "Skewness") - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString() , "Range") - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString() , "Minimum") - self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString() , "Maximum") - self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString() , "Sum") - self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString() , "Count") - - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString() , "Math") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),12) , 41.909090909091) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),13) , 3.5610380137731) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 47) - self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue() , 40) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue() , 32.5) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue() , 51.5) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),11) , 139.49090909091) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12) , 11.810626955878) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),13) , -1.4621677980825) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),14) , 0.01524095329036) - self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue() , 31) - self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue() , 26) - self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue() , 57) - self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue() , 461) - self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue() , 11) - - self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString() , "Physics") - self.assertEqual(round(get_cell_by_position(document, 0, 7, 1).getValue(),1) , 59.7) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),14) , 5.35837869343164) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 49) - self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue() , 64.5) - self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue() , 49) - self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue() , 67.75) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 7).getValue(),11) , 287.12222222222) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 8).getValue(),12) , 16.944681236961) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 9).getValue(),14) , -0.94159887458526) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 10).getValue(),13) , -0.2226426904338) - self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue() , 51) - self.assertEqual(get_cell_by_position(document, 0, 7, 12).getValue() , 33) - self.assertEqual(get_cell_by_position(document, 0, 7, 13).getValue() , 84) - self.assertEqual(get_cell_by_position(document, 0, 7, 14).getValue() , 597) - self.assertEqual(get_cell_by_position(document, 0, 7, 15).getValue() , 10) - - self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString() , "Biology") - self.assertEqual(get_cell_by_position(document, 0, 8, 1).getValue() , 44.7) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 2).getValue(),13) , 4.7680650629416) - self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue() , 60) - self.assertEqual(get_cell_by_position(document, 0, 8, 4).getValue() , 43.5) - self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue() , 40.5) - self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue() , 57.75) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 7).getValue(),11) , 227.34444444444) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 8).getValue(),11) , 15.07794563077) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),12) , 1.418052718986) - self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),14) , -0.97668033725691) - self.assertEqual(get_cell_by_position(document, 0, 8, 11).getValue() , 50) - self.assertEqual(get_cell_by_position(document, 0, 8, 12).getValue() , 12) - self.assertEqual(get_cell_by_position(document, 0, 8, 13).getValue() , 62) - self.assertEqual(get_cell_by_position(document, 0, 8, 14).getValue() , 447) - self.assertEqual(get_cell_by_position(document, 0, 8, 15).getValue() , 10) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "Math") + enter_text_to_cell(gridwin, "A2", "47") + enter_text_to_cell(gridwin, "A3", "36") + enter_text_to_cell(gridwin, "A4", "40") + enter_text_to_cell(gridwin, "A5", "39") + enter_text_to_cell(gridwin, "A7", "47") + enter_text_to_cell(gridwin, "A8", "29") + enter_text_to_cell(gridwin, "A9", "27") + enter_text_to_cell(gridwin, "A10", "57") + enter_text_to_cell(gridwin, "A11", "56") + enter_text_to_cell(gridwin, "A12", "57") + enter_text_to_cell(gridwin, "A13", "26") + + + enter_text_to_cell(gridwin, "B1", "Physics") + enter_text_to_cell(gridwin, "B2", "67") + enter_text_to_cell(gridwin, "B3", "68") + enter_text_to_cell(gridwin, "B4", "65") + enter_text_to_cell(gridwin, "B5", "64") + enter_text_to_cell(gridwin, "B6", "38") + enter_text_to_cell(gridwin, "B7", "84") + enter_text_to_cell(gridwin, "B8", "80") + enter_text_to_cell(gridwin, "B9", "49") + enter_text_to_cell(gridwin, "B10", "49") + enter_text_to_cell(gridwin, "B11", "33") + + enter_text_to_cell(gridwin, "C1", "Biology") + enter_text_to_cell(gridwin, "C2", "33") + enter_text_to_cell(gridwin, "C3", "42") + enter_text_to_cell(gridwin, "C4", "44") + enter_text_to_cell(gridwin, "C5", "60") + enter_text_to_cell(gridwin, "C6", "43") + enter_text_to_cell(gridwin, "C7", "62") + enter_text_to_cell(gridwin, "C8", "51") + enter_text_to_cell(gridwin, "C9", "40") + enter_text_to_cell(gridwin, "C10", "12") + enter_text_to_cell(gridwin, "C11", "60") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$13"})) + + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) + + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString() , "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString() , "Standard Error") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString() , "Mode") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString() , "Median") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString() , "First Quartile") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString() , "Third Quartile") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString() , "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString() , "Standard Deviation") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString() , "Kurtosis") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString() , "Skewness") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString() , "Range") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString() , "Minimum") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString() , "Maximum") + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString() , "Sum") + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString() , "Count") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString() , "Math") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 1).getValue(),12) , 41.909090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),13) , 3.5610380137731) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 47) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue() , 40) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue() , 32.5) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue() , 51.5) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),11) , 139.49090909091) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12) , 11.810626955878) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),13) , -1.4621677980825) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),14) , 0.01524095329036) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue() , 31) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue() , 26) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue() , 57) + self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue() , 461) + self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue() , 11) + + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString() , "Physics") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 1).getValue(),1) , 59.7) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 2).getValue(),14) , 5.35837869343164) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 49) + self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue() , 64.5) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue() , 49) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue() , 67.75) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 7).getValue(),11) , 287.12222222222) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 8).getValue(),12) , 16.944681236961) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 9).getValue(),14) , -0.94159887458526) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 10).getValue(),13) , -0.2226426904338) + self.assertEqual(get_cell_by_position(document, 0, 7, 11).getValue() , 51) + self.assertEqual(get_cell_by_position(document, 0, 7, 12).getValue() , 33) + self.assertEqual(get_cell_by_position(document, 0, 7, 13).getValue() , 84) + self.assertEqual(get_cell_by_position(document, 0, 7, 14).getValue() , 597) + self.assertEqual(get_cell_by_position(document, 0, 7, 15).getValue() , 10) + + self.assertEqual(get_cell_by_position(document, 0, 8, 0).getString() , "Biology") + self.assertEqual(get_cell_by_position(document, 0, 8, 1).getValue() , 44.7) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 2).getValue(),13) , 4.7680650629416) + self.assertEqual(get_cell_by_position(document, 0, 8, 3).getValue() , 60) + self.assertEqual(get_cell_by_position(document, 0, 8, 4).getValue() , 43.5) + self.assertEqual(get_cell_by_position(document, 0, 8, 5).getValue() , 40.5) + self.assertEqual(get_cell_by_position(document, 0, 8, 6).getValue() , 57.75) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 7).getValue(),11) , 227.34444444444) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 8).getValue(),11) , 15.07794563077) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 9).getValue(),12) , 1.418052718986) + self.assertEqual(round(get_cell_by_position(document, 0, 8, 10).getValue(),14) , -0.97668033725691) + self.assertEqual(get_cell_by_position(document, 0, 8, 11).getValue() , 50) + self.assertEqual(get_cell_by_position(document, 0, 8, 12).getValue() , 12) + self.assertEqual(get_cell_by_position(document, 0, 8, 13).getValue() , 62) + self.assertEqual(get_cell_by_position(document, 0, 8, 14).getValue() , 447) + self.assertEqual(get_cell_by_position(document, 0, 8, 15).getValue() , 10) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:DescriptiveStatisticsDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/exponentialSmoothing.py b/sc/qa/uitest/statistics/exponentialSmoothing.py index 7ea2c23ec62f..26b49428bc26 100644 --- a/sc/qa/uitest/statistics/exponentialSmoothing.py +++ b/sc/qa/uitest/statistics/exponentialSmoothing.py @@ -16,174 +16,170 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class exponentialSmoothing(UITestCase): def test_exponential_smoothing_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "0") - enter_text_to_cell(gridwin, "A3", "0") - enter_text_to_cell(gridwin, "A4", "0") - enter_text_to_cell(gridwin, "A5", "0") - enter_text_to_cell(gridwin, "A7", "0") - enter_text_to_cell(gridwin, "A8", "0") - enter_text_to_cell(gridwin, "A9", "0") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "0") - enter_text_to_cell(gridwin, "A12", "0") - enter_text_to_cell(gridwin, "A13", "0") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") - enter_text_to_cell(gridwin, "B1", "0") - enter_text_to_cell(gridwin, "B2", "0") - enter_text_to_cell(gridwin, "B3", "1") - enter_text_to_cell(gridwin, "B4", "0") - enter_text_to_cell(gridwin, "B5", "0") - enter_text_to_cell(gridwin, "B6", "0") - enter_text_to_cell(gridwin, "B7", "0") - enter_text_to_cell(gridwin, "B8", "0") - enter_text_to_cell(gridwin, "B9", "0") - enter_text_to_cell(gridwin, "B10", "0") - enter_text_to_cell(gridwin, "B11", "0") - enter_text_to_cell(gridwin, "B12", "0") - enter_text_to_cell(gridwin, "B13", "0") + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0.25) - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0.125) - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0.0625) - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0.03125) - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0.015625) - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0.0078125) - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0.00390625) - self.assertEqual(get_cell_by_position(document, 0, 5, 13).getValue(), 0.001953125) - self.assertEqual(get_cell_by_position(document, 0, 5, 14).getValue(), 0.0009765625) - self.assertEqual(get_cell_by_position(document, 0, 5, 15).getValue(), 0.00048828125) - self.assertEqual(get_cell_by_position(document, 0, 5, 16).getValue(), 0.000244140625) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0.25) + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0.125) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0.0625) + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0.03125) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0.015625) + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0.0078125) + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0.00390625) + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getValue(), 0.001953125) + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getValue(), 0.0009765625) + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getValue(), 0.00048828125) + self.assertEqual(get_cell_by_position(document, 0, 5, 16).getValue(), 0.000244140625) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0.5) - self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0.25) - self.assertEqual(get_cell_by_position(document, 0, 6, 8).getValue(), 0.125) - self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0.0625) - self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0.03125) - self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0.015625) - self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0.0078125) - self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue(), 0.00390625) - self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue(), 0.001953125) - self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue(), 0.0009765625) - self.assertEqual(get_cell_by_position(document, 0, 6, 16).getValue(), 0.00048828125) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0.25) + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getValue(), 0.125) + self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0.0625) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0.03125) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0.015625) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0.0078125) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getValue(), 0.00390625) + self.assertEqual(get_cell_by_position(document, 0, 6, 14).getValue(), 0.001953125) + self.assertEqual(get_cell_by_position(document, 0, 6, 15).getValue(), 0.0009765625) + self.assertEqual(get_cell_by_position(document, 0, 6, 16).getValue(), 0.00048828125) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() def test_exponential_smoothing_row(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "0") - enter_text_to_cell(gridwin, "A3", "0") - enter_text_to_cell(gridwin, "A4", "0") - enter_text_to_cell(gridwin, "A5", "0") - enter_text_to_cell(gridwin, "A7", "0") - enter_text_to_cell(gridwin, "A8", "0") - enter_text_to_cell(gridwin, "A9", "0") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "0") - enter_text_to_cell(gridwin, "A12", "0") - enter_text_to_cell(gridwin, "A13", "0") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") - enter_text_to_cell(gridwin, "B1", "0") - enter_text_to_cell(gridwin, "B2", "0") - enter_text_to_cell(gridwin, "B3", "1") - enter_text_to_cell(gridwin, "B4", "0") - enter_text_to_cell(gridwin, "B5", "0") - enter_text_to_cell(gridwin, "B6", "0") - enter_text_to_cell(gridwin, "B7", "0") - enter_text_to_cell(gridwin, "B8", "0") - enter_text_to_cell(gridwin, "B9", "0") - enter_text_to_cell(gridwin, "B10", "0") - enter_text_to_cell(gridwin, "B11", "0") - enter_text_to_cell(gridwin, "B12", "0") - enter_text_to_cell(gridwin, "B13", "0") + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:ExponentialSmoothingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xmoothingfactorspin = xDialog.getChild("smoothing-factor-spin") - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Row 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xmoothingfactorspin.executeAction("TYPE", mkPropertyValues({"TEXT":"0.5"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 0.5) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0.5) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Row 2") - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/fTest.py b/sc/qa/uitest/statistics/fTest.py index 1f2762c4f796..38c389f86c30 100644 --- a/sc/qa/uitest/statistics/fTest.py +++ b/sc/qa/uitest/statistics/fTest.py @@ -16,106 +16,104 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tTest(UITestCase): def test_fTest_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "28") - enter_text_to_cell(gridwin, "A2", "26") - enter_text_to_cell(gridwin, "A3", "31") - enter_text_to_cell(gridwin, "A4", "23") - enter_text_to_cell(gridwin, "A5", "20") - enter_text_to_cell(gridwin, "A6", "27") - enter_text_to_cell(gridwin, "A7", "28") - enter_text_to_cell(gridwin, "A8", "14") - enter_text_to_cell(gridwin, "A9", "4") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "2") - enter_text_to_cell(gridwin, "A12", "8") - enter_text_to_cell(gridwin, "A13", "9") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "28") + enter_text_to_cell(gridwin, "A2", "26") + enter_text_to_cell(gridwin, "A3", "31") + enter_text_to_cell(gridwin, "A4", "23") + enter_text_to_cell(gridwin, "A5", "20") + enter_text_to_cell(gridwin, "A6", "27") + enter_text_to_cell(gridwin, "A7", "28") + enter_text_to_cell(gridwin, "A8", "14") + enter_text_to_cell(gridwin, "A9", "4") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "2") + enter_text_to_cell(gridwin, "A12", "8") + enter_text_to_cell(gridwin, "A13", "9") - enter_text_to_cell(gridwin, "B1", "19") - enter_text_to_cell(gridwin, "B2", "13") - enter_text_to_cell(gridwin, "B3", "12") - enter_text_to_cell(gridwin, "B4", "5") - enter_text_to_cell(gridwin, "B5", "34") - enter_text_to_cell(gridwin, "B6", "31") - enter_text_to_cell(gridwin, "B7", "31") - enter_text_to_cell(gridwin, "B8", "12") - enter_text_to_cell(gridwin, "B9", "24") - enter_text_to_cell(gridwin, "B10", "23") - enter_text_to_cell(gridwin, "B11", "19") - enter_text_to_cell(gridwin, "B12", "10") - enter_text_to_cell(gridwin, "B13", "33") + enter_text_to_cell(gridwin, "B1", "19") + enter_text_to_cell(gridwin, "B2", "13") + enter_text_to_cell(gridwin, "B3", "12") + enter_text_to_cell(gridwin, "B4", "5") + enter_text_to_cell(gridwin, "B5", "34") + enter_text_to_cell(gridwin, "B6", "31") + enter_text_to_cell(gridwin, "B7", "31") + enter_text_to_cell(gridwin, "B8", "12") + enter_text_to_cell(gridwin, "B9", "24") + enter_text_to_cell(gridwin, "B10", "23") + enter_text_to_cell(gridwin, "B11", "19") + enter_text_to_cell(gridwin, "B12", "10") + enter_text_to_cell(gridwin, "B13", "33") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xvariable1rangeedit = xDialog.getChild("variable1-range-edit") - xvariable2rangeedit = xDialog.getChild("variable2-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "F-test") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "F-test") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Mean") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Variance") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Observations") - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "df") - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "F") - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "P (F<=f) right-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "F Critical right-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "P (F<=f) left-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "F Critical left-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P two-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "F Critical two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Observations") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "F") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "P (F<=f) right-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "F Critical right-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "P (F<=f) left-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "F Critical left-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "F Critical two-tail") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Variable 1") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),12), 16.923076923077) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 125.076923076923) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 13) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 12) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), 1.324463752376) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), 0.317061414639) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 2.686637112496) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 0.682938585361) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.634122829279) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 0.305131354874) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "Variable 1") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),12), 16.923076923077) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 125.076923076923) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 13) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), 1.324463752376) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), 0.317061414639) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 2.686637112496) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 0.682938585361) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.634122829279) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 0.305131354874) - self.assertEqual(get_cell_by_position(document, 0, 7, 2).getString(), "Variable 2") - self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),12), 20.461538461538) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 94.435897435897) - self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 13) - self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 12) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 13).getValue(),12), 3.277277094033) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getString(), "Variable 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 3).getValue(),12), 20.461538461538) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 94.435897435897) + self.assertEqual(get_cell_by_position(document, 0, 7, 5).getValue(), 13) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 13).getValue(),12), 3.277277094033) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:FTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/movingAverage.py b/sc/qa/uitest/statistics/movingAverage.py index 9f94aaf29856..cd4d77ebc78e 100644 --- a/sc/qa/uitest/statistics/movingAverage.py +++ b/sc/qa/uitest/statistics/movingAverage.py @@ -16,167 +16,163 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class movingAverage(UITestCase): def test_moving_average_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "0") - enter_text_to_cell(gridwin, "A3", "0") - enter_text_to_cell(gridwin, "A4", "0") - enter_text_to_cell(gridwin, "A5", "0") - enter_text_to_cell(gridwin, "A7", "0") - enter_text_to_cell(gridwin, "A8", "0") - enter_text_to_cell(gridwin, "A9", "0") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "0") - enter_text_to_cell(gridwin, "A12", "0") - enter_text_to_cell(gridwin, "A13", "0") - - enter_text_to_cell(gridwin, "B1", "0") - enter_text_to_cell(gridwin, "B2", "0") - enter_text_to_cell(gridwin, "B3", "1") - enter_text_to_cell(gridwin, "B4", "0") - enter_text_to_cell(gridwin, "B5", "0") - enter_text_to_cell(gridwin, "B6", "0") - enter_text_to_cell(gridwin, "B7", "0") - enter_text_to_cell(gridwin, "B8", "0") - enter_text_to_cell(gridwin, "B9", "0") - enter_text_to_cell(gridwin, "B10", "0") - enter_text_to_cell(gridwin, "B11", "0") - enter_text_to_cell(gridwin, "B12", "0") - enter_text_to_cell(gridwin, "B13", "0") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xintervalspin = xDialog.getChild("interval-spin") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Column 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") - self.assertEqual(round(get_cell_by_position(document, 0, 5, 2).getValue(),8), 0.33333333) - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "#N/A") - - - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 2") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),8), 0.33333333) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),8), 0.33333333) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),8), 0.33333333) - self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 13).getString(), "#N/A") - - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xintervalspin = xDialog.getChild("interval-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Column 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") + self.assertEqual(round(get_cell_by_position(document, 0, 5, 2).getValue(),8), 0.33333333) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "#N/A") + + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Column 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 2).getValue(),8), 0.33333333) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 3).getValue(),8), 0.33333333) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),8), 0.33333333) + self.assertEqual(get_cell_by_position(document, 0, 6, 5).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 9).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 11).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 12).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getString(), "#N/A") + + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + def test_moving_average_row(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "0") - enter_text_to_cell(gridwin, "A3", "0") - enter_text_to_cell(gridwin, "A4", "0") - enter_text_to_cell(gridwin, "A5", "0") - enter_text_to_cell(gridwin, "A7", "0") - enter_text_to_cell(gridwin, "A8", "0") - enter_text_to_cell(gridwin, "A9", "0") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "0") - enter_text_to_cell(gridwin, "A12", "0") - enter_text_to_cell(gridwin, "A13", "0") - - enter_text_to_cell(gridwin, "B1", "0") - enter_text_to_cell(gridwin, "B2", "0") - enter_text_to_cell(gridwin, "B3", "1") - enter_text_to_cell(gridwin, "B4", "0") - enter_text_to_cell(gridwin, "B5", "0") - enter_text_to_cell(gridwin, "B6", "0") - enter_text_to_cell(gridwin, "B7", "0") - enter_text_to_cell(gridwin, "B8", "0") - enter_text_to_cell(gridwin, "B9", "0") - enter_text_to_cell(gridwin, "B10", "0") - enter_text_to_cell(gridwin, "B11", "0") - enter_text_to_cell(gridwin, "B12", "0") - enter_text_to_cell(gridwin, "B13", "0") - - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xintervalspin = xDialog.getChild("interval-spin") - - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) - xgroupedbyrowsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Row 1") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "#N/A") - - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Row 2") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "#N/A") - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "0") + enter_text_to_cell(gridwin, "A3", "0") + enter_text_to_cell(gridwin, "A4", "0") + enter_text_to_cell(gridwin, "A5", "0") + enter_text_to_cell(gridwin, "A7", "0") + enter_text_to_cell(gridwin, "A8", "0") + enter_text_to_cell(gridwin, "A9", "0") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "0") + enter_text_to_cell(gridwin, "A12", "0") + enter_text_to_cell(gridwin, "A13", "0") + + enter_text_to_cell(gridwin, "B1", "0") + enter_text_to_cell(gridwin, "B2", "0") + enter_text_to_cell(gridwin, "B3", "1") + enter_text_to_cell(gridwin, "B4", "0") + enter_text_to_cell(gridwin, "B5", "0") + enter_text_to_cell(gridwin, "B6", "0") + enter_text_to_cell(gridwin, "B7", "0") + enter_text_to_cell(gridwin, "B8", "0") + enter_text_to_cell(gridwin, "B9", "0") + enter_text_to_cell(gridwin, "B10", "0") + enter_text_to_cell(gridwin, "B11", "0") + enter_text_to_cell(gridwin, "B12", "0") + enter_text_to_cell(gridwin, "B13", "0") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:MovingAverageDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + xintervalspin = xDialog.getChild("interval-spin") + + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$F$1"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xintervalspin.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xgroupedbyrowsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Row 1") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "#N/A") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "#N/A") + + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "Row 2") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getString(), "#N/A") + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getString(), "#N/A") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/regression.py b/sc/qa/uitest/statistics/regression.py index c726a5aa37ba..6432ed74d53c 100644 --- a/sc/qa/uitest/statistics/regression.py +++ b/sc/qa/uitest/statistics/regression.py @@ -102,12 +102,11 @@ class regression(UITestCase): self.ui_test.close_dialog_through_button(xOKBtn) def test_regression_cancel(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - self.ui_test.execute_modeless_dialog_through_command(".uno:RegressionDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + with self.ui_test.create_doc_in_start_center_guarded("calc"): + self.ui_test.execute_modeless_dialog_through_command(".uno:RegressionDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/sampling.py b/sc/qa/uitest/statistics/sampling.py index dd3fd2698c5b..0483bba190d7 100644 --- a/sc/qa/uitest/statistics/sampling.py +++ b/sc/qa/uitest/statistics/sampling.py @@ -16,100 +16,98 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class sampling(UITestCase): def test_statistic_sampling(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "11") - enter_text_to_cell(gridwin, "A2", "12") - enter_text_to_cell(gridwin, "A3", "13") - enter_text_to_cell(gridwin, "A4", "14") - enter_text_to_cell(gridwin, "A5", "15") - enter_text_to_cell(gridwin, "A6", "16") - enter_text_to_cell(gridwin, "A7", "17") - enter_text_to_cell(gridwin, "A8", "18") - enter_text_to_cell(gridwin, "A9", "19") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "11") + enter_text_to_cell(gridwin, "A2", "12") + enter_text_to_cell(gridwin, "A3", "13") + enter_text_to_cell(gridwin, "A4", "14") + enter_text_to_cell(gridwin, "A5", "15") + enter_text_to_cell(gridwin, "A6", "16") + enter_text_to_cell(gridwin, "A7", "17") + enter_text_to_cell(gridwin, "A8", "18") + enter_text_to_cell(gridwin, "A9", "19") - enter_text_to_cell(gridwin, "B1", "21") - enter_text_to_cell(gridwin, "B2", "22") - enter_text_to_cell(gridwin, "B3", "23") - enter_text_to_cell(gridwin, "B4", "24") - enter_text_to_cell(gridwin, "B5", "25") - enter_text_to_cell(gridwin, "B6", "26") - enter_text_to_cell(gridwin, "B7", "27") - enter_text_to_cell(gridwin, "B8", "28") - enter_text_to_cell(gridwin, "B9", "29") + enter_text_to_cell(gridwin, "B1", "21") + enter_text_to_cell(gridwin, "B2", "22") + enter_text_to_cell(gridwin, "B3", "23") + enter_text_to_cell(gridwin, "B4", "24") + enter_text_to_cell(gridwin, "B5", "25") + enter_text_to_cell(gridwin, "B6", "26") + enter_text_to_cell(gridwin, "B7", "27") + enter_text_to_cell(gridwin, "B8", "28") + enter_text_to_cell(gridwin, "B9", "29") - enter_text_to_cell(gridwin, "C1", "31") - enter_text_to_cell(gridwin, "C2", "32") - enter_text_to_cell(gridwin, "C3", "33") - enter_text_to_cell(gridwin, "C4", "34") - enter_text_to_cell(gridwin, "C5", "35") - enter_text_to_cell(gridwin, "C6", "36") - enter_text_to_cell(gridwin, "C7", "37") - enter_text_to_cell(gridwin, "C8", "38") - enter_text_to_cell(gridwin, "C9", "39") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C9"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xinputrangeedit = xDialog.getChild("input-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xrandommethodradio = xDialog.getChild("random-method-radio") - xsamplesizespin = xDialog.getChild("sample-size-spin") - xperiodicmethodradio = xDialog.getChild("periodic-method-radio") - xperiodspin = xDialog.getChild("period-spin") + enter_text_to_cell(gridwin, "C1", "31") + enter_text_to_cell(gridwin, "C2", "32") + enter_text_to_cell(gridwin, "C3", "33") + enter_text_to_cell(gridwin, "C4", "34") + enter_text_to_cell(gridwin, "C5", "35") + enter_text_to_cell(gridwin, "C6", "36") + enter_text_to_cell(gridwin, "C7", "37") + enter_text_to_cell(gridwin, "C8", "38") + enter_text_to_cell(gridwin, "C9", "39") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C9"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xinputrangeedit = xDialog.getChild("input-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xrandommethodradio = xDialog.getChild("random-method-radio") + xsamplesizespin = xDialog.getChild("sample-size-spin") + xperiodicmethodradio = xDialog.getChild("periodic-method-radio") + xperiodspin = xDialog.getChild("period-spin") - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$9"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xinputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$C$9"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$F$1"})) - xperiodicmethodradio.executeAction("CLICK", tuple()) + xperiodicmethodradio.executeAction("CLICK", tuple()) - xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xperiodspin.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, 5, 0).getValue(), 12) - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 14) - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 16) - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 18) + xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xperiodspin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xperiodspin.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, 5, 0).getValue(), 12) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 14) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 16) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 18) - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 22) - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 24) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 26) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 28) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 22) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 24) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 26) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 28) - self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 32) - self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 34) - self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 36) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 38) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 32) + self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 34) + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 36) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 38) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 0) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue() , 0) + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getValue() , 0) - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:SamplingDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/tTest.py b/sc/qa/uitest/statistics/tTest.py index 035bb4ef6d89..d23c1074333f 100644 --- a/sc/qa/uitest/statistics/tTest.py +++ b/sc/qa/uitest/statistics/tTest.py @@ -16,107 +16,105 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class tTest(UITestCase): def test_tTest_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "28") - enter_text_to_cell(gridwin, "A2", "26") - enter_text_to_cell(gridwin, "A3", "31") - enter_text_to_cell(gridwin, "A4", "23") - enter_text_to_cell(gridwin, "A5", "20") - enter_text_to_cell(gridwin, "A6", "27") - enter_text_to_cell(gridwin, "A7", "28") - enter_text_to_cell(gridwin, "A8", "14") - enter_text_to_cell(gridwin, "A9", "4") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "2") - enter_text_to_cell(gridwin, "A12", "8") - enter_text_to_cell(gridwin, "A13", "9") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "28") + enter_text_to_cell(gridwin, "A2", "26") + enter_text_to_cell(gridwin, "A3", "31") + enter_text_to_cell(gridwin, "A4", "23") + enter_text_to_cell(gridwin, "A5", "20") + enter_text_to_cell(gridwin, "A6", "27") + enter_text_to_cell(gridwin, "A7", "28") + enter_text_to_cell(gridwin, "A8", "14") + enter_text_to_cell(gridwin, "A9", "4") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "2") + enter_text_to_cell(gridwin, "A12", "8") + enter_text_to_cell(gridwin, "A13", "9") - enter_text_to_cell(gridwin, "B1", "19") - enter_text_to_cell(gridwin, "B2", "13") - enter_text_to_cell(gridwin, "B3", "12") - enter_text_to_cell(gridwin, "B4", "5") - enter_text_to_cell(gridwin, "B5", "34") - enter_text_to_cell(gridwin, "B6", "31") - enter_text_to_cell(gridwin, "B7", "31") - enter_text_to_cell(gridwin, "B8", "12") - enter_text_to_cell(gridwin, "B9", "24") - enter_text_to_cell(gridwin, "B10", "23") - enter_text_to_cell(gridwin, "B11", "19") - enter_text_to_cell(gridwin, "B12", "10") - enter_text_to_cell(gridwin, "B13", "33") + enter_text_to_cell(gridwin, "B1", "19") + enter_text_to_cell(gridwin, "B2", "13") + enter_text_to_cell(gridwin, "B3", "12") + enter_text_to_cell(gridwin, "B4", "5") + enter_text_to_cell(gridwin, "B5", "34") + enter_text_to_cell(gridwin, "B6", "31") + enter_text_to_cell(gridwin, "B7", "31") + enter_text_to_cell(gridwin, "B8", "12") + enter_text_to_cell(gridwin, "B9", "24") + enter_text_to_cell(gridwin, "B10", "23") + enter_text_to_cell(gridwin, "B11", "19") + enter_text_to_cell(gridwin, "B12", "10") + enter_text_to_cell(gridwin, "B13", "33") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xvariable1rangeedit = xDialog.getChild("variable1-range-edit") - xvariable2rangeedit = xDialog.getChild("variable2-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Paired t-test") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Mean") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Variance") - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations") - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Pearson Correlation") - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Observed Mean Difference") - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Variance of the Differences") - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "df") - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "t Stat") - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P (T<=t) one-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "t Critical one-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString(), "P (T<=t) two-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString(), "t Critical two-tail") + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "Paired t-test") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Pearson Correlation") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "Observed Mean Difference") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "Variance of the Differences") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "df") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "t Stat") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "P (T<=t) one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "t Critical one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 14).getString(), "P (T<=t) two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 15).getString(), "t Critical two-tail") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1") - self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 16.923076923077) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 125.076923076923) - self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 13) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), -0.061753977175) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), -3.538461538462) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 232.935897435897) - self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 12) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),12), -0.835926213674) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.209765144211) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 1.782287555649) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 14).getValue(),12), 0.419530288422) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 15).getValue(),12), 2.178812829667) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1") + self.assertEqual(round(get_cell_by_position(document, 0, 6, 4).getValue(),12), 16.923076923077) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 125.076923076923) + self.assertEqual(get_cell_by_position(document, 0, 6, 6).getValue(), 13) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 7).getValue(),12), -0.061753977175) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 8).getValue(),12), -3.538461538462) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 9).getValue(),12), 232.935897435897) + self.assertEqual(get_cell_by_position(document, 0, 6, 10).getValue(), 12) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 11).getValue(),12), -0.835926213674) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 0.209765144211) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 13).getValue(),12), 1.782287555649) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 14).getValue(),12), 0.419530288422) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 15).getValue(),12), 2.178812829667) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2") - self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 20.461538461538) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 94.435897435897) - self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2") + self.assertEqual(round(get_cell_by_position(document, 0, 7, 4).getValue(),12), 20.461538461538) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 94.435897435897) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:TTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/statistics/zTest.py b/sc/qa/uitest/statistics/zTest.py index a7f791e1a898..1c23ccef117b 100644 --- a/sc/qa/uitest/statistics/zTest.py +++ b/sc/qa/uitest/statistics/zTest.py @@ -16,97 +16,95 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class zTest(UITestCase): def test_zTest_column(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - #fill data - enter_text_to_cell(gridwin, "A1", "28") - enter_text_to_cell(gridwin, "A2", "26") - enter_text_to_cell(gridwin, "A3", "31") - enter_text_to_cell(gridwin, "A4", "23") - enter_text_to_cell(gridwin, "A5", "20") - enter_text_to_cell(gridwin, "A6", "27") - enter_text_to_cell(gridwin, "A7", "28") - enter_text_to_cell(gridwin, "A8", "14") - enter_text_to_cell(gridwin, "A9", "4") - enter_text_to_cell(gridwin, "A10", "0") - enter_text_to_cell(gridwin, "A11", "2") - enter_text_to_cell(gridwin, "A12", "8") - enter_text_to_cell(gridwin, "A13", "9") + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #fill data + enter_text_to_cell(gridwin, "A1", "28") + enter_text_to_cell(gridwin, "A2", "26") + enter_text_to_cell(gridwin, "A3", "31") + enter_text_to_cell(gridwin, "A4", "23") + enter_text_to_cell(gridwin, "A5", "20") + enter_text_to_cell(gridwin, "A6", "27") + enter_text_to_cell(gridwin, "A7", "28") + enter_text_to_cell(gridwin, "A8", "14") + enter_text_to_cell(gridwin, "A9", "4") + enter_text_to_cell(gridwin, "A10", "0") + enter_text_to_cell(gridwin, "A11", "2") + enter_text_to_cell(gridwin, "A12", "8") + enter_text_to_cell(gridwin, "A13", "9") - enter_text_to_cell(gridwin, "B1", "19") - enter_text_to_cell(gridwin, "B2", "13") - enter_text_to_cell(gridwin, "B3", "12") - enter_text_to_cell(gridwin, "B4", "5") - enter_text_to_cell(gridwin, "B5", "34") - enter_text_to_cell(gridwin, "B6", "31") - enter_text_to_cell(gridwin, "B7", "31") - enter_text_to_cell(gridwin, "B8", "12") - enter_text_to_cell(gridwin, "B9", "24") - enter_text_to_cell(gridwin, "B10", "23") - enter_text_to_cell(gridwin, "B11", "19") - enter_text_to_cell(gridwin, "B12", "10") - enter_text_to_cell(gridwin, "B13", "33") + enter_text_to_cell(gridwin, "B1", "19") + enter_text_to_cell(gridwin, "B2", "13") + enter_text_to_cell(gridwin, "B3", "12") + enter_text_to_cell(gridwin, "B4", "5") + enter_text_to_cell(gridwin, "B5", "34") + enter_text_to_cell(gridwin, "B6", "31") + enter_text_to_cell(gridwin, "B7", "31") + enter_text_to_cell(gridwin, "B8", "12") + enter_text_to_cell(gridwin, "B9", "24") + enter_text_to_cell(gridwin, "B10", "23") + enter_text_to_cell(gridwin, "B11", "19") + enter_text_to_cell(gridwin, "B12", "10") + enter_text_to_cell(gridwin, "B13", "33") - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) - self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xvariable1rangeedit = xDialog.getChild("variable1-range-edit") - xvariable2rangeedit = xDialog.getChild("variable2-range-edit") - xoutputrangeedit = xDialog.getChild("output-range-edit") - xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") - xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B13"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xvariable1rangeedit = xDialog.getChild("variable1-range-edit") + xvariable2rangeedit = xDialog.getChild("variable2-range-edit") + xoutputrangeedit = xDialog.getChild("output-range-edit") + xgroupedbyrowsradio = xDialog.getChild("groupedby-rows-radio") + xgroupedbycolumnsradio = xDialog.getChild("groupedby-columns-radio") - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) - xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) - xgroupedbycolumnsradio.executeAction("CLICK", tuple()) - xOKBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOKBtn) - #Verify - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "z-test") - self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable1rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$13"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvariable2rangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$B$1:$B$13"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xoutputrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + xgroupedbycolumnsradio.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "z-test") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "Alpha") - self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference") - self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Known Variance") - self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Mean") - self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations") - self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Observed Mean Difference") - self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "z") - self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "P (Z<=z) one-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "z Critical one-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "P (Z<=z) two-tail") - self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "z Critical two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "Hypothesized Mean Difference") + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getString(), "Known Variance") + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getString(), "Mean") + self.assertEqual(get_cell_by_position(document, 0, 5, 6).getString(), "Observations") + self.assertEqual(get_cell_by_position(document, 0, 5, 7).getString(), "Observed Mean Difference") + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getString(), "z") + self.assertEqual(get_cell_by_position(document, 0, 5, 9).getString(), "P (Z<=z) one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getString(), "z Critical one-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 11).getString(), "P (Z<=z) two-tail") + self.assertEqual(get_cell_by_position(document, 0, 5, 12).getString(), "z Critical two-tail") - self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) - self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) - self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1") - self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 16.923076923077) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 1.644853626951) - self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 1.959963984540) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0.05) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getString(), "Variable 1") + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getValue(), 0) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 5).getValue(),12), 16.923076923077) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 10).getValue(),12), 1.644853626951) + self.assertEqual(round(get_cell_by_position(document, 0, 6, 12).getValue(),12), 1.959963984540) - self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2") - self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 0) - self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 20.461538461538) - self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13) - #undo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 7, 3).getString(), "Variable 2") + self.assertEqual(get_cell_by_position(document, 0, 7, 4).getValue(), 0) + self.assertEqual(round(get_cell_by_position(document, 0, 7, 5).getValue(),12), 20.461538461538) + self.assertEqual(get_cell_by_position(document, 0, 7, 6).getValue(), 13) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "") - # test cancel button - self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") - xDialog = self.xUITest.getTopFocusWindow() - xCancelBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCancelBtn) + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:ZTestDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/textCase/textCase.py b/sc/qa/uitest/textCase/textCase.py index 7b399670224c..2ace396d9acb 100644 --- a/sc/qa/uitest/textCase/textCase.py +++ b/sc/qa/uitest/textCase/textCase.py @@ -13,117 +13,115 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class textCase(UITestCase): def test_text_case_switch(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #enter data - enter_text_to_cell(gridwin, "A1", "hello world") - enter_text_to_cell(gridwin, "A2", "libre office") - enter_text_to_cell(gridwin, "A4", "free suite") - #select - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) - #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase - self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") - - #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase - self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase") - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") - - #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase - self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE") - - #uppercase = CommandSent Name:.uno:ChangeCaseToUpper - self.xUITest.executeCommand(".uno:ChangeCaseToUpper") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE") - - #lowercase - CommandSent Name:.uno:ChangeCaseToLower - self.xUITest.executeCommand(".uno:ChangeCaseToLower") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") - - #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase - self.xUITest.executeCommand(".uno:ChangeCaseRotateCase") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") - self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") - - #select non continuous range - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B2"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) - gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:A5", "EXTEND":"1"})) - - #lowercase - CommandSent Name:.uno:ChangeCaseToLower - self.xUITest.executeCommand(".uno:ChangeCaseToLower") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") - - #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase - self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") - #Verify - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") - - #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase - self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase") - - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") - - #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase - self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE") - - #uppercase = CommandSent Name:.uno:ChangeCaseToUpper - self.xUITest.executeCommand(".uno:ChangeCaseToUpper") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE") - - #lowercase - CommandSent Name:.uno:ChangeCaseToLower - self.xUITest.executeCommand(".uno:ChangeCaseToLower") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") - - #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase - self.xUITest.executeCommand(".uno:ChangeCaseRotateCase") - self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") - self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") - self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") - self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #enter data + enter_text_to_cell(gridwin, "A1", "hello world") + enter_text_to_cell(gridwin, "A2", "libre office") + enter_text_to_cell(gridwin, "A4", "free suite") + #select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase + self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") + + #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase + self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase") + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") + + #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase + self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE") + + #uppercase = CommandSent Name:.uno:ChangeCaseToUpper + self.xUITest.executeCommand(".uno:ChangeCaseToUpper") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE") + + #lowercase - CommandSent Name:.uno:ChangeCaseToLower + self.xUITest.executeCommand(".uno:ChangeCaseToLower") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") + + #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase + self.xUITest.executeCommand(".uno:ChangeCaseRotateCase") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") + + #select non continuous range + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:A5", "EXTEND":"1"})) + + #lowercase - CommandSent Name:.uno:ChangeCaseToLower + self.xUITest.executeCommand(".uno:ChangeCaseToLower") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") + + #Capitalize every word - CommandSent Name:.uno:ChangeCaseToTitleCase + self.xUITest.executeCommand(".uno:ChangeCaseToTitleCase") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello World") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre Office") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free Suite") + + #Sentence case - CommandSent Name:.uno:ChangeCaseToSentenceCase + self.xUITest.executeCommand(".uno:ChangeCaseToSentenceCase") + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") + + #toggle case - CommandSent Name:.uno:ChangeCaseToToggleCase + self.xUITest.executeCommand(".uno:ChangeCaseToToggleCase") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hELLO WORLD") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "lIBRE OFFICE") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "fREE SUITE") + + #uppercase = CommandSent Name:.uno:ChangeCaseToUpper + self.xUITest.executeCommand(".uno:ChangeCaseToUpper") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "HELLO WORLD") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "LIBRE OFFICE") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "FREE SUITE") + + #lowercase - CommandSent Name:.uno:ChangeCaseToLower + self.xUITest.executeCommand(".uno:ChangeCaseToLower") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "free suite") + + #cycle case = CommandSent Name:.uno:ChangeCaseRotateCase + self.xUITest.executeCommand(".uno:ChangeCaseRotateCase") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Hello world") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Libre office") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Free suite") def test_tdf119155_Capitalize_Every_Word(self): #Bug 119155 - Freeze after command format->text->Capitalize Every Word diff --git a/sc/qa/uitest/validity/tdf138134.py b/sc/qa/uitest/validity/tdf138134.py index c39529b78154..5480c64a2d19 100644 --- a/sc/qa/uitest/validity/tdf138134.py +++ b/sc/qa/uitest/validity/tdf138134.py @@ -15,43 +15,41 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class DetectiveCircle(UITestCase): def test_delete_circle_at_formula(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - enter_text_to_cell(gridwin, "A1", "1") - enter_text_to_cell(gridwin, "A2", "3") - enter_text_to_cell(gridwin, "A3", "=SUM(A1:A2)") - - #Select the cells to be validated - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - #Apply Data > Validity ... > Whole Numbers - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - select_by_text(xallow, "Whole Numbers") - xallowempty.executeAction("CLICK", tuple()) - select_by_text(xdata, "equal") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"5"})) - - self.xUITest.executeCommand(".uno:ShowInvalid") - - detectiveCircle1 = document.Sheets.getByName("Sheet1").DrawPage.getCount() - #There should be 1 detective circle object! - self.assertEqual(detectiveCircle1, 1) - - enter_text_to_cell(gridwin, "A1", "2") - - detectiveCircle2 = document.Sheets.getByName("Sheet1").DrawPage.getCount() - #There should not be a detective circle object! - self.assertEqual(detectiveCircle2, 0) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "=SUM(A1:A2)") + + #Select the cells to be validated + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Apply Data > Validity ... > Whole Numbers + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + select_by_text(xallow, "Whole Numbers") + xallowempty.executeAction("CLICK", tuple()) + select_by_text(xdata, "equal") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"5"})) + + self.xUITest.executeCommand(".uno:ShowInvalid") + + detectiveCircle1 = document.Sheets.getByName("Sheet1").DrawPage.getCount() + #There should be 1 detective circle object! + self.assertEqual(detectiveCircle1, 1) + + enter_text_to_cell(gridwin, "A1", "2") + + detectiveCircle2 = document.Sheets.getByName("Sheet1").DrawPage.getCount() + #There should not be a detective circle object! + self.assertEqual(detectiveCircle2, 0) + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/validity/tdf53920.py b/sc/qa/uitest/validity/tdf53920.py index 82687900c3b0..3ebb6e991a16 100644 --- a/sc/qa/uitest/validity/tdf53920.py +++ b/sc/qa/uitest/validity/tdf53920.py @@ -15,51 +15,49 @@ from uitest.debug import sleep #Bug 53920 - EDITING: Data Validity Cell Range not being applied to multiple selected cells class tdf53920(UITestCase): def test_tdf53920_validity_multiple_cells(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #. Provide the desired values in a range of cells - enter_text_to_cell(gridwin, "C1", "A") - enter_text_to_cell(gridwin, "C2", "B") - enter_text_to_cell(gridwin, "C3", "C") - #Select the cells to be validated - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5", "EXTEND":"1"})) - #Apply Data > Validity ... > Cell Range - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #. Provide the desired values in a range of cells + enter_text_to_cell(gridwin, "C1", "A") + enter_text_to_cell(gridwin, "C2", "B") + enter_text_to_cell(gridwin, "C3", "C") + #Select the cells to be validated + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5", "EXTEND":"1"})) + #Apply Data > Validity ... > Cell Range + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") - select_by_text(xallow, "Cell range") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$C$1:$C$3"})) + select_by_text(xallow, "Cell range") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$C$1:$C$3"})) - #Expected behavior: All selected cells validate data. - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") + #Expected behavior: All selected cells validate data. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xmin = xDialog.getChild("min") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xmin = xDialog.getChild("min") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Cell range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "$Sheet1.$C$1:$C$3") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/validity/tdf65686.py b/sc/qa/uitest/validity/tdf65686.py index 04e0955c352c..278f0d78caf1 100644 --- a/sc/qa/uitest/validity/tdf65686.py +++ b/sc/qa/uitest/validity/tdf65686.py @@ -14,39 +14,37 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #Bug 65686 - EDITING Data > Validity broken (for list entries at least) class tdf65686(UITestCase): def test_tdf65686_validity_list(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - #- Data > Validity - #- Select Allow List - #- Enter Entries Aap Noot Mies - #- OK - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - minlist = xDialog.getChild("minlist") + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #- Data > Validity + #- Select Allow List + #- Enter Entries Aap Noot Mies + #- OK + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + minlist = xDialog.getChild("minlist") - select_by_text(xallow, "List") - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Aap"})) - minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Noot"})) - minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) - minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Mies"})) - #- again open Data > Validity - #> there are empty lines in the list Entries - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - minlist = xDialog.getChild("minlist") + select_by_text(xallow, "List") + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Aap"})) + minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Noot"})) + minlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + minlist.executeAction("TYPE", mkPropertyValues({"TEXT":"Mies"})) + #- again open Data > Validity + #> there are empty lines in the list Entries + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + minlist = xDialog.getChild("minlist") - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "List") - self.assertEqual(get_state_as_dict(minlist)["Text"], "Aap\nNoot\nMies") + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "List") + self.assertEqual(get_state_as_dict(minlist)["Text"], "Aap\nNoot\nMies") - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/validity/tdf96698.py b/sc/qa/uitest/validity/tdf96698.py index fcea7464ea96..95f55284a5e6 100644 --- a/sc/qa/uitest/validity/tdf96698.py +++ b/sc/qa/uitest/validity/tdf96698.py @@ -14,93 +14,91 @@ from libreoffice.uno.propertyvalue import mkPropertyValues #Bug 96698 - Data => Validity => Custom (like Excel) is missing class tdf96698(UITestCase): def test_tdf96698_validity_custom_formula(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - - #A general validity check for the entered new content of the active cell - especially for text - #with a custom formula like in Excel is not possible. - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",B2))"})) - #verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",B2))") - - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(B3))"})) - #verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(B3))") - - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A7"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",A7))"})) - #verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",A7))") - - - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A8"})) - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - select_by_text(xallow, "Custom") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(A8))"})) - #verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xmin = xDialog.getChild("min") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") - self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(A8))") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #A general validity check for the entered new content of the active cell - especially for text + #with a custom formula like in Excel is not possible. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",B2))"})) + #verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",B2))") + + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(B3))"})) + #verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(B3))") + + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A7"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"ISERROR(FIND(\",\",A7))"})) + #verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "ISERROR(FIND(\",\",A7))") + + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A8"})) + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + select_by_text(xallow, "Custom") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"NOT(ISERROR(A8))"})) + #verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xmin = xDialog.getChild("min") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Custom") + self.assertEqual(get_state_as_dict(xmin)["Text"], "NOT(ISERROR(A8))") + + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/validity/validity.py b/sc/qa/uitest/validity/validity.py index 3ac4f790c6cc..789c55e31a85 100644 --- a/sc/qa/uitest/validity/validity.py +++ b/sc/qa/uitest/validity/validity.py @@ -14,107 +14,101 @@ from libreoffice.uno.propertyvalue import mkPropertyValues class validity(UITestCase): def test_validity_tab_criteria(self): - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - select_by_text(xallow, "Whole Numbers") - xallowempty.executeAction("CLICK", tuple()) - select_by_text(xdata, "valid range") - xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) - xmax.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) - #reopen and verify - with self.ui_test.execute_dialog_through_command(".uno:Validation", close_button="cancel") as xDialog: - xallow = xDialog.getChild("allow") - xallowempty = xDialog.getChild("allowempty") - xdata = xDialog.getChild("data") - xmin = xDialog.getChild("min") - xmax = xDialog.getChild("max") - - self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Whole Numbers") - self.assertEqual(get_state_as_dict(xallowempty)["Selected"], "false") - self.assertEqual(get_state_as_dict(xdata)["SelectEntryText"], "valid range") - self.assertEqual(get_state_as_dict(xmin)["Text"], "1") - self.assertEqual(get_state_as_dict(xmax)["Text"], "2") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + select_by_text(xallow, "Whole Numbers") + xallowempty.executeAction("CLICK", tuple()) + select_by_text(xdata, "valid range") + xmin.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xmax.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + #reopen and verify + with self.ui_test.execute_dialog_through_command(".uno:Validation", close_button="cancel") as xDialog: + xallow = xDialog.getChild("allow") + xallowempty = xDialog.getChild("allowempty") + xdata = xDialog.getChild("data") + xmin = xDialog.getChild("min") + xmax = xDialog.getChild("max") + + self.assertEqual(get_state_as_dict(xallow)["SelectEntryText"], "Whole Numbers") + self.assertEqual(get_state_as_dict(xallowempty)["Selected"], "false") + self.assertEqual(get_state_as_dict(xdata)["SelectEntryText"], "valid range") + self.assertEqual(get_state_as_dict(xmin)["Text"], "1") + self.assertEqual(get_state_as_dict(xmax)["Text"], "2") + def test_validity_tab_inputHelp(self): #validationhelptabpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "1") - xtsbhelp = xDialog.getChild("tsbhelp") - xtitle = xDialog.getChild("title") - xinputhelp = xDialog.getChild("inputhelp") - - xtsbhelp.executeAction("CLICK", tuple()) - xtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) - xinputhelp.executeAction("TYPE", mkPropertyValues({"TEXT":"B"})) - #reopen and verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - xtsbhelp = xDialog.getChild("tsbhelp") - xtitle = xDialog.getChild("title") - xinputhelp = xDialog.getChild("inputhelp") - # print(get_state_as_dict(xtsbhelp)) - select_pos(xTabs, "1") - self.assertEqual(get_state_as_dict(xtsbhelp)["Selected"], "true") - self.assertEqual(get_state_as_dict(xtitle)["Text"], "A") - self.assertEqual(get_state_as_dict(xinputhelp)["Text"], "B") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xtsbhelp = xDialog.getChild("tsbhelp") + xtitle = xDialog.getChild("title") + xinputhelp = xDialog.getChild("inputhelp") + + xtsbhelp.executeAction("CLICK", tuple()) + xtitle.executeAction("TYPE", mkPropertyValues({"TEXT":"A"})) + xinputhelp.executeAction("TYPE", mkPropertyValues({"TEXT":"B"})) + #reopen and verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + xtsbhelp = xDialog.getChild("tsbhelp") + xtitle = xDialog.getChild("title") + xinputhelp = xDialog.getChild("inputhelp") + # print(get_state_as_dict(xtsbhelp)) + select_pos(xTabs, "1") + self.assertEqual(get_state_as_dict(xtsbhelp)["Selected"], "true") + self.assertEqual(get_state_as_dict(xtitle)["Text"], "A") + self.assertEqual(get_state_as_dict(xinputhelp)["Text"], "B") + def test_validity_tab_errorAlert(self): # erroralerttabpage.ui - calc_doc = self.ui_test.create_doc_in_start_center("calc") - xCalcDoc = self.xUITest.getTopFocusWindow() - gridwin = xCalcDoc.getChild("grid_window") - document = self.ui_test.get_component() - gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) - - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - - xactionCB = xDialog.getChild("actionCB") - xerroralerttitle = xDialog.getChild("erroralert_title") - xerrorMsg = xDialog.getChild("errorMsg") - - select_by_text(xactionCB, "Warning") - xerroralerttitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn"})) - xerrorMsg.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn2"})) - #reopen and verify - with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "2") - - xactionCB = xDialog.getChild("actionCB") - xerroralerttitle = xDialog.getChild("erroralert_title") - xerrorMsg = xDialog.getChild("errorMsg") - - self.assertEqual(get_state_as_dict(xactionCB)["SelectEntryText"], "Warning") - self.assertEqual(get_state_as_dict(xerroralerttitle)["Text"], "Warn") - self.assertEqual(get_state_as_dict(xerrorMsg)["Text"], "Warn2") - - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center_guarded("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xactionCB = xDialog.getChild("actionCB") + xerroralerttitle = xDialog.getChild("erroralert_title") + xerrorMsg = xDialog.getChild("errorMsg") + + select_by_text(xactionCB, "Warning") + xerroralerttitle.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn"})) + xerrorMsg.executeAction("TYPE", mkPropertyValues({"TEXT":"Warn2"})) + #reopen and verify + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xactionCB = xDialog.getChild("actionCB") + xerroralerttitle = xDialog.getChild("erroralert_title") + xerrorMsg = xDialog.getChild("errorMsg") + + self.assertEqual(get_state_as_dict(xactionCB)["SelectEntryText"], "Warning") + self.assertEqual(get_state_as_dict(xerroralerttitle)["Text"], "Warn") + self.assertEqual(get_state_as_dict(xerrorMsg)["Text"], "Warn2") + + # vim: set shiftwidth=4 softtabstop=4 expandtab: |