diff options
Diffstat (limited to '')
193 files changed, 9906 insertions, 0 deletions
diff --git a/sc/qa/uitest/calc_tests/CalcPasteOnly.py b/sc/qa/uitest/calc_tests/CalcPasteOnly.py new file mode 100644 index 000000000..7253043a7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/CalcPasteOnly.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.path import get_srcdir_url +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +import time +from uitest.debug import sleep + +class CalcPasteOnly(UITestCase): + + def test_paste_only(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xTopWindow = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = xTopWindow.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "=SUM(A2:A3)") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:PasteOnlyText") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:PasteOnlyValue") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 0) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:PasteOnlyFormula") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getFormula(), "=SUM(E2:E3)") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/autofill.py b/sc/qa/uitest/calc_tests/autofill.py new file mode 100644 index 000000000..09b37d6a6 --- /dev/null +++ b/sc/qa/uitest/calc_tests/autofill.py @@ -0,0 +1,153 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +import org.libreoffice.unotest +import pathlib +from libreoffice.uno.propertyvalue import mkPropertyValues +#Test for the AutoFill feature - auto-fill can't increment last octet of ip addresses + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class CalcAutofill(UITestCase): + + def test_autofill(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("autofill.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Select cell A12 and drag the fill handle in the bottom right corner of the cell down to A18 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A12:A18"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 0, 11).getValue(), 18.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 19.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 20.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 14).getValue(), 21.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 15).getValue(), 22.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 16).getValue(), 23.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 17).getValue(), 24.34) + #Select cell A12 and drag the fill handle in the bottom right corner of the cell up to A6 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A6:A12"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getValue(), 12.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 13.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 14.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getValue(), 15.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getValue(), 16.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 10).getValue(), 17.34) + self.assertEqual(get_cell_by_position(document, 0, 0, 11).getValue(), 18.34) + + #Continue with the next cells with grey background + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M12:M18"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 12, 11).getString(), "12abc40") + self.assertEqual(get_cell_by_position(document, 0, 12, 12).getString(), "12abc41") + self.assertEqual(get_cell_by_position(document, 0, 12, 13).getString(), "12abc42") + self.assertEqual(get_cell_by_position(document, 0, 12, 14).getString(), "12abc43") + self.assertEqual(get_cell_by_position(document, 0, 12, 15).getString(), "12abc44") + self.assertEqual(get_cell_by_position(document, 0, 12, 16).getString(), "12abc45") + self.assertEqual(get_cell_by_position(document, 0, 12, 17).getString(), "12abc46") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M6:M12"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 12, 5).getString(), "12abc34") + self.assertEqual(get_cell_by_position(document, 0, 12, 6).getString(), "12abc35") + self.assertEqual(get_cell_by_position(document, 0, 12, 7).getString(), "12abc36") + self.assertEqual(get_cell_by_position(document, 0, 12, 8).getString(), "12abc37") + self.assertEqual(get_cell_by_position(document, 0, 12, 9).getString(), "12abc38") + self.assertEqual(get_cell_by_position(document, 0, 12, 10).getString(), "12abc39") + self.assertEqual(get_cell_by_position(document, 0, 12, 11).getString(), "12abc40") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P12:P18"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 15, 11).getString(), "10.64.127.7") + self.assertEqual(get_cell_by_position(document, 0, 15, 12).getString(), "10.64.127.8") + self.assertEqual(get_cell_by_position(document, 0, 15, 13).getString(), "10.64.127.9") + self.assertEqual(get_cell_by_position(document, 0, 15, 14).getString(), "10.64.127.10") + self.assertEqual(get_cell_by_position(document, 0, 15, 15).getString(), "10.64.127.11") + self.assertEqual(get_cell_by_position(document, 0, 15, 16).getString(), "10.64.127.12") + self.assertEqual(get_cell_by_position(document, 0, 15, 17).getString(), "10.64.127.13") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P6:P12"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xup = xDialog.getChild("up") + xincrement = xDialog.getChild("increment") + xup.executeAction("CLICK", tuple()) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xincrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xincrement.executeAction("TYPE", mkPropertyValues({"TEXT":"-1"})) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(document, 0, 15, 5).getString(), "10.64.127.1") + self.assertEqual(get_cell_by_position(document, 0, 15, 6).getString(), "10.64.127.2") + self.assertEqual(get_cell_by_position(document, 0, 15, 7).getString(), "10.64.127.3") + self.assertEqual(get_cell_by_position(document, 0, 15, 8).getString(), "10.64.127.4") + self.assertEqual(get_cell_by_position(document, 0, 15, 9).getString(), "10.64.127.5") + self.assertEqual(get_cell_by_position(document, 0, 15, 10).getString(), "10.64.127.6") + self.assertEqual(get_cell_by_position(document, 0, 15, 11).getString(), "10.64.127.7") + + self.ui_test.close_doc() + + def test_autofill_with_suffix(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "1st") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/autosum.py b/sc/qa/uitest/calc_tests/autosum.py new file mode 100644 index 000000000..2bb4cff76 --- /dev/null +++ b/sc/qa/uitest/calc_tests/autosum.py @@ -0,0 +1,290 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import os +import pathlib +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#AutoSum feature test +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class calcAutosum(UITestCase): + + def test_autosum_test1(self): + #Sum on range and Sum on Sum's + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Place the cell cursor on the gray cells located under Point 1. + #(Multiselection is not possible at this place) and press the Sum Icon in the formula bar. + #Now hit the enter key and the result should be shown. Do so for each gray cell in this part of the document. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B10"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B13"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B14"})) + self.xUITest.executeCommand(".uno:AutoSum") + self.assertEqual(get_cell_by_position(document, 0, 1, 9).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 9).getFormula(), "=SUM(B8:B9)") + self.assertEqual(get_cell_by_position(document, 0, 1, 12).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 12).getFormula(), "=SUM(B11:B12)") + self.assertEqual(get_cell_by_position(document, 0, 1, 13).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 1, 13).getFormula(), "=SUM(B13:B13;B10:B10)") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "F8:F14"})) + self.xUITest.executeCommand(".uno:AutoSum") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getFormula(), "=SUM(F13:F13;F10:F10)") + + self.ui_test.close_doc() + + def test_autosum_test2(self): + #Sum on Row and Column + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E25"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E26"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E27"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E28"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E29"})) + self.xUITest.executeCommand(".uno:AutoSum") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E30"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 4, 24).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 4, 24).getFormula(), "=SUM(E22:E24)") + self.assertEqual(get_cell_by_position(document, 0, 4, 25).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 4, 25).getFormula(), "=SUM(B26:D26)") + self.assertEqual(get_cell_by_position(document, 0, 4, 26).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 4, 26).getFormula(), "=SUM(B27:D27)") + self.assertEqual(get_cell_by_position(document, 0, 4, 27).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 4, 27).getFormula(), "=SUM(B28:D28)") + self.assertEqual(get_cell_by_position(document, 0, 4, 28).getValue(), 9) + self.assertEqual(get_cell_by_position(document, 0, 4, 28).getFormula(), "=SUM(E26:E28)") + self.assertEqual(get_cell_by_position(document, 0, 4, 29).getValue(), 12) + self.assertEqual(get_cell_by_position(document, 0, 4, 29).getFormula(), "=SUM(E29:E29;E25:E25)") + + self.ui_test.close_doc() + + def test_autosum_test3(self): + #Subtotals on Autosum + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C49"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 2, 48).getValue(), 20) + self.assertEqual(get_cell_by_position(document, 0, 2, 48).getFormula(), "=SUBTOTAL(9;C38:C48)") + + self.ui_test.close_doc() + + def test_autosum_test4(self): + #Autosum on column with selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B59:B64"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 63).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 1, 63).getFormula(), "=SUM(B59:B63)") + + self.ui_test.close_doc() + + def test_autosum_test5(self): + #5.Autosum on rows with selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B76:E80"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 4, 75).getValue(), 30) + self.assertEqual(get_cell_by_position(document, 0, 4, 75).getFormula(), "=SUM(B76:D76)") + self.assertEqual(get_cell_by_position(document, 0, 4, 76).getValue(), 60) + self.assertEqual(get_cell_by_position(document, 0, 4, 76).getFormula(), "=SUM(B77:D77)") + self.assertEqual(get_cell_by_position(document, 0, 4, 77).getValue(), 90) + self.assertEqual(get_cell_by_position(document, 0, 4, 77).getFormula(), "=SUM(B78:D78)") + self.assertEqual(get_cell_by_position(document, 0, 4, 78).getValue(), 120) + self.assertEqual(get_cell_by_position(document, 0, 4, 78).getFormula(), "=SUM(B79:D79)") + self.assertEqual(get_cell_by_position(document, 0, 4, 79).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 4, 79).getFormula(), "=SUM(B80:D80)") + + self.ui_test.close_doc() + + def test_autosum_test6(self): + #6.Subtotal on column with selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C92:C101"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 2, 100).getValue(), 19) + self.assertEqual(get_cell_by_position(document, 0, 2, 100).getFormula(), "=SUBTOTAL(9;C92:C100)") + + self.ui_test.close_doc() + + def test_autosum_test7(self): + #7.Autosum on column without selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B109:B113"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 113).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 1, 113).getFormula(), "=SUM(B109:B113)") + + self.ui_test.close_doc() + + def test_autosum_test8(self): + #8.Autosum on rows without selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B126:D126"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B128:D128", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B130:D130", "EXTEND":"1"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 4, 125).getValue(), 30) + self.assertEqual(get_cell_by_position(document, 0, 4, 125).getFormula(), "=SUM(B126:D126)") + self.assertEqual(get_cell_by_position(document, 0, 4, 127).getValue(), 90) + self.assertEqual(get_cell_by_position(document, 0, 4, 127).getFormula(), "=SUM(B128:D128)") + self.assertEqual(get_cell_by_position(document, 0, 4, 129).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 4, 129).getFormula(), "=SUM(B130:D130)") + + self.ui_test.close_doc() + + def test_autosum_test9(self): + #9.Subtotal on column without selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C142:C149"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 2, 150).getValue(), 19) + self.assertEqual(get_cell_by_position(document, 0, 2, 150).getFormula(), "=SUBTOTAL(9;C142:C149)") + + self.ui_test.close_doc() + + def test_autosum_test10(self): + #10.Autosum on multiselected columns without selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B160:D164"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 1, 164).getFormula(), "=SUM(B160:B164)") + self.assertEqual(get_cell_by_position(document, 0, 2, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 2, 164).getFormula(), "=SUM(C160:C164)") + self.assertEqual(get_cell_by_position(document, 0, 3, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 3, 164).getFormula(), "=SUM(D160:D164)") + self.ui_test.close_doc() + + def test_autosum_test11(self): + #11.Autosum on columns with formula results without selected empty cell for result + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B173:D177"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(round(get_cell_by_position(document, 0, 1, 177).getValue(),2), 2.55) + self.assertEqual(get_cell_by_position(document, 0, 1, 177).getFormula(), "=SUM(B173:B177)") + self.assertEqual(round(get_cell_by_position(document, 0, 2, 177).getValue(),2), -4.91) + self.assertEqual(get_cell_by_position(document, 0, 2, 177).getFormula(), "=SUM(C173:C177)") + self.assertEqual(get_cell_by_position(document, 0, 3, 177).getValue(), 5500) + self.assertEqual(get_cell_by_position(document, 0, 3, 177).getFormula(), "=SUM(D173:D177)") + self.ui_test.close_doc() + + def test_autosum_test12(self): + #12.Autosum on column with filled cell under selected area + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B186:D190"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 1, 191).getFormula(), "=SUM(B186:B190)") + self.assertEqual(get_cell_by_position(document, 0, 2, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 2, 191).getFormula(), "=SUM(C186:C190)") + self.assertEqual(get_cell_by_position(document, 0, 3, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 3, 191).getFormula(), "=SUM(D186:D190)") + self.ui_test.close_doc() + + def test_autosum_test13(self): + #13.Autosum on column and rows with empty cells selected for row and column + calc_doc = self.ui_test.load_file(get_url_for_data_file("autosum.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B203:E208"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 1, 207).getFormula(), "=SUM(B203:B207)") + self.assertEqual(get_cell_by_position(document, 0, 2, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 2, 207).getFormula(), "=SUM(C203:C207)") + self.assertEqual(get_cell_by_position(document, 0, 3, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 3, 207).getFormula(), "=SUM(D203:D207)") + self.assertEqual(get_cell_by_position(document, 0, 4, 207).getValue(), 450) + self.assertEqual(get_cell_by_position(document, 0, 4, 207).getFormula(), "=SUM(B208:D208)") + self.assertEqual(get_cell_by_position(document, 0, 4, 202).getValue(), 30) + self.assertEqual(get_cell_by_position(document, 0, 4, 202).getFormula(), "=SUM(B203:D203)") + self.assertEqual(get_cell_by_position(document, 0, 4, 203).getValue(), 60) + self.assertEqual(get_cell_by_position(document, 0, 4, 203).getFormula(), "=SUM(B204:D204)") + self.assertEqual(get_cell_by_position(document, 0, 4, 204).getValue(), 90) + self.assertEqual(get_cell_by_position(document, 0, 4, 204).getFormula(), "=SUM(B205:D205)") + self.assertEqual(get_cell_by_position(document, 0, 4, 205).getValue(), 120) + self.assertEqual(get_cell_by_position(document, 0, 4, 205).getFormula(), "=SUM(B206:D206)") + self.assertEqual(get_cell_by_position(document, 0, 4, 206).getValue(), 150) + self.assertEqual(get_cell_by_position(document, 0, 4, 206).getFormula(), "=SUM(B207:D207)") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests/calcSheetDelete.py b/sc/qa/uitest/calc_tests/calcSheetDelete.py new file mode 100644 index 000000000..93de48292 --- /dev/null +++ b/sc/qa/uitest/calc_tests/calcSheetDelete.py @@ -0,0 +1,152 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.debug import sleep +from uitest.uihelper.calc import enter_text_to_cell +import time + +class calcSheetDelete(UITestCase): + + def test_tdf114228_insert_and_delete_sheet(self): + + self.ui_test.create_doc_in_start_center("calc") + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"})) + nrSheets = document.Sheets.getCount() #default number + + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + + self.ui_test.close_doc() + + def test_tdf43078_insert_and_delete_sheet_insert_text(self): + + self.ui_test.create_doc_in_start_center("calc") + document = self.ui_test.get_component() + + nrSheets = document.Sheets.getCount() #default number of sheets + + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "B2", "abcd") + + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + + self.ui_test.close_doc() + + def test_delete_more_sheets_at_once(self): + + self.ui_test.create_doc_in_start_center("calc") + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 6: + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + i = i + 1 + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + + i = 0 + while i < 5: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 + + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete selected sheets + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + + self.ui_test.close_doc() + + def test_tdf105105_delete_lots_of_sheets_at_once(self): + + self.ui_test.create_doc_in_start_center("calc") + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 100: + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + i = i + 1 + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + + i = 0 + while i < 99: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 + + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete selected sheets + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py new file mode 100644 index 000000000..09d699068 --- /dev/null +++ b/sc/qa/uitest/calc_tests/columns.py @@ -0,0 +1,341 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep + +class CalcColumns(UITestCase): + def test_column_width(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 2.26 cm + xvalue.executeAction("UP", tuple()) #2.36 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xCancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancel) + + self.ui_test.close_doc() + + def test_column_width_two_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"})) + + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + + def test_column_width_copy(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select column 1 + self.xUITest.executeCommand(".uno:SelectColumn") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + + def test_column_hide_show(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:HideColumn") #uno command moves focus one cell down + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify B (column C is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "1") + #Show hidden column: select B1:D1 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:D1"})) + self.xUITest.executeCommand(".uno:ShowColumn") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 (COlumn C is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + + self.ui_test.close_doc() + + def test_column_test_move(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + #right + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + + self.ui_test.close_doc() + + def test_tdf117522_column_width_insert_left(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #column width + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + #column width + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select E1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + #column width + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select columns C-E + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #Insert Columns Left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"})) + self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/data/autofill.ods b/sc/qa/uitest/calc_tests/data/autofill.ods Binary files differnew file mode 100644 index 000000000..4456e3333 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/autofill.ods diff --git a/sc/qa/uitest/calc_tests/data/autosum.ods b/sc/qa/uitest/calc_tests/data/autosum.ods Binary files differnew file mode 100644 index 000000000..05fa934b7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/autosum.ods diff --git a/sc/qa/uitest/calc_tests/data/chartArea.ods b/sc/qa/uitest/calc_tests/data/chartArea.ods Binary files differnew file mode 100644 index 000000000..c7cead1a5 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/chartArea.ods diff --git a/sc/qa/uitest/calc_tests/data/comments.ods b/sc/qa/uitest/calc_tests/data/comments.ods Binary files differnew file mode 100644 index 000000000..9f1e13e35 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/comments.ods diff --git a/sc/qa/uitest/calc_tests/data/consolidate.ods b/sc/qa/uitest/calc_tests/data/consolidate.ods Binary files differnew file mode 100644 index 000000000..8e17d7478 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/consolidate.ods diff --git a/sc/qa/uitest/calc_tests/data/dataLabels.ods b/sc/qa/uitest/calc_tests/data/dataLabels.ods Binary files differnew file mode 100644 index 000000000..89c8485fc --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/dataLabels.ods diff --git a/sc/qa/uitest/calc_tests/data/emptyFile.ods b/sc/qa/uitest/calc_tests/data/emptyFile.ods Binary files differnew file mode 100644 index 000000000..cd2454dba --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/emptyFile.ods diff --git a/sc/qa/uitest/calc_tests/data/goalSeek.ods b/sc/qa/uitest/calc_tests/data/goalSeek.ods Binary files differnew file mode 100644 index 000000000..fd78ec019 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/goalSeek.ods diff --git a/sc/qa/uitest/calc_tests/data/navigator.ods b/sc/qa/uitest/calc_tests/data/navigator.ods Binary files differnew file mode 100644 index 000000000..c487b1d6b --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/navigator.ods diff --git a/sc/qa/uitest/calc_tests/data/solver.ods b/sc/qa/uitest/calc_tests/data/solver.ods Binary files differnew file mode 100644 index 000000000..a6739664a --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/solver.ods diff --git a/sc/qa/uitest/calc_tests/data/stableSorting.ods b/sc/qa/uitest/calc_tests/data/stableSorting.ods Binary files differnew file mode 100644 index 000000000..90d0575c7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/stableSorting.ods diff --git a/sc/qa/uitest/calc_tests/data/standardFilter.ods b/sc/qa/uitest/calc_tests/data/standardFilter.ods Binary files differnew file mode 100644 index 000000000..eee728b46 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/standardFilter.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf100793.ods b/sc/qa/uitest/calc_tests/data/tdf100793.ods Binary files differnew file mode 100644 index 000000000..e68efdb92 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf100793.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf102525.ods b/sc/qa/uitest/calc_tests/data/tdf102525.ods Binary files differnew file mode 100644 index 000000000..533d2d2ba --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf102525.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf105412.ods b/sc/qa/uitest/calc_tests/data/tdf105412.ods Binary files differnew file mode 100644 index 000000000..d633ed38d --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf105412.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf105544.ods b/sc/qa/uitest/calc_tests/data/tdf105544.ods Binary files differnew file mode 100644 index 000000000..52a1a618c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf105544.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf107267.ods b/sc/qa/uitest/calc_tests/data/tdf107267.ods Binary files differnew file mode 100644 index 000000000..c0eb39fd1 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf107267.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf108654.ods b/sc/qa/uitest/calc_tests/data/tdf108654.ods Binary files differnew file mode 100644 index 000000000..e7feec567 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf108654.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf114992.ods b/sc/qa/uitest/calc_tests/data/tdf114992.ods Binary files differnew file mode 100644 index 000000000..b22a43ae2 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf114992.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf118189.xlsx b/sc/qa/uitest/calc_tests/data/tdf118189.xlsx Binary files differnew file mode 100644 index 000000000..5208b9de9 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf118189.xlsx diff --git a/sc/qa/uitest/calc_tests/data/tdf118206.xlsx b/sc/qa/uitest/calc_tests/data/tdf118206.xlsx Binary files differnew file mode 100644 index 000000000..5208b9de9 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf118206.xlsx diff --git a/sc/qa/uitest/calc_tests/data/tdf118638.ods b/sc/qa/uitest/calc_tests/data/tdf118638.ods Binary files differnew file mode 100644 index 000000000..251d6c7c4 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf118638.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf119155.xlsx b/sc/qa/uitest/calc_tests/data/tdf119155.xlsx Binary files differnew file mode 100644 index 000000000..8deb480f7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf119155.xlsx diff --git a/sc/qa/uitest/calc_tests/data/tdf119162.xls b/sc/qa/uitest/calc_tests/data/tdf119162.xls Binary files differnew file mode 100644 index 000000000..42765fbe9 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf119162.xls diff --git a/sc/qa/uitest/calc_tests/data/tdf119343.ods b/sc/qa/uitest/calc_tests/data/tdf119343.ods Binary files differnew file mode 100644 index 000000000..489d5c5fe --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf119343.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf119954.ods b/sc/qa/uitest/calc_tests/data/tdf119954.ods Binary files differnew file mode 100644 index 000000000..12a112351 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf119954.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf120161.ods b/sc/qa/uitest/calc_tests/data/tdf120161.ods Binary files differnew file mode 100644 index 000000000..4b2c6e3ce --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf120161.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf120660.ods b/sc/qa/uitest/calc_tests/data/tdf120660.ods Binary files differnew file mode 100644 index 000000000..fd9c3defd --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf120660.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf122398.ods b/sc/qa/uitest/calc_tests/data/tdf122398.ods Binary files differnew file mode 100644 index 000000000..48e24de0f --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf122398.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf122509.ods b/sc/qa/uitest/calc_tests/data/tdf122509.ods Binary files differnew file mode 100644 index 000000000..cca0c5beb --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf122509.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf123013.ods b/sc/qa/uitest/calc_tests/data/tdf123013.ods Binary files differnew file mode 100644 index 000000000..1b433b2cb --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf123013.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf123052.ods b/sc/qa/uitest/calc_tests/data/tdf123052.ods Binary files differnew file mode 100644 index 000000000..b87c73d88 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf123052.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf123479.ods b/sc/qa/uitest/calc_tests/data/tdf123479.ods Binary files differnew file mode 100644 index 000000000..90cf7efd8 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf123479.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf123508.ods b/sc/qa/uitest/calc_tests/data/tdf123508.ods Binary files differnew file mode 100644 index 000000000..a91951b08 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf123508.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf123520.ods b/sc/qa/uitest/calc_tests/data/tdf123520.ods Binary files differnew file mode 100644 index 000000000..48e24de0f --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf123520.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf124111.ods b/sc/qa/uitest/calc_tests/data/tdf124111.ods Binary files differnew file mode 100644 index 000000000..82265c4ce --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf124111.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf124818.xls b/sc/qa/uitest/calc_tests/data/tdf124818.xls Binary files differnew file mode 100644 index 000000000..2e5656978 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf124818.xls diff --git a/sc/qa/uitest/calc_tests/data/tdf124822.xls b/sc/qa/uitest/calc_tests/data/tdf124822.xls Binary files differnew file mode 100644 index 000000000..2e5656978 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf124822.xls diff --git a/sc/qa/uitest/calc_tests/data/tdf124829.ods b/sc/qa/uitest/calc_tests/data/tdf124829.ods Binary files differnew file mode 100644 index 000000000..280d349cf --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf124829.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf124896.ods b/sc/qa/uitest/calc_tests/data/tdf124896.ods Binary files differnew file mode 100644 index 000000000..2eef3473c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf124896.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf126673.ods b/sc/qa/uitest/calc_tests/data/tdf126673.ods Binary files differnew file mode 100644 index 000000000..9c75b69ca --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf126673.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf130371.ods b/sc/qa/uitest/calc_tests/data/tdf130371.ods Binary files differnew file mode 100644 index 000000000..41099bda3 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf130371.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf131170.ods b/sc/qa/uitest/calc_tests/data/tdf131170.ods Binary files differnew file mode 100644 index 000000000..09d74a4a2 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf131170.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf131291.ods b/sc/qa/uitest/calc_tests/data/tdf131291.ods Binary files differnew file mode 100644 index 000000000..76a87c2c2 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf131291.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf131907.odt b/sc/qa/uitest/calc_tests/data/tdf131907.odt Binary files differnew file mode 100644 index 000000000..2a08fa54b --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf131907.odt diff --git a/sc/qa/uitest/calc_tests/data/tdf132783.ods b/sc/qa/uitest/calc_tests/data/tdf132783.ods Binary files differnew file mode 100644 index 000000000..fd06c83e5 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf132783.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf31805.ods b/sc/qa/uitest/calc_tests/data/tdf31805.ods Binary files differnew file mode 100644 index 000000000..4660363ef --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf31805.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf37341.ods b/sc/qa/uitest/calc_tests/data/tdf37341.ods Binary files differnew file mode 100644 index 000000000..d0f5024fb --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf37341.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf37623.ods b/sc/qa/uitest/calc_tests/data/tdf37623.ods Binary files differnew file mode 100644 index 000000000..68100bbee --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf37623.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf43693.ods b/sc/qa/uitest/calc_tests/data/tdf43693.ods Binary files differnew file mode 100644 index 000000000..501a07765 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf43693.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf49531.ods b/sc/qa/uitest/calc_tests/data/tdf49531.ods Binary files differnew file mode 100644 index 000000000..26fe76d3c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf49531.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf51368.ods b/sc/qa/uitest/calc_tests/data/tdf51368.ods Binary files differnew file mode 100644 index 000000000..a899fcd6e --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf51368.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf53482.ods b/sc/qa/uitest/calc_tests/data/tdf53482.ods Binary files differnew file mode 100644 index 000000000..cfd682d6a --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf53482.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf54018.ods b/sc/qa/uitest/calc_tests/data/tdf54018.ods Binary files differnew file mode 100644 index 000000000..dab482fb4 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf54018.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf55734.ods b/sc/qa/uitest/calc_tests/data/tdf55734.ods Binary files differnew file mode 100644 index 000000000..d3ccc258f --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf55734.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf56958.ods b/sc/qa/uitest/calc_tests/data/tdf56958.ods Binary files differnew file mode 100644 index 000000000..e2c65a218 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf56958.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf57274.ods b/sc/qa/uitest/calc_tests/data/tdf57274.ods Binary files differnew file mode 100644 index 000000000..306f3c7a2 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf57274.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf62267.ods b/sc/qa/uitest/calc_tests/data/tdf62267.ods Binary files differnew file mode 100644 index 000000000..51ed9aecf --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf62267.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf62349.ods b/sc/qa/uitest/calc_tests/data/tdf62349.ods Binary files differnew file mode 100644 index 000000000..71bc5274c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf62349.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf63805.ods b/sc/qa/uitest/calc_tests/data/tdf63805.ods Binary files differnew file mode 100644 index 000000000..fd2affb4e --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf63805.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf65856.ods b/sc/qa/uitest/calc_tests/data/tdf65856.ods Binary files differnew file mode 100644 index 000000000..c3c27c710 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf65856.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf65856_2.ods b/sc/qa/uitest/calc_tests/data/tdf65856_2.ods Binary files differnew file mode 100644 index 000000000..4a0fe0ff4 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf65856_2.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf68290.ods b/sc/qa/uitest/calc_tests/data/tdf68290.ods Binary files differnew file mode 100644 index 000000000..e8047a372 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf68290.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf69981.ods b/sc/qa/uitest/calc_tests/data/tdf69981.ods Binary files differnew file mode 100644 index 000000000..4647d1a2c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf69981.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf77509.xls b/sc/qa/uitest/calc_tests/data/tdf77509.xls Binary files differnew file mode 100644 index 000000000..d8d690c8b --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf77509.xls diff --git a/sc/qa/uitest/calc_tests/data/tdf81351.ods b/sc/qa/uitest/calc_tests/data/tdf81351.ods Binary files differnew file mode 100644 index 000000000..7888ce008 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf81351.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf81696.ods b/sc/qa/uitest/calc_tests/data/tdf81696.ods Binary files differnew file mode 100644 index 000000000..593c8072c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf81696.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf85403.ods b/sc/qa/uitest/calc_tests/data/tdf85403.ods Binary files differnew file mode 100644 index 000000000..c809d2579 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf85403.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf85979.ods b/sc/qa/uitest/calc_tests/data/tdf85979.ods Binary files differnew file mode 100644 index 000000000..2b8584a20 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf85979.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf86253.ods b/sc/qa/uitest/calc_tests/data/tdf86253.ods Binary files differnew file mode 100644 index 000000000..d4042df43 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf86253.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf88735.ods b/sc/qa/uitest/calc_tests/data/tdf88735.ods Binary files differnew file mode 100644 index 000000000..59abf6050 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf88735.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf88792.ods b/sc/qa/uitest/calc_tests/data/tdf88792.ods Binary files differnew file mode 100644 index 000000000..ecd9e6040 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf88792.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf89958.ods b/sc/qa/uitest/calc_tests/data/tdf89958.ods Binary files differnew file mode 100644 index 000000000..5a48917db --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf89958.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf91217.ods b/sc/qa/uitest/calc_tests/data/tdf91217.ods Binary files differnew file mode 100644 index 000000000..c1bb9da85 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf91217.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf91425.ods b/sc/qa/uitest/calc_tests/data/tdf91425.ods Binary files differnew file mode 100644 index 000000000..5a72f162d --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf91425.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf93506.ods b/sc/qa/uitest/calc_tests/data/tdf93506.ods Binary files differnew file mode 100644 index 000000000..3995e563e --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf93506.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf95192.ods b/sc/qa/uitest/calc_tests/data/tdf95192.ods Binary files differnew file mode 100644 index 000000000..8cee74288 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf95192.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf96432.ods b/sc/qa/uitest/calc_tests/data/tdf96432.ods Binary files differnew file mode 100644 index 000000000..68aa06fb3 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf96432.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf98390.ods b/sc/qa/uitest/calc_tests/data/tdf98390.ods Binary files differnew file mode 100644 index 000000000..19baf412b --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf98390.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf98493.ods b/sc/qa/uitest/calc_tests/data/tdf98493.ods Binary files differnew file mode 100644 index 000000000..1cc0d8b11 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf98493.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf99069.ods b/sc/qa/uitest/calc_tests/data/tdf99069.ods Binary files differnew file mode 100644 index 000000000..9c4fbda4a --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf99069.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf99208.ods b/sc/qa/uitest/calc_tests/data/tdf99208.ods Binary files differnew file mode 100644 index 000000000..2767e7731 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf99208.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf99386.ods b/sc/qa/uitest/calc_tests/data/tdf99386.ods Binary files differnew file mode 100644 index 000000000..767d0ead4 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf99386.ods diff --git a/sc/qa/uitest/calc_tests/data/tdf99627.ods b/sc/qa/uitest/calc_tests/data/tdf99627.ods Binary files differnew file mode 100644 index 000000000..84c4e5134 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/tdf99627.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_comma.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_comma.ods Binary files differnew file mode 100644 index 000000000..3d5b7d583 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_comma.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_dot.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_dot.ods Binary files differnew file mode 100644 index 000000000..29136ae45 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_dot.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_pipe.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_pipe.ods Binary files differnew file mode 100644 index 000000000..16652ceed --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_pipe.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_pipe_space.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_pipe_space.ods Binary files differnew file mode 100644 index 000000000..0895d3497 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_pipe_space.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_semicolon.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_semicolon.ods Binary files differnew file mode 100644 index 000000000..53eb7c615 --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_semicolon.ods diff --git a/sc/qa/uitest/calc_tests/data/text_to_columns_space.ods b/sc/qa/uitest/calc_tests/data/text_to_columns_space.ods Binary files differnew file mode 100644 index 000000000..4ae3f176c --- /dev/null +++ b/sc/qa/uitest/calc_tests/data/text_to_columns_space.ods diff --git a/sc/qa/uitest/calc_tests/documentProperties.py b/sc/qa/uitest/calc_tests/documentProperties.py new file mode 100644 index 000000000..71030b595 --- /dev/null +++ b/sc/qa/uitest/calc_tests/documentProperties.py @@ -0,0 +1,109 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import time +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + + +class CalcDocumentProperties(UITestCase): + + def test_open_document_properties_calc(self): + self.ui_test.create_doc_in_start_center("calc") + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") + xDialog = self.xUITest.getTopFocusWindow() + xResetBtn = xDialog.getChild("reset") + xResetBtn.executeAction("CLICK", tuple()) + xTabs = xDialog.getChild("tabcontrol") + + select_pos(xTabs, "0") #first tab + xUserDataCheckbox = xDialog.getChild("userdatacb") # apply user data + xUserDataCheckbox.executeAction("CLICK", tuple()) + xThumbSaveCheckbox = xDialog.getChild("thumbnailsavecb") # save preview image with document + xThumbSaveCheckbox.executeAction("CLICK", tuple()) + +#digital signature + xDigSignBtn = xDialog.getChild("signature") + def handle_sign_dlg(dialog): + xNoBtn = dialog.getChild("no") + self.ui_test.close_dialog_through_button(xNoBtn) + self.ui_test.execute_blocking_action(xDigSignBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_sign_dlg) + + select_pos(xTabs, "1") #tab Description + + xTitleText = xDialog.getChild("title") + xTitleText.executeAction("TYPE", mkPropertyValues({"TEXT":"Title text"})) + xSubjectText = xDialog.getChild("subject") + xSubjectText.executeAction("TYPE", mkPropertyValues({"TEXT":"Subject text"})) + xKeywordsText = xDialog.getChild("keywords") + xKeywordsText.executeAction("TYPE", mkPropertyValues({"TEXT":"Keywords text"})) + xCommentsText = xDialog.getChild("comments") + xCommentsText.executeAction("TYPE", mkPropertyValues({"TEXT":"Comments text"})) + +#Font tab + select_pos(xTabs, "4") #tab Fonts + xFontEmbedCheckbox = xDialog.getChild("embedFonts") + xFontEmbedCheckbox.executeAction("CLICK", tuple()) + +#Security tab + select_pos(xTabs, "3") #tab Security + xReadOnlyCheckbox = xDialog.getChild("readonly") + xReadOnlyCheckbox.executeAction("CLICK", tuple()) + xRecordChangesCheckbox = xDialog.getChild("recordchanges") + xRecordChangesCheckbox.executeAction("CLICK", tuple()) + xProtectBtn = xDialog.getChild("protect") + def handle_protect_dlg(dialog): + xOkBtn = dialog.getChild("ok") + xPasswordText = dialog.getChild("pass1ed") + xPasswordText.executeAction("TYPE", mkPropertyValues({"TEXT":"password"})) + xConfirmText = dialog.getChild("confirm1ed") + xConfirmText.executeAction("TYPE", mkPropertyValues({"TEXT":"password"})) + self.ui_test.close_dialog_through_button(xOkBtn) + self.ui_test.execute_blocking_action(xProtectBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_protect_dlg) + + select_pos(xTabs, "2") #tab Custom properties +#add custom properties ------>>>>>>>>>>> not supported + xAddBtn = xDialog.getChild("add") + xAddBtn.executeAction("CLICK", tuple()) + + select_pos(xTabs, "5") #tab Statistics + + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) +#now open the dialog again and read the properties + self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") + xDialog = self.xUITest.getTopFocusWindow() + xTitleText = xDialog.getChild("title") + xSubjectText = xDialog.getChild("subject") + xKeywordsText = xDialog.getChild("keywords") + xCommentsText = xDialog.getChild("comments") + xReadOnlyCheckbox = xDialog.getChild("readonly") + xRecordChangesCheckbox = xDialog.getChild("recordchanges") + xFontEmbedCheckbox = xDialog.getChild("embedFonts") + xUserDataCheckbox = xDialog.getChild("userdatacb") + xThumbSaveCheckbox = xDialog.getChild("thumbnailsavecb") + self.assertEqual(get_state_as_dict(xTitleText)["Text"], "Title text") + self.assertEqual(get_state_as_dict(xSubjectText)["Text"], "Subject text") + self.assertEqual(get_state_as_dict(xKeywordsText)["Text"], "Keywords text") + self.assertEqual(get_state_as_dict(xReadOnlyCheckbox)["Selected"], "true") + self.assertEqual(get_state_as_dict(xRecordChangesCheckbox)["Selected"], "true") + self.assertEqual(get_state_as_dict(xReadOnlyCheckbox)["Selected"], "true") + self.assertEqual(get_state_as_dict(xFontEmbedCheckbox)["Selected"], "true") + self.assertEqual(get_state_as_dict(xUserDataCheckbox)["Selected"], "false") + self.assertEqual(get_state_as_dict(xThumbSaveCheckbox)["Selected"], "false") + self.assertEqual(get_state_as_dict(xCommentsText)["Text"], "Comments text") + xResetBtn = xDialog.getChild("reset") + xResetBtn.executeAction("CLICK", tuple()) + xCancBtn = xDialog.getChild("cancel") + xCancBtn.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/fillRandomNumber.py b/sc/qa/uitest/calc_tests/fillRandomNumber.py new file mode 100644 index 000000000..2f9635184 --- /dev/null +++ b/sc/qa/uitest/calc_tests/fillRandomNumber.py @@ -0,0 +1,65 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#randomnumbergenerator.ui +class fillRandomNumber(UITestCase): + def test_fill_random_number(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + props = {"TEXT": "Uniform Integer"} + actionProps = mkPropertyValues(props) + xdistributioncombo.executeAction("SELECT", actionProps) + + xparameter1spin.executeAction("UP", tuple()) + xparameter2spin.executeAction("UP", tuple()) + xenableseedcheck.executeAction("CLICK", tuple()) + xseedspin.executeAction("UP", tuple()) + xenableroundingcheck.executeAction("CLICK", tuple()) + xdecimalplacesspin.executeAction("UP", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) + #close dialog without doing anything + self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") + xDialog = self.xUITest.getTopFocusWindow() + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py new file mode 100644 index 000000000..5d350cf25 --- /dev/null +++ b/sc/qa/uitest/calc_tests/formatCells.py @@ -0,0 +1,442 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class formatCell(UITestCase): + def test_format_cell_numbers_tab(self): + #numberingformatpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + #language + props3 = {"TEXT": "English (USA)"} + actionProps3 = mkPropertyValues(props3) + xlanguagelb.executeAction("SELECT", actionProps3) + #set Number + props = {"TEXT": "Number"} + actionProps = mkPropertyValues(props) + xliststore1.executeAction("SELECT", actionProps) + #set Standard + props2 = {"TEXT": "Standard"} + actionProps2 = mkPropertyValues(props2) + xliststore2.executeAction("SELECT", actionProps2) + #other properties + xdecimalsed.executeAction("UP", tuple()) + xleadzerosed.executeAction("UP", tuple()) + xnegnumred.executeAction("CLICK", tuple()) + xthousands.executeAction("CLICK", tuple()) + #format #,#00.0;[RED]-#,#00.0 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + #save + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") + self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") + self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + self.ui_test.close_doc() + + def test_format_cell_font_tab(self): + #numberingformatpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + select_pos(xLangFont, "0") + select_pos(xLangFontEast, "0") + select_pos(xLangFontCTL, "0") + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + + #Verify - select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("westsizelb-cjk") + xSizeFontEast = xDialog.getChild("eastsizelb") + xSizeFontCTL = xDialog.getChild("ctlsizelb") + xLangFont = xDialog.getChild("westlanglb-cjk") + xLangFontEast = xDialog.getChild("eastlanglb") + xLangFontCTL = xDialog.getChild("ctllanglb") + + self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") + self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size + self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontEast)["SelectEntryText"], "[None]") + self.assertEqual(get_state_as_dict(xLangFontCTL)["SelectEntryText"], "[None]") + + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + + self.ui_test.close_doc() + + def test_format_cell_font_effects_tab(self): + #numberingformatpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Font Effects + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + select_pos(xRelief, "1") + select_pos(xOverline, "1") + select_pos(xStrikeout, "1") + select_pos(xUnderline, "1") + select_pos(xEmphasis, "1") + select_pos(xPosition, "1") + + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") + self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") + self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") + + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + + self.ui_test.close_doc() + + def test_format_cell_alignment_tab(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + props = {"TEXT": "Left"} + actionProps = mkPropertyValues(props) + comboboxHorzAlign.executeAction("SELECT", actionProps) + xspinIndentFrom.executeAction("UP", tuple()) + indentVal = get_state_as_dict(xspinIndentFrom)["Text"] + props2 = {"TEXT": "Top"} + actionProps2 = mkPropertyValues(props2) + xcomboboxVertAlign.executeAction("SELECT", actionProps2) + xcheckVertStack.executeAction("CLICK", tuple()) + xcheckWrapTextAuto.executeAction("CLICK", tuple()) + xcheckHyphActive.executeAction("CLICK", tuple()) + props3 = {"TEXT": "Left-to-right (LTR)"} + actionProps3 = mkPropertyValues(props3) + xcomboTextDirBox.executeAction("SELECT", actionProps3) + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") + self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) + self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") + self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + + def test_format_cell_asian_typography_tab(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Asian typography + xcheckForbidList = xDialog.getChild("checkForbidList") + xcheckForbidList.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + xcheckForbidList = xDialog.getChild("checkForbidList") + self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + + def test_format_cell_borders_tab(self): + #borderpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #set points pt measurement + #Make sure that tools-options-LibreOffice Calc-General-Point + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /point + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Point"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + xsync.executeAction("CLICK", tuple()) #uncheck Synchronize + xleftmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + + leftVal = get_state_as_dict(xleftmf)["Text"] + rightVal = get_state_as_dict(xrightmf)["Text"] + topVal = get_state_as_dict(xtopmf)["Text"] + bottomVal = get_state_as_dict(xbottommf)["Text"] + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") + self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) + self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) + self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) + self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_format_cell_cell_protection_tab(self): + #cellprotectionpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Cell protection + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + xcheckHideFormula.executeAction("CLICK", tuple()) + xcheckHideAll.executeAction("CLICK", tuple()) + xcheckHidePrinting.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Borders + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_tdf130762(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + xspinDegrees = xDialog.getChild("spinDegrees") + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + xspinDegrees.executeAction("DOWN", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") + xspinDegrees.executeAction("UP", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/mergedRowsColumns.py b/sc/qa/uitest/calc_tests/mergedRowsColumns.py new file mode 100644 index 000000000..1302c7b64 --- /dev/null +++ b/sc/qa/uitest/calc_tests/mergedRowsColumns.py @@ -0,0 +1,214 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +import org.libreoffice.unotest +import pathlib +import time +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import get_state_as_dict + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class mergedRowsColumns(UITestCase): + + def test_merged_row_delete_tdf105412(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A20"})) + self.xUITest.executeCommand(".uno:SelectRow") + self.xUITest.executeCommand(".uno:DeleteRows") + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Redo") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 18).getString(), "L6") + + self.ui_test.close_doc() + + def test_merged_columns_delete(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + self.xUITest.executeCommand(".uno:DeleteColumns") + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Redo") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 18).getString(), "L6") + + self.ui_test.close_doc() + + def test_undo_not_available_merged_cells_tdf37901(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B2"})) + self.xUITest.executeCommand(".uno:MergeCells") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), "Key#") + self.xUITest.executeCommand(".uno:ToggleMergeCells") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), "Key#") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:B2"})) + self.xUITest.executeCommand(".uno:MergeCells") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 1).getString(), "Key#") + self.xUITest.executeCommand(".uno:ToggleMergeCells") + self.xUITest.executeCommand(".uno:Undo") + + self.ui_test.close_doc() + + def test_calculations_in_merged_cells_tdf51368(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf51368.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + #move the content of the hidden cells into the first cell + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2 3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "0") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "3") + + #keep the contents of the hidden cells + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getString(), "3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "3") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "3") + + #Empty the contents of the hidden cells + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A11:A12"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2 3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getString(), "") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "0") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 11).getString(), "3") + + #A21-A22 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A21:A22"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 20).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 21).getString(), "3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 21).getString(), "2") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 20).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 21).getString(), "2") + + #A30-A32 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A30:A32"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 31).getString(), "thisisbad") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 30).getString(), "is") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 31).getString(), "thisisbad") + + #J12-K12 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "J12:K12"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 11).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 11).getString(), "3") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 11).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 11).getString(), "3") + + #J22-K22 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "J22:K22"})) + self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") + xDialog = self.xUITest.getTopFocusWindow() + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xDialog.getChild("ok")) + self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 21).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 21).getString(), "2") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 9, 21).getString(), "2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 11, 21).getString(), "2") + self.ui_test.close_doc() + + def test_merge_merged_cells_tdf63766(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C19:F22"})) + self.xUITest.executeCommand(".uno:ToggleMergeCells") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 18).getString(), "L6") + self.xUITest.executeCommand(".uno:Undo") + + self.ui_test.close_doc() + + def test_move_merged_cells(self): + self.ui_test.create_doc_in_start_center("calc") + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:C1"})) + self.xUITest.executeCommand(".uno:ToggleMergeCells") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:GoLeft") + self.xUITest.executeCommand(".uno:GoLeft") + self.assertEqual(get_state_as_dict(gridwin)["CurrentColumn"], "0") + self.assertEqual(get_state_as_dict(gridwin)["CurrentRow"], "0") #position A1 + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: + diff --git a/sc/qa/uitest/calc_tests/naturalSort.py b/sc/qa/uitest/calc_tests/naturalSort.py new file mode 100644 index 000000000..bd583a3c9 --- /dev/null +++ b/sc/qa/uitest/calc_tests/naturalSort.py @@ -0,0 +1,113 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Testcases Sorting TCS_Sorting + +class CalcNaturalSorting(UITestCase): + + def test_natural_sorting_rows(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #enter data + enter_text_to_cell(gridwin, "A1", "MW100SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A2", "MW180SSMOU456.996JIL4") + enter_text_to_cell(gridwin, "A3", "MW110SSMOU456.993JIL4") + enter_text_to_cell(gridwin, "A4", "MW180SSMOU456.994JIL4") + enter_text_to_cell(gridwin, "A5", "MW101SSMOU456.996JIL4") + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW101SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW180SSMOU456.996JIL4") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW100SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "MW180SSMOU456.996JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "MW110SSMOU456.993JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "MW180SSMOU456.994JIL4") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "MW101SSMOU456.996JIL4") + #enter data + enter_text_to_cell(gridwin, "D1", "MW-2") + enter_text_to_cell(gridwin, "D2", "MW-20") + enter_text_to_cell(gridwin, "D3", "MW-1") + enter_text_to_cell(gridwin, "D4", "MW-18") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:D4"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "MW-20") + + self.ui_test.close_doc() + + def test_natural_sorting_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #enter data + enter_text_to_cell(gridwin, "A1", "MW-2") + enter_text_to_cell(gridwin, "B1", "MW-20") + enter_text_to_cell(gridwin, "C1", "MW-1") + enter_text_to_cell(gridwin, "D1", "MW-18") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D1"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xleftright.executeAction("CLICK", tuple()) + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "MW-1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "MW-2") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "MW-18") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "MW-20") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/printRange.py b/sc/qa/uitest/calc_tests/printRange.py new file mode 100644 index 000000000..2a5f26410 --- /dev/null +++ b/sc/qa/uitest/calc_tests/printRange.py @@ -0,0 +1,118 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep + +class printRange(UITestCase): + def test_printRange(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #Set print range + self.xUITest.executeCommand(".uno:DefinePrintArea") + # Print Range dialog + self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") + xDialog = self.xUITest.getTopFocusWindow() + xlbprintarea = xDialog.getChild("lbprintarea") + xedprintarea = xDialog.getChild("edprintarea") + #verify range + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + #set Row + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) + #set Column + xedrepeatcol = xDialog.getChild("edrepeatcol") + xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify Print Range dialog + self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") + xDialog = self.xUITest.getTopFocusWindow() + xedprintarea = xDialog.getChild("edprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") + xCancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancel) + + #delete print ranges + self.xUITest.executeCommand(".uno:DeletePrintArea") + #Verify Print Range dialog + self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") + xDialog = self.xUITest.getTopFocusWindow() + xedprintarea = xDialog.getChild("edprintarea") + xlbprintarea = xDialog.getChild("lbprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "") + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- entire sheet -") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + self.ui_test.close_doc() + + def test_tdf33341_copy_sheet_with_print_range(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #Set print range + self.xUITest.executeCommand(".uno:DefinePrintArea") + # Print Range dialog + self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") + xDialog = self.xUITest.getTopFocusWindow() + xlbprintarea = xDialog.getChild("lbprintarea") + xedprintarea = xDialog.getChild("edprintarea") + #verify range + self.assertEqual(get_state_as_dict(xlbprintarea)["SelectEntryText"], "- selection -") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + #set Row + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatrow.executeAction("TYPE", mkPropertyValues({"TEXT":"$1"})) + #set Column + xedrepeatcol = xDialog.getChild("edrepeatcol") + xedrepeatcol.executeAction("TYPE", mkPropertyValues({"TEXT":"$A"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Copy sheet + self.ui_test.execute_dialog_through_command(".uno:Move") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #Verify Print Range dialog on new sheet + self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") + xDialog = self.xUITest.getTopFocusWindow() + xedprintarea = xDialog.getChild("edprintarea") + xedrepeatrow = xDialog.getChild("edrepeatrow") + xedrepeatcol = xDialog.getChild("edrepeatcol") + self.assertEqual(get_state_as_dict(xedprintarea)["Text"], "$A$1:$F$20") + self.assertEqual(get_state_as_dict(xedrepeatrow)["Text"], "$1") + self.assertEqual(get_state_as_dict(xedrepeatcol)["Text"], "$A") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/rows.py b/sc/qa/uitest/calc_tests/rows.py new file mode 100644 index 000000000..96cffaf5f --- /dev/null +++ b/sc/qa/uitest/calc_tests/rows.py @@ -0,0 +1,286 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class CalcRows(UITestCase): + def test_row_height(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 0.45 cm + xvalue.executeAction("UP", tuple()) #0.50 cm + heightStr = get_state_as_dict(xvalue)["Text"] + heightValNew = heightStr[:4] + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + self.assertEqual(heightValNew > heightVal, True) #new value is bigger + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual(get_state_as_dict(xvalue)["Text"] == heightStrOrig, True) #default value set + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xCancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancel) + + self.ui_test.close_doc() + + def test_row_height_two_rows(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) + + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + + def test_tdf89140_row_height_copy(self): + #Bug 89140 - Calc row paste doesn't keep row height + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select row 1 + self.xUITest.executeCommand(".uno:SelectRow") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + + def test_row_hide_show(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:HideRow") #uno command moves focus one cell down + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 (row 3 is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + #Show hidden row: select A2:A4 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A4"})) + self.xUITest.executeCommand(".uno:ShowRow") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A3 (row 3 is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + + self.ui_test.close_doc() + + def test_row_test_move(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + #down + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + + self.ui_test.close_doc() + + def test_row_height_insert_below(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #row height + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select row 3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:SelectRow") + #insert rows below + self.xUITest.executeCommand(".uno:InsertRowsAfter") + + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/sheetRename.py b/sc/qa/uitest/calc_tests/sheetRename.py new file mode 100644 index 000000000..28acb90cf --- /dev/null +++ b/sc/qa/uitest/calc_tests/sheetRename.py @@ -0,0 +1,111 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class sheetRename(UITestCase): + def test_sheet_rename(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_sheet_rename_invalid_sheet_name(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + nameVal = get_state_as_dict(xname_entry)["Text"] + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) + xOKBtn = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + #show warning + xok = dialog.getChild("ok") + self.ui_test.close_dialog_through_button(xok) + + self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + #Verify + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# def test_tdf81431_rename_sheet_clipboard_content_wiped_out(self): +# calc_doc = self.ui_test.create_doc_in_start_center("calc") +# xCalcDoc = self.xUITest.getTopFocusWindow() +# gridwin = xCalcDoc.getChild("grid_window") +# document = self.ui_test.get_component() +# #enter text and copy text to clipboard +# enter_text_to_cell(gridwin, "A1", "String") +# gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) +# self.xUITest.executeCommand(".uno:Copy") +# #rename sheet +# self.ui_test.execute_dialog_through_command(".uno:RenameTable") +# xDialog = self.xUITest.getTopFocusWindow() +# xname_entry = xDialog.getChild("name_entry") +# nameVal = get_state_as_dict(xname_entry)["Text"] +# xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) +# xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) +# xname_entry.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+V"})) + +# #fails here - text is not pasted +# self.assertEqual(get_state_as_dict(xname_entry)["Text"], "String") + +# xOKBtn = xDialog.getChild("ok") +# self.ui_test.close_dialog_through_button(xOKBtn) +# #paste text to cell +# gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) +# self.xUITest.executeCommand(".uno:Paste") +# self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "String") +# #undo +# self.xUITest.executeCommand(".uno:Undo") +# self.xUITest.executeCommand(".uno:Undo") +# #verify undo cell paste +# self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") +# #verify undo sheet rename +# self.ui_test.execute_dialog_through_command(".uno:RenameTable") +# xDialog = self.xUITest.getTopFocusWindow() +# xname_entry = xDialog.getChild("name_entry") +# self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) +# xOKBtn = xDialog.getChild("ok") +# self.ui_test.close_dialog_through_button(xOKBtn) + +# self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/sorting.py b/sc/qa/uitest/calc_tests/sorting.py new file mode 100644 index 000000000..4b56ceea7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/sorting.py @@ -0,0 +1,303 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Testcases Sorting TCS_Sorting + +class CalcSorting(UITestCase): + + def test_Sortingbuttons_detect_columnheaders(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Press toolbarbutton for descending sorting + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that cell A1 still contains "Number" and B1 "Misc" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.ui_test.close_doc() + + def test_Sortingbuttons_list_has_not_columnheaders(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: 5; 3; 4; 6; 2 / In column B enter: e; s; d; f; g + enter_text_to_cell(gridwin, "A1", "5") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "e") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that cell A1 no longer contains "5" and B1 no longer contains "e" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() != "5", True) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString() != "e", True) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT /Switch to tabpage Options + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #Verify that option "Range contains column labels" is not set + xHeader = xDialog.getChild("header") + self.assertEqual(get_state_as_dict(xHeader)["Selected"], "false") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 2) + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;s;g;f;d) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_TAB_A_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column A (Number;2;3;4;6) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Number") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 6) + + self.ui_test.close_doc() + + def test_Sorting_default_to_selected_TAB_B_column(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Press toolbar button for ascending sorting + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the sortorder was determined for column B (Misc;d;f;g;s) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "d") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "s") + + self.ui_test.close_doc() + + def test_Sorting_sort_criteria(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Number; 3; 4; 6; 2 / In column B enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Number") + enter_text_to_cell(gridwin, "A2", "3") + enter_text_to_cell(gridwin, "A3", "4") + enter_text_to_cell(gridwin, "A4", "6") + enter_text_to_cell(gridwin, "A5", "2") + enter_text_to_cell(gridwin, "B1", "Misc") + enter_text_to_cell(gridwin, "B2", "s") + enter_text_to_cell(gridwin, "B3", "d") + enter_text_to_cell(gridwin, "B4", "f") + enter_text_to_cell(gridwin, "B5", "g") + #Select cell A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #Select cell B3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column A by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Number(ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + #Select Range A1:B5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B5"})) + #Move the active cell inside the range to column B by using the TAB key + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + #Verify that the first sort criteria is set to "Misc (ascending)" + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + self.assertEqual(get_state_as_dict(xSortKey1)["SelectEntryText"], "Misc") + self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Cancel dialog + xCanc = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanc) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests/tdf120161.py b/sc/qa/uitest/calc_tests/tdf120161.py new file mode 100755 index 000000000..18c5f3ed4 --- /dev/null +++ b/sc/qa/uitest/calc_tests/tdf120161.py @@ -0,0 +1,85 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import org.libreoffice.unotest +import os +import pathlib +from tempfile import TemporaryDirectory + + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + + +# Bug 120161: PRINTING, PDF Export: Problem with selected cells which cross pages +class tdf120161(UITestCase): + def getFileContent(self, pathAndFileName): + with open(pathAndFileName, 'rb') as theFile: # b is important -> binary + # Return as binary string + data = theFile.read() + return data + + def verifyExportToFile(self, xDoc, xContext, xRange, xFontName, xFilename): + # set selection + xGridWin = xDoc.getChild("grid_window") + xGridWin.executeAction("SELECT", mkPropertyValues({"RANGE": xRange})) + + # set print area + self.xUITest.executeCommand(".uno:DefinePrintArea") + + # create temp file name + xURL = 'file:///' + xFilename + + # prepare to export into pdf + xServiceManager = xContext.ServiceManager + xDispatcher = xServiceManager.createInstanceWithContext( + 'com.sun.star.frame.DispatchHelper', xContext) + xDocFrame = self.ui_test.get_desktop().getCurrentFrame() + document = self.ui_test.get_component() + + # get selection + xSelection = document.Sheets.getByName("Sheet1").getCellRangeByName(xRange) + self.assertIsNotNone(xSelection) + + # run export into pdf + xFilterData = mkPropertyValues( + {'Selection': xSelection, 'ViewPDFAfterExport': True, 'Printing': '2'}) + xParams = mkPropertyValues( + {'URL': xURL, 'FilterName': 'calc_pdf_Export', 'FilterData': xFilterData}) + xDispatcher.executeDispatch(xDocFrame, '.uno:ExportToPDF', '', 0, xParams) + + # check resulting pdf file + xFileContent = self.getFileContent(xFilename) + position = xFileContent.find(xFontName) + return position > 0 + + # create temp directory and filename inside it + def verifyExport(self, xDoc, xContext, xRange, xFontName): + with TemporaryDirectory() as tempdir: + if os.altsep: # we need URL so replace "\" with "/" + tempdir = tempdir.replace(os.sep, os.altsep) + xFilename = tempdir + "/tdf120161-temp.pdf" + return self.verifyExportToFile(xDoc, xContext, xRange, xFontName, xFilename) + return False + + def test_tdf120161(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf120161.ods")) + xDoc = self.xUITest.getTopFocusWindow() + xContext = self.xContext + + # check different areas to be printed without any lost cell + # note: + # 1. Visually in GridView G1 is on page-1 and H1 is on page-2 + # 2. DejaVuSans is used only in H1 + self.assertFalse(self.verifyExport(xDoc, xContext, "A1:G1", b"DejaVuSans")) + self.assertTrue(self.verifyExport(xDoc, xContext, "H1:I1", b"DejaVuSans")) + self.assertTrue(self.verifyExport(xDoc, xContext, "G1:H1", b"DejaVuSans")) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/consolidate.py b/sc/qa/uitest/calc_tests2/consolidate.py new file mode 100644 index 000000000..b52e3be8f --- /dev/null +++ b/sc/qa/uitest/calc_tests2/consolidate.py @@ -0,0 +1,130 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#consolidatedialog.ui +class consolidate(UITestCase): + def test_consolidate(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("consolidate.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") + xDialog = self.xUITest.getTopFocusWindow() + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + + props = {"TEXT": "Sum"} + actionProps = mkPropertyValues(props) + xfunc.executeAction("SELECT", actionProps) + + propsA = {"TEXT": "range1"} + actionPropsA = mkPropertyValues(propsA) + xlbdataarea.executeAction("SELECT", actionPropsA) + xadd.executeAction("CLICK", tuple()) + propsB = {"TEXT": "range2"} + actionPropsB = mkPropertyValues(propsB) + xlbdataarea.executeAction("SELECT", actionPropsB) + xadd.executeAction("CLICK", tuple()) + propsC = {"TEXT": "range3"} + actionPropsC = mkPropertyValues(propsC) + xlbdataarea.executeAction("SELECT", actionPropsC) + xadd.executeAction("CLICK", tuple()) + xbyrow.executeAction("CLICK", tuple()) + xbycol.executeAction("CLICK", tuple()) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 300) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 303) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 306) + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getValue(), 309) + + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 303) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 306) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 309) + self.assertEqual(get_cell_by_position(document, 0, 2, 5).getValue(), 312) + + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 306) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 309) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 312) + self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 315) + + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 309) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 312) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 315) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 318) + #verify dialog + self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") + xDialog = self.xUITest.getTopFocusWindow() + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xdelete = xDialog.getChild("delete") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + xconsareas = xDialog.getChild("consareas") + self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") + self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") + self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") + self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") + #delete first range + xFirstEntry = xconsareas.getChild("0") + xFirstEntry.executeAction("SELECT", tuple()) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 200) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 202) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 204) + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getValue(), 206) + + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 202) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 204) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 206) + self.assertEqual(get_cell_by_position(document, 0, 2, 5).getValue(), 208) + + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 204) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 206) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 208) + self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 210) + + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 206) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 208) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 210) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 212) + + # test cancel button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/dataform.py b/sc/qa/uitest/calc_tests2/dataform.py new file mode 100644 index 000000000..0ffe0e70d --- /dev/null +++ b/sc/qa/uitest/calc_tests2/dataform.py @@ -0,0 +1,27 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import org.libreoffice.unotest + +#dataformdialog.ui +class dataform(UITestCase): + def test_dataform(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) + + self.ui_test.execute_dialog_through_command(".uno:DataForm") + xDialog = self.xUITest.getTopFocusWindow() + + xCloseBtn = xDialog.getChild("close") + self.ui_test.close_dialog_through_button(xCloseBtn) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/stableSorting.py b/sc/qa/uitest/calc_tests2/stableSorting.py new file mode 100644 index 000000000..986c7cc3d --- /dev/null +++ b/sc/qa/uitest/calc_tests2/stableSorting.py @@ -0,0 +1,104 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# + +import org.libreoffice.unotest +import pathlib +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Testcases Sorting TCS_Sorting Stable sorting +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class CalcStableSorting(UITestCase): + + def test_Must_keep_sort_order_previous_sorting_toolbar_button_Ascending(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Select cell E1 ("Sales") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Select cell D1 ("Product") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Select cell C1 ("Salesman") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:SortAscending") + # Select cell B1 ("Region") and press toolbar button for ascending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.xUITest.executeCommand(".uno:SortAscending") + #Verify that the numbers in column "CheckOrder" are ascending + for i in range(1, 501): + self.assertEqual(get_cell_by_position(document, 0, 5, i).getValue(), i) + self.ui_test.close_doc() + + def test_Must_keep_sort_order_previous_sorting_toolbar_button_Descending(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Select cell E1 ("Sales") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Select cell D1 ("Product") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Select cell C1 ("Salesman") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:SortDescending") + # Select cell B1 ("Region") and press toolbar button for descending sorting. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.xUITest.executeCommand(".uno:SortDescending") + #Verify that the numbers in column "CheckOrder" are ascending + for i in range(1, 501): + j = 501 - i + self.assertEqual(get_cell_by_position(document, 0, 5, i).getValue(), j) + self.ui_test.close_doc() + + # def test_Must_keep_sort_order_previous_sorting_using_sort_dialog(self): +# cannot test for now - criteria names are identical - Markus https://gerrit.libreoffice.org/#/c/52534/ + # calc_doc = self.ui_test.load_file(get_url_for_data_file("stableSorting.ods")) + # xCalcDoc = self.xUITest.getTopFocusWindow() + # gridwin = xCalcDoc.getChild("grid_window") + # document = self.ui_test.get_component() +# Select cell A1 and open sort dialog by DATA - SORT + # gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) +# Open sort dialog by DATA - SORT /Switch to tabpage Options + # self.ui_test.execute_dialog_through_command(".uno:DataSort") + # xDialog = self.xUITest.getTopFocusWindow() + # xTabs = xDialog.getChild("tabcontrol") + # select_pos(xTabs, "1") +# Check option "Range contains column labels" + # xHeader = xDialog.getChild("header") + # self.assertEqual(get_state_as_dict(xHeader)["Selected"], "true") +# Switch to tabpage "Sort Criteria" + # select_pos(xTabs, "0") +# Choose "Salesman(ascending)" as first criteria + # xSortKey1 = xDialog.getChild("sortlb") + # xAsc = xDialog.getChild("up") + # props = {"TEXT": "Salesman"} + # actionProps = mkPropertyValues(props) + # xSortKey1.executeAction("SELECT", actionProps) + # self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + #Choose "Product (ascending)" as second criteria + # xSortKey2 = xDialog.getChild("sortuserlb") + # xAsc = xDialog.getChild("up") + # props = {"TEXT": "Salesman"} + # actionProps = mkPropertyValues(props) + # xSortKey1.executeAction("SELECT", actionProps) + # self.assertEqual(get_state_as_dict(xAsc)["Checked"], "true") + # self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/standardFilter.py b/sc/qa/uitest/calc_tests2/standardFilter.py new file mode 100644 index 000000000..6519fe6af --- /dev/null +++ b/sc/qa/uitest/calc_tests2/standardFilter.py @@ -0,0 +1,743 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 113979 - Paste unformatted text does not ignore empty cells +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class standardFilter(UITestCase): + def test_standard_filter(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + props = {"TEXT": "a"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + propsA = {"TEXT": "OR"} + actionPropsA = mkPropertyValues(propsA) + xconnect2.executeAction("SELECT", actionPropsA) + props2 = {"TEXT": "b"} + actionProps2 = mkPropertyValues(props2) + xfield2.executeAction("SELECT", actionProps2) + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #3x down - should be on row 9 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "8") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "a") + self.assertEqual(get_state_as_dict(xfield2)["SelectEntryText"], "b") + self.assertEqual(get_state_as_dict(xconnect2)["SelectEntryText"], "OR") + self.assertEqual(get_state_as_dict(xval1)["Text"], "1") + self.assertEqual(get_state_as_dict(xval2)["Text"], "3") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.ui_test.close_doc() + + def test_standard_filter_copy_result(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + props = {"TEXT": "a"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + propsA = {"TEXT": "OR"} + actionPropsA = mkPropertyValues(propsA) + xconnect2.executeAction("SELECT", actionPropsA) + props2 = {"TEXT": "b"} + actionProps2 = mkPropertyValues(props2) + xfield2.executeAction("SELECT", actionProps2) + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "a") + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "b") + self.assertEqual(get_cell_by_position(document, 0, 7, 0).getString(), "c") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 7, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 7, 2).getValue(), 4) + self.ui_test.close_doc() + + def test_standard_filter_copy_result_next_sheet(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + props = {"TEXT": "a"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + propsA = {"TEXT": "OR"} + actionPropsA = mkPropertyValues(propsA) + xconnect2.executeAction("SELECT", actionPropsA) + props2 = {"TEXT": "b"} + actionProps2 = mkPropertyValues(props2) + xfield2.executeAction("SELECT", actionProps2) + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet2.$F$1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 1, 5, 0).getString(), "a") + self.assertEqual(get_cell_by_position(document, 1, 6, 0).getString(), "b") + self.assertEqual(get_cell_by_position(document, 1, 7, 0).getString(), "c") + self.assertEqual(get_cell_by_position(document, 1, 5, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 1, 6, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 1, 7, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 1, 5, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 1, 6, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 1, 7, 2).getValue(), 4) + self.ui_test.close_doc() + + def test_standard_filter_case_sensitive(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "a1") + enter_text_to_cell(gridwin, "A3", "A1") + enter_text_to_cell(gridwin, "A4", "A1") + enter_text_to_cell(gridwin, "B2", "4") + enter_text_to_cell(gridwin, "B3", "5") + enter_text_to_cell(gridwin, "B4", "6") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + props = {"TEXT": "first"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a1"})) + xcase.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #2x down - should be on row 5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a1") + self.assertEqual(get_state_as_dict(xcase)["Selected"], "true") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.ui_test.close_doc() + + def test_standard_filter_regular_expression(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + enter_text_to_cell(gridwin, "B5", "4") + enter_text_to_cell(gridwin, "B6", "5") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + props = {"TEXT": "first"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.ui_test.close_doc() + + def test_standard_filter_condition_contains(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + enter_text_to_cell(gridwin, "B5", "4") + enter_text_to_cell(gridwin, "B6", "5") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + props = {"TEXT": "first"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.ui_test.close_doc() + + #from testcasespecification OOo + def test_standard_filter_condition_contains2(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Contains"/Enter value "cio"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Contains"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Contains") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + self.ui_test.close_doc() + + def test_standard_filter_condition_does_not_contains(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Does not contain"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not contain") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_standard_filter_condition_Begins_with(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Begins with"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Begins with") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_standard_filter_condition_Does_not_begin_with(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Does not begin with"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not begin with") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_standard_filter_condition_Ends_with(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Ends with"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Ends with") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_standard_filter_condition_Does_not_end_with(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Does not end with"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/subtotals.py b/sc/qa/uitest/calc_tests2/subtotals.py new file mode 100644 index 000000000..31e87d9ac --- /dev/null +++ b/sc/qa/uitest/calc_tests2/subtotals.py @@ -0,0 +1,196 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict +import org.libreoffice.unotest +import pathlib +import time +from uitest.debug import sleep + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class Subtotals(UITestCase): + + def test_tdf114720(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "1") + enter_text_to_cell(gridwin, "A4", "1") + enter_text_to_cell(gridwin, "A5", "1") + enter_text_to_cell(gridwin, "A6", "1") + enter_text_to_cell(gridwin, "A7", "1") + enter_text_to_cell(gridwin, "A8", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A9"})) + + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "") + + # check cancel button + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + + def test_tdf88792(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88792.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + + # go to cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Select from the menu bar Data + # Select option subtotal + # Subtotal dialog displays + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # Select group by: Category + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Category"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # Select calculate subtotals for the months - selected by default + # Select tab options + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + # select option include formats + xformats = xDialog.getChild("formats") + xformats.executeAction("CLICK", tuple()) + # apply with OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(get_cell_by_position(document, 0, 3, 5).getValue(), 28000) + self.ui_test.close_doc() + + def test_tdf88735(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf88735.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1 select all cells + self.xUITest.executeCommand(".uno:SelectAll")#use uno command Menu Edit->Select All + # 2 invoke sub-total menu and select none + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 2 invoke sort menu and... crash + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getString(), "z") + self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 8) + self.ui_test.close_doc() + + def test_tdf56958(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf56958.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open the test file + # 2. Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 3. Group by->Trans date + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Trans Date"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 4. Tick 'Calculate subtotals for' -> Amount (grid1) + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 5. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 6. Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 7. Group by->-none- + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 8. Untick 'Calculate subtotals for' -> Amount + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xFirstEntry = xTreeList.getChild("2") + xFirstEntry.executeAction("CLICK", tuple()) + # 9. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # 10. Data->Sort + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + # 11. Sort key 1->Post Date. + sortkey1 = xDialog.getChild("sortlb") + props = {"TEXT": "Post Date"} + actionProps = mkPropertyValues(props) + sortkey1.executeAction("SELECT", actionProps) + # 12. Sort key 2->-undefined- + sortkey2 = xDialog.getChild("sortuserlb") + props = {"TEXT": "- undefined -"} + actionProps = mkPropertyValues(props) + sortkey2.executeAction("SELECT", actionProps) + # 13. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), -0.25) + self.ui_test.close_doc() + + def test_tdf55734(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf55734.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open attached document + # 2. Place cursor in cell outside of subtotals range (e.g. B7) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + # 3. Data → Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + # 4. Group by: "- none -" + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "- none -"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 5. Press "OK" and watch LibreOffice crash. + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf104117.py b/sc/qa/uitest/calc_tests2/tdf104117.py new file mode 100644 index 000000000..84ab28580 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf104117.py @@ -0,0 +1,54 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 104117 - Crash in Calc when selecting "Uniform Integer" with an max value "100000000000000" in "Random Number Generator +class tdf104117(UITestCase): + def test_tdf104117(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + props = {"TEXT": "Uniform Integer"} + actionProps = mkPropertyValues(props) + xdistributioncombo.executeAction("SELECT", actionProps) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"1000000000000000000000000000000000000000000000"})) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf105268.py b/sc/qa/uitest/calc_tests2/tdf105268.py new file mode 100644 index 000000000..f501e3511 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf105268.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 105268 - Auto Fill: The Next Value for "001-001-001" is "001-001-002" Rather than "001-001000" + +class tdf105268(UITestCase): + def test_tdf105268(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "001-001-001") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "001-001-001") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "001-001-002") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "001-001-003") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf114992.py b/sc/qa/uitest/calc_tests2/tdf114992.py new file mode 100644 index 000000000..0e4b30c2a --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf114992.py @@ -0,0 +1,32 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import pathlib +#Bug: Delete a sheet in a calc document and LO crashes +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf114992(UITestCase): + def test_tdf114992_delete_sheet_crash(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf114992.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + + self.assertEqual(document.Sheets.getCount(), 1) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), 2) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf116215.py b/sc/qa/uitest/calc_tests2/tdf116215.py new file mode 100644 index 000000000..958546077 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf116215.py @@ -0,0 +1,42 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import os +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug: Sum button: Calc adds wrong sum formulas if you select more than one row or column + +class tdf116215(UITestCase): + + def test_tdf116215_autosum_wrong_more_rows_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "B1", "1") + enter_text_to_cell(gridwin, "B2", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C3"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getFormula(), "=SUM(A1:A2)") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getFormula(), "=SUM(B1:B2)") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getFormula(), "=SUM(A1:B1)") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getFormula(), "=SUM(A2:B2)") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf116421.py b/sc/qa/uitest/calc_tests2/tdf116421.py new file mode 100644 index 000000000..c6d86f164 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf116421.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import os +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug: autosum is not working + +class tdf116421(UITestCase): + + def test_tdf116421_autosum_not_working(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getFormula(), "=SUM(A1:A3)") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf117367.py b/sc/qa/uitest/calc_tests2/tdf117367.py new file mode 100644 index 000000000..36f3e2580 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf117367.py @@ -0,0 +1,55 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep +#Bug 117367 - FORMATTING Merge cells dialog radio buttons cannot be unselected + +class tdf117367(UITestCase): + def test_tdf117367_merge_cells_radio_buttons(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + + #Right-click - Merge cells /Select all three options + self.ui_test.execute_dialog_through_command(".uno:MergeCells") + xDialog = self.xUITest.getTopFocusWindow() + xmoveCellsRadio = xDialog.getChild("move-cells-radio") + xemptyCellsRadio = xDialog.getChild("empty-cells-radio") + xkeepContentRadio = xDialog.getChild("keep-content-radio") + xmoveCellsRadio.executeAction("CLICK", tuple()) + xmoveCellsRadio.executeAction("CLICK", tuple()) + #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xemptyCellsRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xkeepContentRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") + + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf118189.py b/sc/qa/uitest/calc_tests2/tdf118189.py new file mode 100644 index 000000000..e49a471fd --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf118189.py @@ -0,0 +1,53 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 118189 - EDITING Crashes on Undo after Cut conditional formatting data + +class tdf118189(UITestCase): + def test_tdf118189(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf118189.xlsx")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1. Open attached document + #2. Copy Column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + self.xUITest.executeCommand(".uno:Copy") + #3. New Spreadsheet + calc_doc2 = self.ui_test.load_file(get_url_for_data_file("emptyFile.ods")) + gridwin2 = xCalcDoc.getChild("grid_window") + document2 = self.ui_test.get_component() + + frames = self.ui_test.get_frames() + frames[1].activate() + #4. Paste it + gridwin2.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Paste") + #5. Cut it + self.xUITest.executeCommand(".uno:Cut") + #6. Undo + self.xUITest.executeCommand(".uno:Undo") + + #-> CRASH + self.assertEqual(get_cell_by_position(document2, 0, 0, 0).getString(), "On Back Order") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf120174.py b/sc/qa/uitest/calc_tests2/tdf120174.py new file mode 100644 index 000000000..e078147a9 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf120174.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf120174(UITestCase): + def test_tdf120174(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "121") + enter_text_to_cell(gridwin, "B1", "=A1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Delete contents of A1 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + # Before the fix the result would be still 121. + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) # B1 + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf37623.py b/sc/qa/uitest/calc_tests2/tdf37623.py new file mode 100644 index 000000000..cd976269c --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf37623.py @@ -0,0 +1,40 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc.document import get_cell_by_position +from uitest.path import get_srcdir_url +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf37623(UITestCase): + + def test_tdf37623_autofill_rows_hidden(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf37623.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A6"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getValue(), 3) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf46138.py b/sc/qa/uitest/calc_tests2/tdf46138.py new file mode 100644 index 000000000..7aadac6e1 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf46138.py @@ -0,0 +1,37 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 46138 - Calc Frozen after "undo" "Filling Series Number in a Column" + +class tdf46138(UITestCase): + def test_tdf46138(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Choose a column, + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + #then "Ctrl+Z"/ undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf51700.py b/sc/qa/uitest/calc_tests2/tdf51700.py new file mode 100644 index 000000000..ed0cb934d --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf51700.py @@ -0,0 +1,55 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 51700 - Text to columns puts result into first line if whole column is selected + +class tdf51700(UITestCase): + def test_tdf51700_text_to_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Add data + enter_text_to_cell(gridwin, "A2", "3242,43242,3242,2342") + enter_text_to_cell(gridwin, "A3", "fdsfa,afsdfa,adfdas,fsad") + enter_text_to_cell(gridwin, "A4", "21312,1111,1111,111") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xcomma = xDialog.getChild("comma") + if (get_state_as_dict(xcomma)["Selected"]) == "false": + xcomma.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf53482.py b/sc/qa/uitest/calc_tests2/tdf53482.py new file mode 100644 index 000000000..33ffa71d6 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf53482.py @@ -0,0 +1,96 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 53482 - UI: Option 'Range contains column headings' ignored + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf53482(UITestCase): + + def test_tdf53482_Range_contains_column_headings_file(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf53482.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1. Highlight cells to be sorted A8:J124 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:J124"})) + #2. Click Data menu, Sort + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + xSortKey1 = xDialog.getChild("sortlb") + props = {"TEXT": "Occupation"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + #5. Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(document, 0, 6, 7).getString(), "Occupation") + self.assertEqual(get_cell_by_position(document, 0, 6, 8).getString(), "Travel Industry") + self.assertEqual(get_cell_by_position(document, 0, 6, 123).getString(), "13") + + self.ui_test.close_doc() + + def test_tdf53482_Range_contains_column_headings(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter: Misc; s; d; f; g + enter_text_to_cell(gridwin, "A1", "Misc") + enter_text_to_cell(gridwin, "A2", "s") + enter_text_to_cell(gridwin, "A3", "d") + enter_text_to_cell(gridwin, "A4", "f") + enter_text_to_cell(gridwin, "A5", "g") + #1. Highlight cells to be sorted + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + #2. Click Data menu, Sort + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + #3. On Options tab, tick 'Range contains column labels' + xHeader = xDialog.getChild("header") + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + #4. On Sort Criteria tab, set appropriate criteria + select_pos(xTabs, "0") + xDown = xDialog.getChild("down") + xDown.executeAction("CLICK", tuple()) + #5. Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #6. Expected behavior: Ignore column labels when sorting + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Misc") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "s") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "g") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "f") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "d") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests2/tdf54018.py b/sc/qa/uitest/calc_tests2/tdf54018.py new file mode 100644 index 000000000..b1d31e751 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf54018.py @@ -0,0 +1,53 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 54018 - EDITING: CRASH sorting cells range with Comments +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf54018(UITestCase): + def test_td54018_sort_with_comments(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf54018.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #click top left columns / rows heading field to select all cells + self.xUITest.executeCommand(".uno:SelectAll") + #Menu 'Data -> Sort -> Column D -> Descending' <ok> + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xdown = xDialog.getChild("down") + props = {"TEXT": "Column B"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + xdown.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Bug: When progress bar reaches 40% LibO Stops responding + #Verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "7") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "6") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "5") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "4") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "1") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/clearCells.py b/sc/qa/uitest/calc_tests3/clearCells.py new file mode 100644 index 000000000..162ac86e1 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/clearCells.py @@ -0,0 +1,311 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#deletecontents.ui +#+ Bug 101904 - Delete Contents dialog -- won't delete cell content "Date & time" +class clearCells(UITestCase): + def test_clear_cells_text(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "false": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + + self.ui_test.close_doc() + + def test_clear_cells_date_tdf101904(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "01/01/2000") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "false": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + + self.ui_test.close_doc() + + def test_clear_cells_number(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "false": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0) + + self.ui_test.close_doc() + def test_clear_cells_formulas(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "=A1+1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "false": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + + self.ui_test.close_doc() + + def test_clear_cells_formats(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "false": + xformats.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + + xstylelb = xDialog.getChild("weststylelb-cjk") + print(get_state_as_dict(xstylelb)) + + + self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") + + xOK = xDialog.getChild("ok") + xOK.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + + def test_clear_cells_all(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + + self.ui_test.close_doc() + + def test_cancel_clear_cells_all(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_dialog_through_command(".uno:Delete") + xDialog = self.xUITest.getTopFocusWindow() + xdeleteall = xDialog.getChild("deleteall") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "1") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py new file mode 100644 index 000000000..831fe40ee --- /dev/null +++ b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py @@ -0,0 +1,81 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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, type_text +from com.sun.star.lang import IndexOutOfBoundsException + +class insertQrCode(UITestCase): + + def test_insert_qr_code_gen(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + # cancel the dialog without doing anything + self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") + xDialog = self.xUITest.getTopFocusWindow() + + xURL = xDialog.getChild("edit_text") + type_text(xURL, "www.libreoffice.org") + + xCloseBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCloseBtn) + with self.assertRaises(IndexOutOfBoundsException): + document.Sheets.getByIndex(0).DrawPage.getByIndex(0) + + # Reopen the dialog box + self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") + xDialog = self.xUITest.getTopFocusWindow() + + # Get elements in the Dialog Box + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. + xBorder = xDialog.getChild("edit_border") + + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) + xOKBtn = xDialog.getChild("ok") + xOKBtn.executeAction("CLICK", tuple()) + + # check the QR code in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) + + self.ui_test.close_doc() + + def test_insert_qr_code_gen2(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") + xDialog = self.xUITest.getTopFocusWindow() + + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") + xBorder = xDialog.getChild("edit_border") + + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) + xOKBtn = xDialog.getChild("ok") + xOKBtn.executeAction("CLICK", tuple()) + + #check the QR Code in the document + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Payload, "www.libreoffice.org") + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.ErrorCorrection, 1) + self.assertEqual(document.Sheets.getByIndex(0).DrawPage.getByIndex(0).QRCodeProperties.Border, 1) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf57274.py b/sc/qa/uitest/calc_tests3/tdf57274.py new file mode 100644 index 000000000..a3c77109c --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf57274.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import os +import pathlib +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug: Paste Special Link Checkbox fails to insert cell references when the source cell is blank +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf57274(UITestCase): + + def test_tdf57274_tdf116385_row_only(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf57274.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #* Source Cells, range B6..E6 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B6:E6"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B11"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + #We paste here using Paste Special with 'Link' Checkbox activated + xLink = xDialog.getChild("link") + xLink.executeAction("CLICK", tuple()) + xOkBtn = xDialog.getChild("ok") + # self.ui_test.close_dialog_through_button(xOkBtn) + def handle_confirm_dlg(dialog): + xOKBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.execute_blocking_action(xOkBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_confirm_dlg) + #we would expect a reference to cell E6 here and a zero being displayed, but the cell is also simply blank. + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getFormula(), "=$Sheet1.$E$6") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf62267.py b/sc/qa/uitest/calc_tests3/tdf62267.py new file mode 100644 index 000000000..3d1f0e0c8 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf62267.py @@ -0,0 +1,60 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import os +import pathlib +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 62267 - Conditional formatting lost after paste special of text, numbers and dates. +#If you have a cell with conditional formatting and you use paste special only inserting only text, +#numbers and dates the formatting is lost. Undo do not recover the conditional formatting. + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf62267(UITestCase): + + def test_tdf62267(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf62267.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #* Copy A1, then paste special to C1; + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + #it's the default - text, numbers and dates + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #--> Cell formatting should stay as before + self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + + xCondFormatMgr = self.xUITest.getTopFocusWindow() + + # check that we have exactly 1 conditional format + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') + + xTreeEntry = xList.getChild('0') + self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1\tCell value = 1") + + xCancelBtn = xCondFormatMgr.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf63805.py b/sc/qa/uitest/calc_tests3/tdf63805.py new file mode 100644 index 000000000..bdc7f8775 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf63805.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 63805 - EDITING: 'Autofill - Date - Months' wrong if day of month exceeds max. days of month + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf63805(UITestCase): + + def test_tdf63805_autofill_Date_Months(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf63805.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #1 - A1: 2012-10-31 + enter_text_to_cell(gridwin, "A1", "2012-10-31") + #2 - Select A1:A20 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A20"})) + #3 - Edit -> fill -> Series -> Down - Date-Month-Increment=1 <ok> + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #5 -Expected: All Cells show last day of month / Actual: some months skipped + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 41213) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 41243) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 41274) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 41305) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 41333) + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getValue(), 41364) + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 41394) + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 41425) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getValue(), 41455) + self.assertEqual(get_cell_by_position(document, 0, 0, 9).getValue(), 41486) + self.assertEqual(get_cell_by_position(document, 0, 0, 10).getValue(), 41517) + self.assertEqual(get_cell_by_position(document, 0, 0, 11).getValue(), 41547) + self.assertEqual(get_cell_by_position(document, 0, 0, 12).getValue(), 41578) + self.assertEqual(get_cell_by_position(document, 0, 0, 13).getValue(), 41608) + self.assertEqual(get_cell_by_position(document, 0, 0, 14).getValue(), 41639) + self.assertEqual(get_cell_by_position(document, 0, 0, 15).getValue(), 41670) + self.assertEqual(get_cell_by_position(document, 0, 0, 16).getValue(), 41698) + self.assertEqual(get_cell_by_position(document, 0, 0, 17).getValue(), 41729) + self.assertEqual(get_cell_by_position(document, 0, 0, 18).getValue(), 41759) + self.assertEqual(get_cell_by_position(document, 0, 0, 19).getValue(), 41790) + #4 - undo. + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 41213) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 0) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf64001.py b/sc/qa/uitest/calc_tests3/tdf64001.py new file mode 100644 index 000000000..4c19f32c9 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf64001.py @@ -0,0 +1,40 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf64001(UITestCase): + + def test_tdf64001(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1) Type TRUE in cell A1 + enter_text_to_cell(gridwin, "A1", "TRUE") + #2) Autofill/drag A1 to A10, all cells show TRUE + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #3) Type FALSE in A11 + enter_text_to_cell(gridwin, "A11", "FALSE") + #4) Enter in B1: =COUNTIF(A1:A11,TRUE) , hit enter + enter_text_to_cell(gridwin, "B1", "=COUNTIF(A1:A11,TRUE)") + #The formula changes to =COUNTIF(A1:A11,1) and displays result of 1 not 10. + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 10) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf65856.py b/sc/qa/uitest/calc_tests3/tdf65856.py new file mode 100644 index 000000000..c3e03ec7a --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf65856.py @@ -0,0 +1,105 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import os +import pathlib +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf65856(UITestCase): + + def test_tdf65856_paste_special_shift_right(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf65856.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #- mark D1:E14; copy + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D1:E14"})) + self.xUITest.executeCommand(".uno:Copy") + #mark cell D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + + xmove_right = xDialog.getChild("move_right") + xmove_right.executeAction("CLICK", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #check + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "T1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "TE1") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "TES1") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "TEST1") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getString(), "TEST1") + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getString(), "TEST1") + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "TEST1") + self.assertEqual(get_cell_by_position(document, 0, 0, 13).getString(), "T14") + self.assertEqual(get_cell_by_position(document, 0, 1, 13).getString(), "TE14") + self.assertEqual(get_cell_by_position(document, 0, 2, 13).getString(), "TES14") + self.assertEqual(get_cell_by_position(document, 0, 3, 13).getString(), "TEST14") + self.assertEqual(get_cell_by_position(document, 0, 4, 13).getString(), "TEST14") + self.assertEqual(get_cell_by_position(document, 0, 5, 13).getString(), "TEST14") + self.assertEqual(get_cell_by_position(document, 0, 6, 13).getString(), "TEST14") + self.ui_test.close_doc() + + def test_tdf65856_paste_special_shift_right_2(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf65856_2.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #- select range C2:D4; copy + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C2:D4"})) + self.xUITest.executeCommand(".uno:Copy") + #mark cell B2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + + xmove_right = xDialog.getChild("move_right") + xmove_right.executeAction("CLICK", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #check + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getString(), "2") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getString(), "3") + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getFormula(), "=D2") + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getFormula(), "=D2") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getFormula(), "=E3") + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getFormula(), "=E3") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getFormula(), "=F4") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getFormula(), "=F4") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: + diff --git a/sc/qa/uitest/calc_tests3/tdf68290.py b/sc/qa/uitest/calc_tests3/tdf68290.py new file mode 100644 index 000000000..b186efa88 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf68290.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.path import get_srcdir_url +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Enhancement: EDITING: cursor moves with Enter key +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name + +class tdf68290(UITestCase): + + def test_tdf68290_cursor_moves_with_Enter_key(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf68290.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + self.assertEqual(gridWinState["CurrentColumn"], "12") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf69450.py b/sc/qa/uitest/calc_tests3/tdf69450.py new file mode 100644 index 000000000..ad375fecf --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf69450.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc.document import get_sheet_from_doc +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position + +class tdf69450(UITestCase): + + def test_tdf69450(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #add text to A1 and B1 + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + + xtext = xDialog.getChild("text") + xnumbers = xDialog.getChild("numbers") + xdatetime = xDialog.getChild("datetime") + xformats = xDialog.getChild("formats") + + xtext.executeAction("CLICK", tuple()) + xnumbers.executeAction("CLICK", tuple()) + xdatetime.executeAction("CLICK", tuple()) + xformats.executeAction("CLICK", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #check B1 text + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + self.xUITest.executeCommand(".uno:Bold") + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() #previous settings should be remembered (only format) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #check B1 text + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "B") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: + diff --git a/sc/qa/uitest/calc_tests3/tdf69981.py b/sc/qa/uitest/calc_tests3/tdf69981.py new file mode 100644 index 000000000..34a4852b8 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf69981.py @@ -0,0 +1,93 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf69981(UITestCase): + + def test_tdf69981_text_to_columns(self): + + # FIXME flaky test, passed once, but broke multiple times. + return + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf69981.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Select A2:A7 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A7"})) + #Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xtab.executeAction("CLICK", tuple()) + xcomma.executeAction("CLICK", tuple()) + #Click Ok + #overwrite warning come up + #press Ok. + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Original") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "a") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "a") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "a") + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "a") + + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Copy") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "b") + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "b") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "b") + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getString(), "") + + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getString(), "c") + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "c") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getString(), "c") + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 2, 5).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 2, 6).getString(), "c") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf71339.py b/sc/qa/uitest/calc_tests3/tdf71339.py new file mode 100644 index 000000000..0935d3168 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf71339.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import os +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug: EDITING sigma icon (sum function) operating on selected range + +class tdf71339(UITestCase): + + def test_tdf71339_autosum_on_selected_range(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A2", "1") + enter_text_to_cell(gridwin, "A3", "1") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getFormula(), "=SUM(A1:A3)") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf73006.py b/sc/qa/uitest/calc_tests3/tdf73006.py new file mode 100644 index 000000000..8124bb420 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf73006.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 73006 - EDITING: Results filled in wrong cells after Text to Columns + +class tdf73006(UITestCase): + def test_tdf73006_text_to_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Add data + enter_text_to_cell(gridwin, "A2", "A B") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xspace = xDialog.getChild("space") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "B") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf77509.py b/sc/qa/uitest/calc_tests3/tdf77509.py new file mode 100644 index 000000000..216a6f763 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf77509.py @@ -0,0 +1,65 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#consolidatedialog.ui +class tdf77509(UITestCase): + def test_tdf77509_consolidate(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf77509.xls")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1. Open attachment: Consolidate-test.xls + #2. Select any empty cell, eg. cell D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + #3. Tab: Data > Consolidate + self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") + xDialog = self.xUITest.getTopFocusWindow() + xfunc = xDialog.getChild("func") + xeddataarea = xDialog.getChild("eddataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + + props = {"TEXT": "Sum"} + actionProps = mkPropertyValues(props) + xfunc.executeAction("SELECT", actionProps) + #4. Source data ranges: $Sheet1.$A$1:$B$7 + #5. Click 'Add' so that ranges appear in "Consolidation ranges" + xeddataarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$7"})) + xadd.executeAction("CLICK", tuple()) + #6. Click 'Options' > check 'Row labels' > click OK + xbyrow.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "A 1") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getString(), "AB 1") + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "AB 12") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getString(), "AB 123") + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getString(), "ABC 1") + + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 1) + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf79983.py b/sc/qa/uitest/calc_tests3/tdf79983.py new file mode 100644 index 000000000..f4afc77ea --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf79983.py @@ -0,0 +1,71 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep +#Bug 79983 - Calc sort lists aren't case sensitive + +class tdf79983(UITestCase): + def test_tdf79983_sort_list_case_sensitive(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + enter_text_to_cell(gridwin, "A3", "CCC") + enter_text_to_cell(gridwin, "A4", "DDD") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + #Tools / Options / LibreOffice Calc / Sort Lists + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcSortEntry = xCalcEntry.getChild('5') + xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List + #copy new list from selected cells + xcopy = xDialogOpt.getChild("copy") + xcopy.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + + enter_text_to_cell(gridwin, "A1", "AAA") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #fill down + self.ui_test.execute_dialog_through_command(".uno:FillSeries") + xDialog = self.xUITest.getTopFocusWindow() + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "CCC") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "DDD") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf80693.py b/sc/qa/uitest/calc_tests3/tdf80693.py new file mode 100644 index 000000000..f416fce81 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf80693.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 80693 - EDITING: fill cell with random numbers with min = max +class tdf80693(UITestCase): + def test_tdf80693_random_numbers_min_max(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") + xDialog = self.xUITest.getTopFocusWindow() + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + props = {"TEXT": "Uniform"} + actionProps = mkPropertyValues(props) + xdistributioncombo.executeAction("SELECT", actionProps) + + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 2) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests3/tdf81351.py b/sc/qa/uitest/calc_tests3/tdf81351.py new file mode 100644 index 000000000..520f1c3c6 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf81351.py @@ -0,0 +1,82 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from libreoffice.calc.document import get_cell_by_position +import org.libreoffice.unotest +import pathlib +import time + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf81351(UITestCase): + + def test_tdf81351(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf81351.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = xTopWindow.getChild("grid_window") + + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Paste") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"})) + + self.xUITest.executeCommand(".uno:SortAscending") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Bold") + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Paste") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + + def test_tdf81351_comment4(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf81351.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + + gridwin = xTopWindow.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"})) + + + self.xUITest.executeCommand(".uno:SortAscending") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Bold") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Paste") + + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Bold") + + def test_sort_descending(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf81351.ods")) + xTopWindow = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + + gridwin = xTopWindow.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F5"})) + + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Undo") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B7"})) + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Paste") + + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), ".uno:Undo") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf82398.py b/sc/qa/uitest/calc_tests3/tdf82398.py new file mode 100644 index 000000000..66e8d5784 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf82398.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 82398 - EDITING: "Text to Columns" not applied to selected cells after change 'Format Cells' + +class tdf82398(UITestCase): + def test_tdf82398_text_to_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Add data + enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") + enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") + enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") + enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") + #select column A1:A4 / .uno:NumberFormatDate + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + self.xUITest.executeCommand(".uno:NumberFormatDate") + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf118207.py b/sc/qa/uitest/calc_tests4/tdf118207.py new file mode 100644 index 000000000..1f07672fa --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf118207.py @@ -0,0 +1,60 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 118207 - CRASH: Cutting and pasting a conditional format column and undoing + +class tdf118207(UITestCase): + def test_tdf118207(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf118189.xlsx")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-LibreOffice Calc-General-Input settings-Show overwrite warning when pasting data is NOT tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcGeneralEntry = xCalcEntry.getChild('0') + xCalcGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "true": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #Select Column A + #Cut it + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + self.xUITest.executeCommand(".uno:Cut") + #Paste it in Column B , Paste it in Column B again + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + self.xUITest.executeCommand(".uno:Paste") + self.xUITest.executeCommand(".uno:Paste") + #Undo 3 times + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + #-> CRASH + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "On Back Order") + #verify + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf131170.py b/sc/qa/uitest/calc_tests4/tdf131170.py new file mode 100644 index 000000000..726796936 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf131170.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.path import get_srcdir_url + +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name + +class tdf131170(UITestCase): + def test_DefineLabelRange(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf131170.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + self.ui_test.execute_dialog_through_command(".uno:DefineLabelRange") + xDialog = self.xUITest.getTopFocusWindow() + + xRange = xDialog.getChild("range") + self.assertEqual(4, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "$Sheet1.$I$6:$K$6 [AA, BB, CC]") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('3'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + def handle_confirmation_dlg(dialog2): + xOKBtn2 = dialog2.getChild("yes") + self.ui_test.close_dialog_through_button(xOKBtn2) + + xDeleteBtn = xDialog.getChild("delete") + + xRange.getChild('1').executeAction("SELECT", tuple()) + self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_confirmation_dlg) + + self.assertEqual(3, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + xRange.getChild('2').executeAction("SELECT", tuple()) + self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_confirmation_dlg) + + self.assertEqual(2, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf85403.py b/sc/qa/uitest/calc_tests4/tdf85403.py new file mode 100644 index 000000000..e82835fc3 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf85403.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +from uitest.path import get_srcdir_url +#Bug 85403 - no broadcast after text to columns to convert text to numbers +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf85403(UITestCase): + def test_tdf85403_text_to_columns(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf85403.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #'123 in A1, SUM(A1) in B1, result is 0 as expected, + #now select A1 and use data->text to columns->ok and B1 is not updated, + #putting a new SUM(A1) in C1 will show 123 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 123) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf85979.py b/sc/qa/uitest/calc_tests4/tdf85979.py new file mode 100644 index 000000000..359a0f35c --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf85979.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 85979 - Crash: data text to columns +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf85979(UITestCase): + def test_td85979_text_to_columns(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf85979.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #(I selected C1 to C5, then Text to Columns, unselected "Tab" and selected "Space") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xspace = xDialog.getChild("space") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 99) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 9) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 9) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 260) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 10) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 23) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 23) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 149) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 14) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 14) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 16) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 35) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 35) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf86253.py b/sc/qa/uitest/calc_tests4/tdf86253.py new file mode 100644 index 000000000..9e801f851 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf86253.py @@ -0,0 +1,67 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +import os +import pathlib +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf86253(UITestCase): + + def test_tdf86253(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf86253.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #* Copy A1, then paste special only "formatting" to C1:C17; + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C17"})) + self.ui_test.execute_dialog_through_command(".uno:PasteSpecial") + xDialog = self.xUITest.getTopFocusWindow() + + xtext = xDialog.getChild("text") + xnumbers = xDialog.getChild("numbers") + xdatetime = xDialog.getChild("datetime") + xformats = xDialog.getChild("formats") + + xtext.executeAction("CLICK", tuple()) + xnumbers.executeAction("CLICK", tuple()) + xdatetime.executeAction("CLICK", tuple()) + xformats.executeAction("CLICK", tuple()) + + xOkBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOkBtn) + + #--> Cell formatting for C1:C17 is changed. But, if you go to "Format - Conditional Formatting - Manage", + #you will see that a new formatting condition is created with the range "C1:C6", rather than "C1:C17". This is wrong behavior. + self.ui_test.execute_dialog_through_command(".uno:ConditionalFormatManagerDialog") + + xCondFormatMgr = self.xUITest.getTopFocusWindow() + + # check that we have exactly 1 conditional format and range is C1:C17 + xList = xCondFormatMgr.getChild("CONTAINER") + list_state = get_state_as_dict(xList) + self.assertEqual(list_state['Children'], '1') + + xTreeEntry = xList.getChild('0') + self.assertEqual(get_state_as_dict(xTreeEntry)["Text"], "A1:A6,C1:C17\tCell value >= 0") + + xCancelBtn = xCondFormatMgr.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf88999.py b/sc/qa/uitest/calc_tests4/tdf88999.py new file mode 100644 index 000000000..ddbfaa427 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf88999.py @@ -0,0 +1,53 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 88999 - UI: Scientific format: unable to modify number of decimal places through Sidebar or Format > Cells + +class tdf88999(UITestCase): + def test_tdf88999_scientific_format_decimal_value(self): + #numberingformatpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "1e-2") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") + self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf89907.py b/sc/qa/uitest/calc_tests4/tdf89907.py new file mode 100644 index 000000000..13a960145 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf89907.py @@ -0,0 +1,64 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 89907 - Text to columns only affects first line when width is auto set + +class tdf89907(UITestCase): + def test_tdf89907_text_to_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Add data + enter_text_to_cell(gridwin, "A1", "afasdfs.fdfasd.fsadf.fasd") + enter_text_to_cell(gridwin, "A2", "3242.43242.3242.2342") + enter_text_to_cell(gridwin, "A3", "fdsfa.afsdfa.adfdas.fsad") + enter_text_to_cell(gridwin, "A4", "21312.1111.1111.111") + #select column A + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #Optimal Width + self.xUITest.executeCommand(".uno:SetOptimalColumnWidthDirect") + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "afasdfs") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "fdsfa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 21312) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "fdfasd") + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 43242) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getString(), "afsdfa") + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "fsadf") + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3242) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getString(), "adfdas") + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 1111) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "fasd") + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 2342) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getString(), "fsad") + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 111) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf89958.py b/sc/qa/uitest/calc_tests4/tdf89958.py new file mode 100644 index 000000000..d08148fbd --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf89958.py @@ -0,0 +1,71 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 89958 - Data->Filter->Standard Filter, condition "does not end with" does filter too much +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf89958(UITestCase): + def test_td89958_standard_filter(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf89958.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A1-> Column .uno:SelectColumn + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + + #Menu: Data->Filter->Standard Filter ... + #Field Name "Column A", Condition "Does not end with", Value: "CTORS" + self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + xDialog = self.xUITest.getTopFocusWindow() + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + props = {"TEXT": "Column A"} + actionProps = mkPropertyValues(props) + xfield1.executeAction("SELECT", actionProps) + props2 = {"TEXT": "Does not end with"} + actionProps2 = mkPropertyValues(props2) + xcond1.executeAction("SELECT", actionProps2) + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Expected behaviours: A2 is not filtered as it does not end with "CTORS". + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") +# #reopen filter and verify - doesn't works +# gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) +# self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") +# xDialog = self.xUITest.getTopFocusWindow() +# xfield1 = xDialog.getChild("field1") +# xval1 = xDialog.getChild("val1") +# xcond1 = xDialog.getChild("cond1") +# self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "Column A") +# self.assertEqual(get_state_as_dict(xval1)["Text"], "CTORS") +# self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") +# xCancelBtn = xDialog.getChild("cancel") +# self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf91305.py b/sc/qa/uitest/calc_tests4/tdf91305.py new file mode 100644 index 000000000..eae7e8c45 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf91305.py @@ -0,0 +1,140 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 91305 - Sort button does not sort first cell if it has text format + +class tdf91305(UITestCase): + + def test_tdf91305_sort_text_cells_rows(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "ff") + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") + + def test_tdf91305_sort_text_cells_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "cc") + enter_text_to_cell(gridwin, "B1", "ff") + enter_text_to_cell(gridwin, "C1", "aa") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C1"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "ff") + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + xleftright = xDialog.getChild("leftright") + xdown = xDialog.getChild("down") + select_pos(xTabs, "1") + xleftright.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "aa") + self.ui_test.close_doc() + + #comment 6 - Additional sub-bugs: + def test_tdf91305_sort_text_cells_rows(self): + #Selecting some empty cells and pressing SORT causes empty cells to move below. + #No matter if you sort from A to Z or from Z to A. + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter text + enter_text_to_cell(gridwin, "A5", "ff") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #sorting + self.xUITest.executeCommand(".uno:SortAscending") + self.xUITest.executeCommand(".uno:SortDescending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "ff") + # Assert that the correct range has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") + + self.ui_test.close_doc() + + #2) Placing digit to the header position and running set of sorts will make digit to be on 2nd or last position. + def test_tdf91305_sort_text_cells_1st_row_digit(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #In column A enter texts + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "ff") + enter_text_to_cell(gridwin, "A3", "aa") + enter_text_to_cell(gridwin, "A4", "cc") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #Press toolbarbutton for ascending sorting .uno:SortAsc + self.xUITest.executeCommand(".uno:SortAscending") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + #Press toolbarbutton for descending sorting .uno:SortDescending + self.xUITest.executeCommand(".uno:SortDescending") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "ff") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "1") + #Undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "cc") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "ff") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf92423.py b/sc/qa/uitest/calc_tests4/tdf92423.py new file mode 100644 index 000000000..52920ae17 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf92423.py @@ -0,0 +1,75 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.debug import sleep +#Bug 92423 - EDITING Text to columns... does not respect currently selected cells + +class tdf92423(UITestCase): + def test_tdf92423_text_to_columns(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #enter data + enter_text_to_cell(gridwin, "A1", "1;2") + enter_text_to_cell(gridwin, "A2", "2;3") + enter_text_to_cell(gridwin, "A3", "3;4") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + #copy data + self.xUITest.executeCommand(".uno:Copy") + #move down + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + self.xUITest.executeCommand(".uno:GoDown") + #paste data, should be selected + self.xUITest.executeCommand(".uno:Paste") #A7:A9 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A7:Sheet1.A9") + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + xSemicolon = xDialog.getChild("semicolon") #check semicolon checkbox + if (get_state_as_dict(xSemicolon)["Selected"]) == "false": + xSemicolon.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 7).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 8).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 1, 6).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 7).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 1, 8).getValue(), 4) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf94208.py b/sc/qa/uitest/calc_tests4/tdf94208.py new file mode 100644 index 000000000..346b60c61 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf94208.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 94208 - Undo after Control-D Fill doesn't broadcast deleted (undo-inserted) cells for calculation + +class tdf94208(UITestCase): + + def test_tdf94208_Undo_fill_down_rows_selected(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #1 - Fill data + enter_text_to_cell(gridwin, "A3", "Range") + enter_text_to_cell(gridwin, "A4", "Range") + enter_text_to_cell(gridwin, "A5", "Range") + enter_text_to_cell(gridwin, "A6", "Range") + enter_text_to_cell(gridwin, "A7", "Range") + enter_text_to_cell(gridwin, "A8", "Range") + enter_text_to_cell(gridwin, "B6", "test") + #2 - Select rows three though eight. + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:A8"})) + self.xUITest.executeCommand(".uno:SelectRow") + #3 - type Control-D/Fill Down + self.xUITest.executeCommand(".uno:FillDown") + #4 - undo. + self.xUITest.executeCommand(".uno:Undo") + #5 - Ouch! The data isn't right. + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 0, 6).getString(), "Range") + self.assertEqual(get_cell_by_position(document, 0, 1, 5).getString(), "test") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf95192.py b/sc/qa/uitest/calc_tests4/tdf95192.py new file mode 100644 index 000000000..5e1292d9d --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf95192.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 95192 - SORTING Natural sorting not working with non-letter,non-number content + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf95192(UITestCase): + def test_td99627_natural_sort(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf95192.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Capra 1/17") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Sal. Capra 1/20") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Sal. Oregina 1/2") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "Via A. Centurione 11/7") + self.assertEqual(get_cell_by_position(document, 0, 0, 41).getString(), "Vico Chiuso Cinque Santi 18/10") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99208.py b/sc/qa/uitest/calc_tests4/tdf99208.py new file mode 100644 index 000000000..94fed01c3 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf99208.py @@ -0,0 +1,68 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 99208 - Spreadsheet sort hangs +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf99208(UITestCase): + def test_td99627_natural_sort(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99208.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A3:C245 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C245"})) + + #Menu 'Data -> Sort + #Column A - Ascending' <ok> + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xtopdown = xDialog.getChild("topdown") + xHeader = xDialog.getChild("header") + xFormats = xDialog.getChild("formats") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + if (get_state_as_dict(xHeader)["Selected"]) == "false": + xHeader.executeAction("CLICK", tuple()) + if (get_state_as_dict(xFormats)["Selected"]) == "false": + xFormats.executeAction("CLICK", tuple()) + xtopdown.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xSortKey1 = xDialog.getChild("sortlb") + xAsc = xDialog.getChild("up") + props = {"TEXT": "FODMAP"} + actionProps = mkPropertyValues(props) + xSortKey1.executeAction("SELECT", actionProps) + xAsc.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify Expected: Values column B sorted ascending, column "control" unsorted + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "agave") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "almond milk") + self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "zucchini") + # UNDO + self.xUITest.executeCommand(".uno:Undo") + # Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "FODMAP") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "beef (grass fed, no breadcrumbs)") + self.assertEqual(get_cell_by_position(document, 0, 0, 244).getString(), "salsa") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99386.py b/sc/qa/uitest/calc_tests4/tdf99386.py new file mode 100644 index 000000000..ff9286b61 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf99386.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.debug import sleep +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +import org.libreoffice.unotest +import pathlib +import time + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf99386(UITestCase): + + def test_td99386_undo_merged_cell_needs_hard_recalculate(self): + + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99386.ods")) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B1"})) #select cells + self.xUITest.executeCommand(".uno:ToggleMergeCells") # merge cells + self.xUITest.executeCommand(".uno:Undo") + + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getString(), "This") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf99627.py b/sc/qa/uitest/calc_tests4/tdf99627.py new file mode 100644 index 000000000..4f95a9e96 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf99627.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#Bug 99627 - Calc freezes when applying natural sorting on text columns + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf99627(UITestCase): + def test_td99627_natural_sort(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf99627.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + xdown = xDialog.getChild("down") + xNatural.executeAction("CLICK", tuple()) + select_pos(xTabs, "0") + xdown.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2998") + self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "1") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 2998).getString(), "2998") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/tdf99773.py b/sc/qa/uitest/calc_tests4/tdf99773.py new file mode 100644 index 000000000..099788fa1 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf99773.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 99773 - EDITING: calc freezes if sorting in natural mode + +class tdf99773(UITestCase): + def test_tdf99773_natural_sorting_space(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #enter data + enter_text_to_cell(gridwin, "A1", "A 11") + enter_text_to_cell(gridwin, "A2", "A 2") + enter_text_to_cell(gridwin, "A3", "B 2") + enter_text_to_cell(gridwin, "A4", "A 5") + enter_text_to_cell(gridwin, "A5", "A 50") + enter_text_to_cell(gridwin, "A6", "B 20") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A6"})) + #Open sort dialog by DATA - SORT + self.ui_test.execute_dialog_through_command(".uno:DataSort") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + xNatural = xDialog.getChild("naturalsort") + if (get_state_as_dict(xNatural)["Selected"]) == "false": + xNatural.executeAction("CLICK", tuple()) + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "A 5") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "A 11") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "A 50") + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getString(), "B 2") + self.assertEqual(get_cell_by_position(document, 0, 0, 5).getString(), "B 20") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/textToColumns.py b/sc/qa/uitest/calc_tests4/textToColumns.py new file mode 100644 index 000000000..6e2aad2c2 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/textToColumns.py @@ -0,0 +1,526 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +#text to column testcase + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + + +class CalcTextToColumns(UITestCase): + + def test_text_to_columns_dot(self): + #_Dot_as_Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_dot.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + print(get_state_as_dict(xreplwarncb)["Selected"]) + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + print(get_state_as_dict(xreplwarncb)["Selected"]) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #Select A1:A5 on Sheet 'Dot_as_Separator' + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + #Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + #Untag Tab as separator and tag other. Put a dot into the input field next to the other checkbox + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"."})) + #Click Ok + #Does an overwrite warning come up? If not file an Issue. + #Tag the 'Do not show warning again' checkbox and press Ok. + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + xask = dialog.getChild("ask") + xask.executeAction("CLICK", tuple()) + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + #verify setting in options + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + self.assertEqual(get_state_as_dict(xreplwarncb)["Selected"], "false") + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + + def test_text_to_columns_comma(self): + #Comma as Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_comma.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + print(get_state_as_dict(xreplwarncb)["Selected"]) + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + print(get_state_as_dict(xreplwarncb)["Selected"]) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Select A1:A5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # Untag Tab as separator and tag comma. + xComma = xDialog.getChild("comma") + if (get_state_as_dict(xComma)["Selected"]) == "false": + xComma.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + + self.ui_test.close_doc() + def test_text_to_columns_semicolon(self): + #Semicolon as Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_semicolon.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Select A1:A5 on Sheet + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # Untag comma as separator and tag Semicolon + xSemicolon = xDialog.getChild("semicolon") + if (get_state_as_dict(xSemicolon)["Selected"]) == "false": + xSemicolon.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + self.ui_test.close_doc() + + def test_text_to_columns_space(self): + #Space as Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_space.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Select A1:A5 on Sheet + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # Untag comma as separator and tag Semicolon + xSpace = xDialog.getChild("space") + if (get_state_as_dict(xSpace)["Selected"]) == "false": + xSpace.executeAction("CLICK", tuple()) + # xspace.executeAction("CLICK", tuple()) + # Click Ok + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + self.ui_test.close_doc() + + def test_text_to_columns_pipe(self): + #Space as Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Select A1:A5 on Sheet + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # Untag comma as separator and tag Semicolon + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + xSpace = xDialog.getChild("space") + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) + # Click Ok + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + self.ui_test.close_doc() + + def test_text_to_columns_pipespace(self): + #Space as Separator + calc_doc = self.ui_test.load_file(get_url_for_data_file("text_to_columns_pipe_space.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Make sure that tools-options-StarOffice Calc-General-Input settings-Show overwrite warning when pasting data is tagged. + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "false": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + # Select A1:A5 on Sheet + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A5"})) + # Data - Text to Columns + self.ui_test.execute_dialog_through_command(".uno:TextToColumns") + xDialog = self.xUITest.getTopFocusWindow() + # + xtab = xDialog.getChild("tab") + xcomma = xDialog.getChild("comma") + xsemicolon = xDialog.getChild("semicolon") + xspace = xDialog.getChild("space") + xother = xDialog.getChild("other") + xinputother = xDialog.getChild("inputother") + if (get_state_as_dict(xspace)["Selected"]) == "false": + xspace.executeAction("CLICK", tuple()) + if (get_state_as_dict(xother)["Selected"]) == "false": + xother.executeAction("CLICK", tuple()) + xinputother.executeAction("TYPE", mkPropertyValues({"TEXT":"|"})) + # Click Ok + xOK = xDialog.getChild("ok") + def handle_warn_dlg(dialog): + xyesBtn = dialog.getChild("yes") + self.ui_test.close_dialog_through_button(xyesBtn) + + self.ui_test.execute_blocking_action(xOK.executeAction, args=('CLICK', ()), + dialog_handler=handle_warn_dlg) + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 1) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 0, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 3).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 1, 4).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 3).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 1).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 2).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 3).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 3, 4).getValue(), 4) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 5) + self.assertEqual(get_cell_by_position(document, 0, 5, 0).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 3).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 6) + self.assertEqual(get_cell_by_position(document, 0, 6, 0).getString(), "random content") + self.assertEqual(get_cell_by_position(document, 0, 6, 1).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 2).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 3).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getString(), "random content") + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py new file mode 100644 index 000000000..abd26385a --- /dev/null +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -0,0 +1,298 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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/. +# tests for tracked changes ; tdf912270 + +from uitest.framework import UITestCase +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from uitest.path import get_srcdir_url +import datetime + + +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name + +class CalcTrackedChanges(UITestCase): + + def test_tdf131907(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf131907.odt")) + xCalcDoc = self.xUITest.getTopFocusWindow() + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + textStart = "Row inserted \tSheet1.1:1\t \t" + textEnd = "(Row 1:1 inserted)" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + + #it would crash here + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + + def test_tdf66263_Protect_Records(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + self.xUITest.executeCommand(".uno:TraceChangeMode") + #protect dialog + self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") + xDialog = self.xUITest.getTopFocusWindow() + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xconfirm = xDialog.getChild("confirm1ed") + xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + #verify password + self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") + xDialog = self.xUITest.getTopFocusWindow() + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + + def test_tracked_changes_accept(self): + + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + self.ui_test.close_doc() + + def test_tracked_changes_acceptall(self): + + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept All tracked changes + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + self.ui_test.close_doc() + + def test_tracked_changes_reject(self): + + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(3, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('2'))["Text"], "Rejected") + + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd3)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd4)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.ui_test.close_doc() + + def test_tracked_changes_rejectall(self): + + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges") + xTrackDlg = self.xUITest.getTopFocusWindow() + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd4)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd3)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + xCancBtn = xTrackDlg.getChild("close") + xCancBtn.executeAction("CLICK", tuple()) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py new file mode 100644 index 000000000..c38165f36 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -0,0 +1,78 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sc / AutoFormat Styles + +class autoFormat(UITestCase): + def test_autoformat_styles(self): + writer_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A1:C5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) + #AutoFormat Styles + self.ui_test.execute_dialog_through_command(".uno:AutoFormat") + xDialog = self.xUITest.getTopFocusWindow() + + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") + + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #verify + self.ui_test.execute_dialog_through_command(".uno:AutoFormat") + xDialog = self.xUITest.getTopFocusWindow() + + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") + + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") + self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") + self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/autocorrectOptions.py b/sc/qa/uitest/calc_tests6/autocorrectOptions.py new file mode 100644 index 000000000..146e3300f --- /dev/null +++ b/sc/qa/uitest/calc_tests6/autocorrectOptions.py @@ -0,0 +1,95 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import time +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + +class autocorrectOptions(UITestCase): + + def test_autocorrect_options_calc(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + xreset = xDialog.getChild("reset") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["Children"] + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["Children"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["Children"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["Children"] + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["Children"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["Children"], nrRowsDouble) #we have default nr of rules + + xCancelButton = xDialog.getChild("cancel") + xCancelButton.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py b/sc/qa/uitest/calc_tests6/moveCopySheet.py new file mode 100644 index 000000000..16370451e --- /dev/null +++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py @@ -0,0 +1,84 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.debug import sleep +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sc - move/copy sheet dialog + +class moveCopySheet(UITestCase): + def test_copy_move_sheet(self): + writer_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #default - 1 sheet; select the sheet (is selected), dialog move/copy sheet + self.ui_test.execute_dialog_through_command(".uno:Move") + xDialog = self.xUITest.getTopFocusWindow() + #new name = newName + newName = xDialog.getChild("newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify, the file has 2 sheets; first one "newName" is selected + self.assertEqual(document.Sheets.getCount(), 2) + # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName + self.ui_test.execute_dialog_through_command(".uno:Move") + xDialog = self.xUITest.getTopFocusWindow() + insertBefore = xDialog.getChild("insertBefore") + + xTreeEntry = insertBefore.getChild('2') + xTreeEntry.executeAction("SELECT", tuple()) + + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], "newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + # Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName" + self.assertEqual(document.Sheets.getCount(), 2) + + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") + + # Verify that the cancel button does not do anything + self.ui_test.execute_dialog_through_command(".uno:Move") + xDialog = self.xUITest.getTopFocusWindow() + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.assertEqual(document.Sheets.getCount(), 2) + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") + + #Check copy option + self.ui_test.execute_dialog_through_command(".uno:Move") + xDialog = self.xUITest.getTopFocusWindow() + xCopy = xDialog.getChild("copy") + xCopy.executeAction("CLICK", tuple()) + sheetName = "moveName_2" + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.assertEqual(document.Sheets.getCount(), 3) + self.assertEqual(document.Sheets[0].Name, sheetName) + self.assertEqual(document.Sheets[1].Name, "Sheet1") + self.assertEqual(document.Sheets[2].Name, "moveName") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/multipleOperations.py b/sc/qa/uitest/calc_tests6/multipleOperations.py new file mode 100644 index 000000000..34fc4691d --- /dev/null +++ b/sc/qa/uitest/calc_tests6/multipleOperations.py @@ -0,0 +1,129 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import time +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + +#https://www.linuxtopia.org/online_books/office_guides/openoffice_3_calc_user_guide/openoffice_calc_Multiple_operations_Multiple_operations_in_columns_or_rows.html + +class multipleOperations(UITestCase): + + def test_multiple_operations_one_variable(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:E11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) + #Choose Data > Multiple Operations. + self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") + xDialog = self.xUITest.getTopFocusWindow() + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + + self.ui_test.close_doc() + def test_multiple_operations_several_formulas(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + enter_text_to_cell(xGridWindow, "C5", "=B5/B4") + + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:F11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:F11"})) + #Choose Data > Multiple Operations. + self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") + xDialog = self.xUITest.getTopFocusWindow() + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5:$C$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), -12) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), -2) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 3).getValue(),2), 1.33) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 4) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 6).getValue(),2), 4.67) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 7).getValue(),2), 5.14) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 5.5) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 9).getValue(),2), 5.78) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 6) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/scenarios.py b/sc/qa/uitest/calc_tests6/scenarios.py new file mode 100644 index 000000000..67f7952ae --- /dev/null +++ b/sc/qa/uitest/calc_tests6/scenarios.py @@ -0,0 +1,55 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import time +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + +# uitest Tools - Scenarios + +class scenarios(UITestCase): + + def test_scenarios(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #fill B1:B4 with 1, select B1:B4; + enter_text_to_cell(xGridWindow, "B1", "1") + enter_text_to_cell(xGridWindow, "B2", "1") + enter_text_to_cell(xGridWindow, "B3", "1") + enter_text_to_cell(xGridWindow, "B4", "1") + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"})) + #scenarios - scenario A1 + self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") + xDialog = self.xUITest.getTopFocusWindow() + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #next scenarios - scenario B1 + self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") + xDialog = self.xUITest.getTopFocusWindow() + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py new file mode 100644 index 000000000..a2f5be555 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import time +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from uitest.uihelper.common import select_pos + +#just open dialog, select Share, check name and cancel [save not allowed in uitest] + +class shareSpreadsheet(UITestCase): + + def test_share_spreadsheet(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #dialog shareSpreadsheet + self.ui_test.execute_dialog_through_command(".uno:ShareDocument") + xDialog = self.xUITest.getTopFocusWindow() + + share = xDialog.getChild("share") + share.executeAction("CLICK", tuple()) + users = xDialog.getChild("users") + self.assertEqual(get_state_as_dict(users)["Children"], "1") + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf107267.py b/sc/qa/uitest/calc_tests6/tdf107267.py new file mode 100644 index 000000000..34a9a4fa0 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf107267.py @@ -0,0 +1,104 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict +import time +from uitest.debug import sleep + +import org.libreoffice.unotest +import pathlib +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 107267 - During a sub-total calculation or sum, the data set is not computed well. +class Subtotals(UITestCase): + + + def test_tdf107267(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf107267.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open the test file + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F123"})) + # 2. Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + # = 1st group = 3. Group by "Person Number", select "shipping time" and use the Max function. + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Person Number"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected +# xCheckListMenu = xDialog.getChild("grid1") +# xTreeList = xCheckListMenu.getChild("columns") +# x6Entry = xTreeList.getChild("5") +# xFirstEntry.executeAction("CLICK", tuple()) + #use the Max function + xfunctions = xDialog.getChild("functions") + propsF = {"TEXT": "Max"} + actionPropsF = mkPropertyValues(propsF) + xfunctions.executeAction("SELECT", actionPropsF) + + #= 2nd group =5. Group by "Person Number", select "shipping time" and use the Min function. + select_pos(xTabs, "1") + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Person Number"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected +# xCheckListMenu = xDialog.getChild("grid1") +# xTreeList = xCheckListMenu.getChild("columns") +# x6Entry = xTreeList.getChild("5") +# xFirstEntry.executeAction("CLICK", tuple()) + #use the Min function + xfunctions = xDialog.getChild("functions") + propsF2 = {"TEXT": "Min"} + actionPropsF2 = mkPropertyValues(propsF2) + xfunctions.executeAction("SELECT", actionPropsF2) + + #= 3rd group = Group by "Person Number", select "shipping time" and use the Average function. + select_pos(xTabs, "2") + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Person Number"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + # 4. Tick 'Calculate subtotals for' -> "shipping time" - already selected +# xCheckListMenu = xDialog.getChild("grid1") +# xTreeList = xCheckListMenu.getChild("columns") +# x6Entry = xTreeList.getChild("5") +# xFirstEntry.executeAction("CLICK", tuple()) + #use the Average function + xfunctions = xDialog.getChild("functions") + propsF3 = {"TEXT": "Average"} + actionPropsF3 = mkPropertyValues(propsF3) + xfunctions.executeAction("SELECT", actionPropsF3) + + # 5. Click OK + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 141).getString(), "Grand Average") + self.assertEqual(get_cell_by_position(document, 0, 0, 142).getString(), "Grand Min") + self.assertEqual(get_cell_by_position(document, 0, 0, 143).getString(), "Grand Max") + + self.assertEqual(round(get_cell_by_position(document, 0, 5, 141).getValue(), 13), 3.3852459016393) + self.assertEqual(get_cell_by_position(document, 0, 5, 142).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 5, 143).getValue(), 26) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf107869.py b/sc/qa/uitest/calc_tests6/tdf107869.py new file mode 100644 index 000000000..d38861043 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf107869.py @@ -0,0 +1,93 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +#https://bugs.documentfoundation.org/show_bug.cgi?id=107869 +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf107869(UITestCase): + def test_tdf107869_undo_redo_delete_row_with_comment(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("comments.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #- Delete the row with comment. + #select row 1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectRow") + #delete row 1 + self.xUITest.executeCommand(".uno:DeleteRows") + #A1 should be "B" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + #- Undo-redo deletion a few times. + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "B") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + + #select row 1 and 2 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:SelectRow") + #delete row 1 + self.xUITest.executeCommand(".uno:DeleteRows") + #A1 should be "" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + #- Undo-redo deletion a few times. + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf108654.py b/sc/qa/uitest/calc_tests6/tdf108654.py new file mode 100644 index 000000000..93576fe41 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf108654.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 108654 - CRASH while undoing paste on a new sheet +class tdf108654(UITestCase): + def test_tdf108654_Undo_paste_crash(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf108654.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Sheet3 - CTRL+A & CTRL+C + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + #Create a new sheet & paste (CTRL-V) + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKButton) + + self.assertEqual(document.Sheets.getCount(), 4) + + self.xUITest.executeCommand(".uno:Paste") + #Undo the action twice + self.xUITest.executeCommand(".uno:Undo") + self.xUITest.executeCommand(".uno:Undo") + + #-> CRASH + self.assertEqual(document.Sheets.getCount(), 3) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf116996.py b/sc/qa/uitest/calc_tests6/tdf116996.py new file mode 100644 index 000000000..77647d1f5 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf116996.py @@ -0,0 +1,65 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 116996 - Crash recover on selecting Tools -> Options -> Advanced: Enable experimental features + +class tdf116996(UITestCase): + def test_tdf116996_enable_experimental_feature(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + xexperimental.executeAction("CLICK", tuple()) #enable experimental features + + xOKBtn = xDialogOpt.getChild("ok") + + def handle_confirm_dlg(dialog): + xLaterBtn = dialog.getChild("no") + self.ui_test.close_dialog_through_button(xLaterBtn) + + self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_confirm_dlg) + + #reopen options dialog and verify + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + + self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") + xexperimental.executeAction("CLICK", tuple()) #disable experimental features + xOKBtn = xDialogOpt.getChild("ok") + + def handle_confirm_dlg(dialog): + xLaterBtn = dialog.getChild("no") + self.ui_test.close_dialog_through_button(xLaterBtn) + + self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_confirm_dlg) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf118638.py b/sc/qa/uitest/calc_tests6/tdf118638.py new file mode 100644 index 000000000..b6e700e01 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf118638.py @@ -0,0 +1,69 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_state_as_dict +import time +from uitest.debug import sleep + +import org.libreoffice.unotest +import pathlib +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 118638 - subtotal option loses doesn't contain existing format for column +class Subtotals(UITestCase): + + + def test_tdf118638_subtotal_format(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf118638.ods")) + XcalcDoc = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = XcalcDoc.getChild("grid_window") + # Open the test file + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B15"})) + #Data->Subtotals + self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xGroupBy = xDialog.getChild("group_by") + props = {"TEXT": "Store Name"} + actionProps = mkPropertyValues(props) + xGroupBy.executeAction("SELECT", actionProps) + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns") + xEntry = xTreeList.getChild("1") + xEntry.executeAction("CLICK", tuple()) + + #use the SUM function +# xfunctions = xDialog.getChild("functions") +# propsF = {"TEXT": "Sum"} +# actionPropsF = mkPropertyValues(propsF) +# xfunctions.executeAction("SELECT", actionPropsF) + + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 15).getString(), "5408 Sum") + self.assertEqual(get_cell_by_position(document, 0, 0, 16).getString(), "Grand Sum") + + self.assertEqual(get_cell_by_position(document, 0, 1, 15).getValue(), 238.89) + self.assertEqual(get_cell_by_position(document, 0, 1, 16).getValue(), 238.89) + + self.assertEqual(get_cell_by_position(document, 0, 1, 15).getString(), "$238.89") + self.assertEqual(get_cell_by_position(document, 0, 1, 16).getString(), "$238.89") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf121263.py b/sc/qa/uitest/calc_tests6/tdf121263.py new file mode 100644 index 000000000..cb66c5772 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf121263.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from libreoffice.calc.document import get_column +from uitest.path import get_srcdir_url +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_cell_by_position +import time +from uitest.debug import sleep + +class tdf121263(UITestCase): + + def test_tdf121263_hide_more_sheets(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xTopWindow = self.xUITest.getTopFocusWindow() + document = self.ui_test.get_component() + gridwin = xTopWindow.getChild("grid_window") + + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + self.ui_test.execute_dialog_through_command(".uno:Insert") #insert sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("ok") + xOKButton.executeAction("CLICK", tuple()) + + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) + #select previous sheet + self.xUITest.executeCommand(".uno:JumpToPrevTableSel") + + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + + #show sheet Dialog + self.ui_test.execute_dialog_through_command(".uno:Show") + xDialog = self.xUITest.getTopFocusWindow() + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") + xcancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xcancel) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf91726.py b/sc/qa/uitest/calc_tests6/tdf91726.py new file mode 100644 index 000000000..38703cb7e --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf91726.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 91726 - AutoFormat: Crash when using an existing name for a new preset + +class tdf91726(UITestCase): + def test_tdf91726_new_style(self): + writer_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select A1:E9 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:E9"})) + #AutoFormat Styles + self.ui_test.execute_dialog_through_command(".uno:AutoFormat") + xDialog = self.xUITest.getTopFocusWindow() + #add new style "Default" + xadd = xDialog.getChild("add") + def handle_name_dlg(dialog): + nameEntry = dialog.getChild("name_entry") + nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) + xOKBtn = dialog.getChild("ok") + def handle_error_dlg(dialog2): + #Error message: You have entered an invalid name. + #AutoFormat could not be created. + #Try again using a different name. + xOKBtn2 = dialog2.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn2) + + self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_error_dlg) + + xDialog = self.xUITest.getTopFocusWindow() + nameEntry = xDialog.getChild("name_entry") + #back to name dialog, LO should not crash + self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") + xCanceltn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanceltn) + + self.ui_test.execute_blocking_action(xadd.executeAction, args=('CLICK', ()), + dialog_handler=handle_name_dlg) + + xCanceltn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanceltn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf106667.py b/sc/qa/uitest/calc_tests7/tdf106667.py new file mode 100644 index 000000000..5475c7680 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf106667.py @@ -0,0 +1,37 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.debug import sleep + +class tdf106667(UITestCase): + + def test_tdf106667_about_dlg_all(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + enter_text_to_cell(gridwin, "A1", "A") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1000"})) + + self.xUITest.executeCommand(".uno:FillDown") + + self.xUITest.executeCommand(".uno:SelectAll") + + self.ui_test.execute_dialog_through_command(".uno:About") + xAboutDlg = self.xUITest.getTopFocusWindow() + xCloseBtn = xAboutDlg.getChild("btnClose") + self.ui_test.close_dialog_through_button(xCloseBtn) + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf120660.py b/sc/qa/uitest/calc_tests7/tdf120660.py new file mode 100644 index 000000000..d36ad13bc --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf120660.py @@ -0,0 +1,66 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 120660 - cells not recalculated after copy/paste different range of cells + +class tdf120660(UITestCase): + def test_tdf120660_undo_recalculate(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf120660.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Make sure that tools-options-LibreOffice Calc-General-Input settings-Show overwrite warning when pasting data is unselected + #turn off message: You are pasting data into cells that already contain data + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General / replwarncb + xreplwarncb = xDialogOpt.getChild("replwarncb") + if (get_state_as_dict(xreplwarncb)["Selected"]) == "true": + xreplwarncb.executeAction("CLICK", tuple()) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:E8"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:E4"})) + self.xUITest.executeCommand(".uno:Paste") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 1200) + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2200) + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A8:D8"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A4:D4"})) + self.xUITest.executeCommand(".uno:Paste") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 1200) + + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2200) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests7/tdf122509.py b/sc/qa/uitest/calc_tests7/tdf122509.py new file mode 100644 index 000000000..87b28cb69 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf122509.py @@ -0,0 +1,61 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 122509 - EDITING Calc crashes when manipulating Negative numbers in red on Currency ( not gtk3 ) + +class tdf122509(UITestCase): + def test_tdf122509_format_cell_negative_numbers(self): + #numberingformatpage.ui + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf122509.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];[RED]-#,##0.00 [$USD]") + #click negative + xnegnumred.executeAction("CLICK", tuple()) + #format check; https://bugs.documentfoundation.org/show_bug.cgi?id=122509#c7 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];-#,##0.00 [$USD]") + # click negative + xnegnumred.executeAction("CLICK", tuple()) + #OK + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #verify; no crashes + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 2) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf123052.py b/sc/qa/uitest/calc_tests7/tdf123052.py new file mode 100644 index 000000000..f3e7f8796 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf123052.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +#Bug 123052 - [regression] Shift+Tab not working +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf123052(UITestCase): + def test_tdf123052_shit_tab(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf123052.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Holding the Shift key and repeated pressing the Tab key does not correctly cycle though the unprotected cells + #I'm at 7, hold TAB for cycling + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + self.assertEqual(gridWinState["CurrentColumn"], "5") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + self.assertEqual(gridWinState["CurrentColumn"], "3") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + self.assertEqual(gridWinState["CurrentColumn"], "4") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "5") + self.assertEqual(gridWinState["CurrentColumn"], "5") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "7") + self.assertEqual(gridWinState["CurrentColumn"], "0") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "8") + self.assertEqual(gridWinState["CurrentColumn"], "4") + #now shift + tab + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+TAB"})) + # Assert that the correct cell has been selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "7") + self.assertEqual(gridWinState["CurrentColumn"], "0") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf123122.py b/sc/qa/uitest/calc_tests7/tdf123122.py new file mode 100644 index 000000000..f489f3c2f --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf123122.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 123122 - Invoking the number format dialog the format code field is blank for a user-defined date+time format. + +class tdf123122(UITestCase): + def test_tdf123122_format_cell_datetime(self): + #numberingformatpage.ui + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + #Format cells and enter NN MMM DD YYYY HH:MM as format code + xformatted.executeAction("CLEAR", tuple()) #clear textbox + xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) + #save - OK + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") + xDialog = self.xUITest.getTopFocusWindow() + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xliststore2 = xDialog.getChild("formatlb") #2nd list / Format + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf123479.py b/sc/qa/uitest/calc_tests7/tdf123479.py new file mode 100644 index 000000000..046bf8303 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf123479.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 123479 - Crash in: ScFormulaResult::GetMatrixFormulaCellToken() + +class tdf123479(UITestCase): + def test_tdf123479_Crash_ScFormulaResult_GetMatrixFormulaCellToken(self): + #numberingformatpage.ui + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf123479.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Select D14:D16 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "D14:D16"})) + #Open Formula Wizard (Ctrl+F2) + self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") + xDialog = self.xUITest.getTopFocusWindow() + edArg1 = xDialog.getChild("ED_ARG1") + edArg2 = xDialog.getChild("ED_ARG2") + formulaRes = xDialog.getChild("formula_result") + + #check formula wizard data + self.assertEqual(get_state_as_dict(edArg1)["Text"], "CHAR(10)") + self.assertEqual(get_state_as_dict(edArg2)["Text"], "OFFSET($Data.$A$2:$Data.$A$4,0,COLUMN()-3)") + self.assertEqual(get_state_as_dict(formulaRes)["Text"], "{4;4;4}") + + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + #verify; no crashes + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getString(), "Pass/Fail") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf124818.py b/sc/qa/uitest/calc_tests7/tdf124818.py new file mode 100644 index 000000000..134548426 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf124818.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 124818 - CRASH: selecting all and switching spreadsheet + +class tdf124818(UITestCase): + def test_tdf124818_crash_select_all_and_switch_spreadsheet(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf124818.xls")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Select all ( Ctrl + A );Go to sheet Graph2;Select all;Crash + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:JumpToPrevTable") + self.xUITest.executeCommand(".uno:SelectAll") + + #verify; no crashes + self.assertEqual(document.Sheets.getCount(), 3) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf124822.py b/sc/qa/uitest/calc_tests7/tdf124822.py new file mode 100644 index 000000000..8c438df79 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf124822.py @@ -0,0 +1,37 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +# Bug 124822 - CRASH: cutting and undoing + +class tdf124822(UITestCase): + def test_tdf124822_crash_cut_undo(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf124822.xls")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #Select all ( Ctrl + A ) ; Cut ( Ctrl + X );Undo + self.xUITest.executeCommand(".uno:selectAll") + self.xUITest.executeCommand(".uno:Cut") + self.xUITest.executeCommand(".uno:Undo") + #verify; no crashes + self.assertEqual(get_cell_by_position(document, 2, 0, 0).getString(), "X") + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf124896.py b/sc/qa/uitest/calc_tests7/tdf124896.py new file mode 100644 index 000000000..b2f016847 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf124896.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, type_text +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +# Bug 124896 - CRASH: deleting sheet + +class tdf124896(UITestCase): + def test_tdf124896_crash_delete_sheet(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf124896.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + # Remove X Bar R Chart (2) sheet + self.ui_test.execute_dialog_through_command(".uno:Remove") #delete sheet + xDialog = self.xUITest.getTopFocusWindow() + xOKButton = xDialog.getChild("yes") + xOKButton.executeAction("CLICK", tuple()) + #verify; no crashes + self.assertEqual(document.Sheets.getCount(), 2) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf125030.py b/sc/qa/uitest/calc_tests7/tdf125030.py new file mode 100644 index 000000000..5aaa81abc --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf125030.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import os +from uitest.uihelper.common import get_state_as_dict +from uitest.debug import sleep +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell + +#Bug 125030 - nice crash by repeating apply style (Ctrl+Shft+Y) + +class tdf125030(UITestCase): + def test_tdf125030_repeat_crash(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #enter data + enter_text_to_cell(gridwin, "A1", "aaaa") + enter_text_to_cell(gridwin, "B1", "bbbb") + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%201&FamilyName:string=CellStyles") + #focus on A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #repeat (Ctrl+Shft+Y) + self.xUITest.executeCommand(".uno:Repeat") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aaaa") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf132173.py b/sc/qa/uitest/calc_tests7/tdf132173.py new file mode 100644 index 000000000..d74f7dc74 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf132173.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf132173(UITestCase): + def test_tdf132173(self): + self.ui_test.create_doc_in_start_center("calc") + + self.ui_test.execute_modeless_dialog_through_command(".uno:FunctionDialog") + xDialog = self.xUITest.getTopFocusWindow() + xFormula = xDialog.getChild("ed_formula") + xFormula.executeAction("TYPE", mkPropertyValues({"TEXT": 'FIND({"A";"B";"C"},"SAMPLE TEXT")'})) + + self.assertEqual(get_state_as_dict(xFormula)["Text"], '=FIND({"A";"B";"C"},"SAMPLE TEXT")') + + xOk = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOk) + + document = self.ui_test.get_component() + + #Without the fix in place, cell's value would have been #NAME? + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "2") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf31805.py b/sc/qa/uitest/calc_tests7/tdf31805.py new file mode 100644 index 000000000..76d30cf22 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf31805.py @@ -0,0 +1,47 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +#Bug 31805 - Deleting a column or row from merged cells +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf31805(UITestCase): + def test_tdf31805_delete_column_merged(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf31805.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1. open "sample.ods" + #2. click 'G1' + #3. Menu 'edit -> Delete Cell - Delete entire Column' + #expected: Column with cell containing "g" will be deleted, + # a merged cell range will remain left row 1 + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) + self.xUITest.executeCommand(".uno:DeleteColumns") + #verify. C5:F11 should be merged + #isMerged returns true if this cell is merged with another cell. + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 + self.assertEqual(get_cell_by_position(document, 0, 6, 4).getIsMerged(), False) #G5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A11"})) + self.xUITest.executeCommand(".uno:DeleteRows") + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:DeleteColumns") + self.assertEqual(get_cell_by_position(document, 0, 2, 4).getIsMerged(), True) #C5 + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf45020.py b/sc/qa/uitest/calc_tests7/tdf45020.py new file mode 100644 index 000000000..270446941 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf45020.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf45020(UITestCase): + def test_tdf45020_hide_rows_select(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #in cell A1-A4: apple pear melon mango + enter_text_to_cell(gridwin, "A1", "apple") + enter_text_to_cell(gridwin, "A1", "pear") + enter_text_to_cell(gridwin, "A1", "melon") + enter_text_to_cell(gridwin, "A1", "mango") + #select A2 and A3 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A3"})) + #format > Row > Hide + self.ui_test._xUITest.executeCommand(".uno:HideRow") + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #press Shift+down + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"SHIFT+DOWN"})) + #verify A1:A4 selected + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["MarkedArea"], "Sheet1.A1:Sheet1.A4") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf91425.py b/sc/qa/uitest/calc_tests7/tdf91425.py new file mode 100644 index 000000000..cacd96726 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf91425.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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, type_text +from libreoffice.calc.document import get_cell_by_position +import time +from uitest.debug import sleep +import org.libreoffice.unotest +import pathlib + + +#Bug 91425 - CRASH - Calc Insert Columns Left + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class tdf91425(UITestCase): + def test_tdf91425_insert_columns_left(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf91425.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #1) Open test file provided in report + #2) Move mouse pointer over Column A header, the right mouse button click + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #3) Insert columns left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #verify + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "C") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "C") + #redo + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "C") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/navigator.py b/sc/qa/uitest/calc_tests8/navigator.py new file mode 100644 index 000000000..4026ca665 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/navigator.py @@ -0,0 +1,117 @@ +# +# 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 +from uitest.path import get_srcdir_url + +def get_url_for_data_file(file_name): + return get_srcdir_url() + "/sc/qa/uitest/calc_tests/data/" + file_name + +class navigator(UITestCase): + + def test_rename_sheet(self): + self.ui_test.load_file(get_url_for_data_file("navigator.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)') + self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)') + + #The document has one comment too + xComments = xContentBox.getChild("6") + self.assertEqual(get_state_as_dict(xComments)['Text'], 'Comments') + self.assertEqual(len(xComments.getChildren()), 1) + self.assertEqual(get_state_as_dict(xComments.getChild('0'))['Text'], 'Test Comment') + + self.ui_test.execute_dialog_through_command(".uno:RenameTable") + xDialog = self.xUITest.getTopFocusWindow() + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"})) + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'S1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (S1)') + self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (S1)') + + self.xUITest.executeCommand(".uno:Undo") + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + #FIXME: tdf#133082 + #self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)') + #self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)') + + self.xUITest.executeCommand(".uno:Sidebar") + self.ui_test.close_doc() + + def test_tdf98493(self): + + self.ui_test.load_file(get_url_for_data_file("tdf98493.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], "2") + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanelParent") + xNavigatorPanel.executeAction("ROOT", tuple()) + xContentBox = xNavigatorPanel.getChild('contentbox') + + # tdf#133079, without the fix in place, it would be 8 + self.assertEqual(len(xContentBox.getChildren()), 1) + + xSheets = xContentBox.getChild('0') + self.assertEqual(len(xSheets.getChildren()), 12) + + #key=item position, value=sheet ( there are hidden sheets ) + results = { '1': '0', '5': '4', '6': '4', '11': '10'} + + for k, v in results.items(): + xChild = xSheets.getChild(k) + xChild.executeAction("DOUBLECLICK", tuple()) + + self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], v) + + self.xUITest.executeCommand(".uno:Sidebar") + self.ui_test.close_doc() diff --git a/sc/qa/uitest/calc_tests8/tdf119343.py b/sc/qa/uitest/calc_tests8/tdf119343.py new file mode 100644 index 000000000..82c0e11b4 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf119343.py @@ -0,0 +1,42 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +from uitest.path import get_srcdir_url +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 119343 - EDITING: copied and pasted cells containing formulas are not recalculated (2) + +class tdf119343(UITestCase): + def test_tdf119343_copy_paste_formula(self): + #numberingformatpage.ui + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf119343.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "M295"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.xUITest.executeCommand(".uno:Paste") + #verify + self.assertEqual(get_cell_by_position(document, 0, 12, 295).getString(), "Q11005355") + self.assertEqual(get_cell_by_position(document, 0, 12, 294).getString(), "Q1099565") + self.assertEqual(get_cell_by_position(document, 0, 12, 293).getString(), "Q108420") + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf124829.py b/sc/qa/uitest/calc_tests8/tdf124829.py new file mode 100644 index 000000000..97a43f641 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf124829.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_sheet_from_doc +from libreoffice.calc.conditional_format import get_conditional_format_from_sheet +from uitest.debug import sleep +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 124829 - CRASH: cutting and undoing a sheet with external links + +class tdf124829(UITestCase): + def test_tdf124829_Crash_cutting_undo_sheet_external_links(self): + #numberingformatpage.ui + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf124829.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Cut") + for i in range(40): + self.xUITest.executeCommand(".uno:Undo") + + #verify; no crashes + self.assertEqual(document.Sheets.getCount(), 6) + + self.ui_test.close_doc() +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf125051.py b/sc/qa/uitest/calc_tests8/tdf125051.py new file mode 100644 index 000000000..d993aacdf --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf125051.py @@ -0,0 +1,50 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 125051 - EDITING: CRASH when start SpellCheck + +class tdf125051(UITestCase): + def test_tdf125051_crash_spelling_dialog(self): + calc_doc = self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + enter_text_to_cell(gridwin, "A1", "text") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.ui_test.execute_dialog_through_command(".uno:SpellDialog") + xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog + + xDialog2 = self.xUITest.getTopFocusWindow() # info dialog "The spellcheck of this sheet has been completed.-> OK" + okBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(okBtn) + + xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog + #open options + optionsBtn = xDialog.getChild("options") + def handle_options_dlg(dialog): + #print(dialog.getChildren()) + xCancelBtn = dialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + self.ui_test.execute_blocking_action(optionsBtn.executeAction, args=('CLICK', ()), + dialog_handler=handle_options_dlg) + + closeBtn = xDialog.getChild("close") #close Spelling dialog + self.ui_test.close_dialog_through_button(closeBtn) + + #verify, we didn't crash + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf121949.py b/sc/qa/uitest/calc_tests9/tdf121949.py new file mode 100644 index 000000000..92dd66866 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf121949.py @@ -0,0 +1,30 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 tdf121949 (UITestCase): + + def test_tdf121949_copy_block_with_single_cell_not_included(self): + self.ui_test.create_doc_in_start_center("calc") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + # mark a range with a single cell left our and copy to clipboard + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) + self.ui_test.execute_dialog_through_command(".uno:Copy") + xDialog = self.xUITest.getTopFocusWindow() + xOKBtn = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: + diff --git a/sc/qa/uitest/calc_tests9/tdf126673.py b/sc/qa/uitest/calc_tests9/tdf126673.py new file mode 100644 index 000000000..8eb99a123 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126673.py @@ -0,0 +1,66 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 126673 - Calc: Auto-fit column and auto-fit row don't work with line break + +class tdf126673(UITestCase): + def test_tdf126673_auto_fit_row_height(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf126673.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + #set cm Tools-options-StarOffice Calc-General + self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog + xDialogOpt = self.xUITest.getTopFocusWindow() + + xPages = xDialogOpt.getChild("pages") + xWriterEntry = xPages.getChild('3') # Calc + xWriterEntry.executeAction("EXPAND", tuple()) + xWriterGeneralEntry = xWriterEntry.getChild('0') + xWriterGeneralEntry.executeAction("SELECT", tuple()) #General /cm + xunitlb = xDialogOpt.getChild("unitlb") + props = {"TEXT": "Centimeter"} + actionProps = mkPropertyValues(props) + xunitlb.executeAction("SELECT", actionProps) + xOKBtn = xDialogOpt.getChild("ok") + self.ui_test.close_dialog_through_button(xOKBtn) + + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #optimal row height + self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight") + xDialog = self.xUITest.getTopFocusWindow() + # Click Ok + xOK = xDialog.getChild("ok") + self.ui_test.close_dialog_through_button(xOK) + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #row height + self.ui_test.execute_dialog_through_command(".uno:RowHeight") + xDialog = self.xUITest.getTopFocusWindow() + xvalue = xDialog.getChild("value") + heightStrOrig = get_state_as_dict(xvalue)["Text"] + heightVal = heightStrOrig[:4] #default 0.45 cm, + self.assertEqual(heightVal > '0.45', True) #new value is bigger then default + # Click Ok + xcancel = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xcancel) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf130371.py b/sc/qa/uitest/calc_tests9/tdf130371.py new file mode 100644 index 000000000..6a8f00cbf --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf130371.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +class namedRanges(UITestCase): + + def test_tdf130371(self): + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf130371.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + + text1 = "value\t$Sheet2.$B$2\tSheet2" + text2 = "value\t$Sheet3.$B$2\tSheet3" + text3 = "value\t$Sheet4.$B$2\tSheet4" + + self.ui_test.execute_dialog_through_command(".uno:DefineName") + xDialog = self.xUITest.getTopFocusWindow() + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + self.xUITest.executeCommand(".uno:Copy") + + self.xUITest.executeCommand(".uno:JumpToNextTable") + self.xUITest.executeCommand(".uno:JumpToNextTable") + + self.xUITest.executeCommand(".uno:Paste") + + self.ui_test.execute_dialog_through_command(".uno:DefineName") + xDialog = self.xUITest.getTopFocusWindow() + namesList = xDialog.getChild('names') + self.assertEqual(3, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + self.assertEqual(get_state_as_dict(namesList.getChild('2'))["Text"], text3) + + xOkBtn = xDialog.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.xUITest.executeCommand(".uno:Undo") + + self.ui_test.execute_dialog_through_command(".uno:DefineName") + xDialog = self.xUITest.getTopFocusWindow() + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + xCancelBtn = xDialog.getChild("cancel") + xCancelBtn.executeAction("CLICK", tuple()) + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf91217.py b/sc/qa/uitest/calc_tests9/tdf91217.py new file mode 100644 index 000000000..54f56a9fd --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf91217.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# 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 +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +import org.libreoffice.unotest +import pathlib + +def get_url_for_data_file(file_name): + return pathlib.Path(org.libreoffice.unotest.makeCopyFromTDOC(file_name)).as_uri() + +#Bug 91217 - Crash when deleting rows + +class tdf91217(UITestCase): + def test_tdf91217_crash_deleting_rows(self): + # FIXME disable this will it's clear what existing problem did this test uncover. + return + calc_doc = self.ui_test.load_file(get_url_for_data_file("tdf91217.ods")) + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + document = self.ui_test.get_component() + #Select rows 76-1125 in sheet 3 (Daily), right click, Delete Rows. Instant crash. + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A76:A1125"})) + self.xUITest.executeCommand(".uno:SelectRow") + #delete rows + self.xUITest.executeCommand(".uno:DeleteRows") + #A1 should be "Dist" + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist") + #- Undo-redo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist") + + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Dist") + + self.ui_test.close_doc() + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |