Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / table / tdf146145.py
blob55d2092ca51e71114bc9e00962eb1ad644fdb7c4
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
12 import time
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
26 return False
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()
47 # This was false
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():
54 time.sleep(0.1)
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():
61 time.sleep(0.1)
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)
89 for i in range(3):
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()
129 # This was false
130 self.assertTrue(self.is_enabled_Accept_Track_Change())
132 # delete first row
133 self.xUITest.executeCommand(".uno:AcceptTrackedChange")
134 xToolkit.processEventsToIdle()
135 # disabled Accept Track Change
136 while self.is_enabled_Accept_Track_Change():
137 time.sleep(0.1)
138 self.assertFalse(self.is_enabled_Accept_Track_Change())
140 # delete first row
141 self.xUITest.executeCommand(".uno:SelectAll")
142 self.xUITest.executeCommand(".uno:SelectAll")
143 xToolkit.processEventsToIdle()
144 # This was false
145 while not self.is_enabled_Accept_Track_Change():
146 time.sleep(0.1)
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():
153 time.sleep(0.1)
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()
181 # This was false
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 while self.is_enabled_Accept_Track_Change():
188 time.sleep(0.1)
189 self.assertFalse(self.is_enabled_Accept_Track_Change())
191 # check the fix again to avoid of the asynchron state changes
192 self.xUITest.executeCommand(".uno:GoLeft")
193 xToolkit.processEventsToIdle()
194 while not self.is_enabled_Accept_Track_Change():
195 time.sleep(0.1)
196 self.assertTrue(self.is_enabled_Accept_Track_Change())
198 # check 1-click accept of table column deletion (3 redlines in the column)
200 # not at changed text, but Accept Track Change removes the whole column now
202 tables = self.document.getTextTables()
203 self.assertEqual(len(tables[0].getColumns()), 3)
205 self.xUITest.executeCommand(".uno:AcceptTrackedChange")
206 xToolkit.processEventsToIdle()
207 self.assertEqual(len(tables[0].getColumns()), 2)
209 self.xUITest.executeCommand(".uno:Undo")
210 xToolkit.processEventsToIdle()
211 self.assertEqual(len(tables[0].getColumns()), 3)
213 self.xUITest.executeCommand(".uno:Redo")
214 xToolkit.processEventsToIdle()
215 self.assertEqual(len(tables[0].getColumns()), 2)
217 # check 1-click reject of table column insertion (9 redlines in the 3 columns)
219 self.xUITest.executeCommand(".uno:InsertColumnsBefore")
220 self.xUITest.executeCommand(".uno:InsertColumnsBefore")
221 self.xUITest.executeCommand(".uno:InsertColumnsBefore")
222 xToolkit.processEventsToIdle()
223 while self.is_enabled_Accept_Track_Change():
224 time.sleep(0.1)
225 self.assertFalse(self.is_enabled_Accept_Track_Change())
227 self.assertEqual(len(tables[0].getColumns()), 5)
229 # check the fix again to avoid of the asynchron state changes
230 self.xUITest.executeCommand(".uno:GoLeft")
231 xToolkit.processEventsToIdle()
232 while not self.is_enabled_Accept_Track_Change():
233 time.sleep(0.1)
234 # This was false
235 self.assertTrue(self.is_enabled_Accept_Track_Change())
237 self.xUITest.executeCommand(".uno:RejectTrackedChange")
239 self.assertEqual(len(tables[0].getColumns()), 2)
241 self.xUITest.executeCommand(".uno:Undo")
242 xToolkit.processEventsToIdle()
243 self.assertEqual(len(tables[0].getColumns()), 5)
245 self.xUITest.executeCommand(".uno:Redo")
246 xToolkit.processEventsToIdle()
247 self.assertEqual(len(tables[0].getColumns()), 2)
249 self.xUITest.executeCommand(".uno:Undo")
250 xToolkit.processEventsToIdle()
251 self.assertEqual(len(tables[0].getColumns()), 5)
253 def test_crashWithHiddenFirstTableColumn(self):
254 with self.ui_test.load_file(get_url_for_data_file("TC-table-del-add.docx")) as self.document:
256 # accept all tracked changes
257 self.xUITest.executeCommand(".uno:AcceptAllTrackedChanges")
258 # delete first table column
259 self.xUITest.executeCommand(".uno:DeleteColumns")
261 # Check enabling Accept/Reject Track Change icons
262 # and Accept Change/Reject Change context menu items
263 # on table columns with tracked deletion or insertion
265 # enable Track Changes toolbar
266 self.xUITest.executeCommand(".uno:AvailableToolbars?Toolbar:string=changes")
268 xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit')
269 xToolkit.processEventsToIdle()
271 # cursor at changed text: Accept Track Change is enabled
272 self.assertTrue(self.is_enabled_Accept_Track_Change())
274 # hide changes
275 self.xUITest.executeCommand(".uno:ShowTrackedChanges")
276 while self.is_enabled_Accept_Track_Change():
277 time.sleep(0.1)
278 self.assertFalse(self.is_enabled_Accept_Track_Change())
280 # Without the fix in place, this test would have crashed here
281 self.xUITest.executeCommand(".uno:DeleteRows")
283 self.xUITest.executeCommand(".uno:ShowTrackedChanges")
285 # vim: set shiftwidth=4 softtabstop=4 expandtab: