diff options
Diffstat (limited to 'sc/qa/uitest/calc_tests4')
-rw-r--r-- | sc/qa/uitest/calc_tests4/exportToPDF.py | 79 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/saveToCSV.py | 70 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf131170.py | 45 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf138089.py | 45 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf141547.py | 39 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf152722_AddDecimalPlacesToNatNum.py | 38 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf88999.py | 42 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/tdf89958.py | 58 | ||||
-rw-r--r-- | sc/qa/uitest/calc_tests4/trackedChanges.py | 387 |
9 files changed, 803 insertions, 0 deletions
diff --git a/sc/qa/uitest/calc_tests4/exportToPDF.py b/sc/qa/uitest/calc_tests4/exportToPDF.py new file mode 100644 index 0000000000..a635ee60a5 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/exportToPDF.py @@ -0,0 +1,79 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import os.path +from tempfile import TemporaryDirectory + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues +from org.libreoffice.unotest import systemPathToFileUrl + + +class exportToPDF(UITestCase): + + def test_checkDefaultValues(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'exportToPDFFromCalc-tmp.pdf') + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "Hello World") + + # Export as PDF + with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="") as xDialog: + + selectedChildren = ['bookmarks', 'display', 'effects', 'enablea11y', + 'enablecopy', 'exporturl', 'forms', 'reduceresolution', 'tagged'] + + for child in selectedChildren: + self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Selected']) + + nonSelectedChildren = ['allowdups', 'center', 'comments', 'convert', 'embed', 'emptypages', 'export', 'exportplaceholders', + 'firstonleft', 'hiddenpages', 'menubar', 'notes', 'onlynotes', 'open', 'pdfa', 'pdfua', 'resize', 'singlepagesheets', + 'toolbar', 'usereferencexobject', 'viewpdf', 'watermark', 'window'] + + for child in nonSelectedChildren: + self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Selected']) + + checkedChildren = ['allbookmarks', 'changeany', 'default', 'defaultlayout', 'fitdefault', 'jpegcompress', 'outline', 'printhigh', 'selection'] + + for child in checkedChildren: + self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) + + nonCheckedChildren = ['all', 'changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', 'fitwidth', + 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'range', + 'singlelayout', 'thumbs', 'visiblebookmark'] + + for child in nonCheckedChildren: + self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Checked']) + + self.assertEqual("300 DPI", get_state_as_dict(xDialog.getChild("resolution"))['Text']) + self.assertEqual("90", get_state_as_dict(xDialog.getChild("quality"))['Value']) + self.assertEqual("FDF", get_state_as_dict(xDialog.getChild("format"))['DisplayText']) + + xOk = xDialog.getChild("ok") + with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="open") as xSaveDialog: + xFileName = xSaveDialog.getChild('file_name') + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'})) + xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'})) + xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath})) + + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + + self.assertEqual("Sheet1", document.DrawPages[0][0].String) + self.assertEqual("Page 1", document.DrawPages[0][1].String) + self.assertEqual("Hello World", document.DrawPages[0][2].String) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/saveToCSV.py b/sc/qa/uitest/calc_tests4/saveToCSV.py new file mode 100644 index 0000000000..09949b7d71 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/saveToCSV.py @@ -0,0 +1,70 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +import os.path +from tempfile import TemporaryDirectory + +from uitest.framework import UITestCase +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues + + +class saveToCSV(UITestCase): + + def test_saveToCSVDialog(self): + + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, 'exportToCSV-tmp.csv') + + with self.ui_test.create_doc_in_start_center("calc"): + + calcDoc = self.xUITest.getTopFocusWindow() + gridwin = calcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "1") + enter_text_to_cell(gridwin, "A2", "2") + enter_text_to_cell(gridwin, "A3", "3") + enter_text_to_cell(gridwin, "A4", "=SUM(A1:A3)") + + # Save the document + with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="") as xSaveDialog: + xFileName = xSaveDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xFileName.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": xFilePath})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "Text CSV (.csv)") + xOpen = xSaveDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog: + # CSV confirmation dialog is displayed + xSave = xWarnDialog.getChild("save") + + with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog: + xFormulas = xCsvDialog.getChild("formulas") + xAsShown = xCsvDialog.getChild("asshown") + xFixedWidth = xCsvDialog.getChild("fixedwidth") + xQuoteAll = xCsvDialog.getChild("quoteall") + self.assertEqual("false", get_state_as_dict(xFormulas)['Selected']) + self.assertEqual("false", get_state_as_dict(xQuoteAll)['Selected']) + self.assertEqual("false", get_state_as_dict(xFixedWidth)['Selected']) + self.assertEqual("true", get_state_as_dict(xAsShown)['Selected']) + + xFormulas.executeAction("CLICK", tuple()) + + with open(xFilePath, "r") as f: + lines = f.readlines() + self.assertEqual("1", lines[0].strip()) + self.assertEqual("2", lines[1].strip()) + self.assertEqual("3", lines[2].strip()) + self.assertEqual("=SUM(A1:A3)", lines[3].strip()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf131170.py b/sc/qa/uitest/calc_tests4/tdf131170.py new file mode 100644 index 0000000000..65bddc4fd6 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf131170.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class tdf131170(UITestCase): + def test_DefineLabelRange(self): + with self.ui_test.load_file(get_url_for_data_file("tdf131170.ods")): + + with self.ui_test.execute_dialog_through_command(".uno:DefineLabelRange") as xDialog: + + xRange = xDialog.getChild("range") + self.assertEqual(4, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "$Sheet1.$I$6:$K$6 [AA, BB, CC]") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('3'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + xDeleteBtn = xDialog.getChild("delete") + + xRange.getChild('1').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(3, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + self.assertEqual(get_state_as_dict(xRange.getChild('2'))["Text"].strip(), "$Sheet1.$H$7:$H$9 [X, Y, Z]") + + xRange.getChild('2').executeAction("SELECT", tuple()) + with self.ui_test.execute_blocking_action(xDeleteBtn.executeAction, args=('CLICK', ()), close_button="yes"): + pass + + self.assertEqual(2, len(xRange.getChildren())) + self.assertEqual(get_state_as_dict(xRange.getChild('0'))["Text"].strip(), "--- Column ---") + self.assertEqual(get_state_as_dict(xRange.getChild('1'))["Text"].strip(), "--- Row ---") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf138089.py b/sc/qa/uitest/calc_tests4/tdf138089.py new file mode 100644 index 0000000000..7ea3afd09e --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf138089.py @@ -0,0 +1,45 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import is_row_hidden + +class tdf138089(UITestCase): + + def test_tdf138089(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf138089.xlsx")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertTrue(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 2)) + self.assertTrue(is_row_hidden(calc_doc, 3)) + self.assertFalse(is_row_hidden(calc_doc, 4)) + self.assertFalse(is_row_hidden(calc_doc, 5)) + self.assertFalse(is_row_hidden(calc_doc, 6)) + + # Without the fix in place, this test would have crashed here + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("2017-12-01", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + + + self.assertFalse(is_row_hidden(calc_doc, 0)) + self.assertTrue(is_row_hidden(calc_doc, 1)) + self.assertTrue(is_row_hidden(calc_doc, 2)) + self.assertTrue(is_row_hidden(calc_doc, 3)) + self.assertFalse(is_row_hidden(calc_doc, 4)) + self.assertFalse(is_row_hidden(calc_doc, 5)) + self.assertTrue(is_row_hidden(calc_doc, 6)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf141547.py b/sc/qa/uitest/calc_tests4/tdf141547.py new file mode 100644 index 0000000000..2cccba3321 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf141547.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues +from libreoffice.calc.document import is_row_hidden + +class tdf141547(UITestCase): + + def test_tdf141547(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf141547.xlsx")) as calc_doc: + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.assertFalse(is_row_hidden(calc_doc, 0)) + for i in range(1, 7): + self.assertTrue(is_row_hidden(calc_doc, i)) + + # Without the fix in place, this test would have crashed here + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + self.assertEqual("0", get_state_as_dict(xDialog.getChild("val1"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field1"))["DisplayText"]) + self.assertEqual("Empty", get_state_as_dict(xDialog.getChild("val2"))['Text']) + self.assertEqual("过帐日期", get_state_as_dict(xDialog.getChild("field2"))["DisplayText"]) + + + self.assertFalse(is_row_hidden(calc_doc, 0)) + for i in range(1, 7): + self.assertTrue(is_row_hidden(calc_doc, i)) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf152722_AddDecimalPlacesToNatNum.py b/sc/qa/uitest/calc_tests4/tdf152722_AddDecimalPlacesToNatNum.py new file mode 100644 index 0000000000..d30430fe79 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf152722_AddDecimalPlacesToNatNum.py @@ -0,0 +1,38 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 152722 - NatNum12 number format (spell out): add/delete decimal places is losing format + +class tdf152722(UITestCase): + def test_tdf152722_NatNum_modifier_decimal_value(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + #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" ) + xformatted = xDialog.getChild( "formatted" ) + + xformatted.executeAction( "CLEAR", tuple() ) #clear textbox + xformatted.executeAction( "TYPE", mkPropertyValues({"TEXT":"[NatNum12 cardinal]0"}) ) + xdecimalsed.executeAction( "UP", tuple() ) + self.assertEqual( get_state_as_dict(xformatted)["Text"], "[NatNum12 cardinal]0.0" ) + xnegnumred.executeAction( "CLICK", tuple() ) + self.assertEqual( get_state_as_dict(xformatted)["Text"], "[NatNum12 cardinal]0.0;[RED][NatNum12 cardinal]-0.0" ) + #Bug 153023: disable Thousand separator for NatNum12 modifier + self.assertEqual(get_state_as_dict(xthousands)["Enabled"], "false") + #Leading zeroes can be 0 or 1 + self.assertEqual(get_state_as_dict(xleadzerosed)["Enabled"], "true") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf88999.py b/sc/qa/uitest/calc_tests4/tdf88999.py new file mode 100644 index 0000000000..466a8559ab --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf88999.py @@ -0,0 +1,42 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from uitest.uihelper.common import select_pos +from uitest.uihelper.calc import enter_text_to_cell +from libreoffice.uno.propertyvalue import mkPropertyValues +#Bug 88999 - UI: Scientific format: unable to modify number of decimal places through Sidebar or Format > Cells + +class tdf88999(UITestCase): + def test_tdf88999_scientific_format_decimal_value(self): + #numberingformatpage.ui + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + enter_text_to_cell(gridwin, "A1", "1e-2") + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "B1"})) + #select cell A1 + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + #format - cell + with self.ui_test.execute_dialog_through_command(".uno:FormatCellDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") #tab Numbers + xliststore1 = xDialog.getChild("categorylb") #1st list / Category + xdecimalsed = xDialog.getChild("decimalsed") + xleadzerosed = xDialog.getChild("leadzerosed") + xformatted = xDialog.getChild("formatted") + + self.assertEqual(get_state_as_dict(xliststore1)["SelectEntryText"], "Scientific") + self.assertEqual(get_state_as_dict(xdecimalsed)["Text"], "2") + self.assertEqual(get_state_as_dict(xdecimalsed)["Enabled"], "true") + self.assertEqual(get_state_as_dict(xleadzerosed)["Text"], "1") + self.assertEqual(get_state_as_dict(xformatted)["Text"], "0.00E+00") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/tdf89958.py b/sc/qa/uitest/calc_tests4/tdf89958.py new file mode 100644 index 0000000000..6f31939fb8 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/tdf89958.py @@ -0,0 +1,58 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues + +#Bug 89958 - Data->Filter->Standard Filter, condition "does not end with" does filter too much + +class tdf89958(UITestCase): + def test_td89958_standard_filter(self): + with self.ui_test.load_file(get_url_for_data_file("tdf89958.ods")): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #select A1-> Column .uno:SelectColumn + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + self.xUITest.executeCommand(".uno:SelectColumn") + + #Menu: Data->Filter->Standard Filter ... + #Field Name "Column A", Condition "Does not end with", Value: "CTORS" + with self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") as xDialog: + xfield1 = xDialog.getChild("field1") + xval1 = xDialog.getChild("val1") + xcond1 = xDialog.getChild("cond1") + + select_by_text(xfield1, "Column A") + select_by_text(xcond1, "Does not end with") + xval1.executeAction("TYPE", mkPropertyValues({"TEXT":"CTORS"})) + + #Expected behaviours: A2 is not filtered as it does not end with "CTORS". + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "1") + gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + gridWinState = get_state_as_dict(gridwin) + self.assertEqual(gridWinState["CurrentRow"], "3") + # #reopen filter and verify - doesn't works + # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + # gridwin.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + # self.ui_test.execute_modeless_dialog_through_command(".uno:DataFilterStandardFilter") + # xDialog = self.xUITest.getTopFocusWindow() + # xfield1 = xDialog.getChild("field1") + # xval1 = xDialog.getChild("val1") + # xcond1 = xDialog.getChild("cond1") + # self.assertEqual(get_state_as_dict(xfield1)["SelectEntryText"], "Column A") + # self.assertEqual(get_state_as_dict(xval1)["Text"], "CTORS") + # self.assertEqual(get_state_as_dict(xcond1)["SelectEntryText"], "Does not end with") + # xCancelBtn = xDialog.getChild("cancel") + # self.ui_test.close_dialog_through_button(xCancelBtn) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sc/qa/uitest/calc_tests4/trackedChanges.py b/sc/qa/uitest/calc_tests4/trackedChanges.py new file mode 100644 index 0000000000..0f38f9f304 --- /dev/null +++ b/sc/qa/uitest/calc_tests4/trackedChanges.py @@ -0,0 +1,387 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +# tests for tracked changes ; tdf912270 + +from uitest.framework import UITestCase +from libreoffice.calc.document import get_cell_by_position +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.calc import enter_text_to_cell +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +import datetime + +class CalcTrackedChanges(UITestCase): + + def test_tdf131907(self): + with self.ui_test.load_file(get_url_for_data_file("tdf131907.ods")): + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + textStart = "Row inserted \tSheet1.1:1\t \t" + textEnd = "(Row 1:1 inserted)" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + + #it would crash here + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + + def test_tdf66263_Protect_Records(self): + with self.ui_test.create_doc_in_start_center("calc"): + self.ui_test.wait_until_child_is_available("grid_window") + self.xUITest.executeCommand(".uno:TraceChangeMode") + #protect dialog + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + xconfirm = xDialog.getChild("confirm1ed") + xconfirm.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + #verify password + with self.ui_test.execute_dialog_through_command(".uno:ProtectTraceChangeMode") as xDialog: + xpass = xDialog.getChild("pass1ed") + xpass.executeAction("TYPE", mkPropertyValues({"TEXT":"a"})) + + def test_ContentChange(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Hello") + enter_text_to_cell(gridwin, "A1", "There") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + + xChild = xChangesList.getChild('0') + self.assertTrue(get_state_as_dict(xChild)["Text"].startswith(textStart)) + + xChild.executeAction("EXPAND", tuple()) + + self.assertEqual(3, len(xChild.getChildren())) + textStartChild1 = "<empty>\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEndChild1 = "(Original: <empty>)" + textStartChild2 = "'Hello'\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEndChild2 = "(Changed to 'Hello')" + textStartChild3 = "'There'\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEndChild3 = "(Changed to 'There')" + + self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].startswith(textStartChild1)) + self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].endswith(textEndChild1)) + self.assertTrue(get_state_as_dict(xChild.getChild('1'))["Text"].startswith(textStartChild2)) + self.assertTrue(get_state_as_dict(xChild.getChild('1'))["Text"].endswith(textEndChild2)) + self.assertTrue(get_state_as_dict(xChild.getChild('2'))["Text"].startswith(textStartChild3)) + self.assertTrue(get_state_as_dict(xChild.getChild('2'))["Text"].endswith(textEndChild3)) + + self.assertEqual("There", get_cell_by_position(document, 0, 0, 0).getString()) + + def test_Tdf153096(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Hello") + + gridwin.executeAction("SELECT", mkPropertyValues({"CELL": "A1"})) + + self.xUITest.executeCommand(".uno:DeleteRows") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + textStart = "Row deleted\t(Sheet1.1:1)\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Row 1:1 deleted)" + + xChild = xChangesList.getChild('0') + + # Without the fix in place, this test would have failed here + self.assertTrue(get_state_as_dict(xChild)["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChild)["Text"].endswith(textEnd)) + + xChild.executeAction("EXPAND", tuple()) + + self.assertEqual(1, len(xChild.getChildren())) + textStartChild1 = "Changed contents\t(Sheet1.A1)\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEndChild1 = "(Cell (A1) changed from '<empty>' to 'Hello')" + + self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].startswith(textStartChild1)) + self.assertTrue(get_state_as_dict(xChild.getChild('0'))["Text"].endswith(textEndChild1)) + + def test_tracked_changes_accept(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + + def test_tracked_changes_acceptall(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept All tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(1, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "Test LibreOffice") + + def test_tracked_changes_reject(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(3, len(xChangesList.getChildren())) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd2)) + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('2'))["Text"], "Rejected") + + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd3)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd4)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + + def test_tracked_changes_rejectall(self): + + with self.ui_test.create_doc_in_start_center("calc") as document: + self.ui_test.wait_until_child_is_available("grid_window") + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + #track changes; enter text to cell + self.xUITest.executeCommand(".uno:TraceChangeMode") + enter_text_to_cell(gridwin, "A1", "Test LibreOffice") + enter_text_to_cell(gridwin, "A2", "Test LibreOffice") + #accept tracked changes + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(2, len(xChangesList.getChildren())) + + textStart = "Changed contents\tSheet1.A1\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd = "(Cell A1 changed from '<empty>' to 'Test LibreOffice')" + textStart2 = "Changed contents\tSheet1.A2\tUnknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + textEnd2 = "(Cell A2 changed from '<empty>' to 'Test LibreOffice')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1'))["Text"].endswith(textEnd2)) + + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(2, len(xChangesList.getChildren())) + self.assertEqual(get_state_as_dict(xChangesList.getChild('0'))["Text"], "Accepted") + self.assertEqual(get_state_as_dict(xChangesList.getChild('1'))["Text"], "Rejected") + + xChangesList.getChild('0').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('0').getChildren())) + + textEnd3 = "(Cell A1 changed from 'Test LibreOffice' to '<empty>')" + textEnd4 = "(Cell A2 changed from 'Test LibreOffice' to '<empty>')" + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('0'))["Text"].endswith(textEnd4)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('0').getChild('1'))["Text"].endswith(textEnd3)) + + xChangesList.getChild('1').executeAction("EXPAND", tuple()) + self.assertEqual(2, len(xChangesList.getChild('1').getChildren())) + + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].startswith(textStart)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('0'))["Text"].endswith(textEnd)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].startswith(textStart2)) + self.assertTrue(get_state_as_dict(xChangesList.getChild('1').getChild('1'))["Text"].endswith(textEnd2)) + + + self.assertEqual(get_cell_by_position(document, 0, 0, 0).getString(), "") + + def test_tdf136062(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf136062.ods")): + + self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptChanges", close_button="close") as xTrackDlg: + + xChangesList = xTrackDlg.getChild("calcchanges") + self.assertEqual(1, len(xChangesList.getChildren())) + + xRejectAllBtn = xTrackDlg.getChild("rejectall") + xRejectBtn = xTrackDlg.getChild("reject") + xAcceptAllBtn = xTrackDlg.getChild("acceptall") + xAcceptBtn = xTrackDlg.getChild("accept") + + # Without the fix in place, it would have failed with + # AssertionError: 'R~eject All' != 'R~eject All/Clear formatting' + self.assertEqual('R~eject All', get_state_as_dict(xRejectAllBtn)['Text']) + self.assertEqual('~Reject', get_state_as_dict(xRejectBtn)['Text']) + self.assertEqual('A~ccept All', get_state_as_dict(xAcceptAllBtn)['Text']) + self.assertEqual('~Accept', get_state_as_dict(xAcceptBtn)['Text']) + + def test_tdf85353(self): + with self.ui_test.create_doc_in_start_center("calc"): + xCalcDoc = self.xUITest.getTopFocusWindow() + gridwin = xCalcDoc.getChild("grid_window") + + enter_text_to_cell(gridwin, "A1", "15") + enter_text_to_cell(gridwin, "D1", "0") + enter_text_to_cell(gridwin, "E1", "0") + + with self.ui_test.execute_dialog_through_command(".uno:CompareDocuments", close_button="") as xOpenDialog: + xFileName = xOpenDialog.getChild("file_name") + xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf85353.ods")})) + xOpenBtn = xOpenDialog.getChild("open") + + with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK', close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("calcchanges") + + # Without the fix in place, this test would have failed with + # AssertionError: 1 != 0 + self.assertEqual(1, len(changesList.getChildren())) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))['Text'].startswith("Changed contents\tSheet1.E1")) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))['Text'].endswith("(Cell E1 changed from '5' to '0')")) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |