diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /sc/qa/uitest/calc_tests | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
97 files changed, 7610 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..6a24d6df9 --- /dev/null +++ b/sc/qa/uitest/calc_tests/CalcPasteOnly.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell + +class CalcPasteOnly(UITestCase): + + def test_paste_only(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "=SUM(A2:A3)") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:Copy") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:PasteOnlyText") + self.assertEqual(get_cell_by_position(document, 0, 2, 0).getString(), "") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:PasteOnlyValue") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 3, 0).getValue(), 0) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + self.xUITest.executeCommand(".uno:PasteOnlyFormula") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getString(), "0") + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getValue(), 0) + self.assertEqual(get_cell_by_position(document, 0, 4, 0).getFormula(), "=SUM(E2:E3)") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/CellDropDownItems.py b/sc/qa/uitest/calc_tests/CellDropDownItems.py new file mode 100644 index 000000000..86fceeca2 --- /dev/null +++ b/sc/qa/uitest/calc_tests/CellDropDownItems.py @@ -0,0 +1,84 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +class CellDropDownItems(UITestCase): + + def test_dropdownitems(self): + + #This is to test Dropdown items in grid window + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #select cell C10 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"})) + + #Open Validation Dialog + with self.ui_test.execute_dialog_through_command(".uno:Validation") as xDialog: + + #Select List option + xallow = xDialog.getChild("allow") + select_pos(xallow, "6") + + #Add items to the List + xminlist = xDialog.getChild("minlist") + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item1"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item2"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item3"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item4"})) + xminlist.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + xminlist.executeAction("TYPE", mkPropertyValues({"TEXT": "Item5"})) + + #Close the dialog + + #Launch the Select Menu to view the list ans select first item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('0') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item1") + + #Launch the Select Menu to view the list ans select Third item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('2') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item3") + + #Launch the Select Menu to view the list ans select Fifth item in the list + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "2", "ROW": "9"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild('4') + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(document, 0, 2, 9).getString(), "Item5") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/Comments.py b/sc/qa/uitest/calc_tests/Comments.py new file mode 100644 index 000000000..b52437a48 --- /dev/null +++ b/sc/qa/uitest/calc_tests/Comments.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class Comments(UITestCase): + def test_comment(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + # Select Cell D8 + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D8"})) + + # Create comment and open it's window + gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) + + # Write text in the Comment Window + gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "First Comment"})) + + # Close Comment Window + gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) + + # Check on the comment text + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "First Comment") + + # Check on comment in another cell + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"OPEN": ""})) + gridwin.executeAction("TYPE", mkPropertyValues({"TEXT": "Second Comment"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"CLOSE":""})) + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Second Comment") + + # Write Comment without opening Comment window + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B5"})) + gridwin.executeAction("COMMENT", mkPropertyValues({"SETTEXT": "Third Comment"})) + self.assertEqual(get_state_as_dict(gridwin)["CurrentCellCommentText"], "Third Comment") + + +# 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..294d60fd7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/autofill.py @@ -0,0 +1,155 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Test for the AutoFill feature - auto-fill can't increment last octet of ip addresses + +class CalcAutofill(UITestCase): + + def test_autofill(self): + with self.ui_test.load_file(get_url_for_data_file("autofill.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries"): + pass + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getValue(), 18.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 12).getValue(), 19.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 13).getValue(), 20.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 14).getValue(), 21.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 15).getValue(), 22.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 16).getValue(), 23.34) + self.assertEqual(get_cell_by_position(calc_doc, 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"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + 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"})) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 5).getValue(), 12.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 6).getValue(), 13.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 7).getValue(), 14.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 8).getValue(), 15.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 9).getValue(), 16.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 10).getValue(), 17.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 11).getValue(), 18.34) + + #Test that hidden cells are not affected / skipped in the increment process. + #Simulate selecting cell A26 and dragging the fill handle in the bottom right corner of the cell down to A32 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A26:A32"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries"): + pass + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 25).getValue(), 18.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 26).getValue(), 19.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 27).getValue(), 5.0) #hidden + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 28).getValue(), 5.0) #hidden + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 29).getString(), "hiddenA30") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 30).getValue(), 20.34) #overwrite "rows" + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 31).getValue(), 21.34) + #Simulate selecting cell A26 and dragging the fill handle in the bottom right corner of the cell up to A19 + # Note: start at empty cell A19 so Sheet - Fill Cells - Fill Series has good defaults + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A19:A26"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + 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"})) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 19).getString(), "hiddenA20") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 20).getValue(), 15.34) + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 21).getValue(), 5.0) #hidden + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 22).getValue(), 16.34) #overwrite "testing" + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 23).getValue(), 5.0) #hidden + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 24).getValue(), 17.34) #overwrite "hidden" + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 25).getValue(), 18.34) + + #Continue with the next cells with grey background + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M12:M18"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries"): + pass + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 12).getString(), "12abc41") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 13).getString(), "12abc42") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 14).getString(), "12abc43") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 15).getString(), "12abc44") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 16).getString(), "12abc45") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 17).getString(), "12abc46") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "M6:M12"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + 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"})) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 5).getString(), "12abc34") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 6).getString(), "12abc35") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 7).getString(), "12abc36") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 8).getString(), "12abc37") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 9).getString(), "12abc38") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 10).getString(), "12abc39") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 11).getString(), "12abc40") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P12:P18"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries"): + pass + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 11).getString(), "10.64.127.7") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 12).getString(), "10.64.127.8") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 13).getString(), "10.64.127.9") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 14).getString(), "10.64.127.10") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 15).getString(), "10.64.127.11") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 16).getString(), "10.64.127.12") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 17).getString(), "10.64.127.13") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "P6:P12"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + 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"})) + #Compare with the content in the right next column + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 5).getString(), "10.64.127.1") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 6).getString(), "10.64.127.2") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 7).getString(), "10.64.127.3") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 8).getString(), "10.64.127.4") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 9).getString(), "10.64.127.5") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 10).getString(), "10.64.127.6") + self.assertEqual(get_cell_by_position(calc_doc, 0, 15, 11).getString(), "10.64.127.7") + + def test_autofill_with_suffix(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1st") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B2"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1st") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "2nd") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "3rd") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/autosum.py b/sc/qa/uitest/calc_tests/autosum.py new file mode 100644 index 000000000..cc67bae05 --- /dev/null +++ b/sc/qa/uitest/calc_tests/autosum.py @@ -0,0 +1,250 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#AutoSum feature test + +class calcAutosum(UITestCase): + + def test_autosum_test1(self): + #Sum on range and Sum on Sum's + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #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(calc_doc, 0, 1, 9).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 9).getFormula(), "=SUM(B8:B9)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 12).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 12).getFormula(), "=SUM(B11:B12)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 13).getValue(), 4) + self.assertEqual(get_cell_by_position(calc_doc, 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(calc_doc, 0, 5, 13).getValue(), 4) + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 13).getFormula(), "=SUM(F13:F13;F10:F10)") + + def test_autosum_test2(self): + #Sum on Row and Column + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + 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(calc_doc, 0, 4, 24).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 24).getFormula(), "=SUM(E22:E24)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 25).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 25).getFormula(), "=SUM(B26:D26)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 26).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 26).getFormula(), "=SUM(B27:D27)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 27).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 27).getFormula(), "=SUM(B28:D28)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 28).getValue(), 9) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 28).getFormula(), "=SUM(E26:E28)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 29).getValue(), 12) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 29).getFormula(), "=SUM(E29:E29;E25:E25)") + + def test_autosum_test3(self): + #Subtotals on Autosum + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C49"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 48).getValue(), 20) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 48).getFormula(), "=SUBTOTAL(9;C38:C48)") + + def test_autosum_test4(self): + #Autosum on column with selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B59:B64"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 63).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 63).getFormula(), "=SUM(B59:B63)") + + def test_autosum_test5(self): + #5.Autosum on rows with selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B76:E80"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 75).getValue(), 30) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 75).getFormula(), "=SUM(B76:D76)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 76).getValue(), 60) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 76).getFormula(), "=SUM(B77:D77)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 77).getValue(), 90) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 77).getFormula(), "=SUM(B78:D78)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 78).getValue(), 120) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 78).getFormula(), "=SUM(B79:D79)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 79).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 79).getFormula(), "=SUM(B80:D80)") + + def test_autosum_test6(self): + #6.Subtotal on column with selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C92:C101"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 100).getValue(), 19) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 100).getFormula(), "=SUBTOTAL(9;C92:C100)") + + def test_autosum_test7(self): + #7.Autosum on column without selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B109:B113"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 113).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 113).getFormula(), "=SUM(B109:B113)") + + def test_autosum_test8(self): + #8.Autosum on rows without selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + 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(calc_doc, 0, 4, 125).getValue(), 30) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 125).getFormula(), "=SUM(B126:D126)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 127).getValue(), 90) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 127).getFormula(), "=SUM(B128:D128)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 129).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 129).getFormula(), "=SUM(B130:D130)") + + def test_autosum_test9(self): + #9.Subtotal on column without selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C142:C149"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 150).getValue(), 19) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 150).getFormula(), "=SUBTOTAL(9;C142:C149)") + + def test_autosum_test10(self): + #10.Autosum on multiselected columns without selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B160:D164"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 164).getFormula(), "=SUM(B160:B164)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 164).getFormula(), "=SUM(C160:C164)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 164).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 164).getFormula(), "=SUM(D160:D164)") + + def test_autosum_test11(self): + #11.Autosum on columns with formula results without selected empty cell for result + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B173:D177"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 1, 177).getValue(),2), 2.55) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 177).getFormula(), "=SUM(B173:B177)") + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 2, 177).getValue(),2), -4.91) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 177).getFormula(), "=SUM(C173:C177)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 177).getValue(), 5500) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 177).getFormula(), "=SUM(D173:D177)") + + def test_autosum_test12(self): + #12.Autosum on column with filled cell under selected area + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B186:D190"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 191).getFormula(), "=SUM(B186:B190)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 191).getFormula(), "=SUM(C186:C190)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 191).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 191).getFormula(), "=SUM(D186:D190)") + + def test_autosum_test13(self): + #13.Autosum on column and rows with empty cells selected for row and column + with self.ui_test.load_file(get_url_for_data_file("autosum.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B203:E208"})) + self.xUITest.executeCommand(".uno:AutoSum") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 207).getFormula(), "=SUM(B203:B207)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 207).getFormula(), "=SUM(C203:C207)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 207).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 207).getFormula(), "=SUM(D203:D207)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 207).getValue(), 450) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 207).getFormula(), "=SUM(B208:D208)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 202).getValue(), 30) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 202).getFormula(), "=SUM(B203:D203)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 203).getValue(), 60) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 203).getFormula(), "=SUM(B204:D204)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 204).getValue(), 90) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 204).getFormula(), "=SUM(B205:D205)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 205).getValue(), 120) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 205).getFormula(), "=SUM(B206:D206)") + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 206).getValue(), 150) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 206).getFormula(), "=SUM(B207:D207)") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/calcSheetDelete.py b/sc/qa/uitest/calc_tests/calcSheetDelete.py new file mode 100644 index 000000000..3e9da3f51 --- /dev/null +++ b/sc/qa/uitest/calc_tests/calcSheetDelete.py @@ -0,0 +1,127 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +class calcSheetDelete(UITestCase): + + def test_tdf114228_insert_and_delete_sheet(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "L12"})) + nrSheets = document.Sheets.getCount() #default number + + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + 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) + + + def test_tdf43078_insert_and_delete_sheet_insert_text(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + + nrSheets = document.Sheets.getCount() #default number of sheets + + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + enter_text_to_cell(xGridWindow, "B2", "abcd") + + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 2) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 1) + + + def test_delete_more_sheets_at_once(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 6: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + i = i + 1 + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + + i = 0 + while i < 5: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 + + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 6) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + + + def test_tdf105105_delete_lots_of_sheets_at_once(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + nrSheets = document.Sheets.getCount() #default number + i = 0 + while i < 100: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + i = i + 1 + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + xToolkit.processEventsToIdle() + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + + i = 0 + while i < 99: + self.xUITest.executeCommand(".uno:JumpToNextTableSel") #select next sheet + i = i + 1 + + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + + self.assertEqual(document.Sheets.getCount(), nrSheets) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(document.Sheets.getCount(), nrSheets + 100) + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(document.Sheets.getCount(), nrSheets) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py new file mode 100644 index 000000000..dcd7c75c0 --- /dev/null +++ b/sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py @@ -0,0 +1,198 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues + +class CalcCellBackgroundColorSelector(UITestCase): + + def test_color_selector(self): + + #This is to test color selection + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + xpaletteselector = xDialog.getChild("paletteselector") + + # Now we have the ColorPage that we can get the color selector from it + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,66,14)") + + # Select Color with id 5 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "5"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "5") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "4") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 5") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(126,0,33)") + + # For libreoffice colors + select_by_text(xpaletteselector, "libreoffice") + # Select Color with id 6 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "6"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "6") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "5") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "32") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Green Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(44,238,14)") + + # Select Color with id 30 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "30"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "30") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "29") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Yellow Accent") + self.assertEqual(get_state_as_dict(color_selector)["RGB"], "(255,215,76)") + + # For html colors + select_by_text(xpaletteselector, "html") + # Select Color with id 1 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "139") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "White") + # Select Color with id 120 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "120"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "120") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "119") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Navy") + + # For freecolour-hlc colors + select_by_text(xpaletteselector, "freecolour-hlc") + # Select Color with id 988 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "988"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "988") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "987") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "1032") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 350 60 10") + # Select Color with id 575 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "575"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "575") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "574") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "HLC 190 50 20") + + # For tonal colors + select_by_text(xpaletteselector, "tonal") + # Select Color with id 17 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "17"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "17") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "16") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Cyan 82%") + # Select Color with id 13 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "13"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "13") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Magenta 82%") + + # For material colors + select_by_text(xpaletteselector, "material") + # Select Color with id 9 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "9"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "9") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "8") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "228") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Gray 800") + + # For standard colors + select_by_text(xpaletteselector, "standard") + # Select Color with id 3 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "3"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "3") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "2") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "120") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Dark Gray 3") + + + + def test_recent_color_selector(self): + + #This is to test recent color selection + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A5"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + # we will select color for cell A5 to be able to predict the latest color in + # recent color selector + xpaletteselector = xDialog.getChild("paletteselector") + xColorpage = xDialog.getChild("ColorPage") + color_selector = xColorpage.getChild("colorset") + + # For chart-palettes colors + select_by_text(xpaletteselector, "chart-palettes") + # Select Color with id 2 + color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "2"})) + self.assertEqual(get_state_as_dict(color_selector)["CurrColorId"], "2") + self.assertEqual(get_state_as_dict(color_selector)["CurrColorPos"], "1") + self.assertEqual(get_state_as_dict(color_selector)["ColorsCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColCount"], "12") + self.assertEqual(get_state_as_dict(color_selector)["ColorText"], "Chart 2") + xrgb = get_state_as_dict(color_selector)["RGB"] + + # close the dialog after selection of the color + + #select cell D3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D3"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Numbers + # click on color btn + xbtncolor = xDialog.getChild("btncolor") + xbtncolor.executeAction("CLICK",tuple()) + + xColorpage = xDialog.getChild("ColorPage") + recent_color_selector = xColorpage.getChild("recentcolorset") + + # Select Color with id 1 + recent_color_selector.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorId"], "1") + self.assertEqual(get_state_as_dict(recent_color_selector)["CurrColorPos"], "0") + self.assertEqual(get_state_as_dict(recent_color_selector)["ColorText"], "Chart 2") + self.assertEqual(get_state_as_dict(recent_color_selector)["RGB"], xrgb) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/columns.py b/sc/qa/uitest/calc_tests/columns.py new file mode 100644 index 000000000..6813471d7 --- /dev/null +++ b/sc/qa/uitest/calc_tests/columns.py @@ -0,0 +1,227 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import change_measurement_unit +from libreoffice.uno.propertyvalue import mkPropertyValues + +class CalcColumns(UITestCase): + def test_column_width(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + + # tdf#144247: Without the fix in place, this test would have failed with + # AssertionError: '2.26 cm' != '2.2578 cm' + self.assertEqual("2.26 cm", get_state_as_dict(xvalue)["Text"]) + xvalue.executeAction("UP", tuple()) + self.assertEqual("2.30 cm", get_state_as_dict(xvalue)["Text"]) + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual("2.26 cm", get_state_as_dict(xvalue)["Text"]) + + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_column_width_two_columns(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1", "EXTEND":"1"})) + + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_column_width_copy(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select column 1 + self.xUITest.executeCommand(".uno:SelectColumn") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_column_hide_show(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + self.xUITest.executeCommand(".uno:HideColumn") #uno command moves focus one cell down + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify B (column C is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "1") + #Show hidden column: select B1:D1 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:D1"})) + self.xUITest.executeCommand(".uno:ShowColumn") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 (COlumn C is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + + + def test_column_test_move(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + #right + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RIGHT"})) + #verify D1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + #verify C1 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentColumn"], "2") + + + def test_tdf117522_column_width_insert_left(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select C1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"2 cm"})) + # Click Ok + #select E1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + #column width + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"3 cm"})) + # Click Ok + #select columns C-E + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:E1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #Insert Columns Left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "E1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "F1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "2.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "H1"})) + with self.ui_test.execute_dialog_through_command(".uno:ColumnWidth") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "3.00 cm") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/fillRandomNumber.py b/sc/qa/uitest/calc_tests/fillRandomNumber.py new file mode 100644 index 000000000..da4085923 --- /dev/null +++ b/sc/qa/uitest/calc_tests/fillRandomNumber.py @@ -0,0 +1,54 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_by_text +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): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + xenableseedcheck = xDialog.getChild("enable-seed-check") + xseedspin = xDialog.getChild("seed-spin") + xenableroundingcheck = xDialog.getChild("enable-rounding-check") + xdecimalplacesspin = xDialog.getChild("decimal-places-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform Integer") + + xparameter1spin.executeAction("UP", tuple()) + xparameter2spin.executeAction("UP", tuple()) + xenableseedcheck.executeAction("CLICK", tuple()) + xseedspin.executeAction("UP", tuple()) + xenableroundingcheck.executeAction("CLICK", tuple()) + xdecimalplacesspin.executeAction("UP", tuple()) + + #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 + with self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog", close_button="close"): + pass + + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/formatCells.py b/sc/qa/uitest/calc_tests/formatCells.py new file mode 100644 index 000000000..454b69638 --- /dev/null +++ b/sc/qa/uitest/calc_tests/formatCells.py @@ -0,0 +1,406 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text +from uitest.uihelper.common import change_measurement_unit +from libreoffice.uno.propertyvalue import mkPropertyValues + +class formatCell(UITestCase): + def test_format_cell_numbers_tab(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + #language + select_by_text(xlanguagelb, "English (USA)") + #other properties + xdecimalsed.executeAction("UP", tuple()) + xleadzerosed.executeAction("UP", tuple()) + xnegnumred.executeAction("CLICK", tuple()) + xthousands.executeAction("CLICK", tuple()) + #format #,#00.0;[RED]-#,#00.0 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + #save + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xnegnumred = xDialog.getChild("negnumred") + xthousands = xDialog.getChild("thousands") + xlanguagelb = xDialog.getChild("languagelb") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Number") + self.assertEqual(get_state_as_dict(xlanguagelb)["SelectEntryText"], "English (USA)") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "1") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "2") + self.assertEqual(get_state_as_dict(xnegnumred)["Selected"], "true") + self.assertEqual(get_state_as_dict(xthousands)["Selected"], "true") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,#00.0;[RED]-#,#00.0") + + + def test_format_cell_font_tab(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + + # xNoteBook = xDialog.getChild("nbWestern") //western notebook is always active + xSizeFont = xDialog.getChild("cbWestSize") + xSizeFont.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFont.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xLangFont = xDialog.getChild("cbWestLanguage") + select_pos(xLangFont, "0") + + xNoteBook = xDialog.getChild("nbCJKCTL") + select_pos(xNoteBook, "0") + xSizeFontEast = xDialog.getChild("cbCJKSize") + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontEast.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xLangFontEast = xDialog.getChild("cbCJKLanguage") + select_pos(xLangFontEast, "0") + + select_pos(xNoteBook, "1") + xSizeFontCTL = xDialog.getChild("cbCTLSize") + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xSizeFontCTL.executeAction("TYPE", mkPropertyValues({"TEXT":"18"})) #set font size 18 + xLangFontCTL = xDialog.getChild("cbCTLLanguage") + select_pos(xLangFontCTL, "0") + + #Verify - select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + xSizeFont = xDialog.getChild("cbWestSize") + self.assertEqual(get_state_as_dict(xSizeFont)["Text"], "18 pt") + xLangFont = xDialog.getChild("cbWestLanguage") + self.assertEqual(get_state_as_dict(xLangFont)["Text"], "[None]") + + xNoteBook = xDialog.getChild("nbCJKCTL") + select_pos(xNoteBook, "0") + xSizeFontEast = xDialog.getChild("cbCJKSize") + self.assertEqual(get_state_as_dict(xSizeFontEast)["Text"], "18 pt") + xLangFontEast = xDialog.getChild("cbCJKLanguage") + self.assertEqual(get_state_as_dict(xLangFontEast)["Text"], "[None]") + + select_pos(xNoteBook, "1") + xSizeFontCTL = xDialog.getChild("cbCTLSize") + self.assertEqual(get_state_as_dict(xSizeFontCTL)["Text"], "18 pt") #check font size + xLangFontCTL = xDialog.getChild("cbCTLLanguage") + self.assertEqual(get_state_as_dict(xLangFontCTL)["Text"], "[None]") + + + + def test_format_cell_font_effects_tab(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Font Effects + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + select_pos(xRelief, "1") + select_pos(xOverline, "1") + select_pos(xStrikeout, "1") + select_pos(xUnderline, "1") + select_pos(xEmphasis, "1") + select_pos(xPosition, "1") + + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + + xRelief = xDialog.getChild("relieflb") + xOverline = xDialog.getChild("overlinelb") + xStrikeout = xDialog.getChild("strikeoutlb") + xUnderline = xDialog.getChild("underlinelb") + xEmphasis = xDialog.getChild("emphasislb") + xPosition = xDialog.getChild("positionlb") + + self.assertEqual(get_state_as_dict(xRelief)["SelectEntryText"], "Embossed") + self.assertEqual(get_state_as_dict(xOverline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xStrikeout)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xUnderline)["SelectEntryText"], "Single") + self.assertEqual(get_state_as_dict(xEmphasis)["SelectEntryText"], "Dot") + self.assertEqual(get_state_as_dict(xPosition)["SelectEntryText"], "Below text") + + + + def test_format_cell_alignment_tab(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + select_by_text(comboboxHorzAlign, "Left") + xspinIndentFrom.executeAction("UP", tuple()) + indentVal = get_state_as_dict(xspinIndentFrom)["Text"] + select_by_text(xcomboboxVertAlign, "Top") + xcheckVertStack.executeAction("CLICK", tuple()) + xcheckWrapTextAuto.executeAction("CLICK", tuple()) + xcheckHyphActive.executeAction("CLICK", tuple()) + select_by_text(xcomboTextDirBox, "Left-to-right (LTR)") + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") + comboboxHorzAlign = xDialog.getChild("comboboxHorzAlign") + xspinIndentFrom = xDialog.getChild("spinIndentFrom") + xcomboboxVertAlign = xDialog.getChild("comboboxVertAlign") + xcheckVertStack = xDialog.getChild("checkVertStack") + xcheckWrapTextAuto = xDialog.getChild("checkWrapTextAuto") + xcheckHyphActive = xDialog.getChild("checkHyphActive") + xcomboTextDirBox = xDialog.getChild("comboTextDirBox") + + self.assertEqual(get_state_as_dict(comboboxHorzAlign)["SelectEntryText"], "Left") + self.assertEqual(get_state_as_dict(xspinIndentFrom)["Text"] == indentVal, True) + self.assertEqual(get_state_as_dict(xcomboboxVertAlign)["SelectEntryText"], "Top") + self.assertEqual(get_state_as_dict(xcheckVertStack)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckWrapTextAuto)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcheckHyphActive)["Selected"], "true") + self.assertEqual(get_state_as_dict(xcomboTextDirBox)["SelectEntryText"], "Left-to-right (LTR)") + + + def test_format_cell_asian_typography_tab(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") #tab Asian typography + xcheckForbidList = xDialog.getChild("checkForbidList") + xcheckForbidList.executeAction("CLICK", tuple()) + #Verify- select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + xcheckForbidList = xDialog.getChild("checkForbidList") + self.assertEqual(get_state_as_dict(xcheckForbidList)["Selected"], "true") + + + def test_minimal_border_width(self): + #borderpage.ui, tdf#137790 + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #set points pt measurement + change_measurement_unit(self, "Point") + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + + linewidthmf = xDialog.getChild("linewidthmf") + xLineSet = xDialog.getChild('lineset') + + # check line-width for default solid line + self.assertEqual('0', get_state_as_dict(xLineSet)['SelectedItemPos']) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '0.75 pt') + + # set line style to "double" (minimal width is taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": '16'})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + # minimim predefined width is Medium (1.50 pt) + self.assertEqual(widthVal, '1.50 pt') + + # set line style to "solid" + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "1"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '1.50 pt') + + # make custom line width + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + linewidthmf.executeAction("UP", tuple()) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '2.25 pt') + + # set line style to "double" (minimal width is not taken) + xLineSet.executeAction("CHOOSE", mkPropertyValues({"POS": "8"})) + widthVal = get_state_as_dict(linewidthmf)["Text"] + self.assertEqual(widthVal, '2.25 pt') + + + + def test_format_cell_borders_tab(self): + #borderpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + #set points pt measurement + change_measurement_unit(self, "Point") + + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + xsync.executeAction("CLICK", tuple()) #uncheck Synchronize + xleftmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xrightmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xtopmf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + xbottommf.executeAction("UP", tuple()) + + leftVal = get_state_as_dict(xleftmf)["Text"] + rightVal = get_state_as_dict(xrightmf)["Text"] + topVal = get_state_as_dict(xtopmf)["Text"] + bottomVal = get_state_as_dict(xbottommf)["Text"] + + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") #tab Borders + xsync = xDialog.getChild("sync") + xleftmf = xDialog.getChild("leftmf") + xrightmf = xDialog.getChild("rightmf") + xtopmf = xDialog.getChild("topmf") + xbottommf = xDialog.getChild("bottommf") + + self.assertEqual(get_state_as_dict(xsync)["Selected"], "false") + self.assertEqual(get_state_as_dict(xleftmf)["Text"] == leftVal, True) + self.assertEqual(get_state_as_dict(xrightmf)["Text"] == rightVal, True) + self.assertEqual(get_state_as_dict(xtopmf)["Text"] == topVal, True) + self.assertEqual(get_state_as_dict(xbottommf)["Text"] == bottomVal, True) + + + + def test_format_cell_cell_protection_tab(self): + #cellprotectionpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Cell protection + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + xcheckHideFormula.executeAction("CLICK", tuple()) + xcheckHideAll.executeAction("CLICK", tuple()) + xcheckHidePrinting.executeAction("CLICK", tuple()) + + # Verify select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "6") #tab Borders + xcheckHideFormula = xDialog.getChild("checkHideFormula") + xcheckHideAll = xDialog.getChild("checkHideAll") + xcheckHidePrinting = xDialog.getChild("checkHidePrinting") + + self.assertEqual(get_state_as_dict(xcheckHideFormula)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHideAll)["Selected"], "false") + self.assertEqual(get_state_as_dict(xcheckHidePrinting)["Selected"], "false") + + + + def test_tdf130762(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "3") #tab Alignment + xspinDegrees = xDialog.getChild("spinDegrees") + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + xspinDegrees.executeAction("DOWN", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "355") + xspinDegrees.executeAction("UP", tuple()) + self.assertEqual(get_state_as_dict(xspinDegrees)["Text"].replace('°', ''), "0") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/mergedRowsColumns.py b/sc/qa/uitest/calc_tests/mergedRowsColumns.py new file mode 100644 index 000000000..8399d8b76 --- /dev/null +++ b/sc/qa/uitest/calc_tests/mergedRowsColumns.py @@ -0,0 +1,167 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class mergedRowsColumns(UITestCase): + + def test_merged_row_delete_tdf105412(self): + with self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) as calc_doc: + 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") + + def test_merged_columns_delete(self): + with self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) as calc_doc: + 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") + + def test_undo_not_available_merged_cells_tdf37901(self): + with self.ui_test.load_file(get_url_for_data_file("tdf105412.ods")) as calc_doc: + 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") + + def test_calculations_in_merged_cells_tdf51368(self): + with self.ui_test.load_file(get_url_for_data_file("tdf51368.ods")) as calc_doc: + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("move-cells-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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"})) + with self.ui_test.execute_dialog_through_command(".uno:ToggleMergeCells") as xDialog: + xMoveCells = xDialog.getChild("keep-content-radio") + xMoveCells.executeAction("CLICK", tuple()) + 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") + + def test_move_merged_cells(self): + with 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 + +# 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..b2253055c --- /dev/null +++ b/sc/qa/uitest/calc_tests/printRange.py @@ -0,0 +1,95 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class printRange(UITestCase): + def test_printRange(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #Set print range + self.xUITest.executeCommand(".uno:DefinePrintArea") + # Print Range dialog + with self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog: + 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 + + #Verify Print Range dialog + with self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea", close_button="cancel") as xDialog: + 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") + + #delete print ranges + self.xUITest.executeCommand(".uno:DeletePrintArea") + #Verify Print Range dialog + with self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog: + 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") + + def test_tdf33341_copy_sheet_with_print_range(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F20"})) + #Set print range + self.xUITest.executeCommand(".uno:DefinePrintArea") + # Print Range dialog + with self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog: + 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 + + #Copy sheet + with self.ui_test.execute_dialog_through_command(".uno:Move"): + pass + #Verify Print Range dialog on new sheet + with self.ui_test.execute_modeless_dialog_through_command(".uno:EditPrintArea") as xDialog: + 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") + + +# 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..fe65f7236 --- /dev/null +++ b/sc/qa/uitest/calc_tests/rows.py @@ -0,0 +1,192 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import change_measurement_unit +from libreoffice.uno.propertyvalue import mkPropertyValues + +class CalcRows(UITestCase): + def test_row_height(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xdefault = xDialog.getChild("default") + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "true") #default selected + + # tdf#144247: Without the fix in place, this test would have failed with + # AssertionError: '0.45 cm' != '0.4516 cm' + self.assertEqual("0.45 cm", get_state_as_dict(xvalue)["Text"]) + xvalue.executeAction("UP", tuple()) + self.assertEqual("0.50 cm", get_state_as_dict(xvalue)["Text"]) + + self.assertEqual(get_state_as_dict(xdefault)["Selected"], "false") #default not selected + xdefault.executeAction("CLICK", tuple()) #click default + self.assertEqual("0.45 cm", get_state_as_dict(xvalue)["Text"]) + + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_row_height_two_rows(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3", "EXTEND":"1"})) + + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + #write your own value + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_tdf89140_row_height_copy(self): + #Bug 89140 - Calc row paste doesn't keep row height + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select row 1 + self.xUITest.executeCommand(".uno:SelectRow") + #copy + self.xUITest.executeCommand(".uno:Copy") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #paste + self.xUITest.executeCommand(".uno:Paste") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + + def test_row_hide_show(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:HideRow") #uno command moves focus one cell down + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 (row 3 is hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + #Show hidden row: select A2:A4 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A2:A4"})) + self.xUITest.executeCommand(".uno:ShowRow") + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A3 (row 3 is not hidden) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + + + def test_row_test_move(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + #down + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"DOWN"})) + #verify A4 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"UP"})) + #verify A2 + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + + + def test_row_height_insert_below(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xvalue.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xvalue.executeAction("TYPE", mkPropertyValues({"TEXT":"1 cm"})) + # Click Ok + #select row 3 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + self.xUITest.executeCommand(".uno:SelectRow") + #insert rows below + self.xUITest.executeCommand(".uno:InsertRowsAfter") + + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A3"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A4"})) + with self.ui_test.execute_dialog_through_command(".uno:RowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual(get_state_as_dict(xvalue)["Text"], "1.00 cm") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/sheetRename.py b/sc/qa/uitest/calc_tests/sheetRename.py new file mode 100644 index 000000000..95317a111 --- /dev/null +++ b/sc/qa/uitest/calc_tests/sheetRename.py @@ -0,0 +1,86 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class sheetRename(UITestCase): + def test_sheet_rename(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName"})) + #Verify + with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="cancel") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], "NewName") + + + def test_sheet_rename_invalid_sheet_name(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:RenameTable", close_button="") as xDialog: + xname_entry = xDialog.getChild("name_entry") + nameVal = get_state_as_dict(xname_entry)["Text"] + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT":"NewName**"})) + xOKBtn = xDialog.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ())): + pass + + xCancelBtn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCancelBtn) + + #Verify + with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + self.assertEqual(get_state_as_dict(xname_entry)["Text"], nameVal) + + +# 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/tdf133855.py b/sc/qa/uitest/calc_tests/tdf133855.py new file mode 100644 index 000000000..1db7b2eee --- /dev/null +++ b/sc/qa/uitest/calc_tests/tdf133855.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file + +class tdf133855(UITestCase): + + def test_tdf133855(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf133855.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + + results = ['A', 'B', 'C', 'D', 'E', 'F'] + + # Conditional formatted dropdown list + for i in range(len(results)): + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "6", "ROW": "5"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild( str(i) ) + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 5).getString(), results[i]) + + # normal dropdown list + for i in range(len(results)): + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("LAUNCH", mkPropertyValues({"SELECTMENU": "", "COL": "6", "ROW": "6"})) + + #Select the TreeList UI Object + xWin = self.xUITest.getTopFocusWindow() + xlist = xWin.getChild("list") + + xListItem = xlist.getChild( str(i) ) + xListItem.executeAction("DOUBLECLICK" , mkPropertyValues({}) ) + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 6).getString(), results[i]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests/zoom.py b/sc/qa/uitest/calc_tests/zoom.py new file mode 100644 index 000000000..b1cbe021c --- /dev/null +++ b/sc/qa/uitest/calc_tests/zoom.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +#uitest sc / View-Zoom + +class calcZoom(UITestCase): + def test_zoom_calc(self): + with self.ui_test.create_doc_in_start_center("calc"): + MainWindow = self.xUITest.getTopFocusWindow() + gridwin = MainWindow.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "0"})) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + #Set the Zoom to be 100% + gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "100"})) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + + #dialog View-Zoom-Zoom + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + + #select fit weight & height - OK - open and verify + fitwandh = xDialog.getChild("fitwandh") + fitwandh.executeAction("CLICK",tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select fit weight - OK - open and verify + fitw = xDialog.getChild("fitw") + fitw.executeAction("CLICK",tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select 100% & Automatic - OK - open and verify + x100pc = xDialog.getChild("100pc") + x100pc.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + + #Set the Zoom to be 103% + gridwin.executeAction("SET", mkPropertyValues({"ZOOM": "103"})) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "103") + + with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog: + #select variable option and make zoom 100% again - OK - open and verify + zoomsb = xDialog.getChild("zoomsb") + self.assertEqual(get_state_as_dict(zoomsb)["Text"], "103%") + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) + zoomsb.executeAction("DOWN",tuple()) + self.assertEqual(get_state_as_dict(gridwin)["Zoom"], "100") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/consolidate.py b/sc/qa/uitest/calc_tests2/consolidate.py new file mode 100644 index 000000000..19da793c0 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/consolidate.py @@ -0,0 +1,106 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class consolidate(UITestCase): + def test_consolidate(self): + with self.ui_test.load_file(get_url_for_data_file("consolidate.ods")) as calc_doc: + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + + select_by_text(xfunc, "Sum") + + select_by_text(xlbdataarea, "range1") + xadd.executeAction("CLICK", tuple()) + select_by_text(xlbdataarea, "range2") + xadd.executeAction("CLICK", tuple()) + propsC = {"TEXT": "range3"} + actionPropsC = mkPropertyValues(propsC) + xlbdataarea.executeAction("SELECT", actionPropsC) + xadd.executeAction("CLICK", tuple()) + xbyrow.executeAction("CLICK", tuple()) + xbycol.executeAction("CLICK", tuple()) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xeddestarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Total.$A$2"})) + + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 300) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 303) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 4).getValue(), 306) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 5).getValue(), 309) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 303) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 306) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getValue(), 309) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 5).getValue(), 312) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 2).getValue(), 306) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 3).getValue(), 309) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 4).getValue(), 312) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 5).getValue(), 315) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 2).getValue(), 309) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 3).getValue(), 312) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 4).getValue(), 315) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 318) + #verify dialog + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") as xDialog: + xfunc = xDialog.getChild("func") + xlbdataarea = xDialog.getChild("lbdataarea") + xdelete = xDialog.getChild("delete") + xbyrow = xDialog.getChild("byrow") + xbycol = xDialog.getChild("bycol") + xeddestarea = xDialog.getChild("eddestarea") + xconsareas = xDialog.getChild("consareas") + self.assertEqual(get_state_as_dict(xfunc)["SelectEntryText"], "Sum") + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "3") + self.assertEqual(get_state_as_dict(xeddestarea)["Text"], "$Total.$A$2") + self.assertEqual(get_state_as_dict(xbyrow)["Selected"], "true") + self.assertEqual(get_state_as_dict(xbycol)["Selected"], "true") + #delete first range + xFirstEntry = xconsareas.getChild("0") + xFirstEntry.executeAction("SELECT", tuple()) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xconsareas)["Children"], "2") + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 2).getValue(), 200) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 3).getValue(), 202) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 4).getValue(), 204) + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 5).getValue(), 206) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 2).getValue(), 202) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 3).getValue(), 204) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getValue(), 206) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 5).getValue(), 208) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 2).getValue(), 204) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 3).getValue(), 206) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 4).getValue(), 208) + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 5).getValue(), 210) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 2).getValue(), 206) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 3).getValue(), 208) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 4).getValue(), 210) + self.assertEqual(get_cell_by_position(calc_doc, 0, 4, 5).getValue(), 212) + + # test cancel button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate", close_button="cancel"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/dataform.py b/sc/qa/uitest/calc_tests2/dataform.py new file mode 100644 index 000000000..a42d3d342 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/dataform.py @@ -0,0 +1,24 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues + +class dataform(UITestCase): + def test_dataform(self): + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A10"})) + + with self.ui_test.execute_dialog_through_command(".uno:DataForm", close_button="close"): + pass + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/standardFilter.py b/sc/qa/uitest/calc_tests2/standardFilter.py new file mode 100644 index 000000000..76d89a3cd --- /dev/null +++ b/sc/qa/uitest/calc_tests2/standardFilter.py @@ -0,0 +1,604 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 113979 - Paste unformatted text does not ignore empty cells + +class standardFilter(UITestCase): + def test_standard_filter(self): + with self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + #3x down - should be on row 9 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "8") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "a") + self.assertEqual(get_state_as_dict(xfield2)["SelectEntryText"], "b") + self.assertEqual(get_state_as_dict(xconnect2)["SelectEntryText"], "OR") + self.assertEqual(get_state_as_dict(xval1)["Text"], "1") + self.assertEqual(get_state_as_dict(xval2)["Text"], "3") + + def test_standard_filter_copy_result(self): + with self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"F1"})) + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 0).getString(), "a") + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 0).getString(), "b") + self.assertEqual(get_cell_by_position(calc_doc, 0, 7, 0).getString(), "c") + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 0, 7, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 0, 7, 2).getValue(), 4) + + def test_standard_filter_copy_result_next_sheet(self): + with self.ui_test.load_file(get_url_for_data_file("standardFilter.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C8"})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xconnect2 = xDialog.getChild("connect2") + xfield2 = xDialog.getChild("field2") + xval2 = xDialog.getChild("val2") + xcopyresult = xDialog.getChild("copyresult") + xedcopyarea = xDialog.getChild("edcopyarea") + select_by_text(xfield1, "a") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + select_by_text(xconnect2, "OR") + select_by_text(xfield2, "b") + xval2.executeAction("TYPE", mkPropertyValues({"TEXT":"3"})) + xcopyresult.executeAction("CLICK", tuple()) + xedcopyarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet2.$F$1"})) + #verify + self.assertEqual(get_cell_by_position(calc_doc, 1, 5, 0).getString(), "a") + self.assertEqual(get_cell_by_position(calc_doc, 1, 6, 0).getString(), "b") + self.assertEqual(get_cell_by_position(calc_doc, 1, 7, 0).getString(), "c") + self.assertEqual(get_cell_by_position(calc_doc, 1, 5, 1).getValue(), 1) + self.assertEqual(get_cell_by_position(calc_doc, 1, 6, 1).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 1, 7, 1).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 1, 5, 2).getValue(), 2) + self.assertEqual(get_cell_by_position(calc_doc, 1, 6, 2).getValue(), 3) + self.assertEqual(get_cell_by_position(calc_doc, 1, 7, 2).getValue(), 4) + + def test_standard_filter_case_sensitive(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "a1") + enter_text_to_cell(gridwin, "A3", "A1") + enter_text_to_cell(gridwin, "A4", "A1") + enter_text_to_cell(gridwin, "B2", "4") + enter_text_to_cell(gridwin, "B3", "5") + enter_text_to_cell(gridwin, "B4", "6") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a1"})) + xcase.executeAction("CLICK", tuple()) + #2x down - should be on row 5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcase = xDialog.getChild("case") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a1") + self.assertEqual(get_state_as_dict(xcase)["Selected"], "true") + + def test_standard_filter_regular_expression(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + enter_text_to_cell(gridwin, "B5", "4") + enter_text_to_cell(gridwin, "B6", "5") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") + + def test_standard_filter_condition_contains(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "first") + enter_text_to_cell(gridwin, "B1", "second") + enter_text_to_cell(gridwin, "A2", "aa") + enter_text_to_cell(gridwin, "A3", "aaa") + enter_text_to_cell(gridwin, "A4", "abbb") + enter_text_to_cell(gridwin, "A5", "accc") + enter_text_to_cell(gridwin, "A6", "a*") + enter_text_to_cell(gridwin, "B2", "1") + enter_text_to_cell(gridwin, "B3", "2") + enter_text_to_cell(gridwin, "B4", "3") + enter_text_to_cell(gridwin, "B5", "4") + enter_text_to_cell(gridwin, "B6", "5") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B6"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + select_by_text(xfield1, "first") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"a*"})) + xregexp.executeAction("CLICK", tuple()) + #3x down - should be on row 7 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "6") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xregexp = xDialog.getChild("regexp") + + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "first") + self.assertEqual(get_state_as_dict(xval1)["Text"], "a*") + self.assertEqual(get_state_as_dict(xregexp)["Selected"], "true") + + #from testcasespecification OOo + def test_standard_filter_condition_contains2(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Contains"/Enter value "cio"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Contains") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Contains") + + def test_standard_filter_condition_does_not_contains(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not contain") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"cio"})) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "cio") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not contain") + + + def test_standard_filter_condition_Begins_with(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Begins with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Begins with") + + + def test_standard_filter_condition_Does_not_begin_with(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not begin with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"so"})) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "so") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not begin with") + + + def test_standard_filter_condition_Ends_with(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Does not contain"/Enter value "cio"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Ends with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) + + #Verify that row 1,2, 5 are visible (3 and 4 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "4") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Ends with") + + + def test_standard_filter_condition_Does_not_end_with(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "B1", "B") + enter_text_to_cell(gridwin, "C1", "C") + enter_text_to_cell(gridwin, "D1", "D") + enter_text_to_cell(gridwin, "A2", "economics") + enter_text_to_cell(gridwin, "B2", "34") + enter_text_to_cell(gridwin, "C2", "67") + enter_text_to_cell(gridwin, "D2", "122") + enter_text_to_cell(gridwin, "A3", "socioeconomic") + enter_text_to_cell(gridwin, "B3", "45") + enter_text_to_cell(gridwin, "C3", "77") + enter_text_to_cell(gridwin, "D3", "333") + enter_text_to_cell(gridwin, "A4", "sociology") + enter_text_to_cell(gridwin, "B4", "78") + enter_text_to_cell(gridwin, "C4", "89") + enter_text_to_cell(gridwin, "D4", "56") + enter_text_to_cell(gridwin, "A5", "humanities") + enter_text_to_cell(gridwin, "B5", "45") + enter_text_to_cell(gridwin, "C5", "67") + enter_text_to_cell(gridwin, "D5", "89") + #Select + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:D5"})) + #Choose DATA-FILTER-STANDARDFILTER + #Choose field name "A"/ Choose condition "Begins with"/Enter value "si"/Press OK button + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "A") + select_by_text(xcond1, "Does not end with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"s"})) + + #Verify that row 1,3, 4 are visible (2 and 5 are hidden) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "2") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + #reopen filter and verify + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter", close_button="cancel") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "A") + self.assertEqual(get_state_as_dict(xval1)["Text"], "s") + self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf104117.py b/sc/qa/uitest/calc_tests2/tdf104117.py new file mode 100644 index 000000000..8287be14e --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf104117.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_by_text +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 104117 - Crash in Calc when selecting "Uniform Integer" with an max value "100000000000000" in "Random Number Generator +class tdf104117(UITestCase): + def test_tdf104117(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter2spin = xDialog.getChild("parameter2-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform Integer") + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"1000000000000000000000000000000000000000000000"})) + + #Verify + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), True) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), True) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf114992.py b/sc/qa/uitest/calc_tests2/tdf114992.py new file mode 100644 index 000000000..6b3a97b0e --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf114992.py @@ -0,0 +1,24 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +#Bug: Delete a sheet in a calc document and LO crashes + +class tdf114992(UITestCase): + def test_tdf114992_delete_sheet_crash(self): + with self.ui_test.load_file(get_url_for_data_file("tdf114992.ods")) as calc_doc: + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + + self.assertEqual(calc_doc.Sheets.getCount(), 1) + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(calc_doc.Sheets.getCount(), 2) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf117367.py b/sc/qa/uitest/calc_tests2/tdf117367.py new file mode 100644 index 000000000..382873a3c --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf117367.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 117367 - FORMATTING Merge cells dialog radio buttons cannot be unselected + +class tdf117367(UITestCase): + def test_tdf117367_merge_cells_radio_buttons(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B4"})) + + #Right-click - Merge cells /Select all three options + with self.ui_test.execute_dialog_through_command(".uno:MergeCells") as xDialog: + xmoveCellsRadio = xDialog.getChild("move-cells-radio") + xemptyCellsRadio = xDialog.getChild("empty-cells-radio") + xkeepContentRadio = xDialog.getChild("keep-content-radio") + xmoveCellsRadio.executeAction("CLICK", tuple()) + xmoveCellsRadio.executeAction("CLICK", tuple()) + #Issue: I think these should be exclusive, not possible to select more than one. It is also impossible to uncheck any of the buttons. + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xemptyCellsRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "true") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "false") + + xkeepContentRadio.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xmoveCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xemptyCellsRadio)["Checked"], "false") + self.assertEqual(get_state_as_dict(xkeepContentRadio)["Checked"], "true") + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf120174.py b/sc/qa/uitest/calc_tests2/tdf120174.py new file mode 100644 index 000000000..31a9f6167 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf120174.py @@ -0,0 +1,30 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +class tdf120174(UITestCase): + def test_tdf120174(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "121") + enter_text_to_cell(gridwin, "B1", "=A1") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + # Delete contents of A1 + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + # Before the fix the result would be still 121. + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 0) # B1 + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 1, 0).getValue(), 121) # B1 + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf127113.py b/sc/qa/uitest/calc_tests2/tdf127113.py new file mode 100644 index 000000000..daab2f521 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf127113.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf127113(UITestCase): + + def launch_dialog(self, direction): + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xDirection = xDialog.getChild(direction) + xDirection.executeAction("CLICK", tuple()) + + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + self.assertEqual("1", get_state_as_dict(xStart)["Text"]) + + xEnd = xDialog.getChild("endValue") + xEnd.executeAction("TYPE", mkPropertyValues({"TEXT":"5"})) + self.assertEqual("5", get_state_as_dict(xEnd)["Text"]) + + # Without the fix in place, this test would have failed because the increment child + # couldn't be empty and a warning dialog would be displayed + xIncrement = xDialog.getChild("increment") + xIncrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xIncrement.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + self.assertEqual("", get_state_as_dict(xIncrement)["Text"]) + + def test_tdf127113(self): + with self.ui_test.create_doc_in_start_center("calc") as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A9"})) + + self.launch_dialog("down") + + value = 1.0 + for i in range(9): + self.assertEqual(value, get_cell_by_position(calc_doc, 0, 0, i).getValue()) + value += 0.5 + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B9"})) + + self.launch_dialog("up") + + for i in range(9): + value -= 0.5 + self.assertEqual(value, get_cell_by_position(calc_doc, 0, 1, i).getValue()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/tdf46138.py b/sc/qa/uitest/calc_tests2/tdf46138.py new file mode 100644 index 000000000..1a07bf916 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/tdf46138.py @@ -0,0 +1,31 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 46138 - Calc Frozen after "undo" "Filling Series Number in a Column" + +class tdf46138(UITestCase): + def test_tdf46138(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #Choose a column, + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + #select 'edit'>'fill'>'series'>Starting Value '1' then "OK", + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xStart = xDialog.getChild("startValue") + xStart.executeAction("TYPE", mkPropertyValues({"TEXT":"1"})) + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "1") + #then "Ctrl+Z"/ undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests2/xmlSource.py b/sc/qa/uitest/calc_tests2/xmlSource.py new file mode 100644 index 000000000..b2038d233 --- /dev/null +++ b/sc/qa/uitest/calc_tests2/xmlSource.py @@ -0,0 +1,62 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position + +class xmlSource(UITestCase): + + def test_importXml(self): + + with self.ui_test.create_doc_in_start_center("calc") as calc_doc: + + # Create a new tab + with self.ui_test.execute_dialog_through_command(".uno:Insert") as xDialog: + xAfter = xDialog.getChild('after') + xAfter.executeAction("CLICK", tuple()) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:ManageXMLSource") as xDialog: + + xSource = xDialog.getChild("selectsource") + + with self.ui_test.execute_blocking_action(xSource.executeAction, args=('CLICK', ()), close_button="open") as xOpenDialog: + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("xmlSource.xml")})) + + xTree = xDialog.getChild("tree") + self.assertEqual('13', get_state_as_dict(xTree)["Children"]) + + xTree.getChild('0').executeAction("SELECT", tuple()) + xTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + xTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + + self.assertEqual("entry", get_state_as_dict(xTree)["SelectEntryText"]) + self.assertEqual("11", get_state_as_dict(xTree)["SelectionCount"]) + + xEdit = xDialog.getChild("edit") + xEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "$A$1"})) + + # tdf#126565: Without the fix in place, this test would have failed with + # AssertionError: '' != 'name' + for i in range(8): + self.assertEqual("", get_cell_by_position(calc_doc, 0, i, 0).getString()) + + # Check the headers + self.assertEqual("name", get_cell_by_position(calc_doc, 1, 0, 0).getString()) + self.assertEqual("translated-address", get_cell_by_position(calc_doc, 1, 1, 0).getString()) + self.assertEqual("to", get_cell_by_position(calc_doc, 1, 2, 0).getString()) + self.assertEqual("from", get_cell_by_position(calc_doc, 1, 3, 0).getString()) + self.assertEqual("source", get_cell_by_position(calc_doc, 1, 4, 0).getString()) + self.assertEqual("destination", get_cell_by_position(calc_doc, 1, 5, 0).getString()) + self.assertEqual("service", get_cell_by_position(calc_doc, 1, 6, 0).getString()) + self.assertEqual("disabled", get_cell_by_position(calc_doc, 1, 7, 0).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/clearCells.py b/sc/qa/uitest/calc_tests3/clearCells.py new file mode 100644 index 000000000..a94f2c174 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/clearCells.py @@ -0,0 +1,260 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#deletecontents.ui +#+ Bug 101904 - Delete Contents dialog -- won't delete cell content "Date & time" +class clearCells(UITestCase): + def test_clear_cells_text(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "false": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + + + def test_clear_cells_date_tdf101904(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "01/01/2000") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "false": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 1) + + + def test_clear_cells_number(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "false": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 0) + + def test_clear_cells_formulas(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "=A1+1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "false": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "true": + xformats.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "1") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + + + def test_clear_cells_formats(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + xtext = xDialog.getChild("text") + xdatetime = xDialog.getChild("datetime") + xcomments = xDialog.getChild("comments") + xobjects = xDialog.getChild("objects") + xnumbers = xDialog.getChild("numbers") + xformulas = xDialog.getChild("formulas") + xformats = xDialog.getChild("formats") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "true": + xdeleteall.executeAction("CLICK", tuple()) + if (get_state_as_dict(xtext)["Selected"]) == "true": + xtext.executeAction("CLICK", tuple()) + if (get_state_as_dict(xdatetime)["Selected"]) == "true": + xdatetime.executeAction("CLICK", tuple()) + if (get_state_as_dict(xcomments)["Selected"]) == "true": + xcomments.executeAction("CLICK", tuple()) + if (get_state_as_dict(xobjects)["Selected"]) == "true": + xobjects.executeAction("CLICK", tuple()) + if (get_state_as_dict(xnumbers)["Selected"]) == "true": + xnumbers.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformulas)["Selected"]) == "true": + xformulas.executeAction("CLICK", tuple()) + if (get_state_as_dict(xformats)["Selected"]) == "false": + xformats.executeAction("CLICK", tuple()) + + #Verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") #tab Font + + xstylelb = xDialog.getChild("cbWestStyle") + self.assertEqual(get_state_as_dict(xstylelb)["Text"], "Regular") + + def test_clear_cells_all(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + self.xUITest.executeCommand(".uno:Bold") + with self.ui_test.execute_dialog_through_command(".uno:Delete") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "") + + + def test_cancel_clear_cells_all(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "aa") + enter_text_to_cell(gridwin, "A2", "1") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_dialog_through_command(".uno:Delete", close_button="cancel") as xDialog: + xdeleteall = xDialog.getChild("deleteall") + + if (get_state_as_dict(xdeleteall)["Selected"]) == "false": + xdeleteall.executeAction("CLICK", tuple()) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString() , "aa") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString() , "1") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/insertQrCodeGen.py b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py new file mode 100644 index 000000000..a707d9918 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/insertQrCodeGen.py @@ -0,0 +1,35 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import type_text + +class insertQrCode(UITestCase): + + def test_insert_qr_code_gen(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.execute_dialog_through_command(".uno:InsertQrCode") as xDialog: + + # Get elements in the Dialog Box + xURL = xDialog.getChild("edit_text") + xECC_Low = xDialog.getChild("button_low") #How radio button input is written in text. + xBorder = xDialog.getChild("edit_margin") + + type_text(xURL, "www.libreoffice.org") #set the QR code + xECC_Low.executeAction("CLICK", tuple()) + xBorder.executeAction("UP", tuple()) + xBorder.executeAction("DOWN", tuple()) + + # check the QR code in the document + element = document.Sheets[0].DrawPage[0] + self.assertEqual(element.BarCodeProperties.Payload, "www.libreoffice.org") + self.assertEqual(element.BarCodeProperties.ErrorCorrection, 1) + self.assertEqual(element.BarCodeProperties.Border, 1) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf102506.py b/sc/qa/uitest/calc_tests3/tdf102506.py new file mode 100644 index 000000000..cd2fb8ba0 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf102506.py @@ -0,0 +1,46 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell + +class tdf102506(UITestCase): + + def test_tdf102506(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "=2+3") + + # Go to a different cell + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "C10"})) + + self.xUITest.executeCommand("vnd.sun.star.findbar:FocusToFindbar") + + xfind = xCalcDoc.getChild("find") + xfind.executeAction("TYPE", mkPropertyValues({"TEXT": "5"})) + + self.assertEqual("5", get_state_as_dict(xfind)['Text']) + + xfind_bar = xCalcDoc.getChild("FindBar") + + # Search Next + xfind_bar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) + + # Without the fix in place, this test would have failed with + # AssertionError: '0' != '2' + self.assertEqual("0", get_state_as_dict(gridwin)["CurrentColumn"]) + self.assertEqual("0", get_state_as_dict(gridwin)["CurrentRow"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf139974.py b/sc/qa/uitest/calc_tests3/tdf139974.py new file mode 100644 index 000000000..c30a05f90 --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf139974.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file + + +class tdf139974(UITestCase): + + def test_tdf139974(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf139974.ods")) as document: + + self.assertEqual(1930864179960.0, get_cell_by_position(document, 0, 0, 0).getValue()) + self.assertEqual(17204.0, get_cell_by_position(document, 0, 1, 0).getValue()) + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"})) + + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ESC"})) + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"})) + + self.xUITest.executeCommand(".uno:Paste") + + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + # Without the fix in place, this test would have failed with + # AssertionError: 17205 != 17204 + self.assertEqual(17205.0, get_cell_by_position(document, 0, 1, 1).getValue()) + + self.assertEqual(1930864179960.0, get_cell_by_position(document, 0, 0, 1).getValue()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf77509.py b/sc/qa/uitest/calc_tests3/tdf77509.py new file mode 100644 index 000000000..0cbd4a65c --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf77509.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf77509(UITestCase): + def test_tdf77509_consolidate(self): + with self.ui_test.load_file(get_url_for_data_file("tdf77509.xls")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #1. Open attachment: Consolidate-test.xls + #2. Select any empty cell, eg. cell D1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + #3. Tab: Data > Consolidate + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataConsolidate") as xDialog: + + xfunc = xDialog.getChild("func") + xeddataarea = xDialog.getChild("eddataarea") + xadd = xDialog.getChild("add") + xbyrow = xDialog.getChild("byrow") + + select_by_text(xfunc, "Sum") + #4. Source data ranges: $Sheet1.$A$1:$B$7 + #5. Click 'Add' so that ranges appear in "Consolidation ranges" + xeddataarea.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$B$7"})) + xadd.executeAction("CLICK", tuple()) + + xConsAreas = xDialog.getChild("consareas") + self.assertEqual(1, len(xConsAreas.getChildren())) + self.assertEqual("$Sheet1.$A$1:$B$7", get_state_as_dict(xConsAreas.getChild("0"))['Text']) + + #6. Click 'Options' > check 'Row labels' > click OK + xbyrow.executeAction("CLICK", tuple()) + + #verify + self.assertEqual("A 1", get_cell_by_position(calc_doc, 0, 3, 0).getString()) + self.assertEqual("AB 1", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("AB 12", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("AB 123", get_cell_by_position(calc_doc, 0, 3, 3).getString()) + self.assertEqual("ABC 1", get_cell_by_position(calc_doc, 0, 3, 4).getString()) + + self.assertEqual(1, get_cell_by_position(calc_doc, 0, 4, 0).getValue()) + self.assertEqual(2, get_cell_by_position(calc_doc, 0, 4, 1).getValue()) + self.assertEqual(2, get_cell_by_position(calc_doc, 0, 4, 2).getValue()) + self.assertEqual(1, get_cell_by_position(calc_doc, 0, 4, 3).getValue()) + self.assertEqual(1, get_cell_by_position(calc_doc, 0, 4, 4).getValue()) + + self.xUITest.executeCommand(".uno:Undo") + + self.assertEqual("", get_cell_by_position(calc_doc, 0, 3, 0).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 3, 3).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 3, 4).getString()) + + self.assertEqual(0, get_cell_by_position(calc_doc, 0, 4, 0).getValue()) + self.assertEqual(0, get_cell_by_position(calc_doc, 0, 4, 1).getValue()) + self.assertEqual(0, get_cell_by_position(calc_doc, 0, 4, 2).getValue()) + self.assertEqual(0, get_cell_by_position(calc_doc, 0, 4, 3).getValue()) + self.assertEqual(0, get_cell_by_position(calc_doc, 0, 4, 4).getValue()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf79983.py b/sc/qa/uitest/calc_tests3/tdf79983.py new file mode 100644 index 000000000..6625f049e --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf79983.py @@ -0,0 +1,66 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 79983 - Calc sort lists aren't case sensitive + +class tdf79983(UITestCase): + def test_tdf79983_sort_list_case_sensitive(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "AAA") + enter_text_to_cell(gridwin, "A2", "BBB") + enter_text_to_cell(gridwin, "A3", "CCC") + enter_text_to_cell(gridwin, "A4", "DDD") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + + #Tools / Options / LibreOffice Calc / Sort Lists + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialogOpt: + + xPages = xDialogOpt.getChild("pages") + xCalcEntry = xPages.getChild('3') # Calc + xCalcEntry.executeAction("EXPAND", tuple()) + xCalcSortEntry = xCalcEntry.getChild('5') + xCalcSortEntry.executeAction("SELECT", tuple()) #Sort List + #copy new list from selected cells + xcopy = xDialogOpt.getChild("copy") + xcopy.executeAction("CLICK", tuple()) + + self.assertEqual("AAA\nBBB\nCCC\nDDD", get_state_as_dict(xDialogOpt.getChild("entries"))['Text']) + + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DELETE"})) + + enter_text_to_cell(gridwin, "A1", "AAA") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A4"})) + #fill down + with self.ui_test.execute_dialog_through_command(".uno:FillSeries") as xDialog: + xautofill = xDialog.getChild("autofill") + xautofill.executeAction("CLICK", tuple()) + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "BBB") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "CCC") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "DDD") + #UNDO + self.xUITest.executeCommand(".uno:Undo") + #verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "AAA") + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 2).getString(), "") + self.assertEqual(get_cell_by_position(document, 0, 0, 3).getString(), "") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests3/tdf80693.py b/sc/qa/uitest/calc_tests3/tdf80693.py new file mode 100644 index 000000000..951c886fc --- /dev/null +++ b/sc/qa/uitest/calc_tests3/tdf80693.py @@ -0,0 +1,44 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import select_by_text +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 80693 - EDITING: fill cell with random numbers with min = max +class tdf80693(UITestCase): + def test_tdf80693_random_numbers_min_max(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A2"})) + with self.ui_test.execute_modeless_dialog_through_command(".uno:RandomNumberGeneratorDialog") as xDialog: + xcellrangeedit = xDialog.getChild("cell-range-edit") + xdistributioncombo = xDialog.getChild("distribution-combo") + xparameter1spin = xDialog.getChild("parameter1-spin") + xparameter2spin = xDialog.getChild("parameter2-spin") + + xcellrangeedit.executeAction("TYPE", mkPropertyValues({"TEXT":"$Sheet1.$A$1:$A$2"})) + select_by_text(xdistributioncombo, "Uniform") + + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter1spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xparameter2spin.executeAction("TYPE", mkPropertyValues({"TEXT":"2"})) + + #Verify + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getValue(), 2) + self.assertEqual(get_cell_by_position(document, 0, 0, 1).getValue() , 2) + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 0).getString() ), False) + self.assertEqual(bool(get_cell_by_position(document, 0, 0, 1).getString() ), False) +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/exportToPDF.py b/sc/qa/uitest/calc_tests4/exportToPDF.py new file mode 100644 index 000000000..a67b572e6 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/exportToPDF.py @@ -0,0 +1,80 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import os.path +from tempfile import TemporaryDirectory + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl + + +class exportToPDF(UITestCase): + + def test_checkDefaultValues(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'exportToPDFFromCalc-tmp.pdf') + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Hello World") + + # Export as PDF + with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="") as xDialog: + + selectedChildren = ['bookmarks', 'display', 'effects', 'enablea11y', 'enablecopy', 'exporturl', 'forms', 'reduceresolution'] + + for child in selectedChildren: + self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Selected']) + + nonSelectedChildren = ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders', + 'firstonleft', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfa', 'pdfua', 'resize', 'singlepagesheets', + 'tagged', 'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window'] + + for child in nonSelectedChildren: + self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Selected']) + + checkedChildren = ['allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'pageonly', 'printhigh', 'selection'] + + for child in checkedChildren: + self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) + + nonCheckedChildren = ['all', 'changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', 'fitwidth', + 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'outline', 'printlow', 'printnone', 'range', + 'singlelayout', 'thumbs', 'visiblebookmark'] + + for child in nonCheckedChildren: + self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Checked']) + + self.assertEqual("300 DPI", get_state_as_dict(xDialog.getChild("resolution"))['Text']) + self.assertEqual("90", get_state_as_dict(xDialog.getChild("quality"))['Value']) + self.assertEqual("FDF", get_state_as_dict(xDialog.getChild("format"))['DisplayText']) + + xOk = xDialog.getChild("ok") + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="open") as xSaveDialog: + xFileName = xSaveDialog.getChild('file_name') + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'})) + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'})) + xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath})) + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + self.assertEqual("Sheet1", document.DrawPages[0][0].String) + self.assertEqual("Page 1", document.DrawPages[0][1].String) + self.assertEqual("Hello World", document.DrawPages[0][2].String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/saveToCSV.py b/sc/qa/uitest/calc_tests4/saveToCSV.py new file mode 100644 index 000000000..d3876f817 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/saveToCSV.py @@ -0,0 +1,72 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import os.path +from tempfile import TemporaryDirectory + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class saveToCSV(UITestCase): + + def test_saveToCSVDialog(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'exportToCSV-tmp.csv') + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "2") + enter_text_to_cell(gridwin, "A3", "3") + enter_text_to_cell(gridwin, "A4", "=SUM(A1:A3)") + + # Save the document + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "Text CSV (.csv)") + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog: + # CSV confirmation dialog is displayed + xSave = xWarnDialog.getChild("save") + + with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog: + xFormulas = xCsvDialog.getChild("formulas") + xAsShown = xCsvDialog.getChild("asshown") + xFixedWidth = xCsvDialog.getChild("fixedwidth") + xQuoteAll = xCsvDialog.getChild("quoteall") + self.assertEqual("false", get_state_as_dict(xFormulas)['Selected']) + self.assertEqual("false", get_state_as_dict(xQuoteAll)['Selected']) + self.assertEqual("false", get_state_as_dict(xFixedWidth)['Selected']) + self.assertEqual("true", get_state_as_dict(xAsShown)['Selected']) + + xFormulas.executeAction("CLICK", tuple()) + + self.ui_test.wait_until_file_is_available(xFilePath) + + with open(xFilePath, "r") as f: + lines = f.readlines() + self.assertEqual("1", lines[0].strip()) + self.assertEqual("2", lines[1].strip()) + self.assertEqual("3", lines[2].strip()) + self.assertEqual("=SUM(A1:A3)", lines[3].strip()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf131170.py b/sc/qa/uitest/calc_tests4/tdf131170.py new file mode 100644 index 000000000..65bddc4fd --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf131170.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class tdf131170(UITestCase): + def test_DefineLabelRange(self): + with self.ui_test.load_file(get_url_for_data_file("tdf131170.ods")): + + with self.ui_test.execute_dialog_through_command(".uno:DefineLabelRange") as xDialog: + + xRange = xDialog.getChild("range") + self.assertEqual(4, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "$Sheet1.$I$6:$K$6 [AA, BB, CC]") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('3'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + xDeleteBtn = xDialog.getChild("delete") + + xRange.getChild('1').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(3, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + xRange.getChild('2').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(2, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf138089.py b/sc/qa/uitest/calc_tests4/tdf138089.py new file mode 100644 index 000000000..7ea3afd09 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf138089.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import is_row_hidden + +class tdf138089(UITestCase): + + def test_tdf138089(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf138089.xlsx")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertTrue(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 2)) + self.assertTrue(is_row_hidden(calc_doc, 3)) + self.assertFalse(is_row_hidden(calc_doc, 4)) + self.assertFalse(is_row_hidden(calc_doc, 5)) + self.assertFalse(is_row_hidden(calc_doc, 6)) + + # Without the fix in place, this test would have crashed here + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("2017-12-01", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertTrue(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 2)) + self.assertTrue(is_row_hidden(calc_doc, 3)) + self.assertFalse(is_row_hidden(calc_doc, 4)) + self.assertFalse(is_row_hidden(calc_doc, 5)) + self.assertTrue(is_row_hidden(calc_doc, 6)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf141547.py b/sc/qa/uitest/calc_tests4/tdf141547.py new file mode 100644 index 000000000..2cccba332 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf141547.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import is_row_hidden + +class tdf141547(UITestCase): + + def test_tdf141547(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf141547.xlsx")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + for i in range(1, 7): + self.assertTrue(is_row_hidden(calc_doc, i)) + + # Without the fix in place, this test would have crashed here + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("0", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + self.assertEqual("Empty", get_state_as_dict(xDialog.getChild("val2"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field2"))["DisplayText"]) + + + self.assertFalse(is_row_hidden(calc_doc, 0)) + for i in range(1, 7): + self.assertTrue(is_row_hidden(calc_doc, i)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf88999.py b/sc/qa/uitest/calc_tests4/tdf88999.py new file mode 100644 index 000000000..466a8559a --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf88999.py @@ -0,0 +1,42 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 88999 - UI: Scientific format: unable to modify number of decimal places through Sidebar or Format > Cells + +class tdf88999(UITestCase): + def test_tdf88999_scientific_format_decimal_value(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1e-2") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") + self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf89958.py b/sc/qa/uitest/calc_tests4/tdf89958.py new file mode 100644 index 000000000..6f31939fb --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf89958.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 89958 - Data->Filter->Standard Filter, condition "does not end with" does filter too much + +class tdf89958(UITestCase): + def test_td89958_standard_filter(self): + with self.ui_test.load_file(get_url_for_data_file("tdf89958.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1-> Column .uno:SelectColumn + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + + #Menu: Data->Filter->Standard Filter ... + #Field Name "Column A", Condition "Does not end with", Value: "CTORS" + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "Column A") + select_by_text(xcond1, "Does not end with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"})) + + #Expected behaviours: A2 is not filtered as it does not end with "CTORS". + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + # #reopen filter and verify - doesn't works + # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + # self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + # xDialog = self.xUITest.getTopFocusWindow() + # xfield1 = xDialog.getChild("field1") + # xval1 = xDialog.getChild("val1") + # xcond1 = xDialog.getChild("cond1") + # self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "Column A") + # self.assertEqual(get_state_as_dict(xval1)["Text"], "CTORS") + # self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") + # xCancelBtn = xDialog.getChild("cancel") + # self.ui_test.close_dialog_through_button(xCancelBtn) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py new file mode 100644 index 000000000..de42128ac --- /dev/null +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -0,0 +1,311 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +# tests for tracked changes ; tdf912270 + +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +import datetime + +class CalcTrackedChanges(UITestCase): + + def test_tdf131907(self): + with self.ui_test.load_file(get_url_for_data_file("tdf131907.ods")): + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + textStart = "Row inserted \tSheet1.1:1\t \t" + textEnd = "(Row 1:1 inserted)" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + + #it would crash here + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + + def test_tdf66263_Protect_Records(self): + with self.ui_test.create_doc_in_start_center("calc"): + self.ui_test.wait_until_child_is_available("grid_window") + self.xUITest.executeCommand(".uno:TraceChangeMode") + #protect dialog + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xconfirm = xDialog.getChild("confirm1ed") + xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + #verify password + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + + + def test_tracked_changes_accept(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + + def test_tracked_changes_acceptall(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept All tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + + def test_tracked_changes_reject(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(3, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('2'))["Text"], "Rejected") + + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd3)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd4)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + + def test_tracked_changes_rejectall(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\t \t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd4)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd3)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + + def test_tdf136062(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf136062.ods")): + + self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + xRejectAllBtn = xTrackDlg.getChild("rejectall") + xRejectBtn = xTrackDlg.getChild("reject") + xAcceptAllBtn = xTrackDlg.getChild("acceptall") + xAcceptBtn = xTrackDlg.getChild("accept") + + # Without the fix in place, it would have failed with + # AssertionError: 'R~eject All' != 'R~eject All/Clear formatting' + self.assertEqual('R~eject All', get_state_as_dict(xRejectAllBtn)['Text']) + self.assertEqual('~Reject', get_state_as_dict(xRejectBtn)['Text']) + self.assertEqual('A~ccept All', get_state_as_dict(xAcceptAllBtn)['Text']) + self.assertEqual('~Accept', get_state_as_dict(xAcceptBtn)['Text']) + + def test_tdf85353(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "15") + enter_text_to_cell(gridwin, "D1", "0") + enter_text_to_cell(gridwin, "E1", "0") + + with self.ui_test.execute_dialog_through_command(".uno:CompareDocuments", close_button="") as xOpenDialog: + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf85353.ods")})) + xOpenBtn = xOpenDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK', close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("calcchanges") + + # Without the fix in place, this test would have failed with + # AssertionError: 1 != 0 + self.assertEqual(1, len(changesList.getChildren())) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))['Text'].startswith("Changed contents\tSheet1.E1")) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))['Text'].endswith("(Cell E1 changed from '5' to '0')")) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/autoFormat.py b/sc/qa/uitest/calc_tests6/autoFormat.py new file mode 100644 index 000000000..e5ff72f07 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/autoFormat.py @@ -0,0 +1,69 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sc / AutoFormat Styles + +class autoFormat(UITestCase): + def test_autoformat_styles(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1:C5 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:C5"})) + #AutoFormat Styles + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: + + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") + + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) + + + #verify + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat") as xDialog: + + formatlb = xDialog.getChild("formatlb") + numformatcb = xDialog.getChild("numformatcb") + bordercb = xDialog.getChild("bordercb") + fontcb = xDialog.getChild("fontcb") + patterncb = xDialog.getChild("patterncb") + alignmentcb = xDialog.getChild("alignmentcb") + autofitcb = xDialog.getChild("autofitcb") + + entry = formatlb.getChild("7") #Financial + entry.executeAction("SELECT", tuple()) + self.assertEqual(get_state_as_dict(numformatcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(bordercb)["Selected"], "false") + self.assertEqual(get_state_as_dict(fontcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(patterncb)["Selected"], "false") + self.assertEqual(get_state_as_dict(alignmentcb)["Selected"], "false") + self.assertEqual(get_state_as_dict(autofitcb)["Selected"], "false") + numformatcb.executeAction("CLICK", tuple()) + bordercb.executeAction("CLICK", tuple()) + fontcb.executeAction("CLICK", tuple()) + patterncb.executeAction("CLICK", tuple()) + alignmentcb.executeAction("CLICK", tuple()) + autofitcb.executeAction("CLICK", tuple()) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/autocorrectOptions.py b/sc/qa/uitest/calc_tests6/autocorrectOptions.py new file mode 100644 index 000000000..e626ad93f --- /dev/null +++ b/sc/qa/uitest/calc_tests6/autocorrectOptions.py @@ -0,0 +1,95 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos + +class autocorrectOptions(UITestCase): + + def test_autocorrect_options_calc(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg", close_button="cancel") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab replace + origtext = xDialog.getChild("origtext") + newtext = xDialog.getChild("newtext") + xnew = xDialog.getChild("new") + xdelete = xDialog.getChild("delete") + xtabview = xDialog.getChild("tabview") + nrRows = get_state_as_dict(xtabview)["VisibleCount"] + + self.assertTrue(int(nrRows) > 0) + + #add new rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xnew.executeAction("CLICK", tuple()) + nrRowsNew = get_state_as_dict(xtabview)["VisibleCount"] + nrRowsDiff = int(nrRowsNew) - int(nrRows) + self.assertEqual(nrRowsDiff, 1) #we have +1 rule + #delete rule + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + origtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + origtext.executeAction("TYPE", mkPropertyValues({"TEXT":"::::"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newtext.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newtext.executeAction("TYPE", mkPropertyValues({"TEXT":"dvojtecky"})) + xdelete.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xtabview)["VisibleCount"], nrRows) #we have default nr of rules + + select_pos(xTabs, "1") #tab Exceptions + #abbreviations + abbrev = xDialog.getChild("abbrev") + newabbrev = xDialog.getChild("newabbrev") + delabbrev = xDialog.getChild("delabbrev") + abbrevlist = xDialog.getChild("abbrevlist") + + nrRowsAbb = get_state_as_dict(abbrevlist)["VisibleCount"] + + self.assertTrue(int(nrRowsAbb) > 0) + + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + abbrev.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + abbrev.executeAction("TYPE", mkPropertyValues({"TEXT":"qqqqq"})) + newabbrev.executeAction("CLICK", tuple()) + nrRowsAbbNew = get_state_as_dict(abbrevlist)["VisibleCount"] + nrRowsAbbDiff = int(nrRowsAbbNew) - int(nrRowsAbb) + self.assertEqual(nrRowsAbbDiff, 1) #we have +1 rule + delabbrev.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(abbrevlist)["VisibleCount"], nrRowsAbb) #we have default nr of rules + + #words with two initial capitals + double = xDialog.getChild("double") + newdouble = xDialog.getChild("newdouble") + deldouble = xDialog.getChild("deldouble") + doublelist = xDialog.getChild("doublelist") + + nrRowsDouble = get_state_as_dict(doublelist)["VisibleCount"] + + self.assertTrue(int(nrRowsDouble) > 0) + + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + double.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + double.executeAction("TYPE", mkPropertyValues({"TEXT":"QQqqq"})) + newdouble.executeAction("CLICK", tuple()) + nrRowsDoubleNew = get_state_as_dict(doublelist)["VisibleCount"] + nrRowsDoubleDiff = int(nrRowsDoubleNew) - int(nrRowsDouble) #convert string and + self.assertEqual(nrRowsDoubleDiff, 1) #we have +1 rule + deldouble.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(doublelist)["VisibleCount"], nrRowsDouble) #we have default nr of rules + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/hideShowSheet.py b/sc/qa/uitest/calc_tests6/hideShowSheet.py new file mode 100644 index 000000000..3f34fca1a --- /dev/null +++ b/sc/qa/uitest/calc_tests6/hideShowSheet.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sc / Show sheet dialog + +class hideShowSheet(UITestCase): + def test_hide_show_sheet(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #insert sheet + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + #select sheet + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"1"})) + self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "1") + #insert 2nd sheet + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + #select sheet + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE":"2"})) + self.assertEqual(get_state_as_dict(gridwin)["SelectedTable"], "1") + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/moveCopySheet.py b/sc/qa/uitest/calc_tests6/moveCopySheet.py new file mode 100644 index 000000000..a80b7c329 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/moveCopySheet.py @@ -0,0 +1,84 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +#uitest sc - move/copy sheet dialog + +class moveCopySheet(UITestCase): + def test_copy_move_sheet(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + #default - 1 sheet; select the sheet (is selected), dialog move/copy sheet + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + #new name = newName + newName = xDialog.getChild("newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"newName"})) + #verify, the file has 2 sheets; first one "newName" is selected + self.assertEqual(document.Sheets.getCount(), 2) + # dialog move/copy sheet ; Move is selected; select -move to end position - ; New Name = moveName + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + insertBefore = xDialog.getChild("insertBefore") + + xTreeEntry = insertBefore.getChild('2') + xTreeEntry.executeAction("SELECT", tuple()) + + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], "newName") + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + newName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + newName.executeAction("TYPE", mkPropertyValues({"TEXT":"moveName"})) + # Verify, the file has 2 sheets; first one is "Sheet1" ; second one is "moveName" + self.assertEqual(document.Sheets.getCount(), 2) + + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") + + # Verify that the cancel button does not do anything + with self.ui_test.execute_dialog_through_command(".uno:Move", close_button="cancel"): + pass + + self.assertEqual(document.Sheets.getCount(), 2) + self.assertEqual(document.Sheets[0].Name, "Sheet1") + self.assertEqual(document.Sheets[1].Name, "moveName") + + #Check copy option + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xCopy = xDialog.getChild("copy") + xCopy.executeAction("CLICK", tuple()) + sheetName = "moveName_2" + newName = xDialog.getChild("newName") + self.assertEqual(get_state_as_dict(newName)["Text"], sheetName) + + + self.assertEqual(document.Sheets.getCount(), 3) + self.assertEqual(document.Sheets[0].Name, sheetName) + self.assertEqual(document.Sheets[1].Name, "Sheet1") + self.assertEqual(document.Sheets[2].Name, "moveName") + + #tdf#139464 Set OK button label to selected action: Move or Copy + def test_tdf139464_move_sheet(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xOkButton = xDialog.getChild("ok") + xCopyButton = xDialog.getChild("copy") + self.assertEqual(get_state_as_dict(xCopyButton)['Text'], get_state_as_dict(xOkButton)['Text']) + with self.ui_test.execute_dialog_through_command(".uno:Move") as xDialog: + xOkButton = xDialog.getChild("ok") + xCopyButton = xDialog.getChild("copy") + xMoveButton = xDialog.getChild("move") + self.assertEqual(get_state_as_dict(xMoveButton)['Text'], get_state_as_dict(xOkButton)['Text']) + xCopyButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xCopyButton)['Text'], get_state_as_dict(xOkButton)['Text']) + xMoveButton.executeAction("CLICK", tuple()) + self.assertEqual(get_state_as_dict(xMoveButton)['Text'], get_state_as_dict(xOkButton)['Text']) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/multipleOperations.py b/sc/qa/uitest/calc_tests6/multipleOperations.py new file mode 100644 index 000000000..a796016a8 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/multipleOperations.py @@ -0,0 +1,118 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell + +#https://www.linuxtopia.org/online_books/office_guides/openoffice_3_calc_user_guide/openoffice_calc_Multiple_operations_Multiple_operations_in_columns_or_rows.html + +class multipleOperations(UITestCase): + + def test_multiple_operations_one_variable(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:E11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:E11"})) + #Choose Data > Multiple Operations. + with self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") as xDialog: + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + + def test_multiple_operations_several_formulas(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + #enter data + enter_text_to_cell(xGridWindow, "B1", "10") + enter_text_to_cell(xGridWindow, "B2", "2") + enter_text_to_cell(xGridWindow, "B3", "10000") + enter_text_to_cell(xGridWindow, "B4", "2000") + enter_text_to_cell(xGridWindow, "B5", "=B4*(B1-B2)-B3") + enter_text_to_cell(xGridWindow, "C5", "=B5/B4") + + enter_text_to_cell(xGridWindow, "D2", "500") + enter_text_to_cell(xGridWindow, "D3", "1000") + enter_text_to_cell(xGridWindow, "D4", "1500") + enter_text_to_cell(xGridWindow, "D5", "2000") + enter_text_to_cell(xGridWindow, "D6", "2500") + enter_text_to_cell(xGridWindow, "D7", "3000") + enter_text_to_cell(xGridWindow, "D8", "3500") + enter_text_to_cell(xGridWindow, "D9", "4000") + enter_text_to_cell(xGridWindow, "D10", "4500") + enter_text_to_cell(xGridWindow, "D11", "5000") + #Select the range D2:F11 + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "D2:F11"})) + #Choose Data > Multiple Operations. + with self.ui_test.execute_modeless_dialog_through_command(".uno:TableOperationDialog") as xDialog: + #Formulas = B5 ; Column input cell = B4 + formulas = xDialog.getChild("formulas") + col = xDialog.getChild("col") + formulas.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$5:$C$5"})) + col.executeAction("TYPE", mkPropertyValues({"TEXT":"$B$4"})) + #verify + self.assertEqual(get_cell_by_position(document, 0, 4, 1).getValue(), -6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 2).getValue(), -2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 3).getValue(), 2000) + self.assertEqual(get_cell_by_position(document, 0, 4, 4).getValue(), 6000) + self.assertEqual(get_cell_by_position(document, 0, 4, 5).getValue(), 10000) + self.assertEqual(get_cell_by_position(document, 0, 4, 6).getValue(), 14000) + self.assertEqual(get_cell_by_position(document, 0, 4, 7).getValue(), 18000) + self.assertEqual(get_cell_by_position(document, 0, 4, 8).getValue(), 22000) + self.assertEqual(get_cell_by_position(document, 0, 4, 9).getValue(), 26000) + self.assertEqual(get_cell_by_position(document, 0, 4, 10).getValue(), 30000) + + self.assertEqual(get_cell_by_position(document, 0, 5, 1).getValue(), -12) + self.assertEqual(get_cell_by_position(document, 0, 5, 2).getValue(), -2) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 3).getValue(),2), 1.33) + self.assertEqual(get_cell_by_position(document, 0, 5, 4).getValue(), 3) + self.assertEqual(get_cell_by_position(document, 0, 5, 5).getValue(), 4) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 6).getValue(),2), 4.67) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 7).getValue(),2), 5.14) + self.assertEqual(get_cell_by_position(document, 0, 5, 8).getValue(), 5.5) + self.assertEqual(round(get_cell_by_position(document, 0, 5, 9).getValue(),2), 5.78) + self.assertEqual(get_cell_by_position(document, 0, 5, 10).getValue(), 6) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/scenarios.py b/sc/qa/uitest/calc_tests6/scenarios.py new file mode 100644 index 000000000..583c0b1ce --- /dev/null +++ b/sc/qa/uitest/calc_tests6/scenarios.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +# uitest Tools - Scenarios + +class scenarios(UITestCase): + + def test_scenarios(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + #fill B1:B4 with 1, select B1:B4; + enter_text_to_cell(xGridWindow, "B1", "1") + enter_text_to_cell(xGridWindow, "B2", "1") + enter_text_to_cell(xGridWindow, "B3", "1") + enter_text_to_cell(xGridWindow, "B4", "1") + xGridWindow.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B4"})) + #scenarios - scenario A1 + with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"A1"})) + + #next scenarios - scenario B1 + with self.ui_test.execute_dialog_through_command(".uno:ScenarioManager") as xDialog: + + name = xDialog.getChild("name") + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + name.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + name.executeAction("TYPE", mkPropertyValues({"TEXT":"B1"})) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/shareSpreadsheet.py b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py new file mode 100644 index 000000000..265d4a2d1 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/shareSpreadsheet.py @@ -0,0 +1,27 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict + +#just open dialog, select Share, check name and cancel [save not allowed in uitest] + +class shareSpreadsheet(UITestCase): + + def test_share_spreadsheet(self): + with self.ui_test.create_doc_in_start_center("calc"): + #dialog shareSpreadsheet + with self.ui_test.execute_dialog_through_command(".uno:ShareDocument", close_button="cancel") as xDialog: + + share = xDialog.getChild("share") + share.executeAction("CLICK", tuple()) + users = xDialog.getChild("users") + self.assertEqual(get_state_as_dict(users)["Children"], "1") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf104378.py b/sc/qa/uitest/calc_tests6/tdf104378.py new file mode 100644 index 000000000..3f1eaa819 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf104378.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.calc.document import get_cell_by_position + +class tdf104378(UITestCase): + + def test_tdf104378(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "遠程MySQL連接遠程MySQL連接遠程MySQL連接") + + with self.ui_test.execute_dialog_through_command(".uno:ChineseConversion"): + pass + + + # Without the fix in place, this test would have failed with + # - 远程MySQL連接遠程MySQL連接遠程MySQL連接 + # + 远程MySQL连接远程MySQL连接远程MySQL连接 + self.assertEqual(get_cell_by_position( + document, 0, 0, 0).getString(), "远程MySQL连接远程MySQL连接远程MySQL连接") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf107267.py b/sc/qa/uitest/calc_tests6/tdf107267.py new file mode 100644 index 000000000..8ff9a19ba --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf107267.py @@ -0,0 +1,60 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import get_url_for_data_file, get_state_as_dict + +#Bug 107267 - During a sub-total calculation or sum, the data set is not computed well. +class Subtotals(UITestCase): + + + def test_tdf107267(self): + with self.ui_test.load_file(get_url_for_data_file("tdf107267.ods")) as calc_doc: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + # 1. Open the test file + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:F123"})) + # 2. Data->Subtotals + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + + select_pos(xTabs, "0") + xGroupBy1 = xDialog.getChild("group_by1") + self.assertEqual("Person Number", get_state_as_dict(xGroupBy1)["SelectEntryText"]) + + xColumns1 = xDialog.getChild("columns1") + self.assertEqual("shipping time", get_state_as_dict(xColumns1)["SelectEntryText"]) + + select_pos(xTabs, "1") + xGroupBy2 = xDialog.getChild("group_by2") + self.assertEqual("Person Number", get_state_as_dict(xGroupBy2)["SelectEntryText"]) + + xColumns2 = xDialog.getChild("columns2") + self.assertEqual("shipping time", get_state_as_dict(xColumns2)["SelectEntryText"]) + + select_pos(xTabs, "2") + xGroupBy3 = xDialog.getChild("group_by3") + self.assertEqual("Person Number", get_state_as_dict(xGroupBy3)["SelectEntryText"]) + + xColumns3 = xDialog.getChild("columns3") + self.assertEqual("shipping time", get_state_as_dict(xColumns3)["SelectEntryText"]) + + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 141).getString(), "Grand Average") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 142).getString(), "Grand Min") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 143).getString(), "Grand Max") + + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 5, 141).getValue(), 13), 3.3852459016393) + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 142).getValue(), 0) + self.assertEqual(get_cell_by_position(calc_doc, 0, 5, 143).getValue(), 26) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf116996.py b/sc/qa/uitest/calc_tests6/tdf116996.py new file mode 100644 index 000000000..7e3f4e61c --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf116996.py @@ -0,0 +1,47 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict + +#Bug 116996 - Crash recover on selecting Tools -> Options -> Advanced: Enable experimental features + +class tdf116996(UITestCase): + def test_tdf116996_enable_experimental_feature(self): + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + xexperimental.executeAction("CLICK", tuple()) #enable experimental features + + xOKBtn = xDialogOpt.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass + + #reopen options dialog and verify + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog", close_button="") as xDialogOpt: + xPages = xDialogOpt.getChild("pages") + xLOEntry = xPages.getChild('0') # Libreoffice + xLOEntry.executeAction("EXPAND", tuple()) + xAdvancedEntry = xLOEntry.getChild('10') + xAdvancedEntry.executeAction("SELECT", tuple()) #Libreoffice / Advanced + xexperimental = xDialogOpt.getChild("experimental") + + self.assertEqual(get_state_as_dict(xexperimental)["Selected"], "true") + xexperimental.executeAction("CLICK", tuple()) #disable experimental features + xOKBtn = xDialogOpt.getChild("ok") + + with self.ui_test.execute_blocking_action(xOKBtn.executeAction, args=('CLICK', ()), close_button="no"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf118638.py b/sc/qa/uitest/calc_tests6/tdf118638.py new file mode 100644 index 000000000..c928aa388 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf118638.py @@ -0,0 +1,54 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text +from uitest.uihelper.common import get_url_for_data_file +#Bug 118638 - subtotal option loses doesn't contain existing format for column +class Subtotals(UITestCase): + + + def test_tdf118638_subtotal_format(self): + with self.ui_test.load_file(get_url_for_data_file("tdf118638.ods")) as calc_doc: + XcalcDoc = self.xUITest.getTopFocusWindow() + gridwin = XcalcDoc.getChild("grid_window") + # Open the test file + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:B15"})) + #Data->Subtotals + with self.ui_test.execute_dialog_through_command(".uno:DataSubTotals") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + xGroupBy = xDialog.getChild("group_by1") + select_by_text(xGroupBy, "Store Name") + xCheckListMenu = xDialog.getChild("grid1") + xTreeList = xCheckListMenu.getChild("columns1") + xEntry = xTreeList.getChild("1") + xEntry.executeAction("CLICK", tuple()) + + #use the SUM function + # xfunctions = xDialog.getChild("functions") + # propsF = {"TEXT": "Sum"} + # actionPropsF = mkPropertyValues(propsF) + # xfunctions.executeAction("SELECT", actionPropsF) + + + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 15).getString(), "5408 Sum") + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 16).getString(), "Grand Sum") + + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 1, 15).getValue(),12), 238.89) + self.assertEqual(round(get_cell_by_position(calc_doc, 0, 1, 16).getValue(),12), 238.89) + + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 15).getString(), "$238.89") + self.assertEqual(get_cell_by_position(calc_doc, 0, 1, 16).getString(), "$238.89") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf121263.py b/sc/qa/uitest/calc_tests6/tdf121263.py new file mode 100644 index 000000000..3b663c4dd --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf121263.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from libreoffice.uno.propertyvalue import mkPropertyValues + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict + +class tdf121263(UITestCase): + + def test_tdf121263_hide_more_sheets(self): + with self.ui_test.create_doc_in_start_center("calc"): + xTopWindow = self.xUITest.getTopFocusWindow() + gridwin = xTopWindow.getChild("grid_window") + + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "2"})) + #select previous sheet + self.xUITest.executeCommand(".uno:JumpToPrevTableSel") + + #hide sheet + self.xUITest.executeCommand(".uno:Hide") + + #show sheet Dialog + with self.ui_test.execute_dialog_through_command(".uno:Show", close_button="cancel") as xDialog: + treeview = xDialog.getChild("treeview") + self.assertEqual(get_state_as_dict(treeview)["Children"], "2") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf147830.py b/sc/qa/uitest/calc_tests6/tdf147830.py new file mode 100644 index 000000000..521cca659 --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf147830.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file, get_state_as_dict, select_by_text +from libreoffice.calc.document import is_row_hidden + +class tdf147830(UITestCase): + + def test_tdf147830(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf147830.ods")) as calc_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterSpecialFilter") as xDialog: + xFilterArea = xDialog.getChild("lbfilterarea") + self.assertEqual("- undefined -", get_state_as_dict(xFilterArea)["SelectEntryText"]) + self.assertEqual("5", get_state_as_dict(xFilterArea)["EntryCount"]) + + select_by_text(xFilterArea, "Irgendwo") + + xEditFilterArea = xDialog.getChild("edfilterarea") + self.assertEqual("$Filterkriterien.$A$40:$AMF$60", get_state_as_dict(xEditFilterArea)["Text"]) + + # Without the fix in place, this test would have crashed here + + self.assertFalse(is_row_hidden(calc_doc, 0)) + for i in range(1, 17): + self.assertTrue(is_row_hidden(calc_doc, i)) + + self.assertFalse(is_row_hidden(calc_doc, 17)) + self.assertTrue(is_row_hidden(calc_doc, 18)) + self.assertTrue(is_row_hidden(calc_doc, 19)) + self.assertTrue(is_row_hidden(calc_doc, 20)) + + for i in range(21, 26): + self.assertFalse(is_row_hidden(calc_doc, i)) + + self.assertTrue(is_row_hidden(calc_doc, 27)) + self.assertFalse(is_row_hidden(calc_doc, 28)) + self.assertFalse(is_row_hidden(calc_doc, 29)) + + self.xUITest.executeCommand(".uno:Undo") + + for i in range(30): + self.assertFalse(is_row_hidden(calc_doc, i)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests6/tdf91726.py b/sc/qa/uitest/calc_tests6/tdf91726.py new file mode 100644 index 000000000..4c6ff5b0f --- /dev/null +++ b/sc/qa/uitest/calc_tests6/tdf91726.py @@ -0,0 +1,50 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 91726 - AutoFormat: Crash when using an existing name for a new preset + +class tdf91726(UITestCase): + def test_tdf91726_new_style(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1:E9 + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:E9"})) + #AutoFormat Styles + with self.ui_test.execute_dialog_through_command(".uno:AutoFormat", close_button="") as xDialog: + #add new style "Default" + xadd = xDialog.getChild("add") + + # Use empty close_button to open consecutive dialogs + with self.ui_test.execute_blocking_action( + xadd.executeAction, args=('CLICK', ()), close_button="") as dialog: + nameEntry = dialog.getChild("name_entry") + nameEntry.executeAction("TYPE", mkPropertyValues({"TEXT":"Default"})) + xOKBtn = dialog.getChild("ok") + + with self.ui_test.execute_blocking_action( + xOKBtn.executeAction, args=('CLICK', ()), close_button="") as dialog2: + #Error message: You have entered an invalid name. + #AutoFormat could not be created. + #Try again using a different name. + xOKBtn2 = dialog2.getChild("ok") + + with self.ui_test.execute_blocking_action( + xOKBtn2.executeAction, args=('CLICK', ()), close_button="cancel") as dialog3: + nameEntry = dialog3.getChild("name_entry") + #back to name dialog, LO should not crash + self.assertEqual(get_state_as_dict(nameEntry)["Text"], "Default") + + xCanceltn = xDialog.getChild("cancel") + self.ui_test.close_dialog_through_button(xCanceltn) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/save_readonly_with_password.py b/sc/qa/uitest/calc_tests7/save_readonly_with_password.py new file mode 100644 index 000000000..02f125e30 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/save_readonly_with_password.py @@ -0,0 +1,97 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl +from uitest.uihelper.common import select_by_text +from tempfile import TemporaryDirectory +import os.path + +class save_readonly_with_password(UITestCase): + + def test_save_to_xlsx(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "readonly_with_password_tmp.xlsx") + + with self.ui_test.create_doc_in_start_center("calc"): + # Save the document + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "Excel 2007–365 (.xlsx)") + xPasswordCheckButton = xSaveDialog.getChild("password") + xPasswordCheckButton.executeAction("CLICK", tuple()) + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xPasswordDialog: + xReadonly = xPasswordDialog.getChild("readonly") + xReadonly.executeAction("CLICK", tuple()) + xNewPassword = xPasswordDialog.getChild("newpassroEntry") + xNewPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + xConfirmPassword = xPasswordDialog.getChild("confirmropassEntry") + xConfirmPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + xOk = xPasswordDialog.getChild("ok") + # XLSX confirmation dialog is displayed + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + pass + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + + def test_save_to_ods(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "readonly_with_password_tmp.ods") + + with self.ui_test.create_doc_in_start_center("calc"): + # Save the document + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xPasswordCheckButton = xSaveDialog.getChild("password") + xPasswordCheckButton.executeAction("CLICK", tuple()) + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xPasswordDialog: + xReadonly = xPasswordDialog.getChild("readonly") + xReadonly.executeAction("CLICK", tuple()) + xNewPassword = xPasswordDialog.getChild("newpassroEntry") + xNewPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + xConfirmPassword = xPasswordDialog.getChild("confirmropassEntry") + xConfirmPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf106667.py b/sc/qa/uitest/calc_tests7/tdf106667.py new file mode 100644 index 000000000..8d3c4599c --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf106667.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position + +class tdf106667(UITestCase): + + def test_tdf106667_about_dlg_all(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1000"})) + + self.xUITest.executeCommand(".uno:FillDown") + + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_dialog_through_command(".uno:About", close_button="btnClose"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "A") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf117987.py b/sc/qa/uitest/calc_tests7/tdf117987.py new file mode 100644 index 000000000..2a15dedcb --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf117987.py @@ -0,0 +1,29 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position + +class tdf117987(UITestCase): + + def test_highlight_cell_after_moving_cursor(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + colorProperty = mkPropertyValues({"BackgroundColor": 16776960}) + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.xUITest.executeCommandWithParameters(".uno:BackgroundColor", colorProperty) + + self.assertEqual(get_cell_by_position(document, 0, 0, 1).CellBackColor, 16776960) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests7/tdf122509.py b/sc/qa/uitest/calc_tests7/tdf122509.py new file mode 100644 index 000000000..c0d9f5a2a --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf122509.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 122509 - EDITING Calc crashes when manipulating Negative numbers in red on Currency ( not gtk3 ) + +class tdf122509(UITestCase): + def test_tdf122509_format_cell_negative_numbers(self): + #numberingformatpage.ui + with self.ui_test.load_file(get_url_for_data_file("tdf122509.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xnegnumred = xDialog.getChild("negnumred") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];[RED]-#,##0.00 [$USD]") + #click negative + xnegnumred.executeAction("CLICK", tuple()) + #format check; https://bugs.documentfoundation.org/show_bug.cgi?id=122509#c7 + self.assertEqual(get_state_as_dict(xformatted)["Text"], "#,##0.00 [$USD];-#,##0.00 [$USD]") + # click negative + xnegnumred.executeAction("CLICK", tuple()) + #OK + #verify; no crashes + self.assertEqual(get_cell_by_position(calc_doc, 0, 0, 0).getValue(), 2) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf123122.py b/sc/qa/uitest/calc_tests7/tdf123122.py new file mode 100644 index 000000000..8d1d6daeb --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf123122.py @@ -0,0 +1,48 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 123122 - Invoking the number format dialog the format code field is blank for a user-defined date+time format. + +class tdf123122(UITestCase): + def test_tdf123122_format_cell_datetime(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xformatted = xDialog.getChild("formatted") + + #Format cells and enter NN MMM DD YYYY HH:MM as format code + xformatted.executeAction("CLEAR", tuple()) #clear textbox + xformatted.executeAction("TYPE", mkPropertyValues({"TEXT":"NN MMM DD YYYY HH:MM"})) + #save - OK + + #verify + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xformatted = xDialog.getChild("formatted") + + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Date") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "NN MMM DD YYYY HH:MM") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf124896.py b/sc/qa/uitest/calc_tests7/tdf124896.py new file mode 100644 index 000000000..44c6ba4b2 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf124896.py @@ -0,0 +1,24 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +# Bug 124896 - CRASH: deleting sheet + +class tdf124896(UITestCase): + def test_tdf124896_crash_delete_sheet(self): + with self.ui_test.load_file(get_url_for_data_file("tdf124896.ods")) as calc_doc: + # Remove X Bar R Chart (2) sheet + with self.ui_test.execute_dialog_through_command(".uno:Remove", close_button="yes"): + pass + + #verify; no crashes + self.assertEqual(calc_doc.Sheets.getCount(), 2) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf125030.py b/sc/qa/uitest/calc_tests7/tdf125030.py new file mode 100644 index 000000000..cc49edd21 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf125030.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell + +#Bug 125030 - nice crash by repeating apply style (Ctrl+Shft+Y) + +class tdf125030(UITestCase): + def test_tdf125030_repeat_crash(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #enter data + enter_text_to_cell(gridwin, "A1", "aaaa") + enter_text_to_cell(gridwin, "B1", "bbbb") + #select A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:StyleApply?Style:string=Heading%201&FamilyName:string=CellStyles") + #focus on A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #repeat (Ctrl+Shft+Y) + self.xUITest.executeCommand(".uno:Repeat") + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "aaaa") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf137397.py b/sc/qa/uitest/calc_tests7/tdf137397.py new file mode 100644 index 000000000..c98a706d2 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf137397.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import change_measurement_unit + +class tdf137397(UITestCase): + + def test_tdf137397(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf137397.ods")): + + change_measurement_unit(self, 'Centimeter') + + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + xGridWin.executeAction("SELECT", mkPropertyValues({"OBJECT": "Shape"})) + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"})) + + xChild = self.ui_test.wait_until_child_is_available('selectwidth') + self.assertEqual(get_state_as_dict(xChild)['Text'], '6.00 cm') + + # Without the fix in place, this test would have failed with + # AssertionError: '-14,585,309.84 cm' != '2.00 cm' + xChild = self.ui_test.wait_until_child_is_available('selectheight') + self.assertEqual(get_state_as_dict(xChild)['Text'], '2.00 cm') + + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf150044.py b/sc/qa/uitest/calc_tests7/tdf150044.py new file mode 100644 index 000000000..6e42358d7 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf150044.py @@ -0,0 +1,69 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl +from uitest.uihelper.common import select_by_text +from tempfile import TemporaryDirectory +import os.path + +class save_shared_readonly_with_password(UITestCase): + + def test_save_to_shared_ods(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "shared_readonly_with_password_tmp.ods") + + with self.ui_test.create_doc_in_start_center("calc"): + with self.ui_test.execute_dialog_through_command(".uno:ShareDocument", close_button="") as xShareDocumentDialog: + xShareCheckButton = xShareDocumentDialog.getChild("share") + xShareCheckButton.executeAction("CLICK", tuple()) + xOk = xShareDocumentDialog.getChild("ok") + # Save the document + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xPasswordCheckButton = xSaveDialog.getChild("password") + xPasswordCheckButton.executeAction("CLICK", tuple()) + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xPasswordDialog: + xReadonly = xPasswordDialog.getChild("readonly") + xReadonly.executeAction("CLICK", tuple()) + xNewPassword = xPasswordDialog.getChild("newpassroEntry") + xNewPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + xConfirmPassword = xPasswordDialog.getChild("confirmropassEntry") + xConfirmPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.execute_dialog_through_command(".uno:Open", close_button="") as xOpenDialog: + # Open document + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xOpenBtn = xOpenDialog.getChild("open") + xOpenBtn.executeAction("CLICK", tuple()) + + xDialog = self.ui_test.wait_for_top_focus_window('SharedWarningDialog') + xOk = xDialog.getChild("ok") + xOk.executeAction("CLICK", tuple()) + + document = self.ui_test.get_component() + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + # check that we have a password dialog for editing the shared document + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf31805.py b/sc/qa/uitest/calc_tests7/tdf31805.py new file mode 100644 index 000000000..81d15200f --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf31805.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 31805 - Deleting a column or row from merged cells + +class tdf31805(UITestCase): + def test_tdf31805_delete_column_merged(self): + with self.ui_test.load_file(get_url_for_data_file("tdf31805.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #1. open "sample.ods" + #2. click 'G1' + #3. Menu 'edit -> Delete Cell - Delete entire Column' + #expected: Column with cell containing "g" will be deleted, + # a merged cell range will remain left row 1 + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "G1"})) + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getIsMerged(), True) + self.xUITest.executeCommand(".uno:DeleteColumns") + #verify. C5:F11 should be merged + #isMerged returns true if this cell is merged with another cell. + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getIsMerged(), True) #C5 + self.assertEqual(get_cell_by_position(calc_doc, 0, 6, 4).getIsMerged(), False) #G5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A11"})) + self.xUITest.executeCommand(".uno:DeleteRows") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getIsMerged(), True) #C5 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "D1"})) + self.xUITest.executeCommand(".uno:DeleteColumns") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 4).getIsMerged(), True) #C5 + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests7/tdf91425.py b/sc/qa/uitest/calc_tests7/tdf91425.py new file mode 100644 index 000000000..d8acdd8c1 --- /dev/null +++ b/sc/qa/uitest/calc_tests7/tdf91425.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position + +#Bug 91425 - CRASH - Calc Insert Columns Left + +class tdf91425(UITestCase): + def test_tdf91425_insert_columns_left(self): + with self.ui_test.load_file(get_url_for_data_file("tdf91425.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #1) Open test file provided in report + #2) Move mouse pointer over Column A header, the right mouse button click + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #3) Insert columns left + self.xUITest.executeCommand(".uno:InsertColumnsBefore") + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 0).getString(), "C") + #undo + self.xUITest.executeCommand(".uno:Undo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 2, 0).getString(), "C") + #redo + self.xUITest.executeCommand(".uno:Redo") + self.assertEqual(get_cell_by_position(calc_doc, 0, 3, 0).getString(), "C") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/navigator.py b/sc/qa/uitest/calc_tests8/navigator.py new file mode 100644 index 000000000..574d73c72 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/navigator.py @@ -0,0 +1,174 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class navigator(UITestCase): + + def test_rename_sheet(self): + with self.ui_test.load_file(get_url_for_data_file("navigator.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)') + self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)') + + #The document has one comment too + xComments = xContentBox.getChild("6") + self.assertEqual(get_state_as_dict(xComments)['Text'], 'Comments') + self.assertEqual(len(xComments.getChildren()), 1) + self.assertEqual(get_state_as_dict(xComments.getChild('0'))['Text'], 'Test Comment') + + with self.ui_test.execute_dialog_through_command(".uno:RenameTable") as xDialog: + xname_entry = xDialog.getChild("name_entry") + xname_entry.executeAction("TYPE", mkPropertyValues({"TEXT": "S1"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'S1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (S1)') + self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (S1)') + + self.xUITest.executeCommand(".uno:Undo") + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xContentBox = xNavigatorPanel.getChild('contentbox') + xSheets = xContentBox.getChild("0") + self.assertEqual(get_state_as_dict(xSheets)['Text'], 'Sheets') + self.assertEqual(len(xSheets.getChildren()), 2) + self.assertEqual(get_state_as_dict(xSheets.getChild('0'))['Text'], 'Sheet1') + self.assertEqual(get_state_as_dict(xSheets.getChild('1'))['Text'], 'S2') + xRangeNames = xContentBox.getChild("1") + self.assertEqual(get_state_as_dict(xRangeNames)['Text'], 'Range names') + self.assertEqual(len(xRangeNames.getChildren()), 2) + #FIXME: tdf#133082 + #self.assertEqual(get_state_as_dict(xRangeNames.getChild('0'))['Text'], 'first (Sheet1)') + #self.assertEqual(get_state_as_dict(xRangeNames.getChild('1'))['Text'], 'second (Sheet1)') + + self.xUITest.executeCommand(".uno:Sidebar") + + def test_tdf98493(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf98493.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], "2") + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("toolbox2") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button + + xContentBox = xNavigatorPanel.getChild('contentbox') + + # tdf#133079, without the fix in place, it would be 8 + self.assertEqual(len(xContentBox.getChildren()), 1) + + xSheets = xContentBox.getChild('0') + self.assertEqual(len(xSheets.getChildren()), 12) + + #key=item position, value=sheet ( there are hidden sheets ) + results = { '1': '0', '5': '4', '6': '4', '11': '10'} + + for k, v in results.items(): + xChild = xSheets.getChild(k) + xChild.executeAction("DOUBLECLICK", tuple()) + + self.assertEqual(get_state_as_dict(xGridWin)["SelectedTable"], v) + + self.xUITest.executeCommand(".uno:Sidebar") + + + def test_tdf134390(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.xUITest.executeCommand(".uno:Sidebar") + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xToolBar = xNavigatorPanel.getChild("toolbox2") + xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'toggle' button + + xRow = xNavigatorPanel.getChild('row') + xColumn = xNavigatorPanel.getChild('column') + self.assertEqual(get_state_as_dict(xColumn)['Value'], '1') + self.assertEqual(get_state_as_dict(xRow)['Value'], '1') + self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "0") + self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "0") + + xRow.executeAction("UP", tuple()) + xColumn.executeAction("UP", tuple()) + + # Use return to update the current cell + xColumn.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + self.ui_test.wait_until_property_is_updated(xColumn, "Value", "2") + self.assertEqual(get_state_as_dict(xColumn)['Value'], '2') + self.ui_test.wait_until_property_is_updated(xRow, "Value", "2") + self.assertEqual(get_state_as_dict(xRow)['Value'], '2') + + self.assertEqual(get_state_as_dict(xGridWin)["CurrentRow"], "1") + self.assertEqual(get_state_as_dict(xGridWin)["CurrentColumn"], "1") + + self.xUITest.executeCommand(".uno:Sidebar") + + + def test_tdf141973(self): + with self.ui_test.load_file(get_url_for_data_file("tdf141973.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWin = xCalcDoc.getChild("grid_window") + + self.xUITest.executeCommand(".uno:Sidebar") + + # Without the fix in place, this test would have crashed here + xGridWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "ScNavigatorPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + xNavigatorPanel = xCalcDoc.getChild("NavigatorPanel") + xContentBox = xNavigatorPanel.getChild('contentbox') + xDrawings = xContentBox.getChild("7") + self.assertEqual('Drawing objects', get_state_as_dict(xDrawings)['Text']) + self.assertEqual(len(xDrawings.getChildren()), 1) + self.assertEqual('withname', get_state_as_dict(xDrawings.getChild('0'))['Text']) + + self.xUITest.executeCommand(".uno:Sidebar") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf119343.py b/sc/qa/uitest/calc_tests8/tdf119343.py new file mode 100644 index 000000000..0d4581f18 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf119343.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 119343 - EDITING: copied and pasted cells containing formulas are not recalculated (2) +class tdf119343(UITestCase): + def test_tdf119343_copy_paste_formula(self): + #numberingformatpage.ui + with self.ui_test.load_file(get_url_for_data_file("tdf119343.ods")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "M295"})) + self.xUITest.executeCommand(".uno:Copy") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + self.xUITest.executeCommand(".uno:Paste") + #verify + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 295).getString(), "Q11005355") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 294).getString(), "Q1099565") + self.assertEqual(get_cell_by_position(calc_doc, 0, 12, 293).getString(), "Q108420") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf124829.py b/sc/qa/uitest/calc_tests8/tdf124829.py new file mode 100644 index 000000000..f515b265f --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf124829.py @@ -0,0 +1,26 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + + +# Bug 124829 - CRASH: cutting and undoing a sheet with external links +class tdf124829(UITestCase): + def test_tdf124829_Crash_cutting_undo_sheet_external_links(self): + #numberingformatpage.ui + with self.ui_test.load_file(get_url_for_data_file("tdf124829.ods")) as calc_doc: + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Cut") + for i in range(40): + self.xUITest.executeCommand(".uno:Undo") + + #verify; no crashes + self.assertEqual(calc_doc.Sheets.getCount(), 6) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf125051.py b/sc/qa/uitest/calc_tests8/tdf125051.py new file mode 100644 index 000000000..5b8ccd15b --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf125051.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell + +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 125051 - EDITING: CRASH when start SpellCheck +class tdf125051(UITestCase): + def test_tdf125051_crash_spelling_dialog(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "text") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:SpellDialog"): + pass + + xDialog = self.xUITest.getTopFocusWindow() #Spelling dialog + #open options + optionsBtn = xDialog.getChild("options") + + with self.ui_test.execute_blocking_action(optionsBtn.executeAction, args=('CLICK', ()), close_button="cancel"): + pass + + closeBtn = xDialog.getChild("close") #close Spelling dialog + self.ui_test.close_dialog_through_button(closeBtn) + + #verify, we didn't crash + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "text") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf126248.py b/sc/qa/uitest/calc_tests8/tdf126248.py new file mode 100644 index 000000000..dce58b03b --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf126248.py @@ -0,0 +1,87 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import select_pos +from uitest.uihelper.common import select_by_text + +class tdf126248(UITestCase): + + def assertFontName(self, gridwin, fontName): + + #Open the sidebar + self.xUITest.executeCommand(".uno:Sidebar") + gridwin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "TextPropertyPanel"})) + + xCalcDoc = self.xUITest.getTopFocusWindow() + + xFontName = xCalcDoc.getChild("fontnamecombobox") + self.ui_test.wait_until_property_is_updated(xFontName, "Text", fontName) + self.assertEqual(fontName, get_state_as_dict(xFontName)['Text']) + + #Close the sidebar + self.xUITest.executeCommand(".uno:Sidebar") + + def changeLocalSetting(self, language): + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) + + # Check asian support is enabled + asianlanguage = xDialog.getChild("asiansupport") + self.assertEqual("true", get_state_as_dict(asianlanguage)['Selected']) + + localeSetting = xDialog.getChild("localesetting") + select_by_text(localeSetting, language) + self.ui_test.wait_until_property_is_updated(localeSetting, 'SelectEntryText', language) + self.assertEqual(language, get_state_as_dict(localeSetting)['SelectEntryText']) + + def test_tdf126248(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + self.changeLocalSetting("Chinese (traditional)") + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + + # Get current font names from the Format Cell dialog + westFontName = get_state_as_dict(xDialog.getChild("edWestFontName"))['Text'] + eastFontName = get_state_as_dict(xDialog.getChild("edCJKFontName"))['Text'] + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Test") + + # Without the fix in place, this test would have failed here + self.assertFontName(gridwin, westFontName) + + enter_text_to_cell(gridwin, "B1", "測試") + + self.assertFontName(gridwin, eastFontName) + + self.changeLocalSetting("English (USA)") + + enter_text_to_cell(gridwin, "C1", "Test") + + self.assertFontName(gridwin, westFontName) + + enter_text_to_cell(gridwin, "D1", "測試") + + self.assertFontName(gridwin, eastFontName) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf137726.py b/sc/qa/uitest/calc_tests8/tdf137726.py new file mode 100644 index 000000000..d80b51b6d --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf137726.py @@ -0,0 +1,27 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase + +class tdf137726(UITestCase): + + def test_tdf137726(self): + with self.ui_test.create_doc_in_start_center("calc"): + # three dialogs are displayed one after the other, click OK in all of them + with self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun"): + pass + + for i in range(2): + xDialog = self.xUITest.getTopFocusWindow() + xOKBtn = xDialog.getChild('ok') + self.ui_test.close_dialog_through_button(xOKBtn) + + # Without the fix in place, this test would have hung here + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf144457.py b/sc/qa/uitest/calc_tests8/tdf144457.py new file mode 100644 index 000000000..5f6bb939c --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf144457.py @@ -0,0 +1,37 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf144457(UITestCase): + + def test_tdf144457(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:OptionsTreeDialog") as xDialog: + xPages = xDialog.getChild("pages") + xLanguageEntry = xPages.getChild('2') + xLanguageEntry.executeAction("EXPAND", tuple()) + xxLanguageEntryGeneralEntry = xLanguageEntry.getChild('0') + xxLanguageEntryGeneralEntry.executeAction("SELECT", tuple()) + + xDatePatterns = xDialog.getChild("datepatterns") + + xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xDatePatterns.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xDatePatterns.executeAction("TYPE", mkPropertyValues({"TEXT":"m/d/y"})) + + # Without the fix in place, this test would have failed with + # AssertionError: 'M/D/Y' != 'm/M/dM/M/d/M/M/dM/M/d/yM/M/dM/M/d/M/M/dM/M/d/y' + self.assertEqual("M/D/Y", get_state_as_dict(xDatePatterns)['Text']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf144940.py b/sc/qa/uitest/calc_tests8/tdf144940.py new file mode 100644 index 000000000..ab4738431 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf144940.py @@ -0,0 +1,63 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +from tempfile import TemporaryDirectory +from org.libreoffice.unotest import systemPathToFileUrl +import os.path + +class tdf144940(UITestCase): + + def test_tdf144940(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf144940-tmp.ods") + + with self.ui_test.create_doc_in_start_center("calc"): + + with self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "4") + + xCheckHeaderOn = xDialog.getChild("checkHeaderOn") + xCheckSameFP = xDialog.getChild("checkSameFP") + xCheckSameLR = xDialog.getChild("checkSameLR") + + self.assertEqual("true", get_state_as_dict(xCheckHeaderOn)["Selected"]) + self.assertEqual("true", get_state_as_dict(xCheckSameLR)["Selected"]) + self.assertEqual("false", get_state_as_dict(xCheckSameFP)["Selected"]) + + xCheckSameFP.executeAction("CLICK", tuple()) + + self.assertEqual("true", get_state_as_dict(xCheckSameFP)["Selected"]) + + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="open") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + xPageStyles = document.StyleFamilies[1] + xDefaultPageStyle = xPageStyles[0] + + # Without the fix in place, this test would have failed with + # AssertionError: False is not true + self.assertTrue(xDefaultPageStyle.HeaderOn) + self.assertTrue(xDefaultPageStyle.FooterOn) + self.assertTrue(xDefaultPageStyle.FirstPageHeaderIsShared) + self.assertTrue(xDefaultPageStyle.FirstPageFooterIsShared) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests8/tdf147086.py b/sc/qa/uitest/calc_tests8/tdf147086.py new file mode 100755 index 000000000..f594edb69 --- /dev/null +++ b/sc/qa/uitest/calc_tests8/tdf147086.py @@ -0,0 +1,57 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl +from uitest.uihelper.common import select_by_text +from tempfile import TemporaryDirectory +import os.path + +#Bug 147086 - Password in .xlsx creates readonly sheet + +class tdf147086(UITestCase): + + def test_tdf147086(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "tdf147086_tmp.xlsx") + + with self.ui_test.create_doc_in_start_center("calc"): + # Save the document + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "Excel 2007–365 (.xlsx)") + xPasswordCheckButton = xSaveDialog.getChild("password") + xPasswordCheckButton.executeAction("CLICK", tuple()) + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xPasswordDialog: + xReadonly = xPasswordDialog.getChild("readonly") + xReadonly.executeAction("CLICK", tuple()) + + xOk = xPasswordDialog.getChild("ok") + # XLSX confirmation dialog is displayed + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"): + pass + + self.ui_test.wait_until_file_is_available(xFilePath) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + self.assertTrue(document.isReadonly()) + + self.xUITest.executeCommand(".uno:EditDoc") + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/forms.py b/sc/qa/uitest/calc_tests9/forms.py new file mode 100644 index 000000000..35f9feb41 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/forms.py @@ -0,0 +1,30 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class Forms(UITestCase): + + def test_tdf131000(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf131000.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "form"})) + + # Without the fix in place, this test would have hung here + with self.ui_test.execute_modeless_dialog_through_command(".uno:ControlProperties", close_button=""): + + xCellRange = self.ui_test.wait_until_child_is_available('textfield-Source cell range') + + self.assertEqual("A1:A7000", get_state_as_dict(xCellRange)['Text']) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/hashIncompatible.py b/sc/qa/uitest/calc_tests9/hashIncompatible.py new file mode 100644 index 000000000..07ab21db8 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/hashIncompatible.py @@ -0,0 +1,71 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +from tempfile import TemporaryDirectory +import os.path + +class hashIncompatible(UITestCase): + + def test_hashIncompatible(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "hashIncompatible-temp.ods") + + with self.ui_test.load_file(get_url_for_data_file("hashIncompatible.xlsx")): + + # Save the XLSX document as ODS with a sheet protected with an unsupported hash format + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "ODF Spreadsheet (.ods)") + + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xRetypePasswordDialog: + # hash error dialog is still displayed (only disabled for the recovery file) + xCancel = xRetypePasswordDialog.getChild("cancel") + + with self.ui_test.execute_dialog_through_action(xCancel, "CLICK"): + # Write error dialog is displayed + pass + + # Check the document is not created + self.assertFalse(os.path.isfile(xFilePath)) + + # Now check it can be saved to ODS using the correct password + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "ODF Spreadsheet (.ods)") + + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK") as xRetypePasswordDialog: + xRetypeBtn = xRetypePasswordDialog.getChild("button") + + with self.ui_test.execute_blocking_action( + xRetypeBtn.executeAction, args=('CLICK', ())) as xPasswordDialog: + xNewPassEntry = xPasswordDialog.getChild("newpassEntry") + xConfirmPassEntry = xPasswordDialog.getChild("confirmpassEntry") + xNewPassEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"})) + xConfirmPassEntry.executeAction("TYPE", mkPropertyValues({"TEXT": "Hello"})) + + self.assertTrue(os.path.isfile(xFilePath)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/pivotTable.py b/sc/qa/uitest/calc_tests9/pivotTable.py new file mode 100644 index 000000000..bb985429f --- /dev/null +++ b/sc/qa/uitest/calc_tests9/pivotTable.py @@ -0,0 +1,99 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.calc.document import get_cell_by_position + +class pivotTable(UITestCase): + + def test_cancelButton(self): + + # This is basically a test for cf93998eb5abc193d95ae5433bf4dfd11a9d62d8 + # Without the fix in place, this test would have crashed + + with self.ui_test.load_file(get_url_for_data_file("basicPivotTable.ods")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"TABLE": "1"})) + + self.xUITest.executeCommand(".uno:GoUp") + + + with self.ui_test.execute_dialog_through_command(".uno:DataDataPilotRun") as xDialog: + xFields = xDialog.getChild("listbox-fields") + self.assertEqual(2, len(xFields.getChildren())) + self.assertEqual("qtX", get_state_as_dict(xFields.getChild('0'))['Text']) + self.assertEqual("qtY", get_state_as_dict(xFields.getChild('1'))['Text']) + + xColumns = xDialog.getChild("listbox-column") + self.assertEqual(1, len(xColumns.getChildren())) + self.assertEqual("Data", get_state_as_dict(xColumns.getChild('0'))['Text']) + + xPage = xDialog.getChild("listbox-page") + self.assertEqual(1, len(xPage.getChildren())) + xPageChild = xPage.getChild('0') + self.assertEqual("qtX", get_state_as_dict(xPageChild)['Text']) + + with self.ui_test.execute_blocking_action(xPageChild.executeAction, args=('DOUBLECLICK', ())) as dialog: + optionBtn = dialog.getChild("options") + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + xEmptyLine.executeAction("CLICK", tuple()) + self.assertEqual('false', get_state_as_dict(xEmptyLine)['Selected']) + + with self.ui_test.execute_blocking_action(optionBtn.executeAction, args=('CLICK', ())) as dialog2: + xEmptyLine = dialog2.getChild("emptyline") + + self.assertEqual('true', get_state_as_dict(xEmptyLine)['Selected']) + + def test_popup(self): + with self.ui_test.load_file(get_url_for_data_file("pivotTable.ods")) as calc_doc: + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + self.assertEqual("a", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("m", get_cell_by_position(calc_doc, 0, 4, 1).getString()) + self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 2).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 1).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 2).getString()) + + gridwin.executeAction("LAUNCH", mkPropertyValues({"PIVOTTABLE": "", "COL": "3", "ROW": "0"})) + xFloatWindow = self.xUITest.getFloatWindow() + xCheckListMenu = xFloatWindow.getChild("FilterDropDown") + + xTreeList = xCheckListMenu.getChild("check_list_box") + xFirstEntry = xTreeList.getChild("0") + + xFirstEntry.executeAction("CLICK", tuple()) + + xOkBtn = xFloatWindow.getChild("ok") + xOkBtn.executeAction("CLICK", tuple()) + + self.assertEqual("b", get_cell_by_position(calc_doc, 0, 3, 1).getString()) + self.assertEqual("Total Result", get_cell_by_position(calc_doc, 0, 3, 2).getString()) + self.assertEqual("n", get_cell_by_position(calc_doc, 0, 4, 1).getString()) + self.assertEqual("", get_cell_by_position(calc_doc, 0, 4, 2).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 1).getString()) + self.assertEqual("1", get_cell_by_position(calc_doc, 0, 5, 2).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf113571.py b/sc/qa/uitest/calc_tests9/tdf113571.py new file mode 100644 index 000000000..0dc337ca6 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf113571.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class Tdf113571(UITestCase): + + def test_tdf113571(self): + with self.ui_test.load_file(get_url_for_data_file("tdf113571.ods")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_document: + + self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix in place, this test would have failed with + # AssertionError: '<?xml version="1.0" encoding="UTF-8"?>\n<[34 chars]est>' != + # '"<?xml version=""1.0"" encoding=""UTF-8""[40 chars]st>"' + self.assertEqual('<?xml version="1.0" encoding="UTF-8"?>\n<test>\n <hello>world</hello>\n</test>', + writer_document.Text.String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file diff --git a/sc/qa/uitest/calc_tests9/tdf115933.py b/sc/qa/uitest/calc_tests9/tdf115933.py new file mode 100644 index 000000000..0fe7fec06 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf115933.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 115933 - XLSX <fileSharing> password protected with algorithmName, hashValue, saltValue and spinCount + +class tdf115933(UITestCase): + + def test_tdf115933(self): + with self.ui_test.load_file(get_url_for_data_file("tdf115933.xlsx")): + #The document was created in Excel. + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + document = self.ui_test.get_component() + + self.assertTrue(document.isReadonly()) + + #Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+SHIFT+M"})) as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf117879.py b/sc/qa/uitest/calc_tests9/tdf117879.py new file mode 100644 index 000000000..6e3049e6c --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf117879.py @@ -0,0 +1,43 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import type_text +from libreoffice.calc.document import get_cell_by_position + +class tdf117879(UITestCase): + + def test_tdf117879(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") + + # Without the fix in place, this dialog wouldn't have been displayed + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="yes"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5)") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + type_text(gridwin, "=SUM({A1},2,3,4,5}") + + with self.ui_test.execute_blocking_action(gridwin.executeAction, + args=("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})), close_button="no"): + pass + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getFormula(), "=SUM({A1};2;3;4;5})") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf118938.py b/sc/qa/uitest/calc_tests9/tdf118938.py new file mode 100644 index 000000000..eede90451 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf118938.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 118938 - FILESAVE to Microsoft Excel 2007-2013 XML (.xlsx) files as read-only +# with additional password protection for editing not working (Calc) + +class tdf118938(UITestCase): + + def test_tdf118938(self): + with self.ui_test.load_file(get_url_for_data_file("tdf118938.xlsx")): + #The document was created in Calc after this fix. + document = self.ui_test.get_component() + + # Without the fix in place, this test would have failed with + # AssertionError: False is not true + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "a"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf121949.py b/sc/qa/uitest/calc_tests9/tdf121949.py new file mode 100644 index 000000000..03e501234 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf121949.py @@ -0,0 +1,27 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf121949 (UITestCase): + + def test_tdf121949_copy_block_with_single_cell_not_included(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + # mark a range with a single cell left our and copy to clipboard + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A3"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B1:B1", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "B3:B3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "C1:C3", "EXTEND":"1"})) + with self.ui_test.execute_dialog_through_command(".uno:Copy"): + pass + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf124318.py b/sc/qa/uitest/calc_tests9/tdf124318.py new file mode 100644 index 000000000..9fae2d5b4 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf124318.py @@ -0,0 +1,33 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf124318(UITestCase): + + def test_tdf124318(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf124318.xls")): + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B4"})) + + with self.ui_test.execute_dialog_through_action(gridwin, "TYPE", mkPropertyValues({"KEYCODE": "CTRL+k"})) as xDialog: + # Without the fix in place, this test would have failed with + # AssertionError: 'mobile/identification/authentification' != + # 'mobile/identification/authentification%00塹\uf481ᴻ䡿ⲯ嶂藄挧%00%00ꮥ%00' + self.assertEqual("mobile/identification/authentification", + get_state_as_dict(xDialog.getChild("target"))['Text'].split(".fr/")[1]) + self.assertEqual("mobile/identification/authentification", + get_state_as_dict(xDialog.getChild("indication"))['Text'].split(".fr/")[1]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf125440.py b/sc/qa/uitest/calc_tests9/tdf125440.py new file mode 100644 index 000000000..a5319d582 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf125440.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.common import get_url_for_data_file + +class Tdf1254400(UITestCase): + + def test_tdf125440(self): + # In order to simulate copy&paste from external source, + # import the text in Writer, copy it and paste it in Calc + with self.ui_test.load_file(get_url_for_data_file("tdf125440.odt")): + + self.xUITest.executeCommand(".uno:SelectAll") + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("calc") as calc_document: + + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix in place, this test would have failed with + # AssertionError: 'Row' != '"Row"' + self.assertEqual("Row", get_cell_by_position(calc_document, 0, 0, 0).getString()) + self.assertEqual("", get_cell_by_position(calc_document, 0, 1, 0).getString()) + self.assertEqual("", get_cell_by_position(calc_document, 0, 2, 0).getString()) + self.assertEqual("50", get_cell_by_position(calc_document, 0, 3, 0).getString()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py new file mode 100644 index 000000000..91c71f154 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126541_GridVisibilityImportXlsx.py @@ -0,0 +1,29 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +class tdf126541(UITestCase): + + def test_tdf126541_GridVisibilityImportXlsx(self): + # Import an ods file with 'Hide' global grid visibility setting. + with self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOffGlobally.ods")) as document: + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, False) + + # Importing xlsx file should set the global grid visibility setting to 'Show' + # Sheet based grid line visibility setting should not overwrite the global setting. + with self.ui_test.load_file(get_url_for_data_file("tdf126541_GridOff.xlsx")) as document: + controller = document.getCurrentController() + grid = controller.ShowGrid + self.assertEqual(grid, True) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf126673.py b/sc/qa/uitest/calc_tests9/tdf126673.py new file mode 100644 index 000000000..7d60d5195 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf126673.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import change_measurement_unit +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +# Bug 126673 - Calc: Auto-fit column and auto-fit row don't work with line break +class tdf126673(UITestCase): + def test_tdf126673_auto_fit_row_height(self): + with self.ui_test.load_file(get_url_for_data_file("tdf126673.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #optimal row height + with self.ui_test.execute_dialog_through_command(".uno:SetOptimalRowHeight") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual("0.00 cm", get_state_as_dict(xvalue)["Text"]) + + #select A2 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + #row height + with self.ui_test.execute_dialog_through_command(".uno:RowHeight", close_button="cancel") as xDialog: + xvalue = xDialog.getChild("value") + self.assertEqual("1.24 cm", get_state_as_dict(xvalue)["Text"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf130371.py b/sc/qa/uitest/calc_tests9/tdf130371.py new file mode 100644 index 000000000..8e7c09159 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf130371.py @@ -0,0 +1,57 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class namedRanges(UITestCase): + + def test_tdf130371(self): + with self.ui_test.load_file(get_url_for_data_file("tdf130371.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + text1 = "value\t$Sheet2.$B$2\tSheet2" + text2 = "value\t$Sheet3.$B$2\tSheet3" + text3 = "value\t$Sheet4.$B$2\tSheet4" + + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B3"})) + self.xUITest.executeCommand(".uno:Copy") + + self.xUITest.executeCommand(".uno:JumpToNextTable") + self.xUITest.executeCommand(".uno:JumpToNextTable") + + self.xUITest.executeCommand(".uno:Paste") + + with self.ui_test.execute_dialog_through_command(".uno:DefineName") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(3, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + self.assertEqual(get_state_as_dict(namesList.getChild('2'))["Text"], text3) + + + self.xUITest.executeCommand(".uno:Undo") + + with self.ui_test.execute_dialog_through_command(".uno:DefineName", close_button="cancel") as xDialog: + namesList = xDialog.getChild('names') + self.assertEqual(2, len(namesList.getChildren())) + self.assertEqual(get_state_as_dict(namesList.getChild('0'))["Text"], text1) + self.assertEqual(get_state_as_dict(namesList.getChild('1'))["Text"], text2) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf133629.py b/sc/qa/uitest/calc_tests9/tdf133629.py new file mode 100644 index 000000000..8b28fcb99 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf133629.py @@ -0,0 +1,57 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf133629(UITestCase): + + def test_tdf133629(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + with self.ui_test.execute_dialog_through_command(".uno:Insert"): + pass + + self.xUITest.executeCommand(".uno:TableSelectAll") + + self.xUITest.executeCommand(".uno:SelectAll") + + # Check both sheets are selected + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet1.A1:AMJ1048576')) + self.assertIsNotNone(getattr(document.CurrentSelection, 'Sheet2.A1:AMJ1048576')) + + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "5") + + xPresets = xDialog.getChild("presets") + xPresets.executeAction("CHOOSE", mkPropertyValues({"POS": "4"})) + + # Change width + xLineWidth = xDialog.getChild("linewidthmf") + xLineWidth.executeAction("UP", tuple()) + xLineWidth.executeAction("UP", tuple()) + self.assertEqual("1.25 pt", get_state_as_dict(xLineWidth)['Text']) + + + # Without the fix in place, this test would have crash here + + xA1Sheet1 = document.Sheets[0].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet1.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet1.RightBorder.OuterLineWidth) + + xA1Sheet2 = document.Sheets[1].getCellRangeByName("A1") + self.assertEqual(44, xA1Sheet2.BottomBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.TopBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.LeftBorder.OuterLineWidth) + self.assertEqual(44, xA1Sheet2.RightBorder.OuterLineWidth) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf135761.py b/sc/qa/uitest/calc_tests9/tdf135761.py new file mode 100755 index 000000000..fd9e5ebda --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf135761.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position + +class tdf135761(UITestCase): + def test_tdf135761_ctrl_backspace(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Enter text including two whitespaces in the text, and delete the left part of the text + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "a b"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F2"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"LEFT"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+BACKSPACE"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE":"RETURN"})) + + # Without the fix in place, this test would have failed with + # AssertionError: ' b' != 'a b' + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), " b") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf137446.py b/sc/qa/uitest/calc_tests9/tdf137446.py new file mode 100644 index 000000000..e6aa04667 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf137446.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import change_measurement_unit +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf137446(UITestCase): + + def test_tdf137446(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf137446.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + change_measurement_unit(self, "Centimeter") + + gridwin.executeAction("SELECT", mkPropertyValues({"OBJECT": "lineObject"})) + + with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: + + + self.assertEqual('10', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + + + xDialog.getChild('MTR_FLD_WIDTH').executeAction("UP", tuple()) + + + with self.ui_test.execute_dialog_through_command(".uno:TransformDialog") as xDialog: + + + self.assertEqual('10.1', get_state_as_dict(xDialog.getChild('MTR_FLD_WIDTH'))['Value']) + self.assertEqual('0', get_state_as_dict(xDialog.getChild('MTR_FLD_HEIGHT'))['Value']) + self.assertEqual('5.51', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_X'))['Value']) + self.assertEqual('2.55', get_state_as_dict(xDialog.getChild('MTR_FLD_POS_Y'))['Value']) + + # Without the fix in place, this test would have failed with AssertionError: '0' != '180' + self.assertEqual('0', get_state_as_dict(xDialog.getChild('NF_ANGLE'))['Value']) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf141244.py b/sc/qa/uitest/calc_tests9/tdf141244.py new file mode 100644 index 000000000..b292bfefe --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf141244.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict + + +class tdf141244(UITestCase): + + def test_tdf141244(self): + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", '=DDE("soffice";"data1.ods";"sheet1.A1")') + + with self.ui_test.execute_dialog_through_command(".uno:EditLinks", close_button="close") as xDialog: + + xLinks = xDialog.getChild("TB_LINKS") + self.assertEqual(1, len(xLinks.getChildren())) + + xChangeBtn = xDialog.getChild("CHANGE_SOURCE") + + with self.ui_test.execute_blocking_action(xChangeBtn.executeAction, args=('CLICK', ()), close_button="cancel") as dialog: + self.assertEqual("soffice", get_state_as_dict(dialog.getChild("app"))['Text']) + self.assertEqual("data1.ods", get_state_as_dict(dialog.getChild("file"))['Text']) + self.assertEqual("sheet1.A1", get_state_as_dict(dialog.getChild("category"))['Text']) + + # tdf#141770: Without the fix in place, the cancel button wouldn't have worked here + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf142763.py b/sc/qa/uitest/calc_tests9/tdf142763.py new file mode 100644 index 000000000..548be27b4 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf142763.py @@ -0,0 +1,71 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, select_pos + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class Tdf142763(UITestCase): + + def test_tdf142763_header(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xPageFormatDialog: + xTabControl = xPageFormatDialog.getChild("tabcontrol") + select_pos(xTabControl, "4") + + xHeaderOnBtn = xPageFormatDialog.getChild("checkHeaderOn") + xHeaderOnBtn.executeAction("CLICK", tuple()) + xFirstHeaderSameBtn = xPageFormatDialog.getChild("checkSameFP") + xFirstHeaderSameBtn.executeAction("CLICK", tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:EditHeaderAndFooter") as xHeaderDialog: + xLeftTextWindow = xHeaderDialog.getChild("textviewWND_LEFT") + xLeftTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "first"})) + xCenterTextWindow = xHeaderDialog.getChild("textviewWND_CENTER") + xCenterTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "page | "})) + xRightTextWindow = xHeaderDialog.getChild("textviewWND_RIGHT") + xRightTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "header"})) + + self.assertEqual("first", get_state_as_dict(xLeftTextWindow)["Text"]) + self.assertEqual("page | Sheet1", get_state_as_dict(xCenterTextWindow)["Text"]) + self.assertEqual("header", get_state_as_dict(xRightTextWindow)["Text"]) + + def test_tdf142763_footer(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + with self.ui_test.execute_dialog_through_command(".uno:PageFormatDialog") as xPageFormatDialog: + xTabControl = xPageFormatDialog.getChild("tabcontrol") + select_pos(xTabControl, "5") + + xFooterOnBtn = xPageFormatDialog.getChild("checkFooterOn") + xFooterOnBtn.executeAction("CLICK", tuple()) + xFirstFooterSameBtn = xPageFormatDialog.getChild("checkSameFP") + xFirstFooterSameBtn.executeAction("CLICK", tuple()) + + with self.ui_test.execute_dialog_through_command(".uno:EditHeaderAndFooter") as xFooterDialog: + xLeftTextWindow = xFooterDialog.getChild("textviewWND_LEFT") + xLeftTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "first"})) + xCenterTextWindow = xFooterDialog.getChild("textviewWND_CENTER") + xCenterTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "page | "})) + xRightTextWindow = xFooterDialog.getChild("textviewWND_RIGHT") + xRightTextWindow.executeAction("TYPE", mkPropertyValues({"TEXT": "footer"})) + + self.assertEqual("first", get_state_as_dict(xLeftTextWindow)["Text"]) + self.assertEqual("page | Sheet1", get_state_as_dict(xCenterTextWindow)["Text"]) + self.assertEqual("footer", get_state_as_dict(xRightTextWindow)["Text"]) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf144996.py b/sc/qa/uitest/calc_tests9/tdf144996.py new file mode 100644 index 000000000..eabd61ddb --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf144996.py @@ -0,0 +1,49 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_url_for_data_file + +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class tdf144996(UITestCase): + + def test_tdf144996(self): + + # get_url_for_data_file calls makeCopyFromTDOC + # so using save doesn't affect the original file + xFilePath = get_url_for_data_file("tdf144996.xlsx") + + with self.ui_test.load_file(xFilePath) as document: + + self.assertTrue(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"): + # Confirm file format popup + pass + + with self.ui_test.load_file(xFilePath) as document: + + self.assertTrue(document.isReadonly()) + + # Without the fix in place, this test would have failed here because the saved document + # doesn't need a password to edit it + with self.ui_test.execute_dialog_through_command(".uno:EditDoc") as xDialog: + xPassword = xDialog.getChild("newpassEntry") + xPassword.executeAction("TYPE", mkPropertyValues({"TEXT": "password"})) + + self.assertFalse(document.isReadonly()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf148437.py b/sc/qa/uitest/calc_tests9/tdf148437.py new file mode 100644 index 000000000..d457b2324 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf148437.py @@ -0,0 +1,53 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +class tdf148437(UITestCase): + def test_tdf148437_formula_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a formula and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "=HYPERLINK(\"www.libreoffice.org\";\"LibreOffice\")") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + xIndication.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice Document Foundation"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://www.documentfoundation.org/") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf80043.py b/sc/qa/uitest/calc_tests9/tdf80043.py new file mode 100644 index 000000000..eb99f0038 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf80043.py @@ -0,0 +1,243 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import get_cell_by_position +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, select_pos + +class tdf80043(UITestCase): + def test_tdf80043_empty_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select an empty cell and insert a hyperlink + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Both fields in the hyperlink dialog should be empty + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + xIndication.executeAction("TYPE", mkPropertyValues({"TEXT": "LibreOffice"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "http://www.libreoffice.org/") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + def test_tdf80043_text_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "LibreOffice") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog", close_button="cancel") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "http://www.libreoffice.org/") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + def test_tdf80043_link_text_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "LibreOffice") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Insert an additional text without a hyperlink in the cell including a hyperlink + self.xUITest.executeCommand(".uno:SetInputMode") + enter_text_to_cell(xGridWindow, "A1", " Document Foundation") + + # Check contents of the cell + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice Document Foundation") + + # Check contents of the cell - move focus, otherwise text fields won't be updated + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://www.documentfoundation.org/") + + def test_tdf80043_link_link_cell(self): + with self.ui_test.create_doc_in_start_center("calc") as document: + xCalcDoc = self.xUITest.getTopFocusWindow() + xGridWindow = xCalcDoc.getChild("grid_window") + + # Select a cell including a text and insert a hyperlink + enter_text_to_cell(xGridWindow, "A1", "Libre") + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "Libre") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "http://www.libreoffice.org/"})) + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Insert an additional hyperlink in the cell + self.xUITest.executeCommand(".uno:SetInputMode") + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "Office Document Foundation"})) + xGridWindow.executeAction("TYPE", mkPropertyValues({"KEYCODE": "SHIFT+CTRL+LEFT"})) + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + # Text should contain the text of the cell + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "Foundation") + + # Insert a sample hyperlink + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://www.documentfoundation.org/"})) + + # Check contents of the cell + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 2) + self.assertEqual(xTextFields.getByIndex(0).URL, "http://www.libreoffice.org/") + self.assertEqual(xTextFields.getByIndex(1).URL, "https://www.documentfoundation.org/") + + # Move focus to ensure cell is not in edit mode + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + # Reopen hyperlink dialog and check the target and the indication of the hyperlink + with self.ui_test.execute_dialog_through_command(".uno:HyperlinkDialog") as xDialog: + xTab = xDialog.getChild("tabcontrol") + select_pos(xTab, "0") + + xTarget = xDialog.getChild("target") + self.assertEqual(get_state_as_dict(xTarget)["Text"], "") + xTarget.executeAction("TYPE", mkPropertyValues({"TEXT": "https://wiki.documentfoundation.org/Main_Page"})) + xIndication = xDialog.getChild("indication") + self.assertEqual(get_state_as_dict(xIndication)["Text"], "LibreOffice Document Foundation") + + # Check contents of the cell - move focus, otherwise text fields won't be updated + xGridWindow.executeAction("SELECT", mkPropertyValues({"CELL": "A2"})) + xCell = get_cell_by_position(document, 0, 0, 0) + self.assertEqual(xCell.getString(), "LibreOffice Document Foundation") + xTextFields = xCell.getTextFields() + self.assertEqual(xTextFields.getCount(), 1) + self.assertEqual(xTextFields.getByIndex(0).URL, "https://wiki.documentfoundation.org/Main_Page") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests9/tdf95554.py b/sc/qa/uitest/calc_tests9/tdf95554.py new file mode 100644 index 000000000..734711e41 --- /dev/null +++ b/sc/qa/uitest/calc_tests9/tdf95554.py @@ -0,0 +1,51 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell + +import platform + +class Tdf95554(UITestCase): + + def test_tdf95554(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "A") + enter_text_to_cell(gridwin, "A2", "B") + enter_text_to_cell(gridwin, "A3", "C") + enter_text_to_cell(gridwin, "A4", "D") + enter_text_to_cell(gridwin, "A5", "E") + enter_text_to_cell(gridwin, "A6", "F") + + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A1:A1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A3:A3", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A5:A5", "EXTEND":"1"})) + gridwin.executeAction("SELECT", mkPropertyValues({"RANGE": "A6:A6", "EXTEND":"1"})) + self.xUITest.executeCommand(".uno:Copy") + + with self.ui_test.load_empty_file("writer") as writer_document: + + self.xUITest.getTopFocusWindow() + self.xUITest.executeCommand(".uno:PasteUnformatted") + + # Without the fix, the test breaks here with: + #AssertionError: 'A\n\nC\n\nE\nF' != 'A' + + if platform.system() == "Windows": + self.assertEqual('A\r\n\r\nC\r\n\r\nE\r\nF', + writer_document.Text.String) + else: + self.assertEqual('A\n\nC\n\nE\nF', + writer_document.Text.String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab:
\ No newline at end of file |