diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-22 11:17:29 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-06-22 21:47:11 +0200 |
commit | 374baf308979306aa35575118c40ccd7caae1e29 (patch) | |
tree | 2570881a42fe5b5555db1dbf2aecc0a3fdd33878 /sw/qa/uitest/writer_tests4 | |
parent | b2331179fc508fd6bc37355e5c3c5a5ee54557c4 (diff) |
uitest: guard create_doc_in_start_center
Mostly done by a script
for motivation, see 89aaa17a0a4413f07da2bc5084b0164f15dc01ac
< UITest: introduce guarded context managers >
Change-Id: I75ef7712af3676363a9a464acf83f6f68ffc4f85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117617
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw/qa/uitest/writer_tests4')
-rw-r--r-- | sw/qa/uitest/writer_tests4/insertBreakDialog.py | 58 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/insertPageHeader.py | 34 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/spellDialog.py | 74 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/start.py | 32 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/tdf113252.py | 47 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/tdf115572.py | 109 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/tdf115573.py | 211 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/tdf51352.py | 71 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests4/tdf92611.py | 8 |
9 files changed, 307 insertions, 337 deletions
diff --git a/sw/qa/uitest/writer_tests4/insertBreakDialog.py b/sw/qa/uitest/writer_tests4/insertBreakDialog.py index 6dda5b2fcf94..d9a1535f0d6d 100644 --- a/sw/qa/uitest/writer_tests4/insertBreakDialog.py +++ b/sw/qa/uitest/writer_tests4/insertBreakDialog.py @@ -26,57 +26,49 @@ class WriterInsertBreakDialog(UITestCase): def test_insert_line_break(self): - self.ui_test.create_doc_in_start_center("writer") + with self.ui_test.create_doc_in_start_center("writer"): - xDialog = self.launch_dialog_and_select_option("linerb") - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xDialog = self.launch_dialog_and_select_option("linerb") + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.getPages(1) - - self.ui_test.close_doc() + self.getPages(1) def test_insert_column_break(self): - self.ui_test.create_doc_in_start_center("writer") - - xDialog = self.launch_dialog_and_select_option("columnrb") - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + with self.ui_test.create_doc_in_start_center("writer"): - self.getPages(1) + xDialog = self.launch_dialog_and_select_option("columnrb") + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() + self.getPages(1) def test_insert_page_break(self): - self.ui_test.create_doc_in_start_center("writer") - - for i in range(9): - with self.subTest(i=i): - xDialog = self.launch_dialog_and_select_option("pagerb") + with self.ui_test.create_doc_in_start_center("writer"): - xStyleList = xDialog.getChild("stylelb") - xStyleList.executeAction("SELECT", mkPropertyValues({"POS": str(i)})) + for i in range(9): + with self.subTest(i=i): + xDialog = self.launch_dialog_and_select_option("pagerb") - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xStyleList = xDialog.getChild("stylelb") + xStyleList.executeAction("SELECT", mkPropertyValues({"POS": str(i)})) - self.getPages(i + 2) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - self.ui_test.close_doc() + self.getPages(i + 2) def test_cancel_button_insert_line_break_dialog(self): - self.ui_test.create_doc_in_start_center("writer") - - self.ui_test.execute_dialog_through_command(".uno:InsertBreak") - 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("writer"): - self.getPages(1) + self.ui_test.execute_dialog_through_command(".uno:InsertBreak") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) - self.ui_test.close_doc() + self.getPages(1) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/insertPageHeader.py b/sw/qa/uitest/writer_tests4/insertPageHeader.py index 245073ace5a5..28e7ff29a314 100644 --- a/sw/qa/uitest/writer_tests4/insertPageHeader.py +++ b/sw/qa/uitest/writer_tests4/insertPageHeader.py @@ -38,35 +38,31 @@ class WriterInsertPageHeader(UITestCase): document.StyleFamilies.PageStyles.Standard.HeaderIsOn, False) def test_header(self): - self.ui_test.create_doc_in_start_center("writer") + with self.ui_test.create_doc_in_start_center("writer"): - self.insert_header() + self.insert_header() - self.delete_header() - - self.ui_test.close_doc() + self.delete_header() def test_tdf107427(self): - self.ui_test.create_doc_in_start_center("writer") - - self.insert_header() + with self.ui_test.create_doc_in_start_center("writer"): - self.ui_test.execute_dialog_through_command(".uno:InsertTable") + self.insert_header() - xInsertDlg = self.xUITest.getTopFocusWindow() + self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xOkBtn = xInsertDlg.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) + xInsertDlg = self.xUITest.getTopFocusWindow() - document = self.ui_test.get_component() + xOkBtn = xInsertDlg.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) - tables = document.getTextTables() - self.assertEqual(len(tables[0].getRows()), 2) - self.assertEqual(len(tables[0].getColumns()), 2) + document = self.ui_test.get_component() - self.xUITest.executeCommand(".uno:SelectAll") + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[0].getColumns()), 2) - self.delete_header() + self.xUITest.executeCommand(".uno:SelectAll") - self.ui_test.close_doc() + self.delete_header() diff --git a/sw/qa/uitest/writer_tests4/spellDialog.py b/sw/qa/uitest/writer_tests4/spellDialog.py index fea337bd2c3f..b1458933830d 100644 --- a/sw/qa/uitest/writer_tests4/spellDialog.py +++ b/sw/qa/uitest/writer_tests4/spellDialog.py @@ -59,46 +59,46 @@ frog, dogg, catt""" # This automates the steps described in the bug report tdf#46852 # Step 1: Create a document with repetitious misspelled words - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - cursor = document.getCurrentController().getViewCursor() - # Inserted text must be en_US, so make sure to set language in current location - cursor.CharLocale = Locale("en", "US", "") - input_text = self.TDF46852_INPUT.replace('\n', '\r') # \r = para break - document.Text.insertString(cursor, input_text, False) - - # Step 2: Place cursor on 4th line after second "frogg" - cursor.goUp(2, False) - cursor.goLeft(1, False) - - # Step 3: Initiate spellchecking, and make sure "Check grammar" is - # unchecked - spell_dialog = self.launch_dialog() - checkgrammar = spell_dialog.getChild('checkgrammar') - if get_state_as_dict(checkgrammar)['Selected'] == 'true': - checkgrammar.executeAction('CLICK', ()) - self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') - - # Step 4: Repetitively click on "Correct all" for each misspelling - # prompt until end of document is reached. - changeall = spell_dialog.getChild('changeall') - changeall.executeAction("CLICK", ()) - changeall.executeAction("CLICK", ()) - # The third time we click on changeall, the click action is going to - # block while two message boxes are shown, so we need to do this third - # click specially - # Use empty close_button to open consecutive dialogs - with self.ui_test.execute_blocking_action( - changeall.executeAction, args=('CLICK', ()), close_button="") as dialog: - # Step 5: Confirm to "Continue check at beginning of document" - xYesBtn = dialog.getChild("yes") + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + cursor = document.getCurrentController().getViewCursor() + # Inserted text must be en_US, so make sure to set language in current location + cursor.CharLocale = Locale("en", "US", "") + input_text = self.TDF46852_INPUT.replace('\n', '\r') # \r = para break + document.Text.insertString(cursor, input_text, False) + + # Step 2: Place cursor on 4th line after second "frogg" + cursor.goUp(2, False) + cursor.goLeft(1, False) + # Step 3: Initiate spellchecking, and make sure "Check grammar" is + # unchecked + spell_dialog = self.launch_dialog() + checkgrammar = spell_dialog.getChild('checkgrammar') + if get_state_as_dict(checkgrammar)['Selected'] == 'true': + checkgrammar.executeAction('CLICK', ()) + self.assertTrue(get_state_as_dict(checkgrammar)['Selected'] == 'false') + + # Step 4: Repetitively click on "Correct all" for each misspelling + # prompt until end of document is reached. + changeall = spell_dialog.getChild('changeall') + changeall.executeAction("CLICK", ()) + changeall.executeAction("CLICK", ()) + # The third time we click on changeall, the click action is going to + # block while two message boxes are shown, so we need to do this third + # click specially + # Use empty close_button to open consecutive dialogs with self.ui_test.execute_blocking_action( - xYesBtn.executeAction, args=('CLICK', ())): - pass + changeall.executeAction, args=('CLICK', ()), close_button="") as dialog: + # Step 5: Confirm to "Continue check at beginning of document" + xYesBtn = dialog.getChild("yes") + + with self.ui_test.execute_blocking_action( + xYesBtn.executeAction, args=('CLICK', ())): + pass - output_text = document.Text.getString().replace('\r\n', '\n') - self.assertTrue(re.match(self.TDF46852_REGEX, output_text)) + output_text = document.Text.getString().replace('\r\n', '\n') + self.assertTrue(re.match(self.TDF46852_REGEX, output_text)) def test_tdf66043(self): supported_locale = self.is_supported_locale("en", "US") diff --git a/sw/qa/uitest/writer_tests4/start.py b/sw/qa/uitest/writer_tests4/start.py index 1ee80f604013..83b28d616818 100644 --- a/sw/qa/uitest/writer_tests4/start.py +++ b/sw/qa/uitest/writer_tests4/start.py @@ -14,36 +14,32 @@ class SimpleWriterTest(UITestCase): def test_start_writer(self): - self.ui_test.create_doc_in_start_center("writer") + with self.ui_test.create_doc_in_start_center("writer"): - xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterEdit = xWriterDoc.getChild("writer_edit") - xWriterEdit.executeAction("SET", mkPropertyValues({"ZOOM": "200"})) + xWriterEdit.executeAction("SET", mkPropertyValues({"ZOOM": "200"})) - self.assertEqual(get_state_as_dict(xWriterEdit)["Zoom"], "200") - - self.ui_test.close_doc() + self.assertEqual(get_state_as_dict(xWriterEdit)["Zoom"], "200") def test_goto_first_page(self): - self.ui_test.create_doc_in_start_center("writer") + with self.ui_test.create_doc_in_start_center("writer"): - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") - state = get_state_as_dict(xWriterEdit) - while state["CurrentPage"] == "1": - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) state = get_state_as_dict(xWriterEdit) + while state["CurrentPage"] == "1": + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + state = get_state_as_dict(xWriterEdit) - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - - xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"})) + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + xWriterEdit.executeAction("GOTO", mkPropertyValues({"PAGE": "1"})) - self.ui_test.close_doc() + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf113252.py b/sw/qa/uitest/writer_tests4/tdf113252.py index 5e3f868f37ad..11d85e108eeb 100644 --- a/sw/qa/uitest/writer_tests4/tdf113252.py +++ b/sw/qa/uitest/writer_tests4/tdf113252.py @@ -12,28 +12,27 @@ from uitest.uihelper.common import select_pos class tdf113252(UITestCase): def test_tdf113252_macro_dialog(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - - #Start LibreOffice. Go to Tools > Macros > Organize Macros > Basic - self.ui_test.execute_dialog_through_command(".uno:MacroDialog") - xDialog = self.xUITest.getTopFocusWindow() - - #Click Button Organizer - xorganize = xDialog.getChild("organize") - with self.ui_test.execute_blocking_action(xorganize.executeAction, args=('CLICK', ()), close_button="close") as dialog: - xTabs = dialog.getChild("tabcontrol") - select_pos(xTabs, "0") - select_pos(xTabs, "1") - select_pos(xTabs, "2") - #Click button Close in the next dialog -> crash. - - xClose = xDialog.getChild("close") - self.ui_test.close_dialog_through_button(xClose) - - self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + #Start LibreOffice. Go to Tools > Macros > Organize Macros > Basic + self.ui_test.execute_dialog_through_command(".uno:MacroDialog") + xDialog = self.xUITest.getTopFocusWindow() + + #Click Button Organizer + xorganize = xDialog.getChild("organize") + with self.ui_test.execute_blocking_action(xorganize.executeAction, args=('CLICK', ()), close_button="close") as dialog: + xTabs = dialog.getChild("tabcontrol") + select_pos(xTabs, "0") + select_pos(xTabs, "1") + select_pos(xTabs, "2") + #Click button Close in the next dialog -> crash. + + xClose = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xClose) + + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "1") + # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf115572.py b/sw/qa/uitest/writer_tests4/tdf115572.py index 511da669ccc9..6289aa9dd1a8 100644 --- a/sw/qa/uitest/writer_tests4/tdf115572.py +++ b/sw/qa/uitest/writer_tests4/tdf115572.py @@ -15,63 +15,60 @@ class tdf115572(UITestCase): tableText.setString( text ) def test_tdf115572_table_format_gets_reset_deleting_row(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #go to second row - arrow down - self.xUITest.executeCommand(".uno:GoDown") - #delete row - self.xUITest.executeCommand(".uno:DeleteRows") - #now the cursor is in the second column - go left - self.xUITest.executeCommand(".uno:GoLeft") - self.xUITest.executeCommand(".uno:GoLeft") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #go to second row - arrow down + self.xUITest.executeCommand(".uno:GoDown") + #delete row + self.xUITest.executeCommand(".uno:DeleteRows") + #now the cursor is in the second column - go left + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf115572_table_format_gets_reset_deleting_column(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #go to second column - self.xUITest.executeCommand(".uno:GoRight") - #delete column - self.xUITest.executeCommand(".uno:DeleteColumns") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #go to second column + self.xUITest.executeCommand(".uno:GoRight") + #delete column + self.xUITest.executeCommand(".uno:DeleteColumns") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf115573.py b/sw/qa/uitest/writer_tests4/tdf115573.py index af22c155b21e..b931cbcdcbd6 100644 --- a/sw/qa/uitest/writer_tests4/tdf115573.py +++ b/sw/qa/uitest/writer_tests4/tdf115573.py @@ -15,121 +15,114 @@ class tdf115573(UITestCase): tableText.setString( text ) def test_tdf115573_Table_loses_formatting_inserting_row_before(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #go to second row - arrow down - self.xUITest.executeCommand(".uno:GoDown") - #insert row - self.xUITest.executeCommand(".uno:InsertRowsBefore") - #go up - self.xUITest.executeCommand(".uno:GoUp") - self.xUITest.executeCommand(".uno:GoUp") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #go to second row - arrow down + self.xUITest.executeCommand(".uno:GoDown") + #insert row + self.xUITest.executeCommand(".uno:InsertRowsBefore") + #go up + self.xUITest.executeCommand(".uno:GoUp") + self.xUITest.executeCommand(".uno:GoUp") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf115573_Table_loses_formatting_inserting_row_after(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #go to second row - arrow down - self.xUITest.executeCommand(".uno:GoDown") - #insert row - self.xUITest.executeCommand(".uno:InsertRowsAfter") - #go up - self.xUITest.executeCommand(".uno:GoUp") - self.xUITest.executeCommand(".uno:GoUp") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #go to second row - arrow down + self.xUITest.executeCommand(".uno:GoDown") + #insert row + self.xUITest.executeCommand(".uno:InsertRowsAfter") + #go up + self.xUITest.executeCommand(".uno:GoUp") + self.xUITest.executeCommand(".uno:GoUp") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf115573_Table_loses_formatting_inserting_column_left(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #insert column left - self.xUITest.executeCommand(".uno:InsertColumnsBefore") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) - - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #insert column left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) def test_tdf115573_Table_loses_formatting_inserting_column_right(self): - self.ui_test.create_doc_in_start_center("writer") - document = self.ui_test.get_component() - xWriterDoc = self.xUITest.getTopFocusWindow() - #insert table 2x2 - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - self.ui_test.close_dialog_through_button(xOkBtn) - #select font format - Bold and write text "abc" - self.xUITest.executeCommand(".uno:Bold") - tables = document.getTextTables() - self.insertTextIntoCell(tables[0], "A1", "abc" ) - #insert column left - self.xUITest.executeCommand(".uno:InsertColumnsAfter") - #check the format of the text (should be still bold) Format-Character-Font-Style-Bold - self.ui_test.execute_dialog_through_command(".uno:FontDialog") - xDialog = self.xUITest.getTopFocusWindow() - xTabs = xDialog.getChild("tabcontrol") - select_pos(xTabs, "0") - xweststylelbcjk = xDialog.getChild("weststylelb-cjk") - self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") - xCloseBtn = xDialog.getChild("cancel") - self.ui_test.close_dialog_through_button(xCloseBtn) + with self.ui_test.create_doc_in_start_center("writer"): + document = self.ui_test.get_component() + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + #select font format - Bold and write text "abc" + self.xUITest.executeCommand(".uno:Bold") + tables = document.getTextTables() + self.insertTextIntoCell(tables[0], "A1", "abc" ) + #insert column left + self.xUITest.executeCommand(".uno:InsertColumnsAfter") + #check the format of the text (should be still bold) Format-Character-Font-Style-Bold + self.ui_test.execute_dialog_through_command(".uno:FontDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("weststylelb-cjk") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) - self.ui_test.close_doc() # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf51352.py b/sw/qa/uitest/writer_tests4/tdf51352.py index fdc5c66b7e85..1dd766afbfce 100644 --- a/sw/qa/uitest/writer_tests4/tdf51352.py +++ b/sw/qa/uitest/writer_tests4/tdf51352.py @@ -12,41 +12,40 @@ class tdf51352(UITestCase): def test_convert_nested_table_to_text_tdf51352(self): - self.ui_test.create_doc_in_start_center("writer") - xWriterDoc = self.xUITest.getTopFocusWindow() - xWriterEdit = xWriterDoc.getChild("writer_edit") - document = self.ui_test.get_component() - #1. New a text document - #2. Insert a table and then in one cell create another table - #-insert a table (by default 2x2) - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - #-put the cursor inside first cell top left for example - #-insert an inner table (by default 2x2) inside this cell - self.ui_test.execute_dialog_through_command(".uno:InsertTable") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - #3. Select the first table - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) - self.assertEqual(document.TextTables.getCount(), 2) - #4. From menu "Table->Convert->Table to Text - self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") - xDialog = self.xUITest.getTopFocusWindow() - xOkBtn = xDialog.getChild("ok") - xOkBtn.executeAction("CLICK", tuple()) - self.assertEqual(document.TextTables.getCount(), 0) - #5. Undo/Redo - self.xUITest.executeCommand(".uno:Undo") - self.assertEqual(document.TextTables.getCount(), 2) - self.xUITest.executeCommand(".uno:Redo") - self.assertEqual(document.TextTables.getCount(), 0) - self.ui_test.close_doc() + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + #1. New a text document + #2. Insert a table and then in one cell create another table + #-insert a table (by default 2x2) + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + #-put the cursor inside first cell top left for example + #-insert an inner table (by default 2x2) inside this cell + self.ui_test.execute_dialog_through_command(".uno:InsertTable") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + #3. Select the first table + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + self.assertEqual(document.TextTables.getCount(), 2) + #4. From menu "Table->Convert->Table to Text + self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") + xDialog = self.xUITest.getTopFocusWindow() + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + self.assertEqual(document.TextTables.getCount(), 0) + #5. Undo/Redo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 2) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.TextTables.getCount(), 0) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests4/tdf92611.py b/sw/qa/uitest/writer_tests4/tdf92611.py index 8fee6143c4c7..be2971055f79 100644 --- a/sw/qa/uitest/writer_tests4/tdf92611.py +++ b/sw/qa/uitest/writer_tests4/tdf92611.py @@ -10,12 +10,10 @@ class tdf92611(UITestCase): def test_launch_and_close_bibliography(self): - self.ui_test.create_doc_in_start_center("writer") + with self.ui_test.create_doc_in_start_center("writer"): - self.xUITest.executeCommand(".uno:BibliographyComponent") + self.xUITest.executeCommand(".uno:BibliographyComponent") - self.xUITest.executeCommand(".uno:CloseWin") - - self.ui_test.close_doc() + self.xUITest.executeCommand(".uno:CloseWin") # vim: set shiftwidth=4 softtabstop=4 expandtab: |