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_pos
13 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 from time
import sleep
16 class tdf156165(UITestCase
):
18 def test_tdf156165(self
):
19 with self
.ui_test
.load_file(get_url_for_data_file("tdf156165.odt")):
20 xMainWindow
= self
.xUITest
.getTopFocusWindow()
21 writer_edit
= xMainWindow
.getChild("writer_edit")
22 style
=xMainWindow
.getChild('applystyle')
24 with self
.ui_test
.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog
:
25 xTabs
= xDialog
.getChild("tabcontrol")
26 select_pos(xTabs
, "2")
27 options
=xDialog
.getChild('list')
28 checkbox
=options
.getChild("16")
29 self
.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox
)["Text"])
31 # Replace Custom Styles is default to be false
32 self
.assertEqual("false", get_state_as_dict(checkbox
)["IsChecked"])
34 # Replace Custom Styles when applying manully with it disabled, should not change style
35 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
36 self
.xUITest
.executeCommand(".uno:AutoFormatApply")
38 self
.assertEqual(get_state_as_dict(style
)["Text"], "eSelah")
40 # Replace Custom Styles when typing with it disabled, should not change style
41 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
42 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"}))
43 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
45 self
.assertEqual(get_state_as_dict(style
)["Text"], "eSelah") # new line
46 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
47 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
48 self
.assertEqual(get_state_as_dict(style
)["Text"], "eSelah") # original line
50 with self
.ui_test
.execute_dialog_through_command(".uno:AutoCorrectDlg") as xDialog
:
51 xTabs
= xDialog
.getChild("tabcontrol")
52 select_pos(xTabs
, "2")
53 options
=xDialog
.getChild('list')
54 checkbox
=options
.getChild("16")
55 self
.assertEqual("Replace Custom Styles", get_state_as_dict(checkbox
)["Text"])
57 # set Replace Custom Styles to True
58 checkbox
.executeAction("CLICK", tuple())
59 self
.assertEqual("true", get_state_as_dict(checkbox
)["IsChecked"])
61 # Replace Custom Styles when applying manully with it enabled, should change style
62 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
63 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
64 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
65 self
.xUITest
.executeCommand(".uno:AutoFormatApply")
67 self
.assertEqual(get_state_as_dict(style
)["Text"], "Body Text")
69 # Replace Custom Styles when typing with it enabled, should not change style
70 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "DOWN"}))
71 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "12", "START_POS": "12"}))
72 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
74 self
.assertEqual(get_state_as_dict(style
)["Text"], "eSelah") # new line
75 writer_edit
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "UP"}))
76 writer_edit
.executeAction("SELECT", mkPropertyValues({"END_POS": "0", "START_POS": "12"}))
77 self
.assertEqual(get_state_as_dict(style
)["Text"], "eSelah") # original line
80 # vim: set shiftwidth=4 softtabstop=4 expandtab: