on xenial help sign in
more tweaks and test fixes
commit5dea3c2294073cbbe29a0fca0858da52f96139e1 authorNick Dedekind <nick.dedekind@canonical.com> dateThu 9 Oct 2014, 12:20 (12 years ago) parent40122be
4 files changed+21−15
qml/Panel/IndicatorItemRow.qml+7−7 qml/Panel/IndicatorsBar.qml+2−2 qml/Panel/IndicatorsMenu.qml+1 tests/qmltests/Panel/tst_IndicatorsMenu.qml+11−6
qml/Panel/IndicatorItemRow.qml+7−7
@@ -25,7 +25,7 @@ Item {
2525 property QtObject indicatorsModel: null
2626 property real overFlowWidth: width
2727 property bool expanded: false
28− property var currentItem: null
28+ property var currentItem
2929 readonly property int currentItemIndex: currentItem ? currentItem.ownIndex : -1
3030
3131 property real unitProgress: 0.0
@@ -82,16 +82,16 @@ Item {
8282 }
8383
8484 function resetCurrentItem() {
85− currentItem = null;
86− d.previousItem = null;
8785 d.firstItemSwitch = true;
86+ d.previousItem = undefined;
87+ currentItem = undefined;
8888 }
8989
9090 function setCurrentItemIndex(index) {
9191 for (var i = 0; i < row.children.length; i++) {
9292 var item = row.children[i];
9393 if (item.hasOwnProperty("ownIndex") && item.ownIndex === index) {
94− currentItem = item;
94+ if (currentItem !== item) currentItem = item;
9595 break;
9696 }
9797 }
@@ -111,14 +111,14 @@ Item {
111111 break;
112112 }
113113 }
114− currentItem = item;
114+ if (currentItem !== item) currentItem = item;
115115 }
116116 }
117117
118118 QtObject {
119119 id: d
120120 property bool firstItemSwitch: true
121− property var previousItem: null
121+ property var previousItem
122122 }
123123
124124 onCurrentItemChanged: {
@@ -170,7 +170,7 @@ Item {
170170 anchors.bottom: row.bottom
171171 height: units.dp(2)
172172 color: root.hightlightColor
173− visible: currentItem !== null
173+ visible: currentItem !== undefined
174174 opacity: 0.0
175175
176176 width: currentItem ? currentItem.width : 0
qml/Panel/IndicatorsBar.qml+2−2
@@ -73,7 +73,7 @@ Item {
7373
7474 QtObject {
7575 id: d
76− property var initialItem: null
76+ property var initialItem
7777 // the non-expanded distance from row offset to center of initial item
7878 property real originalDistanceFromRight: -1
7979 property real originalItemWidth: -1
@@ -113,7 +113,7 @@ Item {
113113 Connections {
114114 target: row
115115 onCurrentItemChanged: {
116− if (!row.currentItem) d.initialItem = null;
116+ if (!row.currentItem) d.initialItem = undefined;
117117 else if (!d.initialItem) d.initialItem = row.currentItem;
118118 }
119119 }
qml/Panel/IndicatorsMenu.qml+1
@@ -25,6 +25,7 @@ Showable {
2525 property alias showDragHandle: __showDragHandle
2626 property alias hideDragHandle: __hideDragHandle
2727 property alias overFlowWidth: bar.overFlowWidth
28+ property alias verticalVelocityThreashold: yVelocityCalculator.velocityThreashold
2829
2930 property int minimizedPanelHeight: units.gu(3)
3031 property int expandedPanelHeight: units.gu(7)
tests/qmltests/Panel/tst_IndicatorsMenu.qml+11−6
@@ -53,6 +53,9 @@ IndicatorTest {
5353 openedHeight: parent.height
5454 indicatorsModel: root.indicatorsModel
5555 shown: false
56+
57+ // no vertical movement allowed while dragging
58+ verticalVelocityThreashold: 0
5659 }
5760 }
5861
@@ -120,12 +123,10 @@ IndicatorTest {
120123
121124 function test_progress_changes_state_to_reveal() {
122125 indicatorsMenu.height = indicatorsMenu.openedHeight / 2;
123− compare(indicatorsMenu.state, "reveal", "Indicators should be locked when fully opened.");
124− }
126+ compare(indicatorsMenu.state, "reveal", "Indicators should be revealing when partially opened.");
125127
126− function test_progress_changes_state_to_locked() {
127128 indicatorsMenu.height = indicatorsMenu.openedHeight;
128− compare(indicatorsMenu.state, "locked", "Indicators should be locked when fully opened.");
129+ compare(indicatorsMenu.state, "reveal", "Indicators should still be revealing when fully opened.");
129130 }
130131
131132 function test_open_state() {
@@ -218,10 +219,14 @@ IndicatorTest {
218219 touchFlick(indicatorsMenu,
219220 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
220221 nextItemMappedPosition.x, indicatorsMenu.openedHeight / 3,
221− false /* beginTouch */, true /* endTouch */,
222− units.gu(5) /* speed */, 10 /* iterations */); // more samples needed for accurate velocity
222+ false /* beginTouch */, false /* endTouch */,
223+ units.gu(50) /* speed */, 5 /* iterations */); // more samples needed for accurate velocity
223224
224225 compare(indicatorItemRow.currentItem, firstItem, "First indicator should still be the current item");
226+ // after waiting in the same spot with touch down, it should update to the next item.
227+ tryCompare(indicatorItemRow, "currentItem", nextItem);
228+
229+ touchRelease(indicatorsMenu, nextItemMappedPosition.x, indicatorsMenu.openedHeight / 3);
225230 }
226231 }
227232}