Debian Codegraph @

sd/qa/uitest/impress_tests2/tdf128787.py

raw
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
10 from uitest.framework import UITestCase
11 from libreoffice.uno.propertyvalue import mkPropertyValues
12 from uitest.uihelper.common import get_state_as_dict, get_url_for_data_file, select_by_text
13
14 class tdf128787(UITestCase):
15
16 def test_tdf128787(self):
17 with self.ui_test.load_file(get_url_for_data_file("tdf128787.odp")):
18 xImpressDoc = self.xUITest.getTopFocusWindow()
19 xEditWin = xImpressDoc.getChild("impress_win")
20
21 # Without opening the StyleListPanel, executing_dialog_through_command
22 # .uno:StyleNewByExample doesn't work as expected in the test environment.
23 # Perhaps this is required so the styles are loaded. The sidebar can be closed after
24 # this and .uno:StyleNewByExample will work but for this test this is not wanted.
25 xEditWin.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"}))
26
27 # wait until the template panel is available
28 xTemplatePanel = self.ui_test.wait_until_child_is_available('TemplatePanel')
29
30 # select the image
31 xEditWin.executeAction("SELECT", mkPropertyValues({"OBJECT":"Image 1"}))
32
33 # New Style from Selection [uno:StyleNewByExample]
34 with self.ui_test.execute_dialog_through_command(".uno:StyleNewByExample") as xDialog:
35 # Enter a name in the Create Style dialog and press OK
36 stylename = xDialog.getChild("stylename")
37 stylename.executeAction("TYPE", mkPropertyValues({"TEXT": "New Style"}))
38
39 # make sure filter is set "Hierarchical"' so the 'treeview' tree is used
40 xFilter = xTemplatePanel.getChild('filter')
41 select_by_text(xFilter, "Hierarchical")
42
43 xTreeView = xTemplatePanel.getChild('treeview')
44 # "New Style" should be the first child of the first child in the tree
45 xItem = xTreeView.getChild(0).getChild(0)
46 self.assertEqual("New Style", get_state_as_dict(xItem)['Text'])
47
48 # vim: set shiftwidth=4 softtabstop=4 expandtab: