| 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 |
| 13 |
|
| 14 |
class tdf154545(UITestCase): |
| 15 |
|
| 16 |
def test_tdf154545(self): |
| 17 |
global selectionChangedResult |
| 18 |
with self.ui_test.create_doc_in_start_center("writer") as xDoc: |
| 19 |
|
| 20 |
# click on the bookmark name in the Navigator |
| 21 |
|
| 22 |
xWriterDoc = self.xUITest.getTopFocusWindow() |
| 23 |
xWriterEdit = xWriterDoc.getChild("writer_edit") |
| 24 |
|
| 25 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 26 |
xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) |
| 27 |
|
| 28 |
xNavigatorPanel = xWriterEdit.getChild("NavigatorPanel") |
| 29 |
xToolBar = xNavigatorPanel.getChild("content5") |
| 30 |
xToolBar.executeAction("CLICK", mkPropertyValues({"POS": "0"})) # 'root' button |
| 31 |
|
| 32 |
# type "foo", and create a bookmark on it |
| 33 |
|
| 34 |
xDoc.Text.insertString(xDoc.Text.getStart(), "foo", False) |
| 35 |
self.xUITest.executeCommand(".uno:SelectAll") |
| 36 |
|
| 37 |
with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): |
| 38 |
pass |
| 39 |
|
| 40 |
# check selected bookmark in Navigator |
| 41 |
|
| 42 |
xWriterEdit.executeAction("FOCUS", tuple()) |
| 43 |
|
| 44 |
xContentTree = xNavigatorPanel.getChild("contenttree") |
| 45 |
|
| 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") |
| 49 |
|
| 50 |
self.xUITest.executeCommand(".uno:Escape") |
| 51 |
|
| 52 |
# create a nested bookmark on the last "o" |
| 53 |
|
| 54 |
cursor = xDoc.getCurrentController().getViewCursor() |
| 55 |
cursor.goLeft(1, True) |
| 56 |
|
| 57 |
with self.ui_test.execute_dialog_through_command(".uno:InsertBookmark", close_button="insert"): |
| 58 |
pass |
| 59 |
|
| 60 |
self.xUITest.executeCommand(".uno:Escape") |
| 61 |
|
| 62 |
# check selected nested bookmark in Navigator |
| 63 |
|
| 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") |
| 69 |
|
| 70 |
# Select nested bookmark in Navigator |
| 71 |
|
| 72 |
xContentTree.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) |
| 73 |
|
| 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") |
| 79 |
|
| 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") |
| 89 |
|
| 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") |
| 94 |
|
| 95 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 96 |
|
| 97 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |