diff options
Diffstat (limited to 'sc/qa/uitest/calc_tests')
105 files changed, 2828 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: |