diff options
Diffstat (limited to 'sc/qa/uitest/calc_tests')
-rw-r--r-- | sc/qa/uitest/calc_tests/CalcPasteOnly.py | 41 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/CellDropDownItems.py | 84 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/Comments.py | 48 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/autofill.py | 155 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/autosum.py | 250 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/calcSheetDelete.py | 127 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/cellBackgroundColorSelector.py | 198 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/columns.py | 227 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/fillRandomNumber.py | 54 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/formatCells.py | 406 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/mergedRowsColumns.py | 167 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/printRange.py | 95 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/rows.py | 192 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/sheetRename.py | 86 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/tdf133855.py | 49 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests/zoom.py | 58 |
16 files changed, 2237 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: |