1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import get_url_for_data_file
14 from com
.sun
.star
.accessibility
.AccessibleStateType
import ENABLED
16 class tdf146145(UITestCase
):
18 # access to the private:resource changes toolbar via accessibility API
19 def is_enabled_Accept_Track_Change(self
):
20 xFrame
= self
.document
.getCurrentController().getFrame()
22 for i
in xFrame
.getPropertyValue("LayoutManager").getElements():
23 if i
.getPropertyValue('ResourceURL') == 'private:resource/toolbar/changes':
24 return (ENABLED
& i
.getRealInterface().getAccessibleContext().getAccessibleChild(5).getAccessibleStateSet()) == ENABLED
28 def test_tdf146145(self
):
29 with self
.ui_test
.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self
.document
:
31 # Check enabling Accept/Reject Track Change icons
32 # and Accept Change/Reject Change context menu items
33 # on table rows with tracked deletion or insertion
35 # enable Track Changes toolbar
36 self
.xUITest
.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
38 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
39 xToolkit
.processEventsToIdle()
41 # cursor at changed text: Accept Track Change is enabled
42 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
44 # cursor in a changed row, but not at changed text: Accept Track Change is enabled now
45 self
.xUITest
.executeCommand(".uno:GoRight")
46 xToolkit
.processEventsToIdle()
48 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
50 # cursor in a not changed row: Accept Track Change is disabled
51 self
.xUITest
.executeCommand(".uno:GoDown")
52 xToolkit
.processEventsToIdle()
53 while self
.is_enabled_Accept_Track_Change():
55 self
.assertFalse(self
.is_enabled_Accept_Track_Change())
57 # check the fix again to avoid of the asynchron state changes
58 self
.xUITest
.executeCommand(".uno:GoUp")
59 xToolkit
.processEventsToIdle()
60 while not self
.is_enabled_Accept_Track_Change():
62 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
64 # check 1-click accept of table row deletion (3 redlines in the row)
66 # not at changed text, but Accept Track Change removes the whole row now
68 tables
= self
.document
.getTextTables()
69 self
.assertEqual(len(tables
[0].getRows()), 4)
71 self
.xUITest
.executeCommand(".uno:AcceptTrackedChange")
72 xToolkit
.processEventsToIdle()
73 self
.assertEqual(len(tables
[0].getRows()), 3)
75 self
.xUITest
.executeCommand(".uno:Undo")
76 xToolkit
.processEventsToIdle()
77 self
.assertEqual(len(tables
[0].getRows()), 4)
79 self
.xUITest
.executeCommand(".uno:Redo")
80 xToolkit
.processEventsToIdle()
81 self
.assertEqual(len(tables
[0].getRows()), 3)
83 self
.xUITest
.executeCommand(".uno:Undo")
84 xToolkit
.processEventsToIdle()
85 self
.assertEqual(len(tables
[0].getRows()), 4)
87 # check 1-click reject of table row insertion (3 redlines in the row)
90 self
.xUITest
.executeCommand(".uno:GoDown")
92 # not at changed text (the cursor is there at the end of the text of the table row),
93 # but Reject Track Change removes the whole row now
95 tables
= self
.document
.getTextTables()
96 self
.assertEqual(len(tables
[0].getRows()), 4)
98 self
.xUITest
.executeCommand(".uno:RejectTrackedChange")
99 xToolkit
.processEventsToIdle()
100 self
.assertEqual(len(tables
[0].getRows()), 3)
102 self
.xUITest
.executeCommand(".uno:Undo")
103 xToolkit
.processEventsToIdle()
104 self
.assertEqual(len(tables
[0].getRows()), 4)
106 self
.xUITest
.executeCommand(".uno:Redo")
107 xToolkit
.processEventsToIdle()
108 self
.assertEqual(len(tables
[0].getRows()), 3)
110 def test_Related_tdf147182(self
):
111 with self
.ui_test
.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self
.document
:
113 # Check enabling Accept/Reject Track Change icons
114 # and Accept Change/Reject Change context menu items
115 # on table rows with tracked deletion or insertion
117 # enable Track Changes toolbar
118 self
.xUITest
.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
120 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
121 xToolkit
.processEventsToIdle()
123 # cursor at changed text: Accept Track Change is enabled
124 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
126 # cursor in a changed row, but not at changed text: Accept Track Change is enabled now
127 self
.xUITest
.executeCommand(".uno:GoRight")
128 xToolkit
.processEventsToIdle()
130 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
133 self
.xUITest
.executeCommand(".uno:AcceptTrackedChange")
134 xToolkit
.processEventsToIdle()
135 # disabled Accept Track Change
136 while self
.is_enabled_Accept_Track_Change():
138 self
.assertFalse(self
.is_enabled_Accept_Track_Change())
141 self
.xUITest
.executeCommand(".uno:SelectAll")
142 self
.xUITest
.executeCommand(".uno:SelectAll")
143 xToolkit
.processEventsToIdle()
145 while not self
.is_enabled_Accept_Track_Change():
147 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
149 # delete all changes in the selected table
150 self
.xUITest
.executeCommand(".uno:AcceptTrackedChange")
151 xToolkit
.processEventsToIdle()
152 while self
.is_enabled_Accept_Track_Change():
154 # disabled Accept Track Change
155 self
.assertFalse(self
.is_enabled_Accept_Track_Change())
157 def test_tdf155344(self
):
158 with self
.ui_test
.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self
.document
:
160 # accept all tracked changes
161 self
.xUITest
.executeCommand(".uno:AcceptAllTrackedChanges")
162 # delete first table column
163 self
.xUITest
.executeCommand(".uno:DeleteColumns")
165 # Check enabling Accept/Reject Track Change icons
166 # and Accept Change/Reject Change context menu items
167 # on table columns with tracked deletion or insertion
169 # enable Track Changes toolbar
170 self
.xUITest
.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
172 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
173 xToolkit
.processEventsToIdle()
175 # cursor at changed text: Accept Track Change is enabled
176 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
178 # cursor in a changed column, but not at changed text: Accept Track Change is enabled now
179 self
.xUITest
.executeCommand(".uno:GoRight")
180 xToolkit
.processEventsToIdle()
182 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
184 # cursor in a not changed column: Accept Track Change is disabled
185 self
.xUITest
.executeCommand(".uno:GoRight")
186 xToolkit
.processEventsToIdle()
187 # Disable uitest, it keeps getting stuck
188 # while self.is_enabled_Accept_Track_Change():
190 # self.assertFalse(self.is_enabled_Accept_Track_Change())
192 # check the fix again to avoid of the asynchron state changes
193 self
.xUITest
.executeCommand(".uno:GoLeft")
194 xToolkit
.processEventsToIdle()
195 while not self
.is_enabled_Accept_Track_Change():
197 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
199 # check 1-click accept of table column deletion (3 redlines in the column)
201 # not at changed text, but Accept Track Change removes the whole column now
203 tables
= self
.document
.getTextTables()
204 self
.assertEqual(len(tables
[0].getColumns()), 3)
206 self
.xUITest
.executeCommand(".uno:AcceptTrackedChange")
207 xToolkit
.processEventsToIdle()
208 self
.assertEqual(len(tables
[0].getColumns()), 2)
210 self
.xUITest
.executeCommand(".uno:Undo")
211 xToolkit
.processEventsToIdle()
212 self
.assertEqual(len(tables
[0].getColumns()), 3)
214 self
.xUITest
.executeCommand(".uno:Redo")
215 xToolkit
.processEventsToIdle()
216 self
.assertEqual(len(tables
[0].getColumns()), 2)
218 # check 1-click reject of table column insertion (9 redlines in the 3 columns)
220 self
.xUITest
.executeCommand(".uno:InsertColumnsBefore")
221 self
.xUITest
.executeCommand(".uno:InsertColumnsBefore")
222 self
.xUITest
.executeCommand(".uno:InsertColumnsBefore")
223 xToolkit
.processEventsToIdle()
224 # Disabled unreliable test, tends to get stuck here
225 # while self.is_enabled_Accept_Track_Change():
227 # self.assertFalse(self.is_enabled_Accept_Track_Change())
229 # self.assertEqual(len(tables[0].getColumns()), 5)
231 # check the fix again to avoid of the asynchron state changes
232 self
.xUITest
.executeCommand(".uno:GoLeft")
233 xToolkit
.processEventsToIdle()
234 while not self
.is_enabled_Accept_Track_Change():
237 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
239 self
.xUITest
.executeCommand(".uno:RejectTrackedChange")
241 self
.assertEqual(len(tables
[0].getColumns()), 2)
243 self
.xUITest
.executeCommand(".uno:Undo")
244 xToolkit
.processEventsToIdle()
245 self
.assertEqual(len(tables
[0].getColumns()), 5)
247 self
.xUITest
.executeCommand(".uno:Redo")
248 xToolkit
.processEventsToIdle()
249 self
.assertEqual(len(tables
[0].getColumns()), 2)
251 self
.xUITest
.executeCommand(".uno:Undo")
252 xToolkit
.processEventsToIdle()
253 self
.assertEqual(len(tables
[0].getColumns()), 5)
255 def test_crashWithHiddenFirstTableColumn(self
):
256 with self
.ui_test
.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self
.document
:
258 # accept all tracked changes
259 self
.xUITest
.executeCommand(".uno:AcceptAllTrackedChanges")
260 # delete first table column
261 self
.xUITest
.executeCommand(".uno:DeleteColumns")
263 # Check enabling Accept/Reject Track Change icons
264 # and Accept Change/Reject Change context menu items
265 # on table columns with tracked deletion or insertion
267 # enable Track Changes toolbar
268 self
.xUITest
.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
270 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
271 xToolkit
.processEventsToIdle()
273 # cursor at changed text: Accept Track Change is enabled
274 self
.assertTrue(self
.is_enabled_Accept_Track_Change())
276 # Disable uitest, it keeps getting stuck
278 #self.xUITest.executeCommand(".uno:ShowTrackedChanges")
279 #while self.is_enabled_Accept_Track_Change():
281 #self.assertFalse(self.is_enabled_Accept_Track_Change())
283 # Without the fix in place, this test would have crashed here
284 #self.xUITest.executeCommand(".uno:DeleteRows")
286 #self.xUITest.executeCommand(".uno:ShowTrackedChanges")
288 # vim: set shiftwidth=4 softtabstop=4 expandtab: