Merge lp:~tpeeters/ubuntu-ui-toolkit/popup-focus-test into lp:ubuntu-ui-toolkit/staging

Proposed by Tim Peeters
Status: Merged
Approved by: Cris Dywan
Approved revision: 1942
Merged at revision: 1941
Proposed branch: lp:~tpeeters/ubuntu-ui-toolkit/popup-focus-test
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 128 lines (+69/-8)
1 file modified
tests/unit_x11/tst_components/tst_focus.qml (+69/-8)
To merge this branch: bzr merge lp:~tpeeters/ubuntu-ui-toolkit/popup-focus-test
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Approve
Cris Dywan Approve
Review via email: mp+291780@code.launchpad.net

Commit message

Fix the tests for focus restoration in tst_focus.qml

Description of the change

This MR adds the proper tests, but they fail because focus restoration is broken in some cases now. See https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1569979 and https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1569981

To post a comment you must log in.
1942. By Tim Peeters

remove second popoverTest button focus test.

Revision history for this message
Cris Dywan (kalikiana) wrote :

Hmmm I might have renamed the clashing variables for more clarity. Though no super strong opinion. This looks pretty good (given the circumstances). Good job catching the silent breakage due to the id clash.

review: Approve
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/unit_x11/tst_components/tst_focus.qml'
2--- tests/unit_x11/tst_components/tst_focus.qml 2016-03-14 16:45:38 +0000
3+++ tests/unit_x11/tst_components/tst_focus.qml 2016-04-13 16:12:54 +0000
4@@ -131,10 +131,14 @@
5 Button {
6 id: popoverTest
7 text: "Popovers"
8- property var popover
9- property Component popoverComponent
10+ property var popover: null
11+ property Component popoverComponent: popoverComponent
12 onClicked: {
13- popover = PopupUtils.open(popoverComponent)
14+ if (popoverTest.popoverComponent) {
15+ popoverTest.popover = PopupUtils.open(popoverTest.popoverComponent);
16+ } else {
17+ popoverTest.popover.show();
18+ }
19 }
20 }
21 }
22@@ -165,6 +169,26 @@
23 }
24 }
25
26+ Dialog {
27+ id: dialogItem
28+ title: "TestDialog"
29+ Button {
30+ text: "close"
31+ onClicked: dialogItem.hide()
32+ }
33+ }
34+
35+ Popover {
36+ id: popoverItem
37+ contentWidth: units.gu(20)
38+ contentHeight: item.height
39+ ListItem.Standard {
40+ id: item
41+ text: "close"
42+ onClicked: popoverItem.hide();
43+ }
44+ }
45+
46 UbuntuTestCase {
47 name: "FocusingTests"
48 when: windowShown
49@@ -192,8 +216,11 @@
50 function cleanup() {
51 // empty event buffer
52 wait(200);
53+ popoverTest.popover = null;
54+ popoverTest.popoverComponent = popoverComponent;
55 popupCloseSpy.clear();
56 popupCloseSpy.target = null;
57+ popupCloseSpy.signalName = "onDestruction";
58 }
59
60 function test_tab_focus_data() {
61@@ -310,29 +337,63 @@
62
63 function test_popover_refocus_data() {
64 return [
65- {tag: "Dialog", component: dialogComponent},
66- {tag: "Popover", component: popoverComponent},
67+ { tag: "Dialog component",
68+ component: dialogComponent,
69+ item: null,
70+ foreground_name: "dialogForeground",
71+ bug: "1569979"
72+ },
73+ { tag: "Popover component",
74+ component: popoverComponent,
75+ item: null,
76+ foreground_name: "popover_foreground",
77+ bug: "" // this is the only case without a bug
78+ },
79+ { tag: "Dialog item",
80+ component: null,
81+ item: dialogItem,
82+ foreground_name: "dialogForeground",
83+ bug: "1569979 and 1569981"
84+ },
85+ { tag: "Popover item",
86+ component: null,
87+ item: popoverItem,
88+ foreground_name: "popover_foreground",
89+ bug: "1569981"
90+ },
91 ];
92 }
93
94 function test_popover_refocus(data) {
95 popoverTest.popoverComponent = data.component;
96+ popoverTest.popover = data.item;
97 var center = centerOf(popoverTest);
98 mouseClick(popoverTest, center.x, center.y);
99 verify(popoverTest.popover !== undefined, "No popover created");
100 waitForRendering(popoverTest.popover);
101 verify(!popoverTest.focus, "Button focus not lost.");
102- var foreground = findChild(popoverTest.popover, "popover_foreground");
103+ var foreground = findChild(popoverTest.popover, data.foreground_name);
104 verify(foreground, "Popover foreground not ready");
105 verify(foreground.focus, "Popover focus not gained. Focus went to %1".arg(window.activeFocusItem));
106- popupCloseSpy.target = popoverTest.popover.Component;
107+
108+ if (data.item) {
109+ // popup will only be hidden, not destroyed.
110+ popupCloseSpy.signalName = "onVisibleChanged";
111+ popupCloseSpy.target = popoverTest.popover;
112+ } else {
113+ popupCloseSpy.signalName = "onDestruction";
114+ popupCloseSpy.target = popoverTest.popover.Component;
115+ }
116
117 var closeButton = findChildWithProperty(popoverTest.popover, "text", "close");
118 verify(closeButton, "Close button not accessible");
119 center = centerOf(closeButton);
120 mouseClick(closeButton, center.x, center.y);
121- verify(!popoverTest.focus, "Button focus not lost.");
122 popupCloseSpy.wait();
123+ if (data.bug) {
124+ expectFailContinue(data.tag,
125+ "Incorrect focus restoration. See bug " + data.bug + ".");
126+ }
127 verify(popoverTest.focus, "Button focus not restored.");
128 }
129

Subscribers

People subscribed via source and target branches