Merge lp:~aacid/unity8/carouselLastItemClick into lp:unity8

Proposed by Albert Astals Cid
Status: Merged
Approved by: Andrea Cimitan
Approved revision: 813
Merged at revision: 842
Proposed branch: lp:~aacid/unity8/carouselLastItemClick
Merge into: lp:unity8
Diff against target: 145 lines (+43/-25)
2 files modified
qml/Components/Carousel.qml (+16/-22)
tests/qmltests/Components/tst_Carousel.qml (+27/-3)
To merge this branch: bzr merge lp:~aacid/unity8/carouselLastItemClick
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Andrea Cimitan (community) Approve
Michał Sawicz Needs Information
Review via email: mp+214230@code.launchpad.net

Commit message

Fix last item X position

Fixes clicking on the last item sometimes not working

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
No

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

* If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:812
http://jenkins.qa.ubuntu.com/job/unity8-ci/2737/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/37
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4520
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1607
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1258
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1262
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1262/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1258
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/45
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4134
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4134/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5628
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3905
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4631
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4631/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2737/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:812
http://jenkins.qa.ubuntu.com/job/unity8-ci/2742/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/69
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4575
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1612
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1263
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1267
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1267/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1263
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/71
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4176
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4176/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5702
    SUCCESS: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3941
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4693
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4693/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2742/rebuild

review: Approve (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Should we maybe move the test to a separate suite so that the precondition of it "running first" is certain? I don't think alphabetical order is defined during test runs?

Or maybe we need to make it into a component and reload it in that test?

review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

I think it's pretty much to be defined to alphabetical yes.

I can move it to a different file, but we don't have that for anything and then it's not testCarousel anymore but testCarousel and testCarousel2?

I'd prefer not to move it into a component, to be honest the test conditions are pretty much strict, so we either keep the alphabetical change or make it a different file if you can suggest names for the two test files.

Revision history for this message
Andrea Cimitan (cimi) wrote :

+ wait(1000);

instead of this you can just wait for the flick to end or the velocity to decrease under a certain threshold.

review: Needs Fixing
813. By Albert Astals Cid

wait is evil

Revision history for this message
Andrea Cimitan (cimi) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:813
http://jenkins.qa.ubuntu.com/job/unity8-ci/2801/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-trusty-touch/206
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/4789
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1665
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/1322
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1326
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/1326/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/1322
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-mako/194
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4370
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/4370/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/5955
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/4135
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4921
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/4921/artifact/work/output/*zip*/output.zip

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2801/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Components/Carousel.qml'
2--- qml/Components/Carousel.qml 2014-03-27 10:27:30 +0000
3+++ qml/Components/Carousel.qml 2014-04-11 08:33:00 +0000
4@@ -75,6 +75,7 @@
5 The scaling of the items is controlled by the variable continuousIndex, described below. */
6 ListView {
7 id: listView
8+ objectName: "listView"
9
10 property int highlightIndex: -1
11 property real minimumTileWidth: 0
12@@ -148,15 +149,19 @@
13 maximumFlickVelocity: Math.max(2500 * Math.pow(realWidth / referenceWidth, 1.5), 2500) // 2500 is platform default
14 orientation: ListView.Horizontal
15
16+ function getXFromContinuousIndex(index) {
17+ return CarouselJS.getXFromContinuousIndex(index,
18+ realWidth,
19+ footerItem.x,
20+ tileWidth,
21+ gapToMiddlePhase,
22+ gapToEndPhase,
23+ carousel.drawBuffer)
24+ }
25+
26 function itemClicked(index, delegateItem) {
27 listView.currentIndex = index
28- var x = CarouselJS.getXFromContinuousIndex(index,
29- realWidth,
30- realContentWidth,
31- tileWidth,
32- gapToMiddlePhase,
33- gapToEndPhase,
34- carousel.drawBuffer)
35+ var x = getXFromContinuousIndex(index);
36
37 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
38 /* We're clicking the selected item and
39@@ -174,13 +179,7 @@
40 }
41
42 function itemPressAndHold(index, delegateItem) {
43- var x = CarouselJS.getXFromContinuousIndex(index,
44- realWidth,
45- realContentWidth,
46- tileWidth,
47- gapToMiddlePhase,
48- gapToEndPhase,
49- carousel.drawBuffer);
50+ var x = getXFromContinuousIndex(index);
51
52 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
53 /* We're pressAndHold the selected item and
54@@ -209,22 +208,17 @@
55 newContentX = disabledNewContentX
56 }
57 onMovementEnded: {
58- if (realContentX > 0 && realContentX < realContentWidth - realWidth)
59+ if (realContentX > 0)
60 stepAnimation.start()
61 }
62
63 SmoothedAnimation {
64 id: stepAnimation
65+ objectName: "stepAnimation"
66
67 target: listView
68 property: "contentX"
69- to: CarouselJS.getXFromContinuousIndex(listView.selectedIndex,
70- listView.realWidth,
71- listView.realContentWidth,
72- listView.tileWidth,
73- listView.gapToMiddlePhase,
74- listView.gapToEndPhase,
75- carousel.drawBuffer)
76+ to: listView.getXFromContinuousIndex(listView.selectedIndex)
77 duration: 450
78 velocity: 200
79 easing.type: Easing.InOutQuad
80
81=== modified file 'tests/qmltests/Components/tst_Carousel.qml'
82--- tests/qmltests/Components/tst_Carousel.qml 2014-03-27 16:54:32 +0000
83+++ tests/qmltests/Components/tst_Carousel.qml 2014-04-11 08:33:00 +0000
84@@ -18,6 +18,7 @@
85 import QtTest 1.0
86 import "../../../qml/Components/"
87 import "../../../qml/Components/carousel.js" as Carousel
88+import Unity.Test 0.1 as UT
89
90 Item {
91 width: 700
92@@ -32,12 +33,13 @@
93 property int destroyedDelegates: 0
94
95 itemComponent: Rectangle {
96+ border.color: "black"
97 color: "red"
98 Component.onCompleted: carousel.createdDelegates++
99 Component.onDestruction: carousel.destroyedDelegates++
100 }
101 }
102- TestCase {
103+ UT.UnityTestCase {
104 id: root
105 name: "Carousel"
106 when: windowShown
107@@ -55,8 +57,11 @@
108 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)
109 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase
110
111- function test_onlyNeededItemsCreated() {
112- compare(carousel.createdDelegates, 10);
113+ // This test needs to run first since it tests a corner case condition
114+ // to where the carousel is just being created
115+ // That is why it has a 1 in the name
116+ function test_1onlyNeededItemsCreated() {
117+ tryCompare(carousel, "createdDelegates", 10);
118 compare(carousel.destroyedDelegates, 0);
119 }
120
121@@ -216,5 +221,24 @@
122 data.maxTranslation)
123 compare(scale, data.result)
124 }
125+
126+ function test_lastItemXPosition() {
127+ var carouselList = findChild(carousel, "listView");
128+ var stepAnimation = findInvisibleChild(carouselList, "stepAnimation");
129+ var stepDiff = 0;
130+ stepAnimation.onRunningChanged.connect(function() { if (stepAnimation.running) stepDiff = Math.abs(carouselList.contentX - stepAnimation.to); })
131+ var overshootOnce = false;
132+ while (!overshootOnce) {
133+ overshootOnce = carouselList.realContentX > carouselList.realContentWidth - carouselList.realWidth;
134+ mouseFlick(carousel, carousel.width - units.gu(1),
135+ carousel.height / 2,
136+ units.gu(2),
137+ carousel.height / 2);
138+ tryCompare(carouselList, "moving", false);
139+ }
140+ verify(stepDiff < 1);
141+ var x = carouselList.getXFromContinuousIndex(carousel.model - 1);
142+ verify(Math.abs(x - carouselList.contentX) < 1);
143+ }
144 }
145 }

Subscribers

People subscribed via source and target branches