summaryrefslogtreecommitdiff
path: root/sw/qa/uitest/writer_tests
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/uitest/writer_tests')
-rw-r--r--sw/qa/uitest/writer_tests/comments.py245
-rw-r--r--sw/qa/uitest/writer_tests/compareDocuments.py87
-rw-r--r--sw/qa/uitest/writer_tests/insertCaption.py76
-rw-r--r--sw/qa/uitest/writer_tests/tdf134734.py81
-rw-r--r--sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py25
-rw-r--r--sw/qa/uitest/writer_tests/tdf156165.py76
-rw-r--r--sw/qa/uitest/writer_tests/tdf53460.py78
-rw-r--r--sw/qa/uitest/writer_tests/tdf78068.py36
-rw-r--r--sw/qa/uitest/writer_tests/tdf81457.py51
-rw-r--r--sw/qa/uitest/writer_tests/tdf93068.py59
-rw-r--r--sw/qa/uitest/writer_tests/trackedChanges.py796
-rw-r--r--sw/qa/uitest/writer_tests/versionDialog.py28
-rw-r--r--sw/qa/uitest/writer_tests/watermark.py65
-rw-r--r--sw/qa/uitest/writer_tests/wordCount.py531
14 files changed, 1265 insertions, 969 deletions
diff --git a/sw/qa/uitest/writer_tests/comments.py b/sw/qa/uitest/writer_tests/comments.py
index c846372a99aa..3e9d3a6301d8 100644
--- a/sw/qa/uitest/writer_tests/comments.py
+++ b/sw/qa/uitest/writer_tests/comments.py
@@ -8,153 +8,146 @@
#
from uitest.framework import UITestCase
-import time
-from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.uihelper.common import get_state_as_dict
from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.debug import sleep
-from uitest.config import DEFAULT_SLEEP
#test comments
class Comments(UITestCase):
def test_comments_features(self):
- xMainDoc = self.ui_test.create_doc_in_start_center("writer")
+ with self.ui_test.create_doc_in_start_center("writer"):
- xMainWindow = self.xUITest.getTopFocusWindow()
+ xMainWindow = self.xUITest.getTopFocusWindow()
- xwriter_edit = xMainWindow.getChild("writer_edit")
- xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Before "}))
+ xwriter_edit = xMainWindow.getChild("writer_edit")
+ xwriter_edit.executeAction("TYPE", mkPropertyValues({"TEXT": "Before "}))
- # adding new Comment
- self.xUITest.executeCommand(".uno:InsertAnnotation")
+ # adding new Comment
+ self.xUITest.executeCommand(".uno:InsertAnnotation")
- # wait until the comment is available
- xComment1 = self.ui_test.wait_until_child_is_available('Comment1')
+ # 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" )
+ 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({}))
+ 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" )
+ 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 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 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 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())
+ # test delete Comment
+ xComment1.executeAction("DELETE", mkPropertyValues({}))
+ self.assertTrue("Comment1" not in xMainWindow.getChildren())
- self.ui_test.close_doc()
def test_multi_comments(self):
- xMainDoc = 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())
-
- self.ui_test.close_doc()
+ 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
index 6cb90bf99466..f2575f5ec906 100644
--- a/sw/qa/uitest/writer_tests/compareDocuments.py
+++ b/sw/qa/uitest/writer_tests/compareDocuments.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
@@ -7,6 +6,7 @@
# 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
@@ -16,76 +16,51 @@ class compareDocuments(UITestCase):
def test_tdf130960(self):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf130960.odt"))
-
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
-
- self.ui_test.execute_dialog_through_command(".uno:CompareDocuments")
-
- xOpenDialog = self.xUITest.getTopFocusWindow()
- xFileName = xOpenDialog.getChild("file_name")
- xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf130960_2.odt")}))
+ with self.ui_test.load_file(get_url_for_data_file("tdf130960.odt")):
- xOpenBtn = xOpenDialog.getChild("open")
- xOpenBtn.executeAction("CLICK", tuple())
+ 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
- xTrackDlg = self.xUITest.getTopFocusWindow()
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
+ # 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
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- changesList = xTrackDlg.getChild("writerchanges")
+ 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))
+ 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))
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
-
- self.ui_test.close_doc()
def test_tdf137855(self):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf137855.odt"))
-
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
-
- self.ui_test.execute_dialog_through_command(".uno:CompareDocuments")
-
- xOpenDialog = self.xUITest.getTopFocusWindow()
- xFileName = xOpenDialog.getChild("file_name")
- xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")}))
+ with self.ui_test.load_file(get_url_for_data_file("tdf137855.odt")):
- xOpenBtn = xOpenDialog.getChild("open")
- xOpenBtn.executeAction("CLICK", tuple())
+ with self.ui_test.execute_dialog_through_command(".uno:CompareDocuments", close_button="") as xOpenDialog:
- # Close the dialog and open it again so the list of changes is updated
- xTrackDlg = self.xUITest.getTopFocusWindow()
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
+ xFileName = xOpenDialog.getChild("file_name")
+ xFileName.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("tdf137855_2.odt")}))
+ xOpenBtn = xOpenDialog.getChild("open")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- changesList = xTrackDlg.getChild("writerchanges")
+ # 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
- # Check the number of changes
- self.assertEqual(263, len(changesList.getChildren()))
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
+ changesList = xTrackDlg.getChild("writerchanges")
- # Without the fix in place, this test would have crashed here
- xAccBtn = xTrackDlg.getChild("acceptall")
- xAccBtn.executeAction("CLICK", tuple())
+ # Check the number of changes
+ self.assertEqual(263, len(changesList.getChildren()))
- self.assertEqual(0, len(changesList.getChildren()))
+ # Without the fix in place, this test would have crashed here
+ xAccBtn = xTrackDlg.getChild("acceptall")
+ xAccBtn.executeAction("CLICK", tuple())
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
+ self.assertEqual(0, len(changesList.getChildren()))
- self.ui_test.close_doc()
# 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
index de73b3b767e5..7002c748bd8d 100644
--- a/sw/qa/uitest/writer_tests/insertCaption.py
+++ b/sw/qa/uitest/writer_tests/insertCaption.py
@@ -1,76 +1,60 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
+# This file is part of the LibreOffice project.
+#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import get_state_as_dict
-import time
-from uitest.debug import sleep
from uitest.uihelper.common import select_pos
class insertCaption(UITestCase):
def test_insert_caption(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- self.ui_test.execute_dialog_through_command(".uno:InsertFrame") # insert frame
- xDialogFr = self.xUITest.getTopFocusWindow()
-
- xWidth = xDialogFr.getChild("width")
- xWidth.executeAction("UP", tuple())
- xWidth.executeAction("UP", tuple())
+ with self.ui_test.create_doc_in_start_center("writer") as document:
+ with self.ui_test.execute_dialog_through_command(".uno:InsertFrame") as xDialogFr:
- xHeight = xDialogFr.getChild("height")
- xHeight.executeAction("UP", tuple())
- xHeight.executeAction("UP", tuple())
+ xWidth = xDialogFr.getChild("width")
+ xWidth.executeAction("UP", tuple())
+ xWidth.executeAction("UP", tuple())
- xOkBtn=xDialogFr.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ xHeight = xDialogFr.getChild("height")
+ xHeight.executeAction("UP", tuple())
+ xHeight.executeAction("UP", tuple())
- self.assertEqual(document.TextFrames.getCount(), 1)
- self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # caption
- xDialogCaption = self.xUITest.getTopFocusWindow()
+ self.assertEqual(len(document.TextFrames), 1)
- xCapt = xDialogCaption.getChild("caption_edit")
- xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption"}))
+ with self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") as xDialogCaption:
- xOkBtn=xDialogCaption.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
+ 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")
+ self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption")
- self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 2nd caption
- xDialogCaption = self.xUITest.getTopFocusWindow()
- xCapt = xDialogCaption.getChild("caption_edit")
- xCapt.executeAction("TYPE", mkPropertyValues({"TEXT":"Caption2"}))
- xSep = xDialogCaption.getChild("separator_edit")
- xSep.executeAction("TYPE", mkPropertyValues({"TEXT":"-"}))
+ 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":"-"}))
- xOkBtn=xDialogCaption.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
- self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2")
+ self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2")
- self.ui_test.execute_dialog_through_command(".uno:InsertCaptionDialog") # 3. caption
- xDialogCaption = self.xUITest.getTopFocusWindow()
- 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")
+ 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")
- xOkBtn=xDialogCaption.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
- self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3")
+ self.assertEqual(document.TextFrames[0].Text.String.replace('\r\n', '\n'), "\nText 1: Caption\nText 2-: Caption2\nText 3--: Caption3")
- self.ui_test.close_doc()
# 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 000000000000..44edf6c1af5c
--- /dev/null
+++ b/sw/qa/uitest/writer_tests/tdf134734.py
@@ -0,0 +1,81 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict, select_pos
+from com.sun.star.drawing.FillStyle import SOLID
+
+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
index 97e60b8c07de..c33890ca9bd2 100644
--- a/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
+++ b/sw/qa/uitest/writer_tests/tdf137459_editeng_ctrl-DEL.py
@@ -8,28 +8,27 @@
#
from uitest.framework import UITestCase
-from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.uihelper.common import get_state_as_dict
from libreoffice.uno.propertyvalue import mkPropertyValues
class tdf137459(UITestCase):
def test_tdf137459(self):
- xMainDoc = self.ui_test.create_doc_in_start_center("writer")
+ 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')
+ # 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 = 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 )
+ xEditView1.executeAction("TYPE", mkPropertyValues({"KEYCODE": "CTRL+DELETE"}))
+ self.assertEqual(get_state_as_dict(xComment1)["Text"], sText )
- self.ui_test.close_doc()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/writer_tests/tdf156165.py b/sw/qa/uitest/writer_tests/tdf156165.py
new file mode 100644
index 000000000000..02353a533d47
--- /dev/null
+++ b/sw/qa/uitest/writer_tests/tdf156165.py
@@ -0,0 +1,76 @@
+# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+from uitest.framework import UITestCase
+from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
+from uitest.uihelper.common import select_pos
+from libreoffice.uno.propertyvalue import mkPropertyValues
+from time import sleep
+
+class tdf156165(UITestCase):
+
+ def change_autocorrect_option(self, enabled):
+ with self.ui_test.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog:
+ xTabs = xDialog.getChild("tabcontrol")
+ select_pos(xTabs, "2")
+ xList = xDialog.getChild('list')
+ xCheckbox = xList.getChild("17")
+ self.assertEqual("Replace Custom Styles", get_state_as_dict(xCheckbox)["Text"])
+
+ xCheckbox.executeAction("CLICK", tuple())
+ self.assertEqual(enabled, get_state_as_dict(xCheckbox)["IsChecked"])
+
+ def test_tdf156165(self):
+ with self.ui_test.load_file(get_url_for_data_file("tdf156165.odt")):
+ xMainWindow = self.xUITest.getTopFocusWindow()
+ writer_edit = xMainWindow.getChild("writer_edit")
+ style=xMainWindow.getChild('applystyle')
+
+ # Replace Custom Styles when applying manually with it disabled, should not change style
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
+ self.xUITest.executeCommand(".uno:AutoFormatApply")
+ sleep(1)
+ self.assertEqual(get_state_as_dict(style)["Text"], "eSelah")
+
+ # Replace Custom Styles when typing with it disabled, should not change style
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"}))
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ sleep(1)
+ self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
+ self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line
+
+ try:
+ self.change_autocorrect_option("true")
+
+ # Replace Custom Styles when applying manually with it enabled, should change style
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
+ self.xUITest.executeCommand(".uno:AutoFormatApply")
+ sleep(1)
+ self.assertEqual(get_state_as_dict(style)["Text"], "Body Text")
+
+ # Replace Custom Styles when typing with it enabled, should not change style
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"}))
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
+ sleep(1)
+ self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # new line
+ writer_edit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
+ writer_edit.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
+ self.assertEqual(get_state_as_dict(style)["Text"], "eSelah") # original line
+
+ finally:
+ # reset to default
+ self.change_autocorrect_option("false")
+
+# vim: set shiftwidth=4 softtabstop=4 expandtab:
diff --git a/sw/qa/uitest/writer_tests/tdf53460.py b/sw/qa/uitest/writer_tests/tdf53460.py
deleted file mode 100644
index f8fc0ad47451..000000000000
--- a/sw/qa/uitest/writer_tests/tdf53460.py
+++ /dev/null
@@ -1,78 +0,0 @@
-# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-from uitest.framework import UITestCase
-from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.debug import sleep
-
-class tdf53460(UITestCase):
-
- def test_resize_table_with_keyboard_tdf53460(self):
-
- self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
- #-insert a table (by default 2x2)
- self.ui_test.execute_dialog_through_command(".uno:InsertTable")
- xDialog = self.xUITest.getTopFocusWindow()
- xOkBtn = xDialog.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
-
- #-put the cursor inside first cell top left for example
- #-insert an inner table (by default 2x2) inside this cell
- self.ui_test.execute_dialog_through_command(".uno:InsertTable")
- xDialog = self.xUITest.getTopFocusWindow()
- xOkBtn = xDialog.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
- #-still in top left cell, go to the line after the inner table
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
- #- <ALT>+up key => crash
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
-
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
-
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
-
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
-
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+UP"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+DOWN"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+RIGHT"}))
- xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "ALT+LEFT"}))
-
- self.assertEqual(document.TextTables.getCount(), 2)
- self.ui_test.close_doc()
-# 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
index 145b0bd99b51..9c03e76ee579 100644
--- a/sw/qa/uitest/writer_tests/tdf78068.py
+++ b/sw/qa/uitest/writer_tests/tdf78068.py
@@ -1,36 +1,30 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
+# This file is part of the LibreOffice project.
+#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
from uitest.framework import UITestCase
-from libreoffice.uno.propertyvalue import mkPropertyValues
-from uitest.uihelper.common import get_state_as_dict, type_text
+from uitest.uihelper.common import type_text
-import time
-from uitest.debug import sleep
-from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import select_pos
class tdf78068(UITestCase):
def test_tdf78068_format_paragraph_crash(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- #- add some text
- type_text(xWriterEdit, "Test")
- #- go to Format > Paragraph
- self.ui_test.execute_dialog_through_command(".uno:ParagraphDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xTabs = xDialog.getChild("tabcontrol")
- select_pos(xTabs, "0")
- xOK = xDialog.getChild("ok")
- xOK.executeAction("CLICK", tuple()) #close dialog
+ 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")
- self.ui_test.close_doc()
+ self.assertEqual(document.Text.String[0:4], "Test")
-# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file
+# 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
index f8b93a9bc60a..8928a2a96b09 100644
--- a/sw/qa/uitest/writer_tests/tdf81457.py
+++ b/sw/qa/uitest/writer_tests/tdf81457.py
@@ -8,7 +8,6 @@
#
from uitest.framework import UITestCase
-from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file
from uitest.uihelper.common import select_pos
@@ -16,29 +15,27 @@ class tdf81457(UITestCase):
#tdf 81457
def test_open_documentProperties_tdf81457(self):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf81457.odt"))
- self.ui_test.execute_dialog_through_command(".uno:SetDocumentProperties")
- xDialog = self.xUITest.getTopFocusWindow()
- xTabs = xDialog.getChild("tabcontrol")
- select_pos(xTabs, "2") #tab Custom properties
-
- aExpectedNames = ['BookMarkCount', 'BookMarkInfo1', 'BookMarkInfo10', 'BookMarkInfo11',
- 'BookMarkInfo12', 'BookMarkInfo13']
- aExpectedValues = ['78', '00FF0000FF010', '00FF0000FF1E0', '00FF0000FF1E0',
- '00FF0000FF210', '00FF0000FF230']
-
- for i in range(6):
- xNameBox = xDialog.getChild("namebox" + str(i + 1))
- xTypeBox = xDialog.getChild("typebox" + str(i + 1))
- xValueEdit = xDialog.getChild("valueedit" + str(i + 1))
- self.assertEqual(aExpectedNames[i], get_state_as_dict(xNameBox)['Text'])
- self.assertEqual('Text', get_state_as_dict(xTypeBox)['DisplayText'])
- self.assertEqual(aExpectedValues[i], get_state_as_dict(xValueEdit)['Text'][:13])
-
-
- xOkBtn = xDialog.getChild("ok")
- xOkBtn.executeAction("CLICK", tuple())
-
- self.ui_test.close_doc()
-
-# vim: set shiftwidth=4 softtabstop=4 expandtab: \ No newline at end of file
+ with self.ui_test.load_file(get_url_for_data_file("tdf81457.odt")):
+ 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/tdf93068.py b/sw/qa/uitest/writer_tests/tdf93068.py
deleted file mode 100644
index a77b4e42da91..000000000000
--- a/sw/qa/uitest/writer_tests/tdf93068.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-from uitest.framework import UITestCase
-
-class tdf93068(UITestCase):
-
- def test_tdf93068(self):
-
- self.ui_test.create_doc_in_start_center("writer")
-
- document = self.ui_test.get_component()
-
- self.xUITest.getTopFocusWindow()
-
- # tdf#135950: Character dialog crashes if multiple cells in a
- # table are selected
- self.ui_test.execute_dialog_through_command(".uno:InsertTable")
- xDialog = self.xUITest.getTopFocusWindow()
-
- xOkBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
-
- self.xUITest.executeCommand(".uno:SelectAll")
-
- # Check the table is selected
- self.assertEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName())
-
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xFontDlg = self.xUITest.getTopFocusWindow()
- xOKBtn = xFontDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOKBtn)
-
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xFontDlg = self.xUITest.getTopFocusWindow()
- xCancBtn = xFontDlg.getChild("cancel")
- xCancBtn.executeAction("CLICK", tuple())
-
- self.ui_test.execute_dialog_through_command(".uno:FontDialog")
- xFontDlg = self.xUITest.getTopFocusWindow()
- xDiscardBtn = xFontDlg.getChild("reset")
- xDiscardBtn.executeAction("CLICK", tuple())
- xOKBtn = xFontDlg.getChild("ok")
- self.ui_test.close_dialog_through_button(xOKBtn)
-
- self.xUITest.getTopFocusWindow()
-
- # Check the table is still selected after closing the dialog
- self.assertEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName())
-
- self.xUITest.executeCommand(".uno:GoDown")
-
- # Check the table is no longer selected
- self.assertNotEqual("SwXTextTableCursor", document.CurrentSelection.getImplementationName())
-
- self.ui_test.close_doc()
diff --git a/sw/qa/uitest/writer_tests/trackedChanges.py b/sw/qa/uitest/writer_tests/trackedChanges.py
index a3ea2671c6c6..8681140bb695 100644
--- a/sw/qa/uitest/writer_tests/trackedChanges.py
+++ b/sw/qa/uitest/writer_tests/trackedChanges.py
@@ -1,255 +1,665 @@
# -*- 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
+#
+# 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
+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):
- self.ui_test.create_doc_in_start_center("writer")
-
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- type_text(xWriterEdit, "Test")
+ with self.ui_test.create_doc_in_start_center("writer"):
- self.xUITest.executeCommand(".uno:TrackChanges")
+ xWriterDoc = self.xUITest.getTopFocusWindow()
+ xWriterEdit = xWriterDoc.getChild("writer_edit")
+ type_text(xWriterEdit, "Test")
- selection = self.xUITest.executeCommand(".uno:SelectAll") #select whole text
- self.xUITest.executeCommand(".uno:Cut") #cut text
+ self.xUITest.executeCommand(".uno:TrackChanges")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- xCancBtn = xTrackDlg.getChild("close")
- xCancBtn.executeAction("CLICK", tuple())
+ self.xUITest.executeCommand(".uno:SelectAll") #select whole text
+ self.xUITest.executeCommand(".uno:Cut") #cut text
- self.ui_test.close_doc()
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close"):
+ pass
def test_tracked_changes_accept(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ 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")
+ self.xUITest.executeCommand(".uno:TrackChanges")
+ type_text(xWriterEdit, "Test LibreOffice")
+ self.xUITest.executeCommand(".uno:ShowTrackedChanges")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- xAccBtn = xTrackDlg.getChild("accept")
- xAccBtn.executeAction("CLICK", tuple())
- xCancBtn = xTrackDlg.getChild("close")
- xCancBtn.executeAction("CLICK", tuple())
+ 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")
- self.ui_test.close_doc()
+ self.assertEqual(document.Text.String[0:16], "Test LibreOffice")
def test_tracked_changes_acceptall(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ 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")
+ self.xUITest.executeCommand(".uno:TrackChanges")
+ type_text(xWriterEdit, "Test LibreOffice")
+ self.xUITest.executeCommand(".uno:ShowTrackedChanges")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
- xAccBtn = xTrackDlg.getChild("acceptall")
- xAccBtn.executeAction("CLICK", tuple())
- xCancBtn = xTrackDlg.getChild("close")
- xCancBtn.executeAction("CLICK", tuple())
+ xAccBtn = xTrackDlg.getChild("acceptall")
+ xAccBtn.executeAction("CLICK", tuple())
- self.assertEqual(document.Text.String[0:16], "Test LibreOffice")
- self.ui_test.close_doc()
+ self.assertEqual(document.Text.String[0:16], "Test LibreOffice")
def test_tracked_changes_reject(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ 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")
+ self.xUITest.executeCommand(".uno:TrackChanges")
+ type_text(xWriterEdit, "Test LibreOffice")
+ self.xUITest.executeCommand(".uno:ShowTrackedChanges")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
- xRejBtn = xTrackDlg.getChild("reject")
- xRejBtn.executeAction("CLICK", tuple())
- xCancBtn = xTrackDlg.getChild("close")
- xCancBtn.executeAction("CLICK", tuple())
+ xRejBtn = xTrackDlg.getChild("reject")
+ xRejBtn.executeAction("CLICK", tuple())
- self.assertEqual(document.Text.String[0:1], "")
- self.ui_test.close_doc()
+ self.assertEqual(document.Text.String[0:1], "")
def test_tracked_changes_rejectall(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
+ 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")
+ self.xUITest.executeCommand(".uno:TrackChanges")
+ type_text(xWriterEdit, "Test LibreOffice")
+ self.xUITest.executeCommand(".uno:ShowTrackedChanges")
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
- xAccBtn = xTrackDlg.getChild("rejectall")
- xAccBtn.executeAction("CLICK", tuple())
- xCancBtn = xTrackDlg.getChild("close")
- xCancBtn.executeAction("CLICK", tuple())
+ xAccBtn = xTrackDlg.getChild("rejectall")
+ xAccBtn.executeAction("CLICK", tuple())
- self.assertEqual(document.Text.String[0:1], "")
- self.ui_test.close_doc()
+ self.assertEqual(document.Text.String[0:1], "")
def test_tracked_changes_zprev_next(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- 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")
-
- self.ui_test.close_doc()
+ 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):
- self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt"))
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
-
- 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"]
-
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- 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] )
-
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
-
- self.ui_test.close_doc()
+ with self.ui_test.load_file(get_url_for_data_file("trackedChanges.odt")) as document:
+
+ 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):
- self.ui_test.load_file(get_url_for_data_file("tdf135018.odt"))
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
+ with self.ui_test.load_file(get_url_for_data_file("tdf135018.odt")) as document:
+
+ 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:
+
+ 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()))
+
+ # jump to the parent to allow rejecting the table change
+ changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "LEFT"}))
+
+ # 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")):
+
+ # 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 get_annotation_count(self, document):
+ n = 0
+ textfields = document.getTextFields()
+ for textfield in textfields:
+ if textfield.supportsService("com.sun.star.text.TextField.Annotation"):
+ n = n + 1
+ return n
+
+ def test_tdf153016_annotation_in_DOC(self):
+ # load a test document, and add a tracked comment
+ with TemporaryDirectory() as tempdir:
+ xFilePath = os.path.join(tempdir, 'temp_drop_down_form_field.doc')
+
+ with self.ui_test.load_file(get_url_for_data_file('drop_down_form_field.doc')) as document:
+
+ self.xUITest.executeCommand(".uno:TrackChanges")
+ self.xUITest.executeCommand('.uno:SelectAll')
+
+ self.assertEqual(0, self.get_annotation_count(document))
+
+ self.xUITest.executeCommand('.uno:InsertAnnotation')
+
+ self.assertEqual(1, self.get_annotation_count(document))
+
+ # Save Copy as
+ with self.ui_test.execute_dialog_through_command('.uno:SaveAs', close_button="") as xDialog:
+ xFileName = xDialog.getChild('file_name')
+ xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'CTRL+A'}))
+ xFileName.executeAction('TYPE', mkPropertyValues({'KEYCODE':'BACKSPACE'}))
+ xFileName.executeAction('TYPE', mkPropertyValues({'TEXT': xFilePath}))
+
+ xOpen = xDialog.getChild("open")
+ # DOC confirmation dialog is displayed
+ with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"):
+ pass
+
+ with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
+ # This was 2
+ self.assertEqual(1, self.get_annotation_count(document))
+
+
+ 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)")
+
+ # 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'))
+
+ def test_tdf155342_tracked_table_columns(self):
+ with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document:
+
+ # accept all changes and insert new columns with change tracking
+ self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+ tables = document.getTextTables()
+ self.assertEqual(2, len(tables))
+ self.assertEqual(len(tables[0].getColumns()), 3)
+ self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+ self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+ self.assertEqual(len(tables[0].getColumns()), 5)
+
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ xToolkit.processEventsToIdle()
+
+ # check and reject changes
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
+ changesList = xTrackDlg.getChild("writerchanges")
+
+ # six changes, but only one visible in the Manage Changes dialog window
+ state = get_state_as_dict(changesList)
+ self.assertEqual(state['Children'], '6')
+ self.assertEqual(state['VisibleCount'], '1')
+
+ # This was 6 (every cell is a different change instead of counting column changes)
+ # Now: 1 changes (2 inserted columns)
+ self.assertEqual(1, len(changesList.getChildren()))
+
+ # reject column insertion
+
+ xAccBtn = xTrackDlg.getChild("reject")
+ xAccBtn.executeAction("CLICK", tuple())
+
+ # all inserted columns are removed
+
+ self.assertEqual(len(tables[0].getColumns()), 3)
+
+ # no changes in the dialog window
+
+ self.assertEqual(0, len(changesList.getChildren()))
+
+ def test_tdf155847_multiple_tracked_columns(self):
+ with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as document:
+
+ # accept all changes and insert new columns with change tracking
+ self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+ tables = document.getTextTables()
+ self.assertEqual(2, len(tables))
+ self.assertEqual(len(tables[0].getColumns()), 3)
+ self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+ self.xUITest.executeCommand(".uno:DeleteColumns")
+ self.assertEqual(len(tables[0].getColumns()), 4)
+
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ xToolkit.processEventsToIdle()
+
+ # check and reject changes
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
+ changesList = xTrackDlg.getChild("writerchanges")
+
+ # six changes, but only one visible in the Manage Changes dialog window
+ state = get_state_as_dict(changesList)
+ self.assertEqual(state['Children'], '6')
+
+ # This was 4 (missing handling of multiple different columns)
+ self.assertEqual(state['VisibleCount'], '2')
+ # Now: 2 changes (deleted and inserted columns)
+ self.assertEqual(2, len(changesList.getChildren()))
+
+ # accept column deletion
+
+ xAccBtn = xTrackDlg.getChild("accept")
+ xAccBtn.executeAction("CLICK", tuple())
+
+ # deleted column is removed
+
+ self.assertEqual(len(tables[0].getColumns()), 3)
+
+ # single parent left in the dialog window
+ self.assertEqual(1, len(changesList.getChildren()))
+
+ # reject column insertion
+
+ xAccBtn = xTrackDlg.getChild("reject")
+ xAccBtn.executeAction("CLICK", tuple())
+
+ # inserted column is removed
+
+ self.assertEqual(len(tables[0].getColumns()), 2)
+
+ # no changes in the dialog window
+
+ self.assertEqual(0, len(changesList.getChildren()))
+
+ def test_tdf155847_multiple_tracked_columns_crash(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")
+
+ # accept all changes and insert new columns with change tracking
+ self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
+ tables = document.getTextTables()
+ self.assertEqual(2, len(tables))
+ self.assertEqual(len(tables[0].getColumns()), 3)
+ self.xUITest.executeCommand(".uno:InsertColumnsAfter")
+ self.xUITest.executeCommand(".uno:DeleteColumns")
+ self.assertEqual(len(tables[0].getColumns()), 4)
+
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ xToolkit.processEventsToIdle()
+
+ # check and reject changes
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges", close_button="close") as xTrackDlg:
+ changesList = xTrackDlg.getChild("writerchanges")
+
+ # six changes, but only one visible in the Manage Changes dialog window
+ state = get_state_as_dict(changesList)
+ self.assertEqual(state['Children'], '6')
+
+ # This was 4 (missing handling of multiple different columns)
+ self.assertEqual(state['VisibleCount'], '2')
+ # Now: 2 changes (deleted and inserted columns)
+ self.assertEqual(2, len(changesList.getChildren()))
+
+ # select second tracked table column in tree list
+ xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
+ changesList.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
+
+ # while not empty, i.e. starts with CH_TXT_TRACKED_DUMMY_CHAR
+ while len(get_state_as_dict(xWriterEdit)["SelectedText"]):
+ xToolkit.processEventsToIdle()
+
+ # reject column insertion
+
+ xAccBtn = xTrackDlg.getChild("reject")
+ # Without the fix in place, it would have crashed here
+ xAccBtn.executeAction("CLICK", tuple())
- self.assertEqual(5, document.CurrentController.PageCount)
+ # inserted column is removed
- self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
- xTrackDlg = self.xUITest.getTopFocusWindow()
- changesList = xTrackDlg.getChild("writerchanges")
- self.assertEqual(147, len(changesList.getChildren()))
+ self.assertEqual(len(tables[0].getColumns()), 3)
- # Without the fix in place, it would have crashed here
- xAccBtn = xTrackDlg.getChild("acceptall")
- xAccBtn.executeAction("CLICK", tuple())
+ # single parent left in the dialog window
+ self.assertEqual(1, len(changesList.getChildren()))
- self.assertEqual(0, len(changesList.getChildren()))
+ # accept column deletion
- xUndoBtn = xTrackDlg.getChild("undo")
- xUndoBtn.executeAction("CLICK", tuple())
+ xAccBtn = xTrackDlg.getChild("accept")
+ xAccBtn.executeAction("CLICK", tuple())
- self.assertEqual(147, len(changesList.getChildren()))
+ # deleted column is removed
- xcloseBtn = xTrackDlg.getChild("close")
- xcloseBtn.executeAction("CLICK", tuple())
+ self.assertEqual(len(tables[0].getColumns()), 2)
- # Check the changes are shown after opening the Manage Tracked Changes dialog
- self.assertGreater(document.CurrentController.PageCount, 5)
+ # no changes in the dialog window
- self.ui_test.close_doc()
+ self.assertEqual(0, len(changesList.getChildren()))
# 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
index 5d0e3c120b4e..90c1de189048 100644
--- a/sw/qa/uitest/writer_tests/versionDialog.py
+++ b/sw/qa/uitest/writer_tests/versionDialog.py
@@ -1,4 +1,3 @@
-#! /usr/bin/env python
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
@@ -7,6 +6,7 @@
# 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
@@ -14,29 +14,21 @@ class versionDialog(UITestCase):
def test_tdf131931(self):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf131931.odt"))
-
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
-
- self.ui_test.execute_dialog_through_command(".uno:VersionDialog")
+ with self.ui_test.load_file(get_url_for_data_file("tdf131931.odt")):
- xVersionDialog = 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)
+ versiondList = xVersionDialog.getChild("versions")
- xDeleteBtn = xVersionDialog.getChild("delete")
- xDeleteBtn.executeAction("CLICK", tuple())
+ 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)
- self.assertEqual(0, len(versiondList.getChildren()))
+ xDeleteBtn = xVersionDialog.getChild("delete")
+ xDeleteBtn.executeAction("CLICK", tuple())
- xCloseBtn = xVersionDialog.getChild("close")
- xCloseBtn.executeAction("CLICK", tuple())
+ self.assertEqual(0, len(versiondList.getChildren()))
- self.ui_test.close_doc()
# 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
index 0d918e92d061..af369660f197 100644
--- a/sw/qa/uitest/writer_tests/watermark.py
+++ b/sw/qa/uitest/writer_tests/watermark.py
@@ -1,66 +1,51 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
+# This file is part of the LibreOffice project.
+#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
from uitest.framework import UITestCase
from libreoffice.uno.propertyvalue import mkPropertyValues
from uitest.uihelper.common import get_state_as_dict
-import time
-from uitest.debug import sleep
-from uitest.uihelper.common import select_pos
class watermark(UITestCase):
def test_insert_watermark(self):
- self.ui_test.create_doc_in_start_center("writer")
- document = self.ui_test.get_component()
- xWriterDoc = self.xUITest.getTopFocusWindow()
+ with self.ui_test.create_doc_in_start_center("writer"):
- self.ui_test.execute_dialog_through_command(".uno:Watermark")
- xDialog = self.xUITest.getTopFocusWindow()
- xTextInput = xDialog.getChild("TextInput")
- xAngle = xDialog.getChild("Angle")
- xTransparency = xDialog.getChild("Transparency")
+ 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())
+ xTextInput.executeAction("TYPE", mkPropertyValues({"TEXT":"Watermark"}))
+ xAngle.executeAction("UP", tuple())
+ xTransparency.executeAction("UP", tuple())
- xOkBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
- self.ui_test.execute_dialog_through_command(".uno:Watermark")
- xDialog = self.xUITest.getTopFocusWindow()
- xTextInput = xDialog.getChild("TextInput")
- xAngle = xDialog.getChild("Angle")
- xTransparency = xDialog.getChild("Transparency")
+ 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%")
+ 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%")
- xCancBtn = xDialog.getChild("cancel")
- self.ui_test.close_dialog_through_button(xCancBtn)
- self.ui_test.execute_dialog_through_command(".uno:Watermark")
- xDialog = self.xUITest.getTopFocusWindow()
- xTextInput = xDialog.getChild("TextInput")
- xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
- xTextInput.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
- xOkBtn = xDialog.getChild("ok")
- self.ui_test.close_dialog_through_button(xOkBtn)
+ 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"}))
- self.ui_test.execute_dialog_through_command(".uno:Watermark")
- xDialog = self.xUITest.getTopFocusWindow()
- xTextInput = xDialog.getChild("TextInput")
+ 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"], "")
+ self.assertEqual(get_state_as_dict(xTextInput)["Text"], "")
- xCancBtn = xDialog.getChild("cancel")
- self.ui_test.close_dialog_through_button(xCancBtn)
- self.ui_test.close_doc()
# 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
index b7b88dcb4f74..06d62fefb88a 100644
--- a/sw/qa/uitest/writer_tests/wordCount.py
+++ b/sw/qa/uitest/writer_tests/wordCount.py
@@ -1,5 +1,7 @@
# -*- 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/.
@@ -13,314 +15,259 @@ class writerWordCount(UITestCase):
def test_word_count_dialog(self):
- self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
-
- type_text(xWriterEdit, "Test for word count dialog") #type text
- xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "8"})) #select two words
-
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ with self.ui_test.create_doc_in_start_center("writer"):
+ 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
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf68347.odt"))
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
-
- xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "24", "END_POS": "39"})) #select two words
-
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- 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 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ with self.ui_test.load_file(get_url_for_data_file("tdf68347.odt")):
+ 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")
+ 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):
- self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = self.xUITest.getTopFocusWindow()
- document = self.ui_test.get_component()
+ with self.ui_test.create_doc_in_start_center("writer"):
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ with self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog", close_button="close"):
+ pass
def test_tdf58050(self):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf58050.html"))
-
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ with self.ui_test.load_file(get_url_for_data_file("tdf58050.html")):
+
+ 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):
- self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
- #Open writer, enter "Testing one two! Test?"
- type_text(xWriterEdit, "Testing one two! Test?")
- #-> LO says: 4 words. SUCCESS! :)
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ with self.ui_test.create_doc_in_start_center("writer"):
+ 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):
- self.ui_test.create_doc_in_start_center("writer")
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
- #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.
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
- #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.
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
- #6. Move the cursor by pressing Left.
- self.xUITest.executeCommand(".uno:GoLeft")
- # Word count in both, dialogue and status line, shows 5 words.
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
- self.ui_test.close_doc()
+ with self.ui_test.create_doc_in_start_center("writer"):
+ 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):
- writer_doc = self.ui_test.load_file(get_url_for_data_file("tdf51816.odt"))
- xWriterDoc = self.xUITest.getTopFocusWindow()
- xWriterEdit = xWriterDoc.getChild("writer_edit")
- document = self.ui_test.get_component()
- #1. Open attached document
- #2. Tools> Word count
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
- 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")
-
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
- self.ui_test.close_doc()
+ with self.ui_test.load_file(get_url_for_data_file("tdf51816.odt")):
+ #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")
+ xselectchars = xDialog.getChild("selectchars")
+ xselectcharsnospaces = xDialog.getChild("selectcharsnospaces")
+
+ #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):
- self.ui_test.load_file(get_url_for_data_file("tdf117703.odt"))
- self.xUITest.getTopFocusWindow()
-
- self.xUITest.executeCommand(".uno:SelectAll")
-
- self.ui_test.execute_modeless_dialog_through_command(".uno:WordCountDialog")
- xDialog = self.xUITest.getTopFocusWindow()
-
- 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")
- xCloseBtn = xDialog.getChild("close")
- self.ui_test.close_dialog_through_button(xCloseBtn)
-
- self.ui_test.close_doc()
+ 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: