Get the style color and number just once
[LibreOffice.git] / sw / qa / uitest / navigator / tdf154545.py
blobac034af93025d2269e41524bad08ef6ae9544f5b
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 libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict
14 class tdf154545(UITestCase):
16 def test_tdf154545(self):
17 global selectionChangedResult
18 with self.ui_test.create_doc_in_start_center("writer") as xDoc:
20 # click on the bookmark name in the Navigator
22 xWriterDoc = self.xUITest.getTopFocusWindow()
23 xWriterEdit = xWriterDoc.getChild("writer_edit")
25 self.xUITest.executeCommand(".uno:Sidebar")
26 xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
28 xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel")
29 xToolBar = xNavigatorPanel.getChild("content5")
30 xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button
32 # type "foo", and create a bookmark on it
34 xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False)
35 self.xUITest.executeCommand(".uno:SelectAll")
37 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
38 pass
40 # check selected bookmark in Navigator
42 xWriterEdit.executeAction("FOCUS", tuple())
44 xContentTree = xNavigatorPanel.getChild("contenttree")
46 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1")
47 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1")
48 self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1")
50 self.xUITest.executeCommand(".uno:Escape")
52 # create a nested bookmark on the last "o"
54 cursor = xDoc.getCurrentController().getViewCursor()
55 cursor.goLeft(1, True)
57 with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"):
58 pass
60 self.xUITest.executeCommand(".uno:Escape")
62 # check selected nested bookmark in Navigator
64 # This never occurred: Navigator didn't track nested bookmarks
65 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2")
66 # This was Bookmark 1
67 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2")
68 self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1")
70 # Select nested bookmark in Navigator
72 xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
74 # This jumped to Bookmark 1 after selection
75 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 2")
76 # This was Bookmark 1
77 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 2")
78 self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1")
80 # Try the same selection with Bookmark 1
81 xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
82 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1")
83 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1")
84 self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1")
85 xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
86 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmark 1")
87 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmark 1")
88 self.assertEqual(get_state_as_dict(xContentTree)["SelectionCount"], "1")
90 # go to the previous item
91 xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
92 self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Bookmarks")
93 self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Bookmarks")
95 self.xUITest.executeCommand(".uno:Sidebar")
97 # vim: set shiftwidth=4 softtabstop=4 expandtab: