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/.
7 from uitest
.framework
import UITestCase
8 from uitest
.uihelper
.common
import get_state_as_dict
9 from uitest
.uihelper
.common
import select_pos
10 from uitest
.uihelper
.calc
import enter_text_to_cell
11 from libreoffice
.calc
.document
import get_cell_by_position
12 from libreoffice
.uno
.propertyvalue
import mkPropertyValues
14 #Bug 117458 - Selection doesn't move left nor right by pressing ENTER
16 class tdf117458(UITestCase
):
17 def test_tdf117458_selection_move_by_enter(self
):
18 calc_doc
= self
.ui_test
.create_doc_in_start_center("calc")
19 xCalcDoc
= self
.xUITest
.getTopFocusWindow()
20 gridwin
= xCalcDoc
.getChild("grid_window")
21 document
= self
.ui_test
.get_component()
22 #Go to Tools -> Options -> LibreOffice Calc -> General
23 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
24 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
26 xPages
= xDialogOpt
.getChild("pages")
27 xCalcEntry
= xPages
.getChild('3') # Calc
28 xCalcEntry
.executeAction("EXPAND", tuple())
29 xCalcGeneralEntry
= xCalcEntry
.getChild('0')
30 xCalcGeneralEntry
.executeAction("SELECT", tuple()) #General
31 xaligncb
= xDialogOpt
.getChild("aligncb")
32 xalignlb
= xDialogOpt
.getChild("alignlb")
33 if (get_state_as_dict(xaligncb
)["Selected"]) == "false":
34 xaligncb
.executeAction("CLICK", tuple())
36 props
= {"TEXT": "Down"}
37 actionProps
= mkPropertyValues(props
)
38 xalignlb
.executeAction("SELECT", actionProps
)
40 xOKBtn
= xDialogOpt
.getChild("ok")
41 self
.ui_test
.close_dialog_through_button(xOKBtn
)
43 #and down up to "deselect" range
44 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
45 self
.xUITest
.executeCommand(".uno:GoDown")
46 self
.xUITest
.executeCommand(".uno:GoUp")
48 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
50 self
.assertEqual(get_state_as_dict(gridwin
)["CurrentRow"], "1")
52 #Go to Tools -> Options -> LibreOffice Calc -> General
53 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
54 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
56 xPages
= xDialogOpt
.getChild("pages")
57 xCalcEntry
= xPages
.getChild('3') # Calc
58 xCalcEntry
.executeAction("EXPAND", tuple())
59 xCalcGeneralEntry
= xCalcEntry
.getChild('0')
60 xCalcGeneralEntry
.executeAction("SELECT", tuple()) #General
61 xaligncb
= xDialogOpt
.getChild("aligncb")
62 xalignlb
= xDialogOpt
.getChild("alignlb")
63 if (get_state_as_dict(xaligncb
)["Selected"]) == "false":
64 xaligncb
.executeAction("CLICK", tuple())
66 props
= {"TEXT": "Up"}
67 actionProps
= mkPropertyValues(props
)
68 xalignlb
.executeAction("SELECT", actionProps
)
70 xOKBtn
= xDialogOpt
.getChild("ok")
71 self
.ui_test
.close_dialog_through_button(xOKBtn
)
73 #and down up to "deselect" range
74 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "A2"}))
75 self
.xUITest
.executeCommand(".uno:GoDown")
76 self
.xUITest
.executeCommand(".uno:GoUp")
78 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
80 self
.assertEqual(get_state_as_dict(gridwin
)["CurrentRow"], "0")
82 #Go to Tools -> Options -> LibreOffice Calc -> General
83 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
84 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
86 xPages
= xDialogOpt
.getChild("pages")
87 xCalcEntry
= xPages
.getChild('3') # Calc
88 xCalcEntry
.executeAction("EXPAND", tuple())
89 xCalcGeneralEntry
= xCalcEntry
.getChild('0')
90 xCalcGeneralEntry
.executeAction("SELECT", tuple()) #General
91 xaligncb
= xDialogOpt
.getChild("aligncb")
92 xalignlb
= xDialogOpt
.getChild("alignlb")
93 if (get_state_as_dict(xaligncb
)["Selected"]) == "false":
94 xaligncb
.executeAction("CLICK", tuple())
96 props
= {"TEXT": "Right"}
97 actionProps
= mkPropertyValues(props
)
98 xalignlb
.executeAction("SELECT", actionProps
)
100 xOKBtn
= xDialogOpt
.getChild("ok")
101 self
.ui_test
.close_dialog_through_button(xOKBtn
)
103 #and down up to "deselect" range
104 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "A1"}))
105 self
.xUITest
.executeCommand(".uno:GoDown")
106 self
.xUITest
.executeCommand(".uno:GoUp")
108 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
110 self
.assertEqual(get_state_as_dict(gridwin
)["CurrentColumn"], "1")
112 #Go to Tools -> Options -> LibreOffice Calc -> General
113 self
.ui_test
.execute_dialog_through_command(".uno:OptionsTreeDialog") #optionsdialog
114 xDialogOpt
= self
.xUITest
.getTopFocusWindow()
116 xPages
= xDialogOpt
.getChild("pages")
117 xCalcEntry
= xPages
.getChild('3') # Calc
118 xCalcEntry
.executeAction("EXPAND", tuple())
119 xCalcGeneralEntry
= xCalcEntry
.getChild('0')
120 xCalcGeneralEntry
.executeAction("SELECT", tuple()) #General
121 xaligncb
= xDialogOpt
.getChild("aligncb")
122 xalignlb
= xDialogOpt
.getChild("alignlb")
123 if (get_state_as_dict(xaligncb
)["Selected"]) == "false":
124 xaligncb
.executeAction("CLICK", tuple())
126 props
= {"TEXT": "Left"}
127 actionProps
= mkPropertyValues(props
)
128 xalignlb
.executeAction("SELECT", actionProps
)
130 xOKBtn
= xDialogOpt
.getChild("ok")
131 self
.ui_test
.close_dialog_through_button(xOKBtn
)
133 #and down up to "deselect" range
134 gridwin
.executeAction("SELECT", mkPropertyValues({"CELL": "B1"}))
135 self
.xUITest
.executeCommand(".uno:GoDown")
136 self
.xUITest
.executeCommand(".uno:GoUp")
138 gridwin
.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"}))
140 self
.assertEqual(get_state_as_dict(gridwin
)["CurrentColumn"], "0")
142 self
.ui_test
.close_doc()
144 # vim: set shiftwidth=4 softtabstop=4 expandtab: