Merge lp:~aacid/unity-2d/unity-2d_backport_shell_clamp into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michał Sawicz
Approved revision: 881
Merged at revision: 888
Proposed branch: lp:~aacid/unity-2d/unity-2d_backport_shell_clamp
Merge into: lp:unity-2d
Diff against target: 90 lines (+29/-9)
3 files modified
places/RatingStars.qml (+5/-8)
places/utils.js (+4/-0)
tests/manual-tests/places.txt (+20/-1)
To merge this branch: bzr merge lp:~aacid/unity-2d/unity-2d_backport_shell_clamp
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
Review via email: mp+91213@code.launchpad.net

Description of the change

Move clamp to utils.js

Backport from unity-2d-shell

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :

Change happened here http://bazaar.launchpad.net/~unity-2d-team/unity-2d/unity-2d-shell/revision/812 From what i can see it seems it was not MR'ed and simply commited?

Revision history for this message
Michał Sawicz (saviq) wrote :

Please add a manual test for that.

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

Manual test added

881. By Albert Astals Cid

Manual test for rating clamping

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

MR Approval awaiting lift of code freeze.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'places/RatingStars.qml'
2--- places/RatingStars.qml 2011-11-14 10:45:33 +0000
3+++ places/RatingStars.qml 2012-02-03 13:54:24 +0000
4@@ -17,6 +17,7 @@
5 */
6
7 import QtQuick 1.0
8+import "utils.js" as Utils
9
10 Item {
11 id: ratingStars
12@@ -36,16 +37,12 @@
13 width: stars.width
14 height: stars.height
15
16- function clamp(x, min, max) {
17- return Math.max(Math.min(x, max), min)
18- }
19-
20 function incrementRating() {
21- rating = clamp(Math.floor(rating) + 1, 1, size)
22+ rating = Utils.clamp(Math.floor(rating) + 1, 1, size)
23 }
24
25 function decrementRating() {
26- rating = clamp(Math.ceil(rating) - 1, 1, size)
27+ rating = Utils.clamp(Math.ceil(rating) - 1, 1, size)
28 }
29
30 Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true
31@@ -68,7 +65,7 @@
32 model: size
33 Star {
34 fill: if(!enabled){ /* If read-only, display any Star rating */
35- return clamp(rating - index, 0, size)
36+ return Utils.clamp(rating - index, 0, size)
37 }
38 else{ /* If user selectable, restrict to integer selections */
39 return (rating - index > 0) ? 1 : 0
40@@ -99,7 +96,7 @@
41 /* What unit is the mouse over? This is the integer part of the rating (plus one)*/
42 var rating = (posX - posXOverUnit) / unitWidth + 1
43
44- return clamp( rating, 0, size )
45+ return Utils.clamp( rating, 0, size )
46 }
47
48 anchors.fill: stars
49
50=== modified file 'places/utils.js'
51--- places/utils.js 2011-08-24 12:44:05 +0000
52+++ places/utils.js 2012-02-03 13:54:24 +0000
53@@ -27,3 +27,7 @@
54 }
55 return camelName
56 }
57+
58+function clamp(x, min, max) {
59+ return Math.max(Math.min(x, max), min)
60+}
61
62=== modified file 'tests/manual-tests/places.txt'
63--- tests/manual-tests/places.txt 2012-01-25 17:03:58 +0000
64+++ tests/manual-tests/places.txt 2012-02-03 13:54:24 +0000
65@@ -36,4 +36,23 @@
66 # but it does not work realiably because of the reasons explained
67 # in the places-tests.rb file
68
69-----
70\ No newline at end of file
71+----
72+
73+ # Test case objectives:
74+ # * Check that filters rating is clamped
75+ # Pre-conditions
76+ # * Desktop with no running applications
77+ # Test steps
78+ # * Verify dash is not showing
79+ # * Press Super
80+ # * Go to the search applications lens
81+ # * Make sure filtering is enabled
82+ # * Go to the Rating stars with the keyboard navigation
83+ # * Use Left and Right keyboard arrows to verify 1 and 5 are the maximum stars
84+ # that you can get highlighted
85+ # Post-conditions
86+ # * None
87+ # References
88+ # * None
89+
90+----

Subscribers

People subscribed via source and target branches