Merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/paperChase into lp:ubuntu-ui-toolkit/staging

Proposed by Christian Dywan on 2015-02-26
Status: Merged
Approved by: Tim Peeters on 2015-03-03
Approved revision: 1424
Merged at revision: 1425
Proposed branch: lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/paperChase
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 137 lines (+79/-14)
2 files modified
modules/Ubuntu/Components/Popups/Popover.qml (+8/-0)
tests/unit_x11/tst_components/tst_popover.qml (+71/-14)
To merge this branch: bzr merge lp:~ubuntu-sdk-team/ubuntu-ui-toolkit/paperChase
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing on 2015-03-03
Tim Peeters 2015-02-26 Approve on 2015-03-03
Review via email: mp+251038@code.launchpad.net

Commit Message

Update popover position upon pointer movement

To post a comment you must log in.
Tim Peeters (tpeeters) wrote :

8 +
9 + Connections {
10 + target: pointerTarget
11 + onXChanged: internal.updatePosition()
12 + onYChanged: internal.updatePosition()
13 + }

The pointer points to the middle of the target in either x or y direction, and it aligns with the edge of it in the other direction. So changes in width or height of the target need to trigger an update as well.

review: Needs Fixing
Tim Peeters (tpeeters) wrote :

23 + useDeprecatedToolbar: false

I propose to update the import versions (and (C)-year) in tst_popover.qml. If you decide to go for Ubuntu.Components version 1.2, useDeprecatedToolbar: false is not needed.

Tim Peeters (tpeeters) wrote :

Can we have a regression test that is clearly marked as such (with the bug number in the function name), which fails without the proposed updates to Popover.qml?

1420. By Christian Dywan on 2015-02-26

Take also width and height changes into account

1421. By Christian Dywan on 2015-02-26

Bump imports for Test and Popups inx11…tst_popover

Tim Peeters (tpeeters) wrote :

I created a little test program, see http://paste.ubuntu.com/10437208/
I would like to see this program (or something similar) added somewhere in tests/resources.

Also, the results with the test program are not as I expected. When you click the button to open the popover, and then drag the dragging area to move the button, I expect the popover to follow the button. This does not happen.

review: Needs Fixing
Tim Peeters (tpeeters) wrote :

tiny update to the test program: http://paste.ubuntu.com/10437251/

Tim Peeters (tpeeters) wrote :

Note that it works perfect if the position of the pointer target updates, so for example:
                PopupUtils.open(popoverComponent, dragRectangle);

with dragRectangle instead of the popButton.

Tim Peeters (tpeeters) wrote :

> I would like to see this program (or something similar) added somewhere in
> tests/resources.

I missed that we already have a resources/popover/ directory. The test program can be added there, as it tests moving of the pointer target, which the other popover tests do not test.

1422. By Christian Dywan on 2015-03-02

Unit test popover arrow direction and parent displacement

1423. By Christian Dywan on 2015-03-03

Uncomment Moving parent tag with a bug link

1424. By Christian Dywan on 2015-03-03

Forgotten comment markers

Christian Dywan (kalikiana) wrote :

I filed bug 1427557 for the parent movement case, as I don't think it's feasible to fix it here since it will need a hierarchy monitoring feature that we don't have right now (it's not possible to track global coordinates).

Tim Peeters (tpeeters) wrote :

Ok, that's acceptable :)

Thanks.

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Popups/Popover.qml'
2--- modules/Ubuntu/Components/Popups/Popover.qml 2014-11-25 15:39:38 +0000
3+++ modules/Ubuntu/Components/Popups/Popover.qml 2015-03-03 08:49:03 +0000
4@@ -289,4 +289,12 @@
5 onHeightChanged: internal.updatePosition()
6 /*! \internal */
7 onRotatingChanged: hide()
8+
9+ Connections {
10+ target: pointerTarget
11+ onXChanged: internal.updatePosition()
12+ onYChanged: internal.updatePosition()
13+ onWidthChanged: internal.updatePosition()
14+ onHeightChanged: internal.updatePosition()
15+ }
16 }
17
18=== modified file 'tests/unit_x11/tst_components/tst_popover.qml'
19--- tests/unit_x11/tst_components/tst_popover.qml 2014-06-09 08:26:24 +0000
20+++ tests/unit_x11/tst_components/tst_popover.qml 2015-03-03 08:49:03 +0000
21@@ -15,24 +15,52 @@
22 */
23 import QtQuick 2.0
24 import QtTest 1.0
25-import Ubuntu.Test 0.1
26-import Ubuntu.Components 0.1
27-import Ubuntu.Components.Popups 0.1
28+import Ubuntu.Test 1.0
29+import Ubuntu.Components 1.2
30+import Ubuntu.Components.Popups 1.0
31
32 MainView {
33 id: main
34- width: units.gu(40)
35+ width: units.gu(50)
36 height: units.gu(71)
37
38- Button {
39- id: caller
40+ Rectangle {
41+ id: rect
42+ y: main.height / 2
43+ height: units.gu(10)
44+ width: height
45+
46+ Button {
47+ id: pressMe
48+ anchors.top: parent.top
49+ text: "Press me"
50+ onClicked: {
51+ testCase.resetPositions();
52+ var popover = PopupUtils.open(popoverComponent, pressMe);
53+ popoverSpy.target = testCase.findChild(popover, "popover_foreground");
54+ popoverSpy.clear();
55+ pressMe.parent.height = units.gu(25)
56+ pressMe.anchors.top = parent.bottom
57+ }
58+ }
59+
60+ Button {
61+ id: pushMe
62+ anchors.bottom: parent.bottom
63+ text: "Push me"
64+ onClicked: {
65+ testCase.resetPositions();
66+ var popover = PopupUtils.open(popoverComponent, pushMe);
67+ popoverSpy.target = testCase.findChild(popover, "popover_foreground");
68+ popoverSpy.clear();
69+ rect.y = main.height / 10
70+ }
71+ }
72+ }
73+ Label {
74+ id: other
75+ text: "Ignore me"
76 anchors.centerIn: parent
77- text: "Press me"
78- onClicked: {
79- var popover = PopupUtils.open(popoverComponent, caller);
80- popoverSpy.target = testCase.findChild(popover, "popover_foreground");
81- popoverSpy.clear();
82- }
83 }
84
85 // spy to listen on the popover foreground's hideCompleted() signal
86@@ -58,7 +86,13 @@
87 name: "PopoverTests"
88 when: windowShown
89
90+ function resetPositions() {
91+ pressMe.parent.height = units.gu(10)
92+ rect.y = main.height / 2
93+ }
94+
95 function cleanup() {
96+ resetPositions()
97 popoverSpy.target = null;
98 popoverSpy.clear();
99 waitForRendering(main, 500);
100@@ -73,12 +107,35 @@
101 }
102
103 function test_dismiss_on_click(data) {
104- mouseClick(caller, caller.width / 2, caller.height / 2);
105- waitForRendering(caller);
106+ mouseClick(pressMe, pressMe.width / 2, pressMe.height / 2);
107+ waitForRendering(pressMe);
108 verify(popoverSpy.target !== null, "The popover did not open");
109+
110 // dismiss
111 mouseClick(main, 10, 10, data.button);
112 popoverSpy.wait();
113 }
114+
115+ function test_popover_follows_pointerTarget_bug1199502_data() {
116+ return [
117+ { tag: "Moving pointerTarget", button: pressMe, dir: "down", y: 318 },
118+ // FIXME: { tag: "Moving parent", button: pushMe, dir: "up", y: 142.8 },
119+ // https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1427557
120+ ]
121+ }
122+ function test_popover_follows_pointerTarget_bug1199502(data) {
123+ mouseClick(data.button, data.button.width / 2, data.button.height / 2);
124+ waitForRendering(data.button);
125+ var dir = popoverSpy.target.direction
126+ var popoverY = popoverSpy.target.y
127+
128+ // dismiss
129+ mouseClick(main, 10, 10, Qt.LeftButton);
130+ popoverSpy.wait();
131+
132+ // ensure popover was next to caller
133+ compare(dir, data.dir, "Popover arrow is wrong")
134+ compare(popoverY, data.y, "Popover isn't pointing at the caller")
135+ }
136 }
137 }

Subscribers

People subscribed via source and target branches