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
=== modified file 'qml/Components/Carousel.qml'
--- qml/Components/Carousel.qml 2014-03-27 10:27:30 +0000
+++ qml/Components/Carousel.qml 2014-04-11 08:33:00 +0000
@@ -75,6 +75,7 @@
75 The scaling of the items is controlled by the variable continuousIndex, described below. */75 The scaling of the items is controlled by the variable continuousIndex, described below. */
76 ListView {76 ListView {
77 id: listView77 id: listView
78 objectName: "listView"
7879
79 property int highlightIndex: -180 property int highlightIndex: -1
80 property real minimumTileWidth: 081 property real minimumTileWidth: 0
@@ -148,15 +149,19 @@
148 maximumFlickVelocity: Math.max(2500 * Math.pow(realWidth / referenceWidth, 1.5), 2500) // 2500 is platform default149 maximumFlickVelocity: Math.max(2500 * Math.pow(realWidth / referenceWidth, 1.5), 2500) // 2500 is platform default
149 orientation: ListView.Horizontal150 orientation: ListView.Horizontal
150151
152 function getXFromContinuousIndex(index) {
153 return CarouselJS.getXFromContinuousIndex(index,
154 realWidth,
155 footerItem.x,
156 tileWidth,
157 gapToMiddlePhase,
158 gapToEndPhase,
159 carousel.drawBuffer)
160 }
161
151 function itemClicked(index, delegateItem) {162 function itemClicked(index, delegateItem) {
152 listView.currentIndex = index163 listView.currentIndex = index
153 var x = CarouselJS.getXFromContinuousIndex(index,164 var x = getXFromContinuousIndex(index);
154 realWidth,
155 realContentWidth,
156 tileWidth,
157 gapToMiddlePhase,
158 gapToEndPhase,
159 carousel.drawBuffer)
160165
161 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {166 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
162 /* We're clicking the selected item and167 /* We're clicking the selected item and
@@ -174,13 +179,7 @@
174 }179 }
175180
176 function itemPressAndHold(index, delegateItem) {181 function itemPressAndHold(index, delegateItem) {
177 var x = CarouselJS.getXFromContinuousIndex(index,182 var x = getXFromContinuousIndex(index);
178 realWidth,
179 realContentWidth,
180 tileWidth,
181 gapToMiddlePhase,
182 gapToEndPhase,
183 carousel.drawBuffer);
184183
185 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {184 if (Math.abs(x - contentX) < 1 && delegateItem !== undefined) {
186 /* We're pressAndHold the selected item and185 /* We're pressAndHold the selected item and
@@ -209,22 +208,17 @@
209 newContentX = disabledNewContentX208 newContentX = disabledNewContentX
210 }209 }
211 onMovementEnded: {210 onMovementEnded: {
212 if (realContentX > 0 && realContentX < realContentWidth - realWidth)211 if (realContentX > 0)
213 stepAnimation.start()212 stepAnimation.start()
214 }213 }
215214
216 SmoothedAnimation {215 SmoothedAnimation {
217 id: stepAnimation216 id: stepAnimation
217 objectName: "stepAnimation"
218218
219 target: listView219 target: listView
220 property: "contentX"220 property: "contentX"
221 to: CarouselJS.getXFromContinuousIndex(listView.selectedIndex,221 to: listView.getXFromContinuousIndex(listView.selectedIndex)
222 listView.realWidth,
223 listView.realContentWidth,
224 listView.tileWidth,
225 listView.gapToMiddlePhase,
226 listView.gapToEndPhase,
227 carousel.drawBuffer)
228 duration: 450222 duration: 450
229 velocity: 200223 velocity: 200
230 easing.type: Easing.InOutQuad224 easing.type: Easing.InOutQuad
231225
=== modified file 'tests/qmltests/Components/tst_Carousel.qml'
--- tests/qmltests/Components/tst_Carousel.qml 2014-03-27 16:54:32 +0000
+++ tests/qmltests/Components/tst_Carousel.qml 2014-04-11 08:33:00 +0000
@@ -18,6 +18,7 @@
18import QtTest 1.018import QtTest 1.0
19import "../../../qml/Components/"19import "../../../qml/Components/"
20import "../../../qml/Components/carousel.js" as Carousel20import "../../../qml/Components/carousel.js" as Carousel
21import Unity.Test 0.1 as UT
2122
22Item {23Item {
23 width: 70024 width: 700
@@ -32,12 +33,13 @@
32 property int destroyedDelegates: 033 property int destroyedDelegates: 0
3334
34 itemComponent: Rectangle {35 itemComponent: Rectangle {
36 border.color: "black"
35 color: "red"37 color: "red"
36 Component.onCompleted: carousel.createdDelegates++38 Component.onCompleted: carousel.createdDelegates++
37 Component.onDestruction: carousel.destroyedDelegates++39 Component.onDestruction: carousel.destroyedDelegates++
38 }40 }
39 }41 }
40 TestCase {42 UT.UnityTestCase {
41 id: root43 id: root
42 name: "Carousel"44 name: "Carousel"
43 when: windowShown45 when: windowShown
@@ -55,8 +57,11 @@
55 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)57 property real kGapEnd: kMiddleIndex * (1 - gapToEndPhase / gapToMiddlePhase)
56 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase58 property real kXBeginningEnd: 1 / tileWidth + kMiddleIndex / gapToMiddlePhase
5759
58 function test_onlyNeededItemsCreated() {60 // This test needs to run first since it tests a corner case condition
59 compare(carousel.createdDelegates, 10);61 // to where the carousel is just being created
62 // That is why it has a 1 in the name
63 function test_1onlyNeededItemsCreated() {
64 tryCompare(carousel, "createdDelegates", 10);
60 compare(carousel.destroyedDelegates, 0);65 compare(carousel.destroyedDelegates, 0);
61 }66 }
6267
@@ -216,5 +221,24 @@
216 data.maxTranslation)221 data.maxTranslation)
217 compare(scale, data.result)222 compare(scale, data.result)
218 }223 }
224
225 function test_lastItemXPosition() {
226 var carouselList = findChild(carousel, "listView");
227 var stepAnimation = findInvisibleChild(carouselList, "stepAnimation");
228 var stepDiff = 0;
229 stepAnimation.onRunningChanged.connect(function() { if (stepAnimation.running) stepDiff = Math.abs(carouselList.contentX - stepAnimation.to); })
230 var overshootOnce = false;
231 while (!overshootOnce) {
232 overshootOnce = carouselList.realContentX > carouselList.realContentWidth - carouselList.realWidth;
233 mouseFlick(carousel, carousel.width - units.gu(1),
234 carousel.height / 2,
235 units.gu(2),
236 carousel.height / 2);
237 tryCompare(carouselList, "moving", false);
238 }
239 verify(stepDiff < 1);
240 var x = carouselList.getXFromContinuousIndex(carousel.model - 1);
241 verify(Math.abs(x - carouselList.contentX) < 1);
242 }
219 }243 }
220}244}

Subscribers

People subscribed via source and target branches