| 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 tdf148198(UITestCase): |
| 15 |
|
| 16 |
def get_item(self, xTree, name): |
| 17 |
for i in xTree.getChildren(): |
| 18 |
xItem = xTree.getChild(i) |
| 19 |
if name == get_state_as_dict(xItem)['Text']: |
| 20 |
return xItem |
| 21 |
|
| 22 |
def test_tdf148198(self): |
| 23 |
sHyperlink0 = 'a hyperlink with an anchor, different character styles, a footnote1, a field This is a bookmark, and a rsid' |
| 24 |
sHyperlink1 = 'another hyperlink' |
| 25 |
|
| 26 |
with self.ui_test.load_file(get_url_for_data_file('hyperlink_multiple_spans.fodt')): |
| 27 |
xWriterDoc = self.xUITest.getTopFocusWindow() |
| 28 |
xWriterEdit = xWriterDoc.getChild('writer_edit') |
| 29 |
|
| 30 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 31 |
xWriterEdit.executeAction('SIDEBAR', mkPropertyValues({'PANEL': 'SwNavigatorPanel'})) |
| 32 |
|
| 33 |
# wait until the navigator panel is available |
| 34 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 35 |
|
| 36 |
xContentTree = xNavigatorPanel.getChild('contenttree') |
| 37 |
xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') |
| 38 |
self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) |
| 39 |
|
| 40 |
xHyperlinks.executeAction('EXPAND', tuple()) |
| 41 |
|
| 42 |
self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children']) |
| 43 |
self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text']) |
| 44 |
self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text']) |
| 45 |
|
| 46 |
# save and reload: the first hyperlink must be kept in one piece |
| 47 |
self.xUITest.executeCommand('.uno:Save') |
| 48 |
self.xUITest.executeCommand('.uno:Reload') |
| 49 |
|
| 50 |
# wait until the navigator panel is available |
| 51 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 52 |
|
| 53 |
xContentTree = xNavigatorPanel.getChild('contenttree') |
| 54 |
xHyperlinks = self.get_item(xContentTree, 'Hyperlinks') |
| 55 |
self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text']) |
| 56 |
|
| 57 |
xHyperlinks.executeAction('EXPAND', tuple()) |
| 58 |
|
| 59 |
# without the fix in place, this would fail: |
| 60 |
# AssertionError: '2' != '11' |
| 61 |
self.assertEqual('2', get_state_as_dict(xHyperlinks)['Children']) |
| 62 |
self.assertEqual(sHyperlink0, get_state_as_dict(xHyperlinks.getChild('0'))['Text']) |
| 63 |
self.assertEqual(sHyperlink1, get_state_as_dict(xHyperlinks.getChild('1'))['Text']) |
| 64 |
|
| 65 |
self.xUITest.executeCommand('.uno:Sidebar') |
| 66 |
|
| 67 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |