diff options
Diffstat (limited to 'sw/qa/uitest/writer_tests')
-rw-r--r-- | sw/qa/uitest/writer_tests/comments.py | 153 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/compareDocuments.py | 70 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/insertCaption.py | 62 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf134734.py | 83 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py | 34 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf78068.py | 30 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/tdf81457.py | 41 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/trackedChanges.py | 471 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/versionDialog.py | 36 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/watermark.py | 52 | ||||
-rw-r--r-- | sw/qa/uitest/writer_tests/wordCount.py | 282 |
11 files changed, 1314 insertions, 0 deletions
diff --git a/sw/qa/uitest/writer_tests/comments.py b/sw/qa/uitest/writer_tests/comments.py new file mode 100644 index 000000000..3e9d3a630 --- /dev/null +++ b/sw/qa/uitest/writer_tests/comments.py @@ -0,0 +1,153 @@ +# -*- 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 +#test comments + +class Comments(UITestCase): + + def test_comments_features(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + xMainWindow = self.xUITest.getTopFocusWindow() + + xwriter_edit = xMainWindow.getChild("writer_edit") + xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Before "})) + + # adding new Comment + self.xUITest.executeCommand(".uno:InsertAnnotation") + + # wait until the comment is available + xComment1 = self.ui_test.wait_until_child_is_available('Comment1') + + xEditView1 = xComment1.getChild("editview") + xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": "This is the First Comment"})) + self.assertEqual(get_state_as_dict(xComment1)["Text"], "This is the First Comment" ) + self.assertEqual(get_state_as_dict(xComment1)["Resolved"], "false" ) + self.assertEqual(get_state_as_dict(xComment1)["Author"], "Unknown Author" ) + self.assertEqual(get_state_as_dict(xComment1)["ReadOnly"], "false" ) + + xComment1.executeAction("LEAVE", mkPropertyValues({})) + + xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "After"})) + xwriter_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "13"})) + self.assertEqual(get_state_as_dict(xwriter_edit)["SelectedText"], "Before After" ) + + # test Resolve Comment + xComment1.executeAction("RESOLVE", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment1)["Resolved"], "true" ) + + # test Select text from Comment + xComment1.executeAction("SELECT", mkPropertyValues({"FROM": "0", "TO": "4"})) + self.assertEqual(get_state_as_dict(xComment1)["SelectedText"], "This" ) + + # test Hide then Show Comment + xComment1.executeAction("HIDE", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment1)["Visible"], "false" ) + xComment1.executeAction("SHOW", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment1)["Visible"], "true" ) + + # test delete Comment + xComment1.executeAction("DELETE", mkPropertyValues({})) + self.assertTrue("Comment1" not in xMainWindow.getChildren()) + + + def test_multi_comments(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + xMainWindow = self.xUITest.getTopFocusWindow() + + xwriter_edit = xMainWindow.getChild("writer_edit") + + # adding 3 new Comment + xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 1"})) + self.xUITest.executeCommand(".uno:InsertAnnotation") + # wait until the comment is available + xComment1 = self.ui_test.wait_until_child_is_available('Comment1') + xEditView1 = xComment1.getChild("editview") + xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": "First Comment"})) + xComment1.executeAction("LEAVE", mkPropertyValues({})) + xwriter_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 2"})) + self.xUITest.executeCommand(".uno:InsertAnnotation") + # wait until the comment is available + xComment2 = self.ui_test.wait_until_child_is_available('Comment2') + xEditView2 = xComment2.getChild("editview") + xEditView2.executeAction("TYPE", mkPropertyValues({"TEXT": "Second Comment"})) + xComment2.executeAction("LEAVE", mkPropertyValues({})) + xwriter_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Line 3"})) + self.xUITest.executeCommand(".uno:InsertAnnotation") + # wait until the comment is available + xComment3 = self.ui_test.wait_until_child_is_available('Comment3') + xEditView3 = xComment3.getChild("editview") + xEditView3.executeAction("TYPE", mkPropertyValues({"TEXT": "Third Comment"})) + xComment3.executeAction("LEAVE", mkPropertyValues({})) + xwriter_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) + + # Check text + self.assertEqual(get_state_as_dict(xComment1)["Text"], "First Comment" ) + self.assertEqual(get_state_as_dict(xComment2)["Text"], "Second Comment" ) + self.assertEqual(get_state_as_dict(xComment3)["Text"], "Third Comment" ) + + xComment2.executeAction("RESOLVE", mkPropertyValues({})) + xComment3.executeAction("RESOLVE", mkPropertyValues({})) + + # Check Resolved + self.assertEqual(get_state_as_dict(xComment1)["Resolved"], "false" ) + self.assertEqual(get_state_as_dict(xComment2)["Resolved"], "true" ) + self.assertEqual(get_state_as_dict(xComment3)["Resolved"], "true" ) + + # Check ReadOnly + self.assertEqual(get_state_as_dict(xComment1)["ReadOnly"], "false" ) + self.assertEqual(get_state_as_dict(xComment2)["ReadOnly"], "false" ) + self.assertEqual(get_state_as_dict(xComment3)["ReadOnly"], "false" ) + + # Check Select + xComment1.executeAction("SELECT", mkPropertyValues({"FROM": "0", "TO": "5"})) + self.assertEqual(get_state_as_dict(xComment1)["SelectedText"], "First" ) + + xComment2.executeAction("SELECT", mkPropertyValues({"FROM": "0", "TO": "6"})) + self.assertEqual(get_state_as_dict(xComment2)["SelectedText"], "Second" ) + + xComment3.executeAction("SELECT", mkPropertyValues({"FROM": "0", "TO": "5"})) + self.assertEqual(get_state_as_dict(xComment3)["SelectedText"], "Third" ) + + # Check that they all are Visible + self.assertEqual(get_state_as_dict(xComment1)["Visible"], "true" ) + self.assertEqual(get_state_as_dict(xComment2)["Visible"], "true" ) + self.assertEqual(get_state_as_dict(xComment3)["Visible"], "true" ) + + # Hide all + xComment1.executeAction("HIDE", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment1)["Visible"], "false" ) + xComment2.executeAction("HIDE", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment2)["Visible"], "false" ) + xComment3.executeAction("HIDE", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment3)["Visible"], "false" ) + + # Show comment 2 only + xComment2.executeAction("SHOW", mkPropertyValues({})) + self.assertEqual(get_state_as_dict(xComment2)["Visible"], "true" ) + + # Then remove the 3 comments + xComment1.executeAction("DELETE", mkPropertyValues({})) + xComment2.executeAction("DELETE", mkPropertyValues({})) + xComment3.executeAction("DELETE", mkPropertyValues({})) + self.assertTrue("Comment1" not in xMainWindow.getChildren()) + self.assertTrue("Comment2" not in xMainWindow.getChildren()) + self.assertTrue("Comment3" not in xMainWindow.getChildren()) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/compareDocuments.py b/sw/qa/uitest/writer_tests/compareDocuments.py new file mode 100644 index 000000000..55cbdd047 --- /dev/null +++ b/sw/qa/uitest/writer_tests/compareDocuments.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/. +# +# +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 +import datetime + +class compareDocuments(UITestCase): + + def test_tdf130960(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf130960.odt")) as writer_doc: + + xWriterDoc = self.xUITest.getTopFocusWindow() + + 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("tdf130960_2.odt")})) + xOpenBtn = xOpenDialog.getChild("open") + + # Close the dialog and open it again so the list of changes is updated + with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK', close_button="close"): + pass + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + text = "Unknown Author\t" + datetime.datetime.now().strftime("%m/%d/%Y") + self.assertEqual(2, len(changesList.getChildren())) + self.assertTrue(get_state_as_dict(changesList.getChild('0'))["Text"].startswith(text)) + self.assertTrue(get_state_as_dict(changesList.getChild('1'))["Text"].startswith(text)) + + + def test_tdf137855(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf137855.odt")) as writer_doc: + + xWriterDoc = self.xUITest.getTopFocusWindow() + + 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("tdf137855_2.odt")})) + xOpenBtn = xOpenDialog.getChild("open") + + # Close the dialog and open it again so the list of changes is updated + with self.ui_test.execute_dialog_through_action(xOpenBtn, 'CLICK', close_button="close"): + pass + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # Check the number of changes + self.assertEqual(263, len(changesList.getChildren())) + + # Without the fix in place, this test would have crashed here + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(0, len(changesList.getChildren())) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/insertCaption.py b/sw/qa/uitest/writer_tests/insertCaption.py new file mode 100644 index 000000000..5831f3cf3 --- /dev/null +++ b/sw/qa/uitest/writer_tests/insertCaption.py @@ -0,0 +1,62 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import select_pos + +class insertCaption(UITestCase): + + def test_insert_caption(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + with self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialogFr: + + xWidth = xDialogFr.getChild("width") + xWidth.executeAction("UP", tuple()) + xWidth.executeAction("UP", tuple()) + + xHeight = xDialogFr.getChild("height") + xHeight.executeAction("UP", tuple()) + xHeight.executeAction("UP", tuple()) + + + self.assertEqual(document.TextFrames.getCount(), 1) + + with self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") as xDialogCaption: + + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"})) + + + xFrame = document.TextFrames[0] + + self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption") + + with self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") as xDialogCaption: + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption2"})) + xSep = xDialogCaption.getChild("separator_edit") + xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) + + + self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2") + + with self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") as xDialogCaption: + xCapt = xDialogCaption.getChild("caption_edit") + xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption3"})) + xSep = xDialogCaption.getChild("separator_edit") + xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"})) + xPos = xDialogCaption.getChild("position") + select_pos(xPos, "1") + + + self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf134734.py b/sw/qa/uitest/writer_tests/tdf134734.py new file mode 100644 index 000000000..4497649f6 --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf134734.py @@ -0,0 +1,83 @@ +# -*- 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, select_pos +from com.sun.star.drawing.FillStyle import SOLID +import importlib + +class TestClass(UITestCase): + def test_master_page_background(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + + # set margins and fill color + with self.ui_test.execute_dialog_through_command(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") + spinMargLeft = DrawPageDialog.getChild("spinMargLeft") + for _ in range(20): + spinMargLeft.executeAction("UP",tuple()) + spinMargRight = DrawPageDialog.getChild("spinMargRight") + for _ in range(15): + spinMargRight.executeAction("UP",tuple()) + spinMargTop = DrawPageDialog.getChild("spinMargTop") + for _ in range(10): + spinMargTop.executeAction("UP",tuple()) + spinMargBot = DrawPageDialog.getChild("spinMargBot") + for _ in range(5): + spinMargBot.executeAction("UP",tuple()) + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "2") + btncolor = DrawPageDialog.getChild("btncolor") + btncolor.executeAction("CLICK",tuple()) + + xStyle = document.StyleFamilies["PageStyles"]["Standard"] + + self.assertEqual(xStyle.FillStyle, SOLID) + self.assertEqual(xStyle.LeftMargin, 2997) + self.assertEqual(xStyle.RightMargin, 2743) + self.assertEqual(xStyle.TopMargin, 2489) + self.assertEqual(xStyle.BottomMargin, 2235) + self.assertEqual(xStyle.BackgroundFullSize, True) + + # uncheck it + with self.ui_test.execute_dialog_through_command(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "true") + checkBackgroundFullSize.executeAction("CLICK",tuple()) + + self.assertEqual(xStyle.FillStyle, SOLID) + self.assertEqual(xStyle.LeftMargin, 2997) + self.assertEqual(xStyle.RightMargin, 2743) + self.assertEqual(xStyle.TopMargin, 2489) + self.assertEqual(xStyle.BottomMargin, 2235) + self.assertEqual(xStyle.BackgroundFullSize, False) + + # check it again + with self.ui_test.execute_dialog_through_command(".uno:PageDialog") as DrawPageDialog: + xTabs = DrawPageDialog.getChild("tabcontrol") + select_pos(xTabs, "1") + checkBackgroundFullSize = DrawPageDialog.getChild("checkBackgroundFullSize") + self.assertEqual(get_state_as_dict(checkBackgroundFullSize)["Selected"], "false") + checkBackgroundFullSize.executeAction("CLICK",tuple()) + + self.assertEqual(xStyle.FillStyle, SOLID) + self.assertEqual(xStyle.LeftMargin, 2997) + self.assertEqual(xStyle.RightMargin, 2743) + self.assertEqual(xStyle.TopMargin, 2489) + self.assertEqual(xStyle.BottomMargin, 2235) + self.assertEqual(xStyle.BackgroundFullSize, True) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py new file mode 100644 index 000000000..c33890ca9 --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py @@ -0,0 +1,34 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf137459(UITestCase): + + def test_tdf137459(self): + + with self.ui_test.create_doc_in_start_center("writer"): + + # adding new Comment + self.xUITest.executeCommand(".uno:InsertAnnotation") + # wait until the comment is available + xComment1 = self.ui_test.wait_until_child_is_available('Comment1') + + xEditView1 = xComment1.getChild("editview") + sText = "Ctrl+Del should not delete BACKWARDS" + xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": sText})) + self.assertEqual(get_state_as_dict(xComment1)["Text"], sText ) + + xEditView1.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+DELETE"})) + self.assertEqual(get_state_as_dict(xComment1)["Text"], sText ) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf78068.py b/sw/qa/uitest/writer_tests/tdf78068.py new file mode 100644 index 000000000..9c03e76ee --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf78068.py @@ -0,0 +1,30 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import type_text + +from uitest.uihelper.common import select_pos + +class tdf78068(UITestCase): + + def test_tdf78068_format_paragraph_crash(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #- add some text + type_text(xWriterEdit, "Test") + #- go to Format > Paragraph + with self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "0") + + self.assertEqual(document.Text.String[0:4], "Test") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/tdf81457.py b/sw/qa/uitest/writer_tests/tdf81457.py new file mode 100644 index 000000000..ff021a4f7 --- /dev/null +++ b/sw/qa/uitest/writer_tests/tdf81457.py @@ -0,0 +1,41 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file +from uitest.uihelper.common import select_pos + +class tdf81457(UITestCase): + +#tdf 81457 + def test_open_documentProperties_tdf81457(self): + with self.ui_test.load_file(get_url_for_data_file("tdf81457.odt")) as writer_doc: + with self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties") as xDialog: + xTabs = xDialog.getChild("tabcontrol") + select_pos(xTabs, "2") #tab Custom properties + + # tdf#123919 - custom document properties are sorted now + aExpectedDocProp = { + 2: {'aAndra': 'Ja'}, + 4: {'BookMarkCount': '78'}, + 5: {'BookMarkInfo1': '00FF0000FF010'}, + 6: {'BookMarkInfo2': '00FF0000FF030'}} + + for pos, aDocProp in aExpectedDocProp.items(): + xNameBox = xDialog.getChild("namebox" + str(pos)) + xTypeBox = xDialog.getChild("typebox" + str(pos)) + xValueEdit = xDialog.getChild("valueedit" + str(pos)) + name, value = aDocProp.popitem() + self.assertEqual(name, get_state_as_dict(xNameBox)['Text']) + self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText']) + self.assertEqual(value, get_state_as_dict(xValueEdit)['Text'][:13]) + + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py new file mode 100644 index 000000000..04834aef0 --- /dev/null +++ b/sw/qa/uitest/writer_tests/trackedChanges.py @@ -0,0 +1,471 @@ +# -*- 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 uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, type_text, select_by_text +from libreoffice.uno.propertyvalue import mkPropertyValues +from tempfile import TemporaryDirectory +from org.libreoffice.unotest import systemPathToFileUrl +import os.path + +class trackedchanges(UITestCase): + + def test_tdf91270(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + type_text(xWriterEdit, "Test") + + self.xUITest.executeCommand(".uno:TrackChanges") + + self.xUITest.executeCommand(".uno:SelectAll") #select whole text + self.xUITest.executeCommand(".uno:Cut") #cut text + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close"): + pass + + def test_tracked_changes_accept(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, "Test LibreOffice") + self.xUITest.executeCommand(".uno:ShowTrackedChanges") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String[0:16], "Test LibreOffice") + + def test_tracked_changes_acceptall(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, "Test LibreOffice") + self.xUITest.executeCommand(".uno:ShowTrackedChanges") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + + self.assertEqual(document.Text.String[0:16], "Test LibreOffice") + + def test_tracked_changes_reject(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, "Test LibreOffice") + self.xUITest.executeCommand(".uno:ShowTrackedChanges") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + + xRejBtn = xTrackDlg.getChild("reject") + xRejBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String[0:1], "") + + def test_tracked_changes_rejectall(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, "Test LibreOffice") + self.xUITest.executeCommand(".uno:ShowTrackedChanges") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String[0:1], "") + + def test_tracked_changes_zprev_next(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, "Test LibreOffice") + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, " Test2") + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, " Test3") + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, " Test4") + self.xUITest.executeCommand(".uno:TrackChanges") + type_text(xWriterEdit, " Test5") + self.xUITest.executeCommand(".uno:PreviousTrackedChange") + self.xUITest.executeCommand(".uno:RejectTrackedChange") + self.assertEqual(document.Text.String[0:37], "Test LibreOffice Test2 Test3 Test4") + + self.xUITest.executeCommand(".uno:PreviousTrackedChange") + self.xUITest.executeCommand(".uno:PreviousTrackedChange") + self.xUITest.executeCommand(".uno:AcceptTrackedChange") + self.assertEqual(document.Text.String[0:37], "Test LibreOffice Test2 Test3 Test4") + + self.xUITest.executeCommand(".uno:NextTrackedChange") + self.xUITest.executeCommand(".uno:RejectTrackedChange") + self.assertEqual(document.Text.String[0:30], "Test LibreOffice Test2 Test4") + + + def test_list_of_changes(self): + with self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt")) as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + listText = [ + "Unknown Author\t01/24/2020 16:19:32\t", + "Unknown Author\t01/24/2020 16:19:35\t", + "Unknown Author\t01/24/2020 16:19:39\t", + "Unknown Author\t01/24/2020 16:19:39\t", + "Xisco Fauli\t01/27/2020 17:42:55\t"] + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + resultsAccept = [ + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger.", + "The tennis ball is a small ball. The basketball is much bigger."] + + for i in range(len(listText)): + self.assertEqual(document.Text.String.strip(), resultsAccept[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String.strip(), resultsAccept[5]) + #List is empty + self.assertFalse('0' in changesList.getChildren()) + + for i in reversed(range(len(listText))): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(document.Text.String.strip(), resultsAccept[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + + resultsReject = [ + "The tennis ball is a small ball. The baskedtball is much bigger.", + "The tenis ball is a small ball. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedtball is much bigger.", + "The tenis ball is a small bal. The baskedball is much bigger.", + "The tenis ball is a small bal. The baskedball is much biger."] + + for i in range(len(listText)): + self.assertEqual(document.Text.String.strip(), resultsReject[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(document.Text.String.strip(), resultsReject[5]) + #List is empty + self.assertFalse('0' in changesList.getChildren()) + + for i in reversed(range(len(listText))): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(document.Text.String.strip(), resultsReject[i]) + self.assertEqual(get_state_as_dict(changesList.getChild('0'))["Text"], listText[i] ) + + + def test_tdf135018(self): + with self.ui_test.load_file(get_url_for_data_file("tdf135018.odt")) as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + self.assertEqual(5, document.CurrentController.PageCount) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + self.assertEqual(111, len(changesList.getChildren())) + + # Without the fix in place, it would have crashed here + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + + self.assertEqual(0, len(changesList.getChildren())) + + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + + self.assertEqual(111, len(changesList.getChildren())) + + + # Check the changes are shown after opening the Manage Tracked Changes dialog + self.assertGreater(document.CurrentController.PageCount, 5) + + def test_tdf144270_tracked_table_rows(self): + with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + # Accept + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # This was 14 (every cell is a different change instead of counting rows or tables) + # Now: 4 changes (2 deleted/inserted rows and 2 deleted/inserted tables) + self.assertEqual(4, len(changesList.getChildren())) + + # Without the fix in place, it would have crashed here + for i in (3, 2, 1, 0): + xAccBtn = xTrackDlg.getChild("accept") + xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(i, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(2, len(tables)) + + for i in range(1, 5): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(i, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + # Accept All + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # This was 14 (every cell is a different change instead of counting rows or tables) + # Now: 4 changes (2 deleted/inserted rows and 2 deleted/inserted tables) + self.assertEqual(4, len(changesList.getChildren())) + + xAccBtn = xTrackDlg.getChild("acceptall") + xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(0, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(2, len(tables)) + + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(4, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + # goto to the start of the document to reject from the first tracked table row change + self.xUITest.executeCommand(".uno:GoToStartOfDoc") + + # Reject + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # This was 14 (every cell is a different change instead of counting rows or tables) + # Now: 4 changes (2 deleted/inserted rows and 2 deleted/inserted tables) + self.assertEqual(4, len(changesList.getChildren())) + + # Without the fix in place, it would have crashed here + for i in (3, 2, 1, 0): + xAccBtn = xTrackDlg.getChild("reject") + xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(i, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(2, len(tables)) + + for i in range(1, 5): + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(i, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + # Reject All + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # This was 14 (every cell is a different change instead of counting rows or tables) + # Now: 4 changes (2 deleted/inserted rows and 2 deleted/inserted tables) + self.assertEqual(4, len(changesList.getChildren())) + + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(0, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(2, len(tables)) + + xUndoBtn = xTrackDlg.getChild("undo") + xUndoBtn.executeAction("CLICK", tuple()) + self.assertEqual(4, len(changesList.getChildren())) + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + def test_tdf148032(self): + + with self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt")) as document: + + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + # adding new Comment + self.xUITest.executeCommand(".uno:InsertAnnotation") + + # wait until the comment is available + xComment1 = self.ui_test.wait_until_child_is_available('Comment1') + + xEditView1 = xComment1.getChild("editview") + xEditView1.executeAction("TYPE", mkPropertyValues({"TEXT": "This is the First Comment"})) + self.assertEqual(get_state_as_dict(xComment1)["Text"], "This is the First Comment" ) + self.assertEqual(get_state_as_dict(xComment1)["Resolved"], "false" ) + self.assertEqual(get_state_as_dict(xComment1)["Author"], "Unknown Author" ) + self.assertEqual(get_state_as_dict(xComment1)["ReadOnly"], "false" ) + + xComment1.executeAction("LEAVE", mkPropertyValues({})) + + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + self.assertEqual(6, len(changesList.getChildren())) + + xChild = changesList.getChild(0) + # This was False (missing comment) + self.assertEqual(True, get_state_as_dict(xChild)["Text"].endswith('\tComment added')) + + def test_tdf147179(self): + with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + tables = document.getTextTables() + self.assertEqual(3, len(tables)) + + # Select text of the tracked row, not only text of its first cell + with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild("writerchanges") + + # select second tracked table row in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') + while get_state_as_dict(xWriterEdit)["SelectedText"] != 'klj': + xToolkit.processEventsToIdle() + + # this was "j" (only text of the first cell was selected, not text of the row) + self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "klj" ) + + # select first tracked table row in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"})) + while get_state_as_dict(xWriterEdit)["SelectedText"] != 'bca': + xToolkit.processEventsToIdle() + + # this was "a" (only text of the first cell was selected, not text of the row) + self.assertEqual(get_state_as_dict(xWriterEdit)["SelectedText"], "bca" ) + + def test_RedlineSuccessorData(self): + with TemporaryDirectory() as tempdir: + xFilePath = os.path.join(tempdir, "redlinesuccessordata-temp.odt") + with self.ui_test.load_file(get_url_for_data_file("redlinesuccessordata.docx")) as document: + + # check tracked deletion in tracked insertion + with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild('writerchanges') + # four children, but only three visible + state = get_state_as_dict(changesList) + self.assertEqual(state['Children'], '4') + self.assertEqual(state['VisibleCount'], '3') + + # select tracked deletion with RedlineSuccessorData in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['SelectEntryText'], 'Kelemen Gábor 2\t05/19/2021 12:35:00\t') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['Children'], '1') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['VisibleChildCount'], '0') + + # open tree node with the tracked insertion: four visible children + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['Children'], '4') + self.assertEqual(state['VisibleCount'], '4') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['Children'], '1') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['VisibleChildCount'], '1') + + # select tracked insertion in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['SelectEntryText'], 'First Person\t10/21/2012 23:45:00\t') + + # Save the DOCX document as ODT with a tracked deletion in a tracked insertion + with self.ui_test.execute_dialog_through_command(".uno:SaveAs", 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})) + xFileTypeCombo = xSaveDialog.getChild("file_type") + select_by_text(xFileTypeCombo, "ODF Text Document (.odt)") + + self.ui_test.wait_until_file_is_available(xFilePath) + # load the temporary file, and check ODF roundtrip of the tracked deletion in a tracked insertion + with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document: + # check tracked deletion in tracked insertion + with self.ui_test.execute_modeless_dialog_through_command('.uno:AcceptTrackedChanges', close_button="close") as xTrackDlg: + changesList = xTrackDlg.getChild('writerchanges') + # four children, but only three visible + state = get_state_as_dict(changesList) + self.assertEqual(state['Children'], '4') + self.assertEqual(state['VisibleCount'], '3') + + # select tracked deletion with RedlineSuccessorData in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['SelectEntryText'], 'Kelemen Gábor 2\t05/19/2021 12:35:00\t') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['Children'], '1') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['VisibleChildCount'], '0') + + # open tree node with the tracked insertion: four visible children + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['Children'], '4') + self.assertEqual(state['VisibleCount'], '4') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['Children'], '1') + self.assertEqual(get_state_as_dict(changesList.getChild(1))['VisibleChildCount'], '1') + + # select tracked insertion in tree list + changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"})) + state = get_state_as_dict(changesList) + self.assertEqual(state['SelectEntryText'], 'First Person\t10/21/2012 23:45:00\t') + + # reject all + xAccBtn = xTrackDlg.getChild("rejectall") + xAccBtn.executeAction("CLICK", tuple()) + # FIXME why we need double rejectall (dialog-only)? + xAccBtn.executeAction("CLICK", tuple()) + self.assertEqual(0, len(changesList.getChildren())) + # This was false, because of not rejected tracked deletion + # of the text "inserts": "Document text inserts document"... + self.assertTrue(document.getText().getString().startswith('Document text document text')) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/versionDialog.py b/sw/qa/uitest/writer_tests/versionDialog.py new file mode 100644 index 000000000..5f34de511 --- /dev/null +++ b/sw/qa/uitest/writer_tests/versionDialog.py @@ -0,0 +1,36 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# +from uitest.framework import UITestCase +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file + +class versionDialog(UITestCase): + + def test_tdf131931(self): + + with self.ui_test.load_file(get_url_for_data_file("tdf131931.odt")) as writer_doc: + + xWriterDoc = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_dialog_through_command(".uno:VersionDialog", close_button="close") as xVersionDialog: + + + versiondList = xVersionDialog.getChild("versions") + + text = "04/06/2020 15:18\t\tHELLO" + self.assertEqual(1, len(versiondList.getChildren())) + self.assertEqual(get_state_as_dict(versiondList.getChild('0'))["Text"].strip(), text) + + xDeleteBtn = xVersionDialog.getChild("delete") + xDeleteBtn.executeAction("CLICK", tuple()) + + self.assertEqual(0, len(versiondList.getChildren())) + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/watermark.py b/sw/qa/uitest/writer_tests/watermark.py new file mode 100644 index 000000000..1ba46cecc --- /dev/null +++ b/sw/qa/uitest/writer_tests/watermark.py @@ -0,0 +1,52 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict + + +class watermark(UITestCase): + + def test_insert_watermark(self): + with self.ui_test.create_doc_in_start_center("writer"): + xWriterDoc = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_dialog_through_command(".uno:Watermark") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xAngle = xDialog.getChild("Angle") + xTransparency = xDialog.getChild("Transparency") + + xTextInput.executeAction("TYPE", mkPropertyValues({"TEXT":"Watermark"})) + xAngle.executeAction("UP", tuple()) + xTransparency.executeAction("UP", tuple()) + + + with self.ui_test.execute_dialog_through_command(".uno:Watermark", close_button="cancel") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xAngle = xDialog.getChild("Angle") + xTransparency = xDialog.getChild("Transparency") + + self.assertEqual(get_state_as_dict(xTextInput)["Text"], "Watermark") + self.assertEqual(get_state_as_dict(xAngle)["Text"], "90°") + self.assertEqual(get_state_as_dict(xTransparency)["Text"], "51%") + + + with self.ui_test.execute_dialog_through_command(".uno:Watermark") as xDialog: + xTextInput = xDialog.getChild("TextInput") + xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"})) + xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"})) + + with self.ui_test.execute_dialog_through_command(".uno:Watermark", close_button="cancel") as xDialog: + xTextInput = xDialog.getChild("TextInput") + + self.assertEqual(get_state_as_dict(xTextInput)["Text"], "") + + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/qa/uitest/writer_tests/wordCount.py b/sw/qa/uitest/writer_tests/wordCount.py new file mode 100644 index 000000000..c1e816337 --- /dev/null +++ b/sw/qa/uitest/writer_tests/wordCount.py @@ -0,0 +1,282 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +from uitest.framework import UITestCase +from libreoffice.uno.propertyvalue import mkPropertyValues +from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, type_text + +class writerWordCount(UITestCase): + + def test_word_count_dialog(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + type_text(xWriterEdit, "Test for word count dialog") #type text + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "8"})) #select two words + + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "5") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "8") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "26") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "7") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "22") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + + + def test_tdf68347(self): + #Bug 68347 - Incorrect word count in a document with recorded changes + with self.ui_test.load_file(get_url_for_data_file("tdf68347.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "24", "END_POS": "39"})) #select two words + + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "4") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "15") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "12") + #Bug 117703 Word Count: Wrong result for "Characters excluding spaces" + #self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + + def test_tdf91100(self): + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close"): + pass + + def test_tdf58050(self): + with self.ui_test.load_file(get_url_for_data_file("tdf58050.html")) as writer_doc: + + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "3") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "14") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + + def test_word_count_interpunction_counted_tdf56975_a(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #Open writer, enter "Testing one two! Test?" + type_text(xWriterEdit, "Testing one two! Test?") + #-> LO says: 4 words. SUCCESS! :) + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "4") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "22") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "19") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + + + def test_word_count_interpunction_counted_tdf56975_b(self): + + with self.ui_test.create_doc_in_start_center("writer") as document: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #1. Create a new text document. + #2. Type-in the words: + # This is a test sentence. + type_text(xWriterEdit, "This is a test sentence.") + #3. Open the word count dialogue. + # Word count in both, dialogue and status line, shows 5 words. + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "5") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "24") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "20") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + #4. Select the space between 'a' and 'test'. + xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "9", "END_POS": "10"})) + #5. Replace selection by a non-breaking space by pressing Shift+Ctrl+Space. Don't move the cursor. + self.xUITest.executeCommand(".uno:InsertNonBreakingSpace") + # Word count in dialogue shows 4 words, whereas in the status line it shows 5 words. + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "5") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "24") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "20") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + #6. Move the cursor by pressing Left. + self.xUITest.executeCommand(".uno:GoLeft") + # Word count in both, dialogue and status line, shows 5 words. + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "5") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "24") + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "20") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + + def test_tdf51816(self): + with self.ui_test.load_file(get_url_for_data_file("tdf51816.odt")) as writer_doc: + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + #1. Open attached document + #2. Tools> Word count + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + #3. Click after "At nunc" then <Ctrl><Shift><Left> + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:GoRight") + self.xUITest.executeCommand(".uno:WordLeftSel") + + #needs to wait, because Word count dialog is already open and it takes time to refresh the counter + #Expected result : Words 1 & Characters 4 #Actual result : Words 0 & Characters 0 + self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "1") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "1") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "4") + + #4. Click after "At nunc" then <Shift><Home> + self.xUITest.executeCommand(".uno:StartOfParaSel") + + #needs to wait, because Word count dialog is already open and it takes time to refresh the counter + #Expected result : Words 2 & Characters 7 & excluding space 6 #Actual result : Words 0 & Characters 0 + self.ui_test.wait_until_property_is_updated(xselectwords, "Text", "2") + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "2") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "7") + + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "6") + + + def test_tdf117703(self): + with self.ui_test.load_file(get_url_for_data_file("tdf117703.odt")): + self.xUITest.getTopFocusWindow() + + self.xUITest.executeCommand(".uno:SelectAll") + + with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close") as xDialog: + + xselectwords = xDialog.getChild("selectwords") + xdocwords = xDialog.getChild("docwords") + xselectchars = xDialog.getChild("selectchars") + xdocchars = xDialog.getChild("docchars") + xselectcharsnospaces = xDialog.getChild("selectcharsnospaces") + xdoccharsnospaces = xDialog.getChild("doccharsnospaces") + xselectcjkchars = xDialog.getChild("selectcjkchars") + xdoccjkchars = xDialog.getChild("doccjkchars") + + self.assertEqual(get_state_as_dict(xselectwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xdocwords)["Text"], "12") + self.assertEqual(get_state_as_dict(xselectchars)["Text"], "54") + self.assertEqual(get_state_as_dict(xdocchars)["Text"], "54") + + # Without the fix in place it would have failed with: AssertionError: '0' != '44' + self.assertEqual(get_state_as_dict(xselectcharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xdoccharsnospaces)["Text"], "44") + self.assertEqual(get_state_as_dict(xselectcjkchars)["Text"], "0") + self.assertEqual(get_state_as_dict(xdoccjkchars)["Text"], "0") + +# vim: set shiftwidth=4 softtabstop=4 expandtab: |