1 # -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
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/.
8 from uitest
.uihelper
.common
import get_state_as_dict
10 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
12 from uitest
.framework
import UITestCase
13 from uitest
.uihelper
.common
import type_text
, select_pos
14 from uitest
.debug
import sleep
18 class SimpleMathTest(UITestCase
):
20 def test_start_math(self
):
22 self
.ui_test
.create_doc_in_start_center("math")
24 xMathDoc
= self
.xUITest
.getTopFocusWindow()
26 self
.ui_test
.close_doc()
28 def test_docking_window_listbox(self
):
30 self
.ui_test
.create_doc_in_start_center("math")
32 xMathDoc
= self
.xUITest
.getTopFocusWindow()
34 xList
= xMathDoc
.getChild("listbox")
35 state
= get_state_as_dict(xList
)
36 self
.assertEqual(state
["SelectEntryText"], "Unary/Binary Operators")
37 select_pos(xList
, "1")
38 state
= get_state_as_dict(xList
)
39 self
.assertEqual(state
["SelectEntryText"], "Relations")
41 self
.ui_test
.close_doc()
43 def test_math_edit(self
):
44 self
.ui_test
.create_doc_in_start_center("math")
46 xMathDoc
= self
.xUITest
.getTopFocusWindow()
48 xMathEdit
= xMathDoc
.getChild("math_edit")
50 type_text(xMathEdit
, "E=mc^2")
52 self
.ui_test
.close_doc()
54 def test_math_selector(self
):
55 self
.ui_test
.create_doc_in_start_center("math")
57 xMathDoc
= self
.xUITest
.getTopFocusWindow()
59 xMathSelector
= xMathDoc
.getChild("element_selector")
61 xElement
= xMathSelector
.getChild("1")
62 xElement
.executeAction("SELECT", tuple())
64 self
.ui_test
.close_doc()
66 @unittest.skip("on windows the f4 does not always work")
67 def test_complete_math(self
):
68 self
.ui_test
.create_doc_in_start_center("math")
70 xMathDoc
= self
.xUITest
.getTopFocusWindow()
72 xList
= xMathDoc
.getChild("listbox")
73 state
= get_state_as_dict(xList
)
74 self
.assertEqual(state
["SelectEntryText"], "Unary/Binary Operators")
75 select_pos(xList
, "1")
77 xMathSelector
= xMathDoc
.getChild("element_selector")
79 xElement
= xMathSelector
.getChild("1")
80 xElement
.executeAction("SELECT", tuple())
82 xMathEdit
= xMathDoc
.getChild("math_edit")
83 type_text(xMathEdit
, "1")
84 xMathEdit
.executeAction("TYPE", mkPropertyValues({"KEYCODE":"F4"}))
85 type_text(xMathEdit
, "2")
87 edit_state
= get_state_as_dict(xMathEdit
)
88 self
.assertEqual("1 <> 2 ", edit_state
["Text"])
90 self
.ui_test
.close_doc()
92 # vim: set shiftwidth=4 softtabstop=4 expandtab: