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/.
9 from uitest
.framework
import UITestCase
10 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
11 from uitest
.uihelper
.common
import get_state_as_dict
, type_text
12 from uitest
.uihelper
.common
import select_pos
13 from uitest
.uihelper
.common
import select_by_text
15 class Tdf140257(UITestCase
):
17 def change_outline_level(self
, sText
):
19 with self
.ui_test
.execute_dialog_through_command(".uno:ParagraphDialog") as xDialog
:
20 xTabs
= xDialog
.getChild("tabcontrol")
21 select_pos(xTabs
, "4")
23 xOutline
= xDialog
.getChild("comboLB_OUTLINE_LEVEL")
25 select_by_text(xOutline
, sText
)
28 def test_tdf140257(self
):
29 with self
.ui_test
.create_doc_in_start_center("writer") as document
:
30 xMainWindow
= self
.xUITest
.getTopFocusWindow()
31 xWriterEdit
= xMainWindow
.getChild("writer_edit")
33 self
.change_outline_level("Level 1")
36 type_text(xWriterEdit
, 'P' + str(i
+ 1))
37 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
39 type_text(xWriterEdit
, 'P5')
41 self
.xUITest
.executeCommand(".uno:Sidebar")
43 xWriterEdit
.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
45 # wait until the navigator panel is available
46 xNavigatorPanel
= self
.ui_test
.wait_until_child_is_available('NavigatorPanel')
48 xContentTree
= xNavigatorPanel
.getChild("contenttree")
49 xHeadings
= xContentTree
.getChild('0')
50 self
.assertEqual('Headings', get_state_as_dict(xHeadings
)['Text'])
52 xHeadings
.executeAction("EXPAND", tuple())
54 self
.assertEqual(5, len(xHeadings
.getChildren()))
57 self
.assertEqual('P' + str(i
+ 1), get_state_as_dict(xHeadings
.getChild(str(i
)))['Text'])
59 self
.xUITest
.executeCommand(".uno:Sidebar")
61 cursor
= document
.getCurrentController().getViewCursor()
63 # Use Adding Selection
64 selectionProperty
= mkPropertyValues({"SelectionMode": 2})
65 self
.xUITest
.executeCommandWithParameters(".uno:SelectionMode", selectionProperty
)
67 # Go to P2 and select it
69 cursor
.gotoStartOfLine(False)
70 cursor
.gotoEndOfLine(True)
72 # Go to P4 and select it
73 cursor
.goDown(2, False)
74 cursor
.gotoStartOfLine(False)
75 cursor
.gotoEndOfLine(True)
77 self
.change_outline_level("Level 2")
79 self
.xUITest
.executeCommand(".uno:Sidebar")
81 xWriterEdit
.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
83 # wait until the navigator panel is available
84 xNavigatorPanel
= self
.ui_test
.wait_until_child_is_available('NavigatorPanel')
86 xContentTree
= xNavigatorPanel
.getChild("contenttree")
87 xHeadings
= xContentTree
.getChild('0')
88 self
.assertEqual('Headings', get_state_as_dict(xHeadings
)['Text'])
90 xHeadings
.executeAction("EXPAND", tuple())
92 # Without the fix in place, this test would have failed with
93 # AssertionError: 3 != 4
94 self
.assertEqual(3, len(xHeadings
.getChildren()))
95 xChild1
= xHeadings
.getChild('0')
96 self
.assertEqual('P1', get_state_as_dict(xChild1
)['Text'])
97 xChild1
.executeAction("EXPAND", tuple())
98 self
.assertEqual(1, len(xChild1
.getChildren()))
99 self
.assertEqual('P2', get_state_as_dict(xChild1
.getChild('0'))['Text'])
101 xChild2
= xHeadings
.getChild('1')
102 self
.assertEqual('P3', get_state_as_dict(xChild2
)['Text'])
103 xChild2
.executeAction("EXPAND", tuple())
104 self
.assertEqual(1, len(xChild2
.getChildren()))
105 self
.assertEqual('P4', get_state_as_dict(xChild2
.getChild('0'))['Text'])
107 self
.assertEqual('P5', get_state_as_dict(xHeadings
.getChild('2'))['Text'])
109 self
.xUITest
.executeCommand(".uno:Sidebar")
112 # vim: set shiftwidth=4 softtabstop=4 expandtab: