160
175
popupCloseSpy.target = null;
163
// make this as the very first test executed
164
function test_0_transfer_focus_data() {
166
{tag: "TextArea", previousFocused: textField, focusOn: textArea, clickToDismiss: false},
167
{tag: "Button", previousFocused: textArea, focusOn: button, clickToDismiss: false},
168
{tag: "Checkbox", previousFocused: button, focusOn: checkbox, clickToDismiss: false},
169
{tag: "Switch", previousFocused: checkbox, focusOn: switchBox, clickToDismiss: false},
170
{tag: "Picker - linear", previousFocused: switchBox, focusOn: picker, clickToDismiss: false},
171
{tag: "Picker - circular", previousFocused: picker, focusOn: roundPicker, clickToDismiss: false},
172
{tag: "PickerPanel", previousFocused: roundPicker, focusOn: pickerPanel, clickToDismiss: true},
173
{tag: "UbuntuListView", previousFocused: pickerPanel, focusOn: listView, clickToDismiss: false},
174
{tag: "Slider", previousFocused: listView, focusOn: slider, clickToDismiss: false},
175
{tag: "ComboButton", previousFocused: slider, focusOn: comboButton, clickToDismiss: false},
178
function test_0_transfer_focus(data) {
179
// perform mouse press on
180
mouseClick(data.focusOn, centerOf(data.focusOn).x, centerOf(data.focusOn).y);
181
compare(data.previousFocused.focus, false, "Previous focus is still set!");
182
compare(data.focusOn.focus, true, data.tag + " is not focused!");
183
if (data.clickToDismiss) {
184
mouseClick(main, 0, 0);
186
waitForRendering(data.focusOn, 200);
189
178
function test_tab_focus_data() {
180
// (Shift)Tab via keyboard
191
181
{tag: "TextField", from: dummy, to: textField, key: Qt.Key_Tab},
192
182
{tag: "TextField(back)", from: textField, to: dummy, key: Qt.Key_Backtab},
193
183
{tag: "TextArea", from: textField, to: textArea, key: Qt.Key_Tab},
194
184
{tag: "TextArea(back)", from: textArea, to: textField, key: Qt.Key_Backtab},
195
185
{tag: "Button(back)", from: button, to: textArea, key: Qt.Key_Backtab},
186
{tag: "CheckBox", from: checkbox, to: switchbox, key: Qt.Key_Tab},
187
{tag: "CheckBox", from: switchbox, to: checkbox, key: Qt.Key_Backtab},
188
{tag: "Switch", from: switchbox, to: dummy2, key: Qt.Key_Tab},
189
{tag: "Switch(back)", from: dummy2, to: switchbox, key: Qt.Key_Backtab},
190
/* FIXME: Figure out how to test ActionBar delegate focus
191
{tag: "ActionBar", from: 'actionBarShare_button', to: picker, key: Qt.Key_Tab},
192
{tag: "ActionBar(back)", from: picker, to: 'actionBarShare_button', key: Qt.Key_Backtab},
195
{tag: "TextField(click)", from: dummy, to: textField, key: Qt.LeftButton},
196
{tag: "TextArea(click)", from: dummy, to: textArea, key: Qt.LeftButton},
197
// FIXME: lp#1368390: Buttons shouldn't grab input focus on click
198
{tag: "Button(click)", from: dummy, to: button, key: Qt.LeftButton},
199
{tag: "CheckBox(click)", from: dummy, to: checkbox, key: Qt.LeftButton},
200
{tag: "Switch(click)", from: dummy, to: switchbox, key: Qt.LeftButton}
198
203
function test_tab_focus(data) {
199
204
data.from.forceActiveFocus();
200
205
verify(data.from.activeFocus, "Source component is not focused");
206
if (data.key == Qt.LeftButton) {
207
verify(data.to.activeFocusOnPress, "Target doesn't take focus on click");
208
mouseClick(data.to, centerOf(data.to).x, centerOf(data.to).y);
210
verify(data.to.activeFocusOnTab, "Target doesn't take keyboard focus");
202
213
waitForRendering(data.to, 500);
203
214
verify(!data.from.activeFocus, "Source component still keeps focus");
204
215
verify(data.to.activeFocus, "Target component is not focused");