1# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6#
7from uitest.framework import UITestCase
8from uitest.uihelper.common import get_state_as_dict
9from uitest.uihelper.common import change_measurement_unit
10from libreoffice.uno.propertyvalue import mkPropertyValues
11#uitest sw / Columns dialog
12
13class columns(UITestCase):
14    def test_columns(self):
15        writer_doc = self.ui_test.create_doc_in_start_center("writer")
16        document = self.ui_test.get_component()
17        xWriterDoc = self.xUITest.getTopFocusWindow()
18
19        change_measurement_unit(self, "Centimeter")
20
21        #dialog Columns
22        self.ui_test.execute_dialog_through_command(".uno:FormatColumns")
23        xDialog = self.xUITest.getTopFocusWindow()
24
25        colsnf = xDialog.getChild("colsnf")
26        colsnf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
27        colsnf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
28        colsnf.executeAction("TYPE", mkPropertyValues({"TEXT":"2"}))
29        colsnf.executeAction("UP", tuple())
30        colsnf.executeAction("DOWN", tuple())
31        spacing1mf = xDialog.getChild("spacing1mf")
32        spacing1mf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"CTRL+A"}))
33        spacing1mf.executeAction("TYPE", mkPropertyValues({"KEYCODE":"BACKSPACE"}))
34        spacing1mf.executeAction("TYPE", mkPropertyValues({"TEXT":"1"}))
35        autowidth = xDialog.getChild("autowidth")
36        autowidth.executeAction("CLICK", tuple())
37        xOKBtn = xDialog.getChild("ok")
38        self.ui_test.close_dialog_through_button(xOKBtn)
39        #verify
40        self.ui_test.execute_dialog_through_command(".uno:FormatColumns")
41        xDialog = self.xUITest.getTopFocusWindow()
42        colsnf = xDialog.getChild("colsnf")
43        spacing1mf = xDialog.getChild("spacing1mf")
44        autowidth = xDialog.getChild("autowidth")
45
46        self.assertEqual(get_state_as_dict(colsnf)["Text"], "2")
47        self.assertEqual(get_state_as_dict(spacing1mf)["Text"], "1.00 cm")
48        self.assertEqual(get_state_as_dict(autowidth)["Selected"], "false")
49        xOKBtn = xDialog.getChild("cancel")
50        self.ui_test.close_dialog_through_button(xOKBtn)
51
52        self.ui_test.close_doc()
53
54# vim: set shiftwidth=4 softtabstop=4 expandtab:
55