1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
# -*- 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/.
# tests for tracked changes ; tdf912270
from uitest.framework import UITestCase
from uitest.debug import sleep
from uitest.path import get_srcdir_url
import time
from uitest.uihelper.common import get_state_as_dict, type_text
def get_url_for_data_file(file_name):
return get_srcdir_url() + "/sw/qa/uitest/writer_tests/data/" + file_name
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")
self.xUITest.executeCommand(".uno:TrackChanges")
selection = self.xUITest.executeCommand(".uno:SelectAll") #select whole text
self.xUITest.executeCommand(".uno:Cut") #cut text
self.ui_test.execute_modeless_dialog_through_command(".uno:AcceptTrackedChanges")
xTrackDlg = self.xUITest.getTopFocusWindow()
xCancBtn = xTrackDlg.getChild("close")
xCancBtn.executeAction("CLICK", tuple())
self.ui_test.close_doc()
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")
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())
self.assertEqual(document.Text.String[0:16], "Test LibreOffice")
self.ui_test.close_doc()
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")
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("acceptall")
xAccBtn.executeAction("CLICK", tuple())
xCancBtn = xTrackDlg.getChild("close")
xCancBtn.executeAction("CLICK", tuple())
self.assertEqual(document.Text.String[0:16], "Test LibreOffice")
self.ui_test.close_doc()
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")
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()
xRejBtn = xTrackDlg.getChild("reject")
xRejBtn.executeAction("CLICK", tuple())
xCancBtn = xTrackDlg.getChild("close")
xCancBtn.executeAction("CLICK", tuple())
self.assertEqual(document.Text.String[0:1], "")
self.ui_test.close_doc()
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")
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("rejectall")
xAccBtn.executeAction("CLICK", tuple())
xCancBtn = xTrackDlg.getChild("close")
xCancBtn.executeAction("CLICK", tuple())
self.assertEqual(document.Text.String[0:1], "")
self.ui_test.close_doc()
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()
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()
# vim: set shiftwidth=4 softtabstop=4 expandtab:
|