Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / navigator / tdf134960.py
blob8388b63e40f9719068948a1dc98edd0b7119ed15
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, get_url_for_data_file
13 class tdf134960_hyperlinks(UITestCase):
15 def get_item(self, xTree, name):
16 for i in xTree.getChildren():
17 xItem = xTree.getChild(i)
18 if name == get_state_as_dict(xItem)['Text']:
19 return xItem
21 def launch_sidebar(self, xWriterEdit):
23 self.xUITest.executeCommand(".uno:Sidebar")
25 xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
27 # wait until the navigator panel is available
28 xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
30 xContentTree = xNavigatorPanel.getChild("contenttree")
31 xHyperlinks = self.get_item(xContentTree, 'Hyperlinks')
32 self.assertEqual('Hyperlinks', get_state_as_dict(xHyperlinks)['Text'])
34 xHyperlinks.executeAction("EXPAND", tuple())
36 expectedHyperlinksOrder = [1, 2, 8, 9, 7, 10, 11, 3, 12, 4, 5, 6]
37 for i in range(12):
38 self.assertEqual('Hyperlink ' + str(expectedHyperlinksOrder[i]), get_state_as_dict(xHyperlinks.getChild(str(i)))['Text'])
40 xHyperlinks.executeAction("COLLAPSE", tuple())
42 self.xUITest.executeCommand(".uno:Sidebar")
44 def test_tdf134960_hyperlinks(self):
46 with self.ui_test.load_file(get_url_for_data_file("tdf134960.odt")):
47 xWriterDoc = self.xUITest.getTopFocusWindow()
48 xWriterEdit = xWriterDoc.getChild("writer_edit")
50 # Without the fix in place, this test would have failed with
51 # AssertionError: 'Hyperlink 2' != 'Hyperlink 6'
52 self.launch_sidebar(xWriterEdit)
54 def test_tdf134960_hyperlinks_with_multiple_pages(self):
56 with self.ui_test.load_file(get_url_for_data_file("tdf134960.odt")):
57 xWriterDoc = self.xUITest.getTopFocusWindow()
58 xWriterEdit = xWriterDoc.getChild("writer_edit")
60 # Insert a page break so we have different links in different pages
61 xWriterEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
62 self.xUITest.executeCommand(".uno:InsertPagebreak")
63 self.assertEqual("3", get_state_as_dict(xWriterEdit)["Pages"])
65 # Change view to 20% and 2 columns
66 with self.ui_test.execute_dialog_through_command(".uno:Zoom") as xDialog:
67 variable = xDialog.getChild("variable")
68 variable.executeAction("CLICK", tuple())
70 zoomsb = xDialog.getChild("zoomsb")
71 zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
72 zoomsb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
73 zoomsb.executeAction("TYPE", mkPropertyValues({"TEXT":"20"}))
75 columns = xDialog.getChild("columns")
76 columns.executeAction("CLICK", tuple())
78 columnssb = xDialog.getChild("columnssb")
79 columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
80 columnssb.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
81 columnssb.executeAction("TYPE", mkPropertyValues({"TEXT":"3"}))
83 # Without the fix in place, this test would have failed with
84 # AssertionError: 'Hyperlink 2' != 'Hyperlink 8'
85 self.launch_sidebar(xWriterEdit)
87 # vim: set shiftwidth=4 softtabstop=4 expandtab: