| 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, get_url_for_data_file |
| 12 |
|
| 13 |
class tdf140661(UITestCase): |
| 14 |
|
| 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 |
| 20 |
|
| 21 |
def launch_navigator(self, bIsBeforeUngroup): |
| 22 |
xMainWindow = self.xUITest.getTopFocusWindow() |
| 23 |
xWriterEdit = xMainWindow.getChild("writer_edit") |
| 24 |
|
| 25 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 26 |
|
| 27 |
xWriterEdit.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "SwNavigatorPanel"})) |
| 28 |
|
| 29 |
# wait until the navigator panel is available |
| 30 |
xNavigatorPanel = self.ui_test.wait_until_child_is_available('NavigatorPanel') |
| 31 |
|
| 32 |
xContentTree = xNavigatorPanel.getChild("contenttree") |
| 33 |
xDrawings = self.get_item(xContentTree, 'Drawing objects') |
| 34 |
self.assertEqual('Drawing objects', get_state_as_dict(xDrawings)['Text']) |
| 35 |
|
| 36 |
xDrawings.executeAction("EXPAND", tuple()) |
| 37 |
|
| 38 |
if bIsBeforeUngroup: |
| 39 |
self.assertEqual(1, len(xDrawings.getChildren())) |
| 40 |
self.assertEqual('DrawObject1', get_state_as_dict(xDrawings.getChild('0'))['Text']) |
| 41 |
else: |
| 42 |
self.assertEqual(12, len(xDrawings.getChildren())) |
| 43 |
|
| 44 |
# tdf#134960 |
| 45 |
expectedShapeOrder = [1, 2, 8, 9, 7, 10, 11, 3, 12, 4, 5, 6] |
| 46 |
for i in range(12): |
| 47 |
self.assertEqual('Shape' + str(expectedShapeOrder[i]), get_state_as_dict(xDrawings.getChild(str(i)))['Text']) |
| 48 |
|
| 49 |
xDrawings.executeAction("COLLAPSE", tuple()) |
| 50 |
|
| 51 |
self.xUITest.executeCommand(".uno:Sidebar") |
| 52 |
|
| 53 |
def test_tdf140661(self): |
| 54 |
|
| 55 |
with self.ui_test.load_file(get_url_for_data_file("tdf140661.odt")): |
| 56 |
|
| 57 |
self.launch_navigator(True) |
| 58 |
|
| 59 |
# Select the shape and ungroup it |
| 60 |
self.xUITest.executeCommand(".uno:JumpToNextFrame") |
| 61 |
|
| 62 |
self.ui_test.wait_until_child_is_available('metricfield') |
| 63 |
|
| 64 |
self.xUITest.executeCommand(".uno:FormatUngroup") |
| 65 |
|
| 66 |
# Without the fix in place, this test would have failed with |
| 67 |
# AssertionError: 12 != 0 |
| 68 |
self.launch_navigator(False) |
| 69 |
|
| 70 |
# vim: set shiftwidth=4 softtabstop=4 expandtab: |