diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sw/qa/uitest/table | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
22 files changed, 1503 insertions, 0 deletions
diff --git a/sw/qa/uitest/table/insertTableDialog.py b/sw/qa/uitest/table/insertTableDialog.py new file mode 100644 index 000000000..727334c31 --- /dev/null +++ b/sw/qa/uitest/table/insertTableDialog.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict + +class WriterInsertTableDialog(UITestCase): + + def insertTextIntoCell(self, table, cellName, text ): + tableText = table.getCellByName( cellName ) + tableText.setString( text ) + + def test_tdf104158(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + + with self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog: + + xNameEdit = xDialog.getChild("nameedit") + + xNameEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xNameEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test3"})) + + xColSpin = xDialog.getChild("colspin") + xColSpin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xColSpin.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) + + xRowSpin = xDialog.getChild("rowspin") + xRowSpin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xRowSpin.executeAction("TYPE", mkPropertyValues({"TEXT": "2"})) + + self.assertEqual(get_state_as_dict(xNameEdit)["Text"], "Test3") + self.assertEqual(get_state_as_dict(xColSpin)["Text"], "2") + self.assertEqual(get_state_as_dict(xRowSpin)["Text"], "2") + + + tables = document.getTextTables() + + self.assertEqual(tables[0].getName(), "Test3") + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[0].getColumns()), 2) + + with self.ui_test.execute_dialog_through_command(".uno:TableNumberFormatDialog"): + pass + + + def test_cancel_button_insert_table_dialog(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + with self.ui_test.execute_dialog_through_command(".uno:InsertTable", close_button="cancel"): + pass + + tables = document.getTextTables() + self.assertEqual(len(tables), 0) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/sheetToTable.py b/sw/qa/uitest/table/sheetToTable.py new file mode 100644 index 000000000..e90f65e9f --- /dev/null +++ b/sw/qa/uitest/table/sheetToTable.py @@ -0,0 +1,123 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file +from uitest.uihelper.calc import enter_text_to_cell + +#Calc sheet to Writer table + +class sheetToTable(UITestCase): + def test_sheet_to_table_without_hidden_rows(self): + with self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:Paste") + #verify (don't copy hidden cells) + self.assertEqual(writer_doc.TextTables.getCount(), 1) + table = writer_doc.getTextTables()[0] + # This was 3 (copied hidden row) + self.assertEqual(len(table.getRows()), 2) + self.assertEqual(table.getCellByName("A1").getString(), "1") + # This was "2 (hidden)" (copied hidden row) + self.assertEqual(table.getCellByName("A2").getString(), "3") + + def test_tdf138688(self): + with self.ui_test.load_file(get_url_for_data_file("hiddenRow.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + # set numbering in the paragraph after the table + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:DefaultNumbering") + self.xUITest.executeCommand(".uno:GoUp") + self.xUITest.executeCommand(".uno:GoUp") + + #verify (this was a freezing/crash) + self.xUITest.executeCommand(".uno:Paste") + + #verify also tdf#124646 (don't copy hidden cells) + self.assertEqual(writer_doc.TextTables.getCount(), 1) + table = writer_doc.getTextTables()[0] + # This was 3 (copied hidden row) + self.assertEqual(len(table.getRows()), 2) + self.assertEqual(table.getCellByName("A1").getString(), "1") + # This was "2 (hidden)" (copied hidden row) + self.assertEqual(table.getCellByName("A2").getString(), "3") + + def test_tdf129083(self): + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Test 1") + enter_text_to_cell(gridwin, "A2", "Test 2") + enter_text_to_cell(gridwin, "A3", "Test 3") + enter_text_to_cell(gridwin, "A4", "Test 4") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + self.xUITest.executeCommand(".uno:Copy") + + + with self.ui_test.load_empty_file("writer") as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:InsertTable?Columns:short=1&Rows:short=4") + + self.xUITest.executeCommand(".uno:Paste") + + self.assertEqual(writer_doc.TextTables.getCount(), 1) + table = writer_doc.getTextTables()[0] + self.assertEqual(len(table.getRows()), 4) + self.assertEqual(table.getCellByName("A1").getString(), "Test 1") + self.assertEqual(table.getCellByName("A2").getString(), "Test 2") + self.assertEqual(table.getCellByName("A3").getString(), "Test 3") + self.assertEqual(table.getCellByName("A4").getString(), "Test 4") + + def test_tdf116685(self): + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Test 1") + enter_text_to_cell(gridwin, "A2", "Test 2") + enter_text_to_cell(gridwin, "A3", "Test 3") + enter_text_to_cell(gridwin, "A4", "Test 4") + + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:Paste") + + # Without the fix in place, this test would have failed with + # AssertionError: 0 != 1 + self.assertEqual(writer_doc.TextTables.getCount(), 1) + table = writer_doc.getTextTables()[0] + self.assertEqual(len(table.getRows()), 4) + self.assertEqual(table.getCellByName("A1").getString(), "Test 1") + self.assertEqual(table.getCellByName("A2").getString(), "Test 2") + self.assertEqual(table.getCellByName("A3").getString(), "Test 3") + self.assertEqual(table.getCellByName("A4").getString(), "Test 4") + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sw/qa/uitest/table/splitTable.py b/sw/qa/uitest/table/splitTable.py new file mode 100644 index 000000000..033c140bb --- /dev/null +++ b/sw/qa/uitest/table/splitTable.py @@ -0,0 +1,70 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +#Writer Split Table + +class splitTable(UITestCase): + def test_split_table(self): + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + #dialog Split table, check Copy heading, OK -> verify 2 tables, 1st has 2 rows, second has 5 rows + with self.ui_test.execute_dialog_through_command(".uno:SplitTable") as xDialog: + + copyheading = xDialog.getChild("copyheading") + copyheading.executeAction("CLICK", tuple()) + self.assertEqual(writer_doc.TextTables.getCount(), 2) + tables = writer_doc.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 5) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + + #dialog Split table, check Custom heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + with self.ui_test.execute_dialog_through_command(".uno:SplitTable") as xDialog: + + customheading = xDialog.getChild("customheading") + customheading.executeAction("CLICK", tuple()) + self.assertEqual(writer_doc.TextTables.getCount(), 2) + tables = writer_doc.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 4) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + + #dialog Split table, check No heading, OK -> verify 2 tables, 1st has 2 rows, second has 4 rows + with self.ui_test.load_file(get_url_for_data_file("splitTable.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #go to row 2 + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + with self.ui_test.execute_dialog_through_command(".uno:SplitTable") as xDialog: + + noheading = xDialog.getChild("noheading") + noheading.executeAction("CLICK", tuple()) + self.assertEqual(writer_doc.TextTables.getCount(), 2) + tables = writer_doc.getTextTables() + self.assertEqual(len(tables[0].getRows()), 2) + self.assertEqual(len(tables[1].getRows()), 4) + #undo -> verify 1 tables + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tableProperties.py b/sw/qa/uitest/table/tableProperties.py new file mode 100644 index 000000000..c0edf484f --- /dev/null +++ b/sw/qa/uitest/table/tableProperties.py @@ -0,0 +1,195 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import change_measurement_unit + +#Writer Table Properties + +class tableProperties(UITestCase): + def test_table_properties(self): + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + change_measurement_unit(self, "Centimeter") + + #dialog Table Properties - Table + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "0") + + name = xDialog.getChild("name") + free = xDialog.getChild("free") + widthmf = xDialog.getChild("widthmf") + leftmf = xDialog.getChild("leftmf") + rightmf = xDialog.getChild("rightmf") + abovemf = xDialog.getChild("abovemf") + belowmf = xDialog.getChild("belowmf") + textdirection = xDialog.getChild("textdirection") + + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + free.executeAction("CLICK", tuple()) + widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + widthmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + widthmf.executeAction("TYPE", mkPropertyValues({"TEXT":"15"})) + leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + leftmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + leftmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + rightmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + rightmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abovemf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abovemf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + belowmf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + belowmf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(textdirection, "Left-to-right (LTR)") + #verify + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "0") + + name = xDialog.getChild("name") + free = xDialog.getChild("free") + widthmf = xDialog.getChild("widthmf") + leftmf = xDialog.getChild("leftmf") + rightmf = xDialog.getChild("rightmf") + abovemf = xDialog.getChild("abovemf") + belowmf = xDialog.getChild("belowmf") + textdirection = xDialog.getChild("textdirection") + + self.assertEqual(get_state_as_dict(name)["Text"], "NewName") + self.assertEqual(get_state_as_dict(free)["Checked"], "true") + self.assertEqual(get_state_as_dict(widthmf)["Text"], "15.00 cm") + self.assertEqual(get_state_as_dict(leftmf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(rightmf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(abovemf)["Text"], "1.00 cm") + self.assertEqual(get_state_as_dict(belowmf)["Text"], "1.00 cm") + + #dialog Table Properties - Text flow + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + xbreak = xDialog.getChild("break") + xbreak.executeAction("CLICK", tuple()) + column = xDialog.getChild("column") + column.executeAction("CLICK", tuple()) + after = xDialog.getChild("after") + after.executeAction("CLICK", tuple()) + keep = xDialog.getChild("keep") + keep.executeAction("CLICK", tuple()) + headline = xDialog.getChild("headline") + headline.executeAction("CLICK", tuple()) + textdirection = xDialog.getChild("textorientation") + select_by_text(textdirection, "Vertical (bottom to top)") + vertorient = xDialog.getChild("vertorient") + select_by_text(vertorient, "Bottom") + #verify + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + xbreak = xDialog.getChild("break") + self.assertEqual(get_state_as_dict(xbreak)["Selected"], "true") + column = xDialog.getChild("column") + self.assertEqual(get_state_as_dict(column)["Checked"], "true") + after = xDialog.getChild("column") + self.assertEqual(get_state_as_dict(after)["Checked"], "true") + keep = xDialog.getChild("keep") + self.assertEqual(get_state_as_dict(keep)["Selected"], "true") + headline = xDialog.getChild("headline") + self.assertEqual(get_state_as_dict(headline)["Selected"], "true") + textdirection = xDialog.getChild("textorientation") + self.assertEqual(get_state_as_dict(textdirection)["SelectEntryText"], "Vertical (bottom to top)") + vertorient = xDialog.getChild("vertorient") + self.assertEqual(get_state_as_dict(vertorient)["SelectEntryText"], "Bottom") + + #dialog Table Properties - Columns + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "2") + + adaptwidth = xDialog.getChild("adaptwidth") + adaptwidth.executeAction("CLICK", tuple()) + + #verify + #doesn't work / probably Bug 100537 - Width and relative checkboxes disabled in Table + #dialog by default with automatic alignment + # self.ui_test.execute_dialog_through_command(".uno:TableDialog") + # xDialog = self.xUITest.getTopFocusWindow() + # tabcontrol = xDialog.getChild("tabcontrol") + # select_pos(tabcontrol, "2") + # adaptwidth = xDialog.getChild("adaptwidth") + # self.assertEqual(get_state_as_dict(adaptwidth)["Selected"], "true") + # xOKBtn = xDialog.getChild("ok") + # self.ui_test.close_dialog_through_button(xOKBtn) + + #dialog Table Properties - Borders + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "3") + + sync = xDialog.getChild("sync") + mergeadjacent = xDialog.getChild("mergeadjacent") + sync.executeAction("CLICK", tuple()) + mergeadjacent.executeAction("CLICK", tuple()) + + #verify + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "3") + sync = xDialog.getChild("sync") + mergeadjacent = xDialog.getChild("mergeadjacent") + # self.assertEqual(get_state_as_dict(sync)["Selected"], "false") #need change spacing, but ui names are not unique + self.assertEqual(get_state_as_dict(mergeadjacent)["Selected"], "false") + + #dialog Table Properties - Background + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "4") + + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + R_custom = xDialog.getChild("R_custom") + G_custom = xDialog.getChild("G_custom") + B_custom = xDialog.getChild("B_custom") + R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + R_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + R_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + G_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + G_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + B_custom.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + B_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"100"})) + B_custom.executeAction("UP", tuple()) + B_custom.executeAction("DOWN", tuple()) #need to refresh HEX value... + + #verify + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "4") + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + R_custom = xDialog.getChild("R_custom") + G_custom = xDialog.getChild("G_custom") + B_custom = xDialog.getChild("B_custom") + + self.assertEqual(get_state_as_dict(R_custom)["Text"], "100") + self.assertEqual(get_state_as_dict(B_custom)["Text"], "100") + self.assertEqual(get_state_as_dict(G_custom)["Text"], "100") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tableToText.py b/sw/qa/uitest/table/tableToText.py new file mode 100644 index 000000000..87e116bef --- /dev/null +++ b/sw/qa/uitest/table/tableToText.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file + +#Writer Table to text + +class tableToText(UITestCase): + def test_table_to_text(self): + with self.ui_test.load_file(get_url_for_data_file("tableToText.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #dialog Table to text - Tabs; verify + with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog: + tabs = xDialog.getChild("tabs") + tabs.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.Text.String[0:3], "a\ta") + self.assertEqual(writer_doc.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + + #dialog Table to text - Paragraph; verify + with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog: + paragraph = xDialog.getChild("paragraph") + paragraph.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:4], "a\na\n") + self.assertEqual(writer_doc.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + + #dialog Table to text - Semicolons; verify + with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog: + semicolons = xDialog.getChild("semicolons") + semicolons.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:6], "a;a\n;\n") + self.assertEqual(writer_doc.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + + #dialog Table to text - other; verify + with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText") as xDialog: + other = xDialog.getChild("other") + other.executeAction("CLICK", tuple()) + othered = xDialog.getChild("othered") + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) + #verify + self.assertEqual(writer_doc.Text.String.replace('\r\n', '\n')[0:6], "a:a\n:\n") + self.assertEqual(writer_doc.TextTables.getCount(), 0) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 1) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf109083.py b/sw/qa/uitest/table/tdf109083.py new file mode 100644 index 000000000..d369ee8a5 --- /dev/null +++ b/sw/qa/uitest/table/tdf109083.py @@ -0,0 +1,62 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +#Bug 109083 - Updating table style: changes didn't propagate to other tables when selection was over two columns at the moment of updating +class tdf109083(UITestCase): + def test_tdf109083(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #generate two 2x2 tables with the same autoformat table style (Default Table Style) + #Note that this style is different than applying nothing! + for i in range(0, 2): + with self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog: + formatlbinstable = xDialog.getChild("formatlbinstable") + entry = formatlbinstable.getChild("1") + entry.executeAction("SELECT", tuple()) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + #select the last row of the first table + for i in range (0,2): + self.xUITest.executeCommand(".uno:GoDown") + for i in range (0,2): + self.xUITest.executeCommand(".uno:CharRightSel") + #set a specific color on the selected cells (last row) + self.xUITest.executeCommandWithParameters(".uno:TableCellBackgroundColor", mkPropertyValues({"TableCellBackgroundColor" : 16776960 })) + + #Sidebar -> Table Styles -> Style Actions -> "Update Selected Style" (note: the row is still selected) + self.xUITest.executeCommand(".uno:Sidebar") + xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"})) + xLeft = xWriterEdit.getChild('left') + xLeft.executeAction("CLICK", mkPropertyValues({"POS": "5"})) + xRight = xWriterEdit.getChild('right') + xRight.executeAction("CLICK", mkPropertyValues({"POS": "3"})) + #select the second table + for i in range (0,2): + self.xUITest.executeCommand(".uno:GoDown") + + #first row's cells must be yellow, second/last row's cells must be updated to yellow by now + for i in range (0,4): + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Background + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + hex_custom = xDialog.getChild("hex_custom") + if i >= 2: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ffff00") + else: + self.assertEqual(get_state_as_dict(hex_custom)["Text"], "ffffff") + self.xUITest.executeCommand(".uno:GoRight") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf115026.py b/sw/qa/uitest/table/tdf115026.py new file mode 100644 index 000000000..3b372f643 --- /dev/null +++ b/sw/qa/uitest/table/tdf115026.py @@ -0,0 +1,31 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict + +class tdf115026(UITestCase): + + def test_pageBreak_and_tableAutoFormat(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:InsertPagebreak") + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat"): + pass + + self.assertEqual(get_state_as_dict(xWriterEdit)["CurrentPage"], "2") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf115572.py b/sw/qa/uitest/table/tdf115572.py new file mode 100644 index 000000000..ebd42ab0e --- /dev/null +++ b/sw/qa/uitest/table/tdf115572.py @@ -0,0 +1,66 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class tdf115572(UITestCase): + + def insertTextIntoCell(self, table, cellName, text ): + tableText = table.getCellByName( cellName ) + tableText.setString( text ) + + def test_tdf115572_table_format_gets_reset_deleting_row(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + + + def test_tdf115572_table_format_gets_reset_deleting_column(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf115573.py b/sw/qa/uitest/table/tdf115573.py new file mode 100644 index 000000000..2b2ae0a8a --- /dev/null +++ b/sw/qa/uitest/table/tdf115573.py @@ -0,0 +1,109 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class tdf115573(UITestCase): + + def insertTextIntoCell(self, table, cellName, text ): + tableText = table.getCellByName( cellName ) + tableText.setString( text ) + + def test_tdf115573_Table_loses_formatting_inserting_row_before(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + + + def test_tdf115573_Table_loses_formatting_inserting_row_after(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + + + def test_tdf115573_Table_loses_formatting_inserting_column_left(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + + + def test_tdf115573_Table_loses_formatting_inserting_column_right(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + #insert table 2x2 + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xweststylelbcjk = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xweststylelbcjk)["Text"], "Bold") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf116737.py b/sw/qa/uitest/table/tdf116737.py new file mode 100644 index 000000000..0e6c1b216 --- /dev/null +++ b/sw/qa/uitest/table/tdf116737.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +#Bug 116737 - INSERT TABLE: Can't select table style (gen/gtk) +class tdf116737(UITestCase): + def test_tdf116737_select_table_style(self): + + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + + #Insert => Insert Table / It's not possible to select a table style + with self.ui_test.execute_dialog_through_command(".uno:InsertTable") as xDialog: + + formatlbinstable = xDialog.getChild("formatlbinstable") + entry = formatlbinstable.getChild("11") #Simple List Shaded + entry.executeAction("SELECT", tuple()) + + + #verify .uno:TableDialog + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Background + + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + + R_custom = xDialog.getChild("R_custom") + G_custom = xDialog.getChild("G_custom") + B_custom = xDialog.getChild("B_custom") + #"Simple List Shaded" -> header should be black + self.assertEqual(get_state_as_dict(R_custom)["Text"], "0") + self.assertEqual(get_state_as_dict(G_custom)["Text"], "0") + self.assertEqual(get_state_as_dict(B_custom)["Text"], "0") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf128593.py b/sw/qa/uitest/table/tdf128593.py new file mode 100755 index 000000000..19158f6e4 --- /dev/null +++ b/sw/qa/uitest/table/tdf128593.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, select_pos + +#https://bugs.documentfoundation.org/show_bug.cgi?id=128593 +#Bug 128593 - Writer table cell's background color is always black + +class tdf128593(UITestCase): + def test_tdf128593_table_background_color(self): + with self.ui_test.create_doc_in_start_center("writer"): + MainWindow = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + + self.xUITest.executeCommandWithParameters(".uno:TableCellBackgroundColor", mkPropertyValues({"TableCellBackgroundColor" : 16776960 }) ) + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as TablePropertiesDialog: + writer_edit = MainWindow.getChild("writer_edit") + writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "0"})) + tabcontrol = TablePropertiesDialog.getChild("tabcontrol") + select_pos(tabcontrol, "4") + Rcustom = TablePropertiesDialog.getChild("R_custom") #255 + self.assertEqual(get_state_as_dict(Rcustom)["Text"], "255") + Gcustom = TablePropertiesDialog.getChild("G_custom") #255 + self.assertEqual(get_state_as_dict(Gcustom)["Text"], "255") + Bcustom = TablePropertiesDialog.getChild("B_custom") #0 + self.assertEqual(get_state_as_dict(Bcustom)["Text"], "0") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py b/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py new file mode 100644 index 000000000..74bb5d40f --- /dev/null +++ b/sw/qa/uitest/table/tdf134881_colProportionalAdjust.py @@ -0,0 +1,47 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import change_measurement_unit +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Writer Table Properties + +class tdf134881(UITestCase): + def test_tdf134881(self): + with self.ui_test.load_file(get_url_for_data_file("tdf134881_colProportionalAdjust.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + + change_measurement_unit(self, "Centimeter") + + #dialog Table Properties + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "2") #columns + + adaptcolumns = xDialog.getChild("adaptcolumns") + width1 = xDialog.getChild("width1") + width2 = xDialog.getChild("width2") + # Get the baseline. The first column is much shorter than the second. + self.assertEqual((get_state_as_dict(width1)["Text"])[0:3], "3.0") + self.assertEqual((get_state_as_dict(width2)["Text"])[0:4], "14.0") + # Set proportional adjust - so all columns are affected. + adaptcolumns.executeAction("CLICK", tuple()) + # Cut the second column in half. + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + width2.executeAction("TYPE", mkPropertyValues({"TEXT":"7"})) + width2.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # The first column should now be half it's original value, not zero (not 3 - 7) + self.assertEqual((get_state_as_dict(width1)["Text"])[0:2], "1.") #1.5 + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf135693.py b/sw/qa/uitest/table/tdf135693.py new file mode 100644 index 000000000..90544a228 --- /dev/null +++ b/sw/qa/uitest/table/tdf135693.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class tdf135693(UITestCase): + + def test_tdf135693(self): + with self.ui_test.load_file(get_url_for_data_file("tdf135693.odt")) as writer_doc: + + self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoDown") + + # Without the fix in place, this would have crashed here + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xTableDlg: + + + xTabs = xTableDlg.getChild("tabcontrol") + select_pos(xTabs, "0") + + # Check we are in the right table + self.assertEqual("Table1", get_state_as_dict(xTabs.getChild('name'))['Text']) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf140506.py b/sw/qa/uitest/table/tdf140506.py new file mode 100644 index 000000000..220f46bf6 --- /dev/null +++ b/sw/qa/uitest/table/tdf140506.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf140506(UITestCase): + + def test_tdf140506(self): + with self.ui_test.load_file(get_url_for_data_file("tdf140506.odt")) as writer_doc: + + xMainWindow = self.xUITest.getTopFocusWindow() + xwriter_edit = xMainWindow.getChild("writer_edit") + + tables = writer_doc.getTextTables() + self.assertEqual(len(tables[0].getRows()), 20) + self.assertEqual(len(tables[0].getColumns()), 2) + + self.assertEqual(2, writer_doc.CurrentController.PageCount) + + with self.ui_test.execute_dialog_through_command(".uno:TableDialog") as xDialog: + tabcontrol = xDialog.getChild("tabcontrol") + select_pos(tabcontrol, "1") + + headline = xDialog.getChild("headline") + repeatheader = xDialog.getChild("repeatheadernf") + self.assertEqual('false', get_state_as_dict(headline)["Selected"]) + headline.executeAction("CLICK", tuple()) + self.assertEqual('true', get_state_as_dict(headline)["Selected"]) + self.assertEqual('1', get_state_as_dict(repeatheader)["Value"]) + + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + self.assertEqual(len(tables[0].getRows()), 20) + self.assertEqual(len(tables[0].getColumns()), 2) + + # Without the fix in place, this test would have failed with + # AssertionError: 20 != 2 + self.assertEqual(20, writer_doc.CurrentController.PageCount) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf144843.py b/sw/qa/uitest/table/tdf144843.py new file mode 100644 index 000000000..1920cda02 --- /dev/null +++ b/sw/qa/uitest/table/tdf144843.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf144843(UITestCase): + + def test_tdf144843(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + + self.xUITest.executeCommand(".uno:InsertTable?Columns:short=2&Rows:short=2") + + self.xUITest.executeCommand(".uno:SelectAll") + + self.assertEqual(-1, document.TextTables[0].getCellByName("A1").BackColor) + + # Without the fix in place, this test would have crashed here + with self.ui_test.execute_dialog_through_command(".uno:BackgroundDialog") as xDialog: + btncolor = xDialog.getChild("btncolor") + btncolor.executeAction("CLICK", tuple()) + + hex_custom = xDialog.getChild("hex_custom") + hex_custom.executeAction("TYPE", mkPropertyValues({"TEXT":"101010"})) + + self.assertEqual("0x101010", hex(document.TextTables[0].getCellByName("A1").BackColor)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf146145.py b/sw/qa/uitest/table/tdf146145.py new file mode 100644 index 000000000..357ce82a4 --- /dev/null +++ b/sw/qa/uitest/table/tdf146145.py @@ -0,0 +1,157 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +import time + +from com.sun.star.accessibility.AccessibleStateType import ENABLED + +class tdf146145(UITestCase): + + # access to the private:resource changes toolbar via accessibility API + def is_enabled_Accept_Track_Change(self): + xFrame = self.document.getCurrentController().getFrame() + + for i in xFrame.getPropertyValue("LayoutManager").getElements(): + if i.getPropertyValue('ResourceURL') == 'private:resource/toolbar/changes': + return ENABLED in i.getRealInterface().getAccessibleContext().getAccessibleChild(5).getAccessibleStateSet().getStates() + + return False + + def test_tdf146145(self): + with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + + # Check enabling Accept/Reject Track Change icons + # and Accept Change/Reject Change context menu items + # on table rows with tracked deletion or insertion + + # enable Track Changes toolbar + self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes") + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + # cursor at changed text: Accept Track Change is enabled + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # cursor in a changed row, but not at changed text: Accept Track Change is enabled now + self.xUITest.executeCommand(".uno:GoRight") + xToolkit.processEventsToIdle() + # This was false + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # cursor in a not changed row: Accept Track Change is disabled + self.xUITest.executeCommand(".uno:GoDown") + xToolkit.processEventsToIdle() + while self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertFalse(self.is_enabled_Accept_Track_Change()) + + # check the fix again to avoid of the asynchron state changes + self.xUITest.executeCommand(".uno:GoUp") + xToolkit.processEventsToIdle() + while not self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # check 1-click accept of table row deletion (3 redlines in the row) + + # not at changed text, but Accept Track Change removes the whole row now + + tables = self.document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 4) + + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 3) + + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 4) + + self.xUITest.executeCommand(".uno:Redo") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 3) + + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 4) + + # check 1-click reject of table row insertion (3 redlines in the row) + + for i in range(3): + self.xUITest.executeCommand(".uno:GoDown") + + # not at changed text (the cursor is there at the end of the text of the table row), + # but Reject Track Change removes the whole row now + + tables = self.document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 4) + + self.xUITest.executeCommand(".uno:RejectTrackedChange") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 3) + + self.xUITest.executeCommand(".uno:Undo") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 4) + + self.xUITest.executeCommand(".uno:Redo") + xToolkit.processEventsToIdle() + self.assertEqual(len(tables[0].getRows()), 3) + + def test_Related_tdf147182(self): + with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document: + + # Check enabling Accept/Reject Track Change icons + # and Accept Change/Reject Change context menu items + # on table rows with tracked deletion or insertion + + # enable Track Changes toolbar + self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes") + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + # cursor at changed text: Accept Track Change is enabled + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # cursor in a changed row, but not at changed text: Accept Track Change is enabled now + self.xUITest.executeCommand(".uno:GoRight") + xToolkit.processEventsToIdle() + # This was false + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # delete first row + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + xToolkit.processEventsToIdle() + # disabled Accept Track Change + while self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertFalse(self.is_enabled_Accept_Track_Change()) + + # delete first row + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:SelectAll") + xToolkit.processEventsToIdle() + # This was false + while not self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + self.assertTrue(self.is_enabled_Accept_Track_Change()) + + # delete all changes in the selected table + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + xToolkit.processEventsToIdle() + while self.is_enabled_Accept_Track_Change(): + time.sleep(0.1) + # disabled Accept Track Change + self.assertFalse(self.is_enabled_Accept_Track_Change()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf51352.py b/sw/qa/uitest/table/tdf51352.py new file mode 100644 index 000000000..4a2fa79d5 --- /dev/null +++ b/sw/qa/uitest/table/tdf51352.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf51352(UITestCase): + + def test_convert_nested_table_to_text_tdf51352(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #1. New a text document + #2. Insert a table and then in one cell create another table + #-insert a table (by default 2x2) + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #-put the cursor inside first cell top left for example + #-insert an inner table (by default 2x2) inside this cell + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + #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 + with self.ui_test.execute_dialog_through_command(".uno:ConvertTableToText"): + pass + 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/table/tdf53460.py b/sw/qa/uitest/table/tdf53460.py new file mode 100644 index 000000000..b0e8fcaba --- /dev/null +++ b/sw/qa/uitest/table/tdf53460.py @@ -0,0 +1,74 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf53460(UITestCase): + + def test_resize_table_with_keyboard_tdf53460(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #-insert a table (by default 2x2) + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + + #-put the cursor inside first cell top left for example + #-insert an inner table (by default 2x2) inside this cell + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + + #-still in top left cell, go to the line after the inner table + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + #- <ALT>+up key => crash + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"})) + + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"})) + + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"})) + + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"})) + + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"})) + xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"})) + + self.assertEqual(document.TextTables.getCount(), 2) +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf81292.py b/sw/qa/uitest/table/tdf81292.py new file mode 100644 index 000000000..324be1d7f --- /dev/null +++ b/sw/qa/uitest/table/tdf81292.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +#Bug 81292 - TABLE: Crashes on sorting table + +class tdf81292(UITestCase): + + def test_tdf81292_table_sort(self): + with self.ui_test.load_file(get_url_for_data_file("tdf81292.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #select whole table + self.xUITest.executeCommand(".uno:SelectTable") + #Tools - Sort + with self.ui_test.execute_dialog_through_command(".uno:SortDialog") as xDialog: + xDown = xDialog.getChild("down1") + xDown.executeAction("CLICK", tuple()) + #verify + tables = writer_doc.getTextTables() + table = tables[0] + tableText = table.getCellByName("B3") + b3 = tableText.getString() + tableTextc1 = table.getCellByName("C1").getString() + self.assertEqual(b3, "https://www.hightail.com/") + self.assertEqual(tableTextc1, "inlognaam") + #undo + self.xUITest.executeCommand(".uno:Undo") + b3 = tableText.getString() + self.assertEqual(b3, "www.comicstripshop.com") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/tdf93068.py b/sw/qa/uitest/table/tdf93068.py new file mode 100644 index 000000000..4dae8ae74 --- /dev/null +++ b/sw/qa/uitest/table/tdf93068.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase + +class tdf93068(UITestCase): + + def test_tdf93068(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + + + self.xUITest.getTopFocusWindow() + + # tdf#135950: Character dialog crashes if multiple cells in a + # table are selected + with self.ui_test.execute_dialog_through_command(".uno:InsertTable"): + pass + + self.xUITest.executeCommand(".uno:SelectAll") + + # Check the table is selected + self.assertEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName()) + + with self.ui_test.execute_dialog_through_command(".uno:FontDialog"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:FontDialog", close_button="cancel"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:FontDialog") as xFontDlg: + xDiscardBtn = xFontDlg.getChild("reset") + xDiscardBtn.executeAction("CLICK", tuple()) + + self.xUITest.getTopFocusWindow() + + # Check the table is still selected after closing the dialog + self.assertEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName()) + + self.xUITest.executeCommand(".uno:GoDown") + + # Check the table is no longer selected + self.assertNotEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sw/qa/uitest/table/tdf99334.py b/sw/qa/uitest/table/tdf99334.py new file mode 100644 index 000000000..0f5e55b30 --- /dev/null +++ b/sw/qa/uitest/table/tdf99334.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +#Bug 99334 - Crashes when sorting table by columns with umlauts + +class tdf99334(UITestCase): + + def test_tdf99334_table_sort_umlauts(self): + with self.ui_test.load_file(get_url_for_data_file("tdf99334.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + #select whole table + self.xUITest.executeCommand(".uno:SelectTable") + #Tools - Sort + with self.ui_test.execute_dialog_through_command(".uno:SortDialog"): + pass + #verify + tables = writer_doc.getTextTables() + table = tables[0] + tableText = table.getCellByName("B1") + b1 = tableText.getString() + self.assertEqual(b1, "two") + #undo + self.xUITest.executeCommand(".uno:Undo") + b1 = tableText.getString() + self.assertEqual(b1, "one") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/table/textToTable.py b/sw/qa/uitest/table/textToTable.py new file mode 100644 index 000000000..06d4b02da --- /dev/null +++ b/sw/qa/uitest/table/textToTable.py @@ -0,0 +1,62 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file, type_text + +#Writer Text to table + +class textToTable(UITestCase): + def test_text_to_table(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #Enter A;B ; select the text ; dialog Text to table - Semicolon; verify + type_text(xWriterEdit, "A;B;C") + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "5"})) + with self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") as xDialog: + semicolons = xDialog.getChild("semicolons") + semicolons.executeAction("CLICK", tuple()) + #verify + self.assertEqual(document.TextTables.getCount(), 1) + tables = document.getTextTables() + self.assertEqual(len(tables[0].getRows()), 1) + self.assertEqual(len(tables[0].getColumns()), 3) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.TextTables.getCount(), 0) + self.assertEqual(document.Text.String[0:5], "A;B;C") + + + def test_text_to_table_header(self): + with self.ui_test.load_file(get_url_for_data_file("textToTable.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #open file; select all text ; dialog Text to table - other ":"; verify + self.xUITest.executeCommand(".uno:SelectAll") + with self.ui_test.execute_dialog_through_command(".uno:ConvertTextToTable") as xDialog: + other = xDialog.getChild("other") + other.executeAction("CLICK", tuple()) + othered = xDialog.getChild("othered") + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + othered.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + othered.executeAction("TYPE", mkPropertyValues({"TEXT":":"})) + headingcb = xDialog.getChild("headingcb") + headingcb.executeAction("CLICK", tuple()) + #verify + self.assertEqual(writer_doc.TextTables.getCount(), 1) + tables = writer_doc.getTextTables() + self.assertEqual(len(tables[0].getRows()), 4) + self.assertEqual(len(tables[0].getColumns()), 3) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(writer_doc.TextTables.getCount(), 0) + self.assertEqual(writer_doc.Text.String[0:5], "A:B:C") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |