Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / qa / uitest / navigator / tdf137274.py
blob5192045b826444cd07f9eea5adbf3e1b505d677e
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
13 class tdf137274(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 test_tdf137274(self):
23 with self.ui_test.create_doc_in_start_center("writer"):
25 xMainWindow = self.xUITest.getTopFocusWindow()
26 xWriterEdit = xMainWindow.getChild("writer_edit")
28 xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"}))
30 # Insert first comment
31 xArgs = mkPropertyValues({"Text": "C1"})
32 self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
34 # wait until the comment is available
35 self.ui_test.wait_until_child_is_available('Comment1')
37 self.xUITest.executeCommand(".uno:Sidebar")
39 xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
41 # wait until the navigator panel is available
42 xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel')
44 xContentTree = xNavigatorPanel.getChild("contenttree")
45 xComments = self.get_item(xContentTree, 'Comments')
46 self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
48 xComments.executeAction("EXPAND", tuple())
50 self.assertEqual(1, len(xComments.getChildren()))
51 self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
53 xComments.executeAction("COLLAPSE", tuple())
55 xArgs = mkPropertyValues({"Text": "C2"})
56 self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs)
58 # wait until the second comment is available
59 self.ui_test.wait_until_child_is_available('Comment2')
61 # xComments needs reassigned after content tree change
62 xComments = self.get_item(xContentTree, 'Comments')
63 self.assertEqual('Comments', get_state_as_dict(xComments)['Text'])
65 xComments.executeAction("EXPAND", tuple())
67 # Without the fix in place, this test would have failed with AssertionError: 2 != 0
68 self.assertEqual(2, len(xComments.getChildren()))
69 self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text'])
71 xComments.executeAction("COLLAPSE", tuple())
73 self.xUITest.executeCommand(".uno:Sidebar")
76 # vim: set shiftwidth=4 softtabstop=4 expandtab: