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
14 class tdf137274(UITestCase
):
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']:
22 def test_tdf137274(self
):
24 with self
.ui_test
.create_doc_in_start_center("writer"):
26 xMainWindow
= self
.xUITest
.getTopFocusWindow()
27 xWriterEdit
= xMainWindow
.getChild("writer_edit")
29 xWriterEdit
.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"}))
31 # Insert first comment
32 xArgs
= mkPropertyValues({"Text": "C1"})
33 self
.xUITest
.executeCommandWithParameters(".uno:InsertAnnotation", xArgs
)
35 # wait until the comment is available
36 self
.ui_test
.wait_until_child_is_available('Comment1')
38 self
.xUITest
.executeCommand(".uno:Sidebar")
40 xWriterEdit
.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"}))
42 # wait until the navigator panel is available
43 xNavigatorPanel
= self
.ui_test
.wait_until_child_is_available('NavigatorPanel')
45 # See the `m_aUpdateTimer.SetTimeout(200)` (to "avoid flickering of buttons")
46 # in the SwChildWinWrapper ctor in sw/source/uibase/fldui/fldwrap.cxx, where that
47 # m_aUpdateTimer is started by SwChildWinWrapper::ReInitDlg triggered from the
48 # xInsert click above.
49 xToolkit
= self
.xContext
.ServiceManager
.createInstance('com.sun.star.awt.Toolkit')
50 xToolkit
.waitUntilAllIdlesDispatched()
52 xContentTree
= xNavigatorPanel
.getChild("contenttree")
53 xComments
= self
.get_item(xContentTree
, 'Comments')
54 self
.assertEqual('Comments', get_state_as_dict(xComments
)['Text'])
56 xComments
.executeAction("EXPAND", tuple())
58 self
.assertEqual(1, len(xComments
.getChildren()))
59 self
.assertEqual('C1', get_state_as_dict(xComments
.getChild('0'))['Text'])
61 xComments
.executeAction("COLLAPSE", tuple())
63 xArgs
= mkPropertyValues({"Text": "C2"})
64 self
.xUITest
.executeCommandWithParameters(".uno:InsertAnnotation", xArgs
)
66 # wait until the second comment is available
67 self
.ui_test
.wait_until_child_is_available('Comment2')
69 # xComments needs reassigned after content tree change
71 xComments
= self
.get_item(xContentTree
, 'Comments')
72 if '1' in xComments
.getChildren():
74 time
.sleep(self
.ui_test
.get_default_sleep())
75 self
.assertEqual('Comments', get_state_as_dict(xComments
)['Text'])
77 xComments
.executeAction("EXPAND", tuple())
79 # Without the fix in place, this test would have failed with AssertionError: 2 != 0
80 self
.assertEqual(2, len(xComments
.getChildren()))
81 self
.assertEqual('C1', get_state_as_dict(xComments
.getChild('0'))['Text'])
83 xComments
.executeAction("COLLAPSE", tuple())
85 self
.xUITest
.executeCommand(".uno:Sidebar")
88 # vim: set shiftwidth=4 softtabstop=4 expandtab: