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/.
10 from uitest
.framework
import UITestCase
11 from uitest
.uihelper
.common
import get_state_as_dict
, get_url_for_data_file
12 from uitest
.uihelper
.common
import select_by_text
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
15 class StylesSidebar(UITestCase
):
17 def test_load_styles_from_template(self
):
18 with self
.ui_test
.create_doc_in_start_center("writer"):
20 with self
.ui_test
.execute_dialog_through_command(".uno:LoadStyles", close_button
="") as xDialog
:
21 xText
= xDialog
.getChild("text")
22 xNumbering
= xDialog
.getChild("numbering")
23 xFrame
= xDialog
.getChild("frame")
24 xPages
= xDialog
.getChild("pages")
26 self
.assertEqual('true', get_state_as_dict(xText
)['Selected'])
27 self
.assertEqual('false', get_state_as_dict(xNumbering
)['Selected'])
28 self
.assertEqual('false', get_state_as_dict(xFrame
)['Selected'])
29 self
.assertEqual('false', get_state_as_dict(xPages
)['Selected'])
31 xNumbering
.executeAction("CLICK", tuple())
32 xFrame
.executeAction("CLICK", tuple())
33 xPages
.executeAction("CLICK", tuple())
35 self
.assertEqual('true', get_state_as_dict(xText
)['Selected'])
36 self
.assertEqual('true', get_state_as_dict(xNumbering
)['Selected'])
37 self
.assertEqual('true', get_state_as_dict(xFrame
)['Selected'])
38 self
.assertEqual('true', get_state_as_dict(xPages
)['Selected'])
40 xFileName
= xDialog
.getChild("fromfile")
42 with self
.ui_test
.execute_dialog_through_action(xFileName
, 'CLICK', close_button
="open") as dialog
:
43 xFileName
= dialog
.getChild("file_name")
44 xFileName
.executeAction("TYPE", mkPropertyValues({"TEXT": get_url_for_data_file("customStyles.odt")}))
46 xWriterDoc
= self
.xUITest
.getTopFocusWindow()
47 xWriterEdit
= xWriterDoc
.getChild("writer_edit")
49 expectedResults
= ["customParagraphStyle", "customCharacterStyle", "customFrameStyle",
50 "customPageStyle", "customNumberingStyle"]
54 self
.xUITest
.executeCommand(".uno:Sidebar")
55 xWriterEdit
.executeAction("SIDEBAR", mkPropertyValues({"PANEL": "StyleListPanel"}))
57 xFilter
= xWriterEdit
.getChild('filter')
58 select_by_text(xFilter
, "Custom Styles")
60 xLeft
= xWriterEdit
.getChild('left')
62 #change to another style type
63 xLeft
.executeAction("CLICK", mkPropertyValues({"POS": str( i
)}))
65 xFlatView
= xWriterEdit
.getChild("flatview")
67 self
.assertEqual(1, len(xFlatView
.getChildren()))
69 xFlatView
.getChild('0').executeAction("SELECT", tuple())
70 self
.ui_test
.wait_until_property_is_updated(xFlatView
, "SelectEntryText", expectedResults
[i
])
71 self
.assertEqual(expectedResults
[i
], get_state_as_dict(xFlatView
)['SelectEntryText'])
73 self
.xUITest
.executeCommand(".uno:Sidebar")
76 # vim: set shiftwidth=4 softtabstop=4 expandtab: