| 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 |
from uitest.framework import UITestCase |
| 10 |
from libreoffice.uno.propertyvalue import mkPropertyValues |
| 11 |
from uitest.uihelper.common import get_state_as_dict |
| 12 |
import time |
| 13 |
|
| 14 |
class tdf137274(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_tdf137274(self): |
| 23 |
|
| 24 |
with self.ui_test.create_doc_in_start_center("writer"): |
| 25 |
|
| 26 |
xMainWindow = self.xUITest.getTopFocusWindow() |
| 27 |
xWriterEdit = xMainWindow.getChild("writer_edit") |
| 28 |
|
| 29 |
xWriterEdit.executeAction("TYPE", mkPropertyValues({"TEXT": "Test"})) |
| 30 |
|
| 31 |
# Insert first comment |
| 32 |
xArgs = mkPropertyValues({"Text": "C1"}) |
| 33 |
self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) |
| 34 |
|
| 35 |
# wait until the comment is available |
| 36 |
self.ui_test.wait_until_child_is_available('Comment1') |
| 37 |
|
| 38 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 39 |
|
| 40 |
xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) |
| 41 |
|
| 42 |
# wait until the navigator panel is available |
| 43 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 44 |
|
| 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() |
| 51 |
|
| 52 |
xContentTree = xNavigatorPanel.getChild("contenttree") |
| 53 |
xComments = self.get_item(xContentTree, 'Comments') |
| 54 |
self.assertEqual('Comments', get_state_as_dict(xComments)['Text']) |
| 55 |
|
| 56 |
xComments.executeAction("EXPAND", tuple()) |
| 57 |
|
| 58 |
self.assertEqual(1, len(xComments.getChildren())) |
| 59 |
self.assertEqual('C1', get_state_as_dict(xComments.getChild('0'))['Text']) |
| 60 |
|
| 61 |
xComments.executeAction("COLLAPSE", tuple()) |
| 62 |
|
| 63 |
xArgs = mkPropertyValues({"Text": "C2"}) |
| 64 |
self.xUITest.executeCommandWithParameters(".uno:InsertAnnotation", xArgs) |
| 65 |
|
| 66 |
# wait until the second comment is available |
| 67 |
self.ui_test.wait_until_child_is_available('Comment2') |
| 68 |
|
| 69 |
# xComments needs reassigned after content tree change |
| 70 |
while True: |
| 71 |
xComments = self.get_item(xContentTree, 'Comments') |
| 72 |
if '1' in xComments.getChildren(): |
| 73 |
break |
| 74 |
time.sleep(self.ui_test.get_default_sleep()) |
| 75 |
self.assertEqual('Comments', get_state_as_dict(xComments)['Text']) |
| 76 |
|
| 77 |
xComments.executeAction("EXPAND", tuple()) |
| 78 |
|
| 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']) |
| 82 |
|
| 83 |
xComments.executeAction("COLLAPSE", tuple()) |
| 84 |
|
| 85 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 86 |
|
| 87 |
|
| 88 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |