| 1 |
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- |
| 2 |
# |
| 3 |
# This file is part of the LibreOffice project. |
| 4 |
# |
| 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/. |
| 8 |
# |
| 9 |
|
| 10 |
from uitest.framework import UITestCase |
| 11 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 12 |
from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file |
| 13 |
|
| 14 |
class movechapterupdown(UITestCase): |
| 15 |
|
| 16 |
def test_movechapterupdown(self): |
| 17 |
|
| 18 |
with self.ui_test.load_file(get_url_for_data_file('MoveChapterUpDown.odt')): |
| 19 |
xWriterDoc = self.xUITest.getTopFocusWindow() |
| 20 |
xWriterEdit = xWriterDoc.getChild('writer_edit') |
| 21 |
|
| 22 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 23 |
xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) |
| 24 |
|
| 25 |
# wait until the navigator panel is available |
| 26 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 27 |
|
| 28 |
# See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") |
| 29 |
# in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that |
| 30 |
# m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the |
| 31 |
# xInsert click above. |
| 32 |
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') |
| 33 |
xToolkit.waitUntilAllIdlesDispatched() |
| 34 |
|
| 35 |
# Given the document chapter structure: |
| 36 |
# 1. One H1 |
| 37 |
# 1.1. one_A (H2) |
| 38 |
# 1.2. one_B (H2) |
| 39 |
# 2. Two (H1) |
| 40 |
# A heading of level 3 |
| 41 |
# 2.1. Two_A (H2) |
| 42 |
# 2.1. Two_B (H2) |
| 43 |
# 3. Three (H1) |
| 44 |
# 3.1. Three_A (H2) |
| 45 |
# 3.2. Three_B (H2) |
| 46 |
|
| 47 |
xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree") |
| 48 |
|
| 49 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 50 |
xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple()) |
| 51 |
|
| 52 |
# |
| 53 |
# test a level 1 chapter move up then move down |
| 54 |
# |
| 55 |
|
| 56 |
# Double click on the "2. Two (H1)" entry to select and set focus |
| 57 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 58 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 59 |
xHeadingsChild1.executeAction("DOUBLECLICK", tuple()) |
| 60 |
|
| 61 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2. Two (H1)") |
| 62 |
|
| 63 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 64 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 65 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 66 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 67 |
|
| 68 |
# Expected chapter order: |
| 69 |
# 2. Two (H1) |
| 70 |
# A heading of level 3 |
| 71 |
# 2.1. Two_A (H2) |
| 72 |
# 2.1. Two_B (H2) |
| 73 |
# 1. One (H1) |
| 74 |
# 1.1. One_A (H2) |
| 75 |
# 1.2. One_B (H2) |
| 76 |
# 3. Three (H1) |
| 77 |
# 3.1. Three_A (H2) |
| 78 |
# 3.2. Three_B (H2) |
| 79 |
|
| 80 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 81 |
|
| 82 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 83 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "2. Two (H1)") |
| 84 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 85 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "A heading of level 3") |
| 86 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 87 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "2.1. Two_A (H2)") |
| 88 |
xHeadingsChild0Child2 = xHeadingsChild0.getChild('2') |
| 89 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child2)["Text"], "2.1. Two_B (H2)") |
| 90 |
|
| 91 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 92 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "1. One (H1)") |
| 93 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 94 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "1.1. One_A (H2)") |
| 95 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 96 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "1.2. One_B (H2)") |
| 97 |
|
| 98 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 99 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 100 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 101 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 102 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 103 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 104 |
|
| 105 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 106 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 107 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 108 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 109 |
|
| 110 |
# Expected chapter order is the original order |
| 111 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 112 |
|
| 113 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 114 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 115 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 116 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 117 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 118 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 119 |
|
| 120 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 121 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 122 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 123 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") |
| 124 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 125 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 126 |
xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') |
| 127 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") |
| 128 |
|
| 129 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 130 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 131 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 132 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 133 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 134 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 135 |
|
| 136 |
# |
| 137 |
# test a level 1 chapter move down then move up |
| 138 |
# |
| 139 |
|
| 140 |
# Double click on the "2. Two (H1)" entry to select and set focus |
| 141 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 142 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 143 |
xHeadingsChild1.executeAction("DOUBLECLICK", tuple()) |
| 144 |
|
| 145 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2. Two (H1)") |
| 146 |
|
| 147 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 148 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 149 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 150 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 151 |
|
| 152 |
# Expected chapter order: |
| 153 |
# 1. One (H1) |
| 154 |
# 1.1. One_A (H2) |
| 155 |
# 1.2. One_B (H2) |
| 156 |
# 3. Three (H1) |
| 157 |
# 3.1. Three_A (H2) |
| 158 |
# 3.2. Three_B (H2) |
| 159 |
# 2. Two (H1) |
| 160 |
# A heading of level 3 |
| 161 |
# 2.1. Two_A (H2) |
| 162 |
# 2.1. Two_B (H2) |
| 163 |
|
| 164 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 165 |
|
| 166 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 167 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 168 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 169 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 170 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 171 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 172 |
|
| 173 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 174 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "3. Three (H1)") |
| 175 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 176 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "3.1. Three_A (H2)") |
| 177 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 178 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "3.2. Three_B (H2)") |
| 179 |
|
| 180 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 181 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "2. Two (H1)") |
| 182 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 183 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "A heading of level 3") |
| 184 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 185 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "2.1. Two_A (H2)") |
| 186 |
xHeadingsChild2Child2 = xHeadingsChild2.getChild('2') |
| 187 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child2)["Text"], "2.1. Two_B (H2)") |
| 188 |
|
| 189 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 190 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 191 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 192 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 193 |
|
| 194 |
# Expected chapter order is the original order |
| 195 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 196 |
|
| 197 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 198 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 199 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 200 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 201 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 202 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 203 |
|
| 204 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 205 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 206 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 207 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") |
| 208 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 209 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 210 |
xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') |
| 211 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") |
| 212 |
|
| 213 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 214 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 215 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 216 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 217 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 218 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 219 |
|
| 220 |
# |
| 221 |
# test a sub chapter move chapter up then move down |
| 222 |
# |
| 223 |
|
| 224 |
# Double click on the "2.1. Two_A (H2)" entry to select and set focus |
| 225 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 226 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 227 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 228 |
xHeadingsChild1Child1.executeAction("DOUBLECLICK", tuple()) |
| 229 |
|
| 230 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_A (H2)") |
| 231 |
|
| 232 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 233 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 234 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 235 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 236 |
|
| 237 |
# Expected chapter order: |
| 238 |
# 1. One H1 |
| 239 |
# 1.1. one_A (H2) |
| 240 |
# 1.2. one_B (H2) |
| 241 |
# 2. Two (H1) |
| 242 |
# 2.1. Two_A (H2) |
| 243 |
# A heading of level 3 |
| 244 |
# 2.1. Two_B (H2) |
| 245 |
# 3. Three (H1) |
| 246 |
# 3.1. Three_A (H2) |
| 247 |
# 3.2. Three_B (H2) |
| 248 |
|
| 249 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 250 |
|
| 251 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 252 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 253 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 254 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 255 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 256 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 257 |
|
| 258 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 259 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 260 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 261 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "2.1. Two_A (H2)") |
| 262 |
xHeadingsChild1Child0Child0 = xHeadingsChild1Child0.getChild('0') |
| 263 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0Child0)["Text"], "A heading of level 3") |
| 264 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 265 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") |
| 266 |
|
| 267 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 268 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 269 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 270 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 271 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 272 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 273 |
|
| 274 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_A (H2)") |
| 275 |
|
| 276 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 277 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 278 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 279 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 280 |
|
| 281 |
# Expected chapter order: |
| 282 |
# 1. One H1 |
| 283 |
# 1.1. one_A (H2) |
| 284 |
# 1.2. one_B (H2) |
| 285 |
# 2. Two (H1) |
| 286 |
# 2.1. Two_B (H2) |
| 287 |
# 2.1. Two_A (H2) |
| 288 |
# A heading of level 3 |
| 289 |
# 3. Three (H1) |
| 290 |
# 3.1. Three_A (H2) |
| 291 |
# 3.2. Three_B (H2) |
| 292 |
|
| 293 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 294 |
|
| 295 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 296 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 297 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 298 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 299 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 300 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 301 |
|
| 302 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 303 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 304 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 305 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "2.1. Two_B (H2)") |
| 306 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 307 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 308 |
xHeadingsChild1Child1Child0 = xHeadingsChild1Child1.getChild('0') |
| 309 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1Child0)["Text"], "A heading of level 3") |
| 310 |
|
| 311 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 312 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 313 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 314 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 315 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 316 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 317 |
|
| 318 |
# Move "A heading of level 3" to its original position |
| 319 |
|
| 320 |
# Double click on the "A heading of level 3" entry to select and set focus |
| 321 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 322 |
xHeadingsChild1Child1Child0 = xHeadingsChild1Child1.getChild('0') |
| 323 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1Child0)["Text"], "A heading of level 3") |
| 324 |
xHeadingsChild1Child1Child0.executeAction("DOUBLECLICK", tuple()) |
| 325 |
|
| 326 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "A heading of level 3") |
| 327 |
|
| 328 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 329 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 330 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 331 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 332 |
|
| 333 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 334 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 335 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 336 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 337 |
|
| 338 |
# Expected chapter order: |
| 339 |
# 1. One H1 |
| 340 |
# 1.1. one_A (H2) |
| 341 |
# 1.2. one_B (H2) |
| 342 |
# 2. Two (H1) |
| 343 |
# A heading of level 3 |
| 344 |
# 2.1. Two_B (H2) |
| 345 |
# 2.1. Two_A (H2) |
| 346 |
# 3. Three (H1) |
| 347 |
# 3.1. Three_A (H2) |
| 348 |
# 3.2. Three_B (H2) |
| 349 |
|
| 350 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 351 |
|
| 352 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 353 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 354 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 355 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 356 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 357 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 358 |
|
| 359 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 360 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 361 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 362 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") |
| 363 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 364 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") |
| 365 |
xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') |
| 366 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_A (H2)") |
| 367 |
|
| 368 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 369 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 370 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 371 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 372 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 373 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 374 |
|
| 375 |
# Move "2.1. Two_B (H2)" to its original position |
| 376 |
|
| 377 |
# Double click on the "2.1. Two_B (H2)" entry to select and set focus |
| 378 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 379 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 380 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_B (H2)") |
| 381 |
xHeadingsChild1Child1.executeAction("DOUBLECLICK", tuple()) |
| 382 |
|
| 383 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2.1. Two_B (H2)") |
| 384 |
|
| 385 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 386 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 387 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 388 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 389 |
|
| 390 |
# Expected chapter order is the original order |
| 391 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 392 |
|
| 393 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 394 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 395 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 396 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 397 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 398 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 399 |
|
| 400 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 401 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 402 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 403 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") |
| 404 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 405 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 406 |
xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') |
| 407 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") |
| 408 |
|
| 409 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 410 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 411 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 412 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 413 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 414 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 415 |
|
| 416 |
# |
| 417 |
# test moving a sub chapter out of and then back into its parent |
| 418 |
# |
| 419 |
|
| 420 |
# Double click on the "1.1. One_A (H2)" entry to select and set focus |
| 421 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 422 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 423 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 424 |
xHeadingsChild0Child0.executeAction("DOUBLECLICK", tuple()) |
| 425 |
|
| 426 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "1.1. One_A (H2)") |
| 427 |
|
| 428 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 429 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 430 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 431 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 432 |
|
| 433 |
# Expected chapter order: |
| 434 |
# 1.1. One_A (H2) |
| 435 |
# 1. One H1 |
| 436 |
# 1.2. One_B (H2) |
| 437 |
# 2. Two (H1) |
| 438 |
# A heading of level 3 |
| 439 |
# 2.1. Two_A (H2) |
| 440 |
# 2.1. Two_B (H2) |
| 441 |
# 3. Three (H1) |
| 442 |
# 3.1. Three_A (H2) |
| 443 |
# 3.2. Three_B (H2) |
| 444 |
|
| 445 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 446 |
|
| 447 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 448 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1.1. One_A (H2)") |
| 449 |
|
| 450 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 451 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "1. One (H1)") |
| 452 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 453 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "1.2. One_B (H2)") |
| 454 |
|
| 455 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 456 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "2. Two (H1)") |
| 457 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 458 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "A heading of level 3") |
| 459 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 460 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "2.1. Two_A (H2)") |
| 461 |
xHeadingsChild2Child2 = xHeadingsChild2.getChild('2') |
| 462 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child2)["Text"], "2.1. Two_B (H2)") |
| 463 |
|
| 464 |
xHeadingsChild3 = xNavigatorPanelContentTreeHeadings.getChild('3') |
| 465 |
self.assertEqual(get_state_as_dict(xHeadingsChild3)["Text"], "3. Three (H1)") |
| 466 |
xHeadingsChild3Child0 = xHeadingsChild3.getChild('0') |
| 467 |
self.assertEqual(get_state_as_dict(xHeadingsChild3Child0)["Text"], "3.1. Three_A (H2)") |
| 468 |
xHeadingsChild3Child1 = xHeadingsChild3.getChild('1') |
| 469 |
self.assertEqual(get_state_as_dict(xHeadingsChild3Child1)["Text"], "3.2. Three_B (H2)") |
| 470 |
|
| 471 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 472 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 473 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 474 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 475 |
|
| 476 |
# Expected chapter order is the original order |
| 477 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 478 |
|
| 479 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 480 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. One (H1)") |
| 481 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 482 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. One_A (H2)") |
| 483 |
xHeadingsChild0Child1 = xHeadingsChild0.getChild('1') |
| 484 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child1)["Text"], "1.2. One_B (H2)") |
| 485 |
|
| 486 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 487 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. Two (H1)") |
| 488 |
xHeadingsChild1Child0 = xHeadingsChild1.getChild('0') |
| 489 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child0)["Text"], "A heading of level 3") |
| 490 |
xHeadingsChild1Child1 = xHeadingsChild1.getChild('1') |
| 491 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child1)["Text"], "2.1. Two_A (H2)") |
| 492 |
xHeadingsChild1Child2 = xHeadingsChild1.getChild('2') |
| 493 |
self.assertEqual(get_state_as_dict(xHeadingsChild1Child2)["Text"], "2.1. Two_B (H2)") |
| 494 |
|
| 495 |
xHeadingsChild2 = xNavigatorPanelContentTreeHeadings.getChild('2') |
| 496 |
self.assertEqual(get_state_as_dict(xHeadingsChild2)["Text"], "3. Three (H1)") |
| 497 |
xHeadingsChild2Child0 = xHeadingsChild2.getChild('0') |
| 498 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child0)["Text"], "3.1. Three_A (H2)") |
| 499 |
xHeadingsChild2Child1 = xHeadingsChild2.getChild('1') |
| 500 |
self.assertEqual(get_state_as_dict(xHeadingsChild2Child1)["Text"], "3.2. Three_B (H2)") |
| 501 |
|
| 502 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 503 |
|
| 504 |
def test_tdf164074(self): |
| 505 |
|
| 506 |
with self.ui_test.load_file(get_url_for_data_file('tdf164074.fodt')): |
| 507 |
xWriterDoc = self.xUITest.getTopFocusWindow() |
| 508 |
xWriterEdit = xWriterDoc.getChild('writer_edit') |
| 509 |
|
| 510 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 511 |
xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) |
| 512 |
|
| 513 |
# wait until the navigator panel is available |
| 514 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 515 |
|
| 516 |
# See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons") |
| 517 |
# in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that |
| 518 |
# m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the |
| 519 |
# xInsert click above. |
| 520 |
xToolkit = self.xContext.ServiceManager.createInstance('com.sun.star.awt.Toolkit') |
| 521 |
xToolkit.waitUntilAllIdlesDispatched() |
| 522 |
|
| 523 |
# Given the document chapter structure: |
| 524 |
# 1. One H1 |
| 525 |
# 1.1. one_A (H2) |
| 526 |
# 1.2. one_B (H2) |
| 527 |
# 2. Two (H1) |
| 528 |
# A heading of level 3 |
| 529 |
# 2.1. Two_A (H2) |
| 530 |
# 2.1. Two_B (H2) |
| 531 |
# 3. Three (H1) |
| 532 |
# 3.1. Three_A (H2) |
| 533 |
# 3.2. Three_B (H2) |
| 534 |
|
| 535 |
xNavigatorPanelContentTree = xNavigatorPanel.getChild("contenttree") |
| 536 |
|
| 537 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 538 |
xNavigatorPanelContentTreeHeadings.executeAction("EXPAND", tuple()) |
| 539 |
|
| 540 |
# |
| 541 |
# test a level 1 chapter move up then move down |
| 542 |
# |
| 543 |
|
| 544 |
# Double click on the "2. Two (H1)" entry to select and set focus |
| 545 |
xHeadingsChild1 = xNavigatorPanelContentTreeHeadings.getChild('1') |
| 546 |
self.assertEqual(get_state_as_dict(xHeadingsChild1)["Text"], "2. H1") |
| 547 |
xHeadingsChild1.executeAction("DOUBLECLICK", tuple()) |
| 548 |
|
| 549 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "2. H1") |
| 550 |
|
| 551 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 552 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 553 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 554 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 555 |
|
| 556 |
# Expected chapter order: |
| 557 |
# 2. H1 |
| 558 |
# 2.1. H2 |
| 559 |
# 2.1.1. H3 |
| 560 |
# 2.1.1.1. Lorem |
| 561 |
# 2.1.1.1.1. Vestibulum |
| 562 |
# 2.1.1.1.2. Integer |
| 563 |
# 2.1.1.2. Aliquam |
| 564 |
|
| 565 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 566 |
|
| 567 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 568 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "2. H1") |
| 569 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 570 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "2.1. H2") |
| 571 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 572 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "2.1.1. H3") |
| 573 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 574 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "2.1.1.1. Lorem") |
| 575 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 576 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "2.1.1.1.1. Vestibulum") |
| 577 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 578 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "2.1.1.1.2. Integer") |
| 579 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 580 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "2.1.1.2. Aliquam") |
| 581 |
|
| 582 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 583 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 584 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 585 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 586 |
|
| 587 |
# Expected chapter order is the original order |
| 588 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 589 |
|
| 590 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 591 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. H1") |
| 592 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 593 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. H2") |
| 594 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 595 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "1.1.1. H3") |
| 596 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 597 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.1.1. Lorem") |
| 598 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 599 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "1.1.1.1.1. Vestibulum") |
| 600 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 601 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "1.1.1.1.2. Integer") |
| 602 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 603 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.1.2. Aliquam") |
| 604 |
|
| 605 |
# |
| 606 |
# test moving a sub chapter out of and then back into its parent |
| 607 |
# |
| 608 |
|
| 609 |
# Double click on the "1.1.2. (H3)" entry to select and set focus |
| 610 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 611 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 612 |
xHeadingsChild0Child0Child1 = xHeadingsChild0Child0.getChild('1') |
| 613 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child1)["Text"], "1.1.2. H3") |
| 614 |
xHeadingsChild0Child0Child1.executeAction("DOUBLECLICK", tuple()) |
| 615 |
|
| 616 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "1.1.2. H3") |
| 617 |
|
| 618 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 619 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 620 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 621 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 622 |
|
| 623 |
# Expected chapter order: |
| 624 |
# 1. H1 |
| 625 |
# 1.1. H2 |
| 626 |
# 1.1.2. H3 <---- |
| 627 |
# 1.1.2.1. Lorem |
| 628 |
# 1.1.2.1.1. Vestibulum |
| 629 |
# 1.1.2.1.2. Integer |
| 630 |
# 1.1.2.2. Aliquam |
| 631 |
# 1.1.2.2.1. Donec |
| 632 |
# 1.1.2.2.2. Praesent |
| 633 |
# 1.1.1. H3 |
| 634 |
|
| 635 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 636 |
|
| 637 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 638 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. H1") |
| 639 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 640 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. H2") |
| 641 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 642 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "1.1.2. H3") |
| 643 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 644 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.2.1. Lorem") |
| 645 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 646 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "1.1.2.1.1. Vestibulum") |
| 647 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 648 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "1.1.2.1.2. Integer") |
| 649 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 650 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.2.2. Aliquam") |
| 651 |
xHeadingsChild0Child0Child0Child1Child0 = xHeadingsChild0Child0Child0Child1.getChild('0') |
| 652 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child0)["Text"], "1.1.2.2.1. Donec") |
| 653 |
xHeadingsChild0Child0Child0Child1Child1 = xHeadingsChild0Child0Child0Child1.getChild('1') |
| 654 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child1)["Text"], "1.1.2.2.2. Praesent") |
| 655 |
xHeadingsChild0Child0Child1 = xHeadingsChild0Child0.getChild('1') |
| 656 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child1)["Text"], "1.1.1. H3") |
| 657 |
|
| 658 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 659 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 660 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 661 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 662 |
|
| 663 |
# Expected chapter order is the original order |
| 664 |
# 1. H1 |
| 665 |
# 1.1. H2 |
| 666 |
# 1.1.1. H3 |
| 667 |
# 1.1.1.1. Lorem |
| 668 |
# 1.1.1.1.1. Vestibulum |
| 669 |
# 1.1.1.1.2. Integer |
| 670 |
# 1.1.1.2. Aliquam |
| 671 |
# 1.1.1.2.1. Donec |
| 672 |
# 1.1.1.2.2. Praesent |
| 673 |
# 1.1.2. H3 |
| 674 |
|
| 675 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 676 |
|
| 677 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 678 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. H1") |
| 679 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 680 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. H2") |
| 681 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 682 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "1.1.1. H3") |
| 683 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 684 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.1.1. Lorem") |
| 685 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 686 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "1.1.1.1.1. Vestibulum") |
| 687 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 688 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "1.1.1.1.2. Integer") |
| 689 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 690 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.1.2. Aliquam") |
| 691 |
xHeadingsChild0Child0Child0Child1Child0 = xHeadingsChild0Child0Child0Child1.getChild('0') |
| 692 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child0)["Text"], "1.1.1.2.1. Donec") |
| 693 |
xHeadingsChild0Child0Child0Child1Child1 = xHeadingsChild0Child0Child0Child1.getChild('1') |
| 694 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child1)["Text"], "1.1.1.2.2. Praesent") |
| 695 |
xHeadingsChild0Child0Child1 = xHeadingsChild0Child0.getChild('1') |
| 696 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child1)["Text"], "1.1.2. H3") |
| 697 |
|
| 698 |
# |
| 699 |
# test moving a sub chapter out of and then back into its parent |
| 700 |
# |
| 701 |
|
| 702 |
# Double click on the "1.1.2. (H3)" entry to select and set focus |
| 703 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 704 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 705 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 706 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 707 |
|
| 708 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.1.2. Aliquam") |
| 709 |
xHeadingsChild0Child0Child0Child1.executeAction("DOUBLECLICK", tuple()) |
| 710 |
|
| 711 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "1.1.1.2. Aliquam") |
| 712 |
|
| 713 |
# Click on the 'Move chapter up' button in the Navigator tool box |
| 714 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 715 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 716 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "2"})) |
| 717 |
|
| 718 |
# Expected chapter order: |
| 719 |
# 1. H1 |
| 720 |
# 1.1. H2 |
| 721 |
# 1.1.1. H3 |
| 722 |
# 1.1.1.2. Aliquam <--- |
| 723 |
# 1.1.1.2.1. Donec |
| 724 |
# 1.1.1.2.2. Praesent |
| 725 |
# 1.1.1.1. Lorem |
| 726 |
# 1.1.1.1.1. Vestibulum |
| 727 |
# 1.1.1.1.2. Integer |
| 728 |
# 1.1.2. H3 |
| 729 |
|
| 730 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 731 |
|
| 732 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 733 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. H1") |
| 734 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 735 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. H2") |
| 736 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 737 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "1.1.1. H3") |
| 738 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 739 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.1.2. Aliquam") |
| 740 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 741 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "1.1.1.2.1. Donec") |
| 742 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 743 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "1.1.1.2.2. Praesent") |
| 744 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 745 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.1.1. Lorem") |
| 746 |
xHeadingsChild0Child0Child0Child1Child0 = xHeadingsChild0Child0Child0Child1.getChild('0') |
| 747 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child0)["Text"], "1.1.1.1.1. Vestibulum") |
| 748 |
xHeadingsChild0Child0Child0Child1Child1 = xHeadingsChild0Child0Child0Child1.getChild('1') |
| 749 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child1)["Text"], "1.1.1.1.2. Integer") |
| 750 |
xHeadingsChild0Child0Child1 = xHeadingsChild0Child0.getChild('1') |
| 751 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child1)["Text"], "1.1.2. H3") |
| 752 |
|
| 753 |
# Double click on the "1.1.1.2. Aliquam" entry to select and set focus |
| 754 |
# FIXME: restore focus to avoid this |
| 755 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 756 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 757 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 758 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 759 |
|
| 760 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.1.2. Aliquam") |
| 761 |
xHeadingsChild0Child0Child0Child0.executeAction("DOUBLECLICK", tuple()) |
| 762 |
|
| 763 |
self.ui_test.wait_until_property_is_updated(xNavigatorPanelContentTree, "SelectEntryText", "1.1.1.2. Aliquam") |
| 764 |
|
| 765 |
# Click on the 'Move chapter down' button in the Navigator tool box |
| 766 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 767 |
xToolBar = xNavigatorPanel.getChild("HeadingsContentFunctionButtonsToolbar") |
| 768 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "3"})) |
| 769 |
|
| 770 |
# Expected chapter order is the original order |
| 771 |
# 1. H1 |
| 772 |
# 1.1. H2 |
| 773 |
# 1.1.1. H3 |
| 774 |
# 1.1.1.1. Lorem |
| 775 |
# 1.1.1.1.1. Vestibulum |
| 776 |
# 1.1.1.1.2. Integer |
| 777 |
# 1.1.1.2. Aliquam |
| 778 |
# 1.1.1.2.1. Donec |
| 779 |
# 1.1.1.2.2. Praesent |
| 780 |
# 1.1.2. H3 |
| 781 |
|
| 782 |
xNavigatorPanelContentTreeHeadings = xNavigatorPanelContentTree.getChild('0') |
| 783 |
|
| 784 |
xHeadingsChild0 = xNavigatorPanelContentTreeHeadings.getChild('0') |
| 785 |
self.assertEqual(get_state_as_dict(xHeadingsChild0)["Text"], "1. H1") |
| 786 |
xHeadingsChild0Child0 = xHeadingsChild0.getChild('0') |
| 787 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0)["Text"], "1.1. H2") |
| 788 |
xHeadingsChild0Child0Child0 = xHeadingsChild0Child0.getChild('0') |
| 789 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0)["Text"], "1.1.1. H3") |
| 790 |
xHeadingsChild0Child0Child0Child0 = xHeadingsChild0Child0Child0.getChild('0') |
| 791 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0)["Text"], "1.1.1.1. Lorem") |
| 792 |
xHeadingsChild0Child0Child0Child0Child0 = xHeadingsChild0Child0Child0Child0.getChild('0') |
| 793 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child0)["Text"], "1.1.1.1.1. Vestibulum") |
| 794 |
xHeadingsChild0Child0Child0Child0Child1 = xHeadingsChild0Child0Child0Child0.getChild('1') |
| 795 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child0Child1)["Text"], "1.1.1.1.2. Integer") |
| 796 |
xHeadingsChild0Child0Child0Child1 = xHeadingsChild0Child0Child0.getChild('1') |
| 797 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1)["Text"], "1.1.1.2. Aliquam") |
| 798 |
xHeadingsChild0Child0Child0Child1Child0 = xHeadingsChild0Child0Child0Child1.getChild('0') |
| 799 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child0)["Text"], "1.1.1.2.1. Donec") |
| 800 |
xHeadingsChild0Child0Child0Child1Child1 = xHeadingsChild0Child0Child0Child1.getChild('1') |
| 801 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child0Child1Child1)["Text"], "1.1.1.2.2. Praesent") |
| 802 |
xHeadingsChild0Child0Child1 = xHeadingsChild0Child0.getChild('1') |
| 803 |
self.assertEqual(get_state_as_dict(xHeadingsChild0Child0Child1)["Text"], "1.1.2. H3") |
| 804 |
|
| 805 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |