| 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 tdf159428(UITestCase): |
| 15 |
|
| 16 |
def test_tdf159428(self): |
| 17 |
global selectionChangedResult |
| 18 |
with self.ui_test.load_file(get_url_for_data_file('tdf159428.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 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 26 |
xContentTree = xNavigatorPanel.getChild("contenttree") |
| 27 |
|
| 28 |
# select first bookmark - Heading "H1" should be tracked |
| 29 |
self.xUITest.executeCommand(".uno:GoToNextPara") |
| 30 |
self.xUITest.executeCommand(".uno:GoToNextPara") |
| 31 |
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "111", "END_POS": "119"})) |
| 32 |
self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "H1") |
| 33 |
self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "H1") |
| 34 |
|
| 35 |
# select second bookmark - Heading "H1 mit Lesezeichen" should be tracked |
| 36 |
self.xUITest.executeCommand(".uno:GoToNextPara") |
| 37 |
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "0", "END_POS": "18"})) |
| 38 |
self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "H1 mit Lesezeichen") |
| 39 |
self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "H1 mit Lesezeichen") |
| 40 |
|
| 41 |
# select third bookmark - no heading tracked |
| 42 |
self.xUITest.executeCommand(".uno:GoToPrevPara") |
| 43 |
self.xUITest.executeCommand(".uno:GoToPrevPara") |
| 44 |
self.xUITest.executeCommand(".uno:GoToPrevPara") |
| 45 |
xWriterEdit.executeAction("SELECT", mkPropertyValues({"START_POS": "141", "END_POS": "146"})) |
| 46 |
self.ui_test.wait_until_property_is_updated(xContentTree, "SelectEntryText", "Lesezeichen 3") |
| 47 |
self.assertEqual(get_state_as_dict(xContentTree)["SelectEntryText"], "Lesezeichen 3") |
| 48 |
|
| 49 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |