on xenial help sign in
more test fixes
commit86d4415b8480f2ab7d56817e929b1061bced5402 authorNick Dedekind <nick.dedekind@canonical.com> dateFri 30 Sep 2016, 13:04 (10 years ago) parent4d6bd0b
10 files changed+120−103
qml/Panel/MenuContent.qml+2−2 qml/Panel/Panel.qml−4 qml/Panel/PanelBar.qml+2−2 qml/Panel/PanelItemRow.qml+2−28 qml/Panel/PanelMenu.qml+2−2 tests/qmltests/Panel/PanelTest.qml−5 tests/qmltests/Panel/tst_Panel.qml+35−5 tests/qmltests/Panel/tst_PanelBar.qml+24−33 tests/qmltests/Panel/tst_PanelItemRow.qml+24−12 tests/qmltests/Panel/tst_PanelMenu.qml+29−10
qml/Panel/MenuContent.qml+2−2
@@ -25,7 +25,7 @@ import "Indicators"
2525Rectangle {
2626 id: content
2727
28− property QtObject indicatorsModel: null
28+ property QtObject model: null
2929 property int currentMenuIndex: -1
3030 property Component pageDelegate
3131
@@ -42,7 +42,7 @@ Rectangle {
4242 id: listViewContent
4343 objectName: "indicatorsContentListView"
4444 anchors.fill: parent
45− model: content.indicatorsModel
45+ model: content.model
4646
4747 highlightFollowsCurrentItem: true
4848 interactive: false
qml/Panel/Panel.qml−4
@@ -409,10 +409,6 @@ Item {
409409 showOnClick: true
410410 panelColor: panelAreaBackground.color
411411
412− onShownChanged: {
413− if (d.menuBar) d.menuBar.close();
414− }
415−
416412 rowItemDelegate: IndicatorItem {
417413 id: indicatorItem
418414 objectName: identifier+"-panelItem"
qml/Panel/PanelBar.qml+2−2
@@ -22,7 +22,7 @@ Item {
2222 id: root
2323 property alias expanded: row.expanded
2424 property alias interactive: flickable.interactive
25− property alias indicatorsModel: row.indicatorsModel
25+ property alias model: row.model
2626 property alias unitProgress: row.unitProgress
2727 property alias enableLateralChanges: row.enableLateralChanges
2828 property alias overFlowWidth: row.overFlowWidth
@@ -169,7 +169,7 @@ Item {
169169
170170 PanelItemRow {
171171 id: row
172− objectName: "indicatorItemRow"
172+ objectName: "panelItemRow"
173173 anchors {
174174 top: parent.top
175175 bottom: parent.bottom
qml/Panel/PanelItemRow.qml+2−28
@@ -25,7 +25,7 @@ Item {
2525
2626 property bool showRowTitle: false
2727 property alias rowTitle: rowLabel.text
28− property QtObject indicatorsModel: null
28+ property QtObject model: null
2929 property real overFlowWidth: width
3030 property bool expanded: false
3131 readonly property alias currentItem: row.currentItem
@@ -158,7 +158,7 @@ Item {
158158 ListView {
159159 id: row
160160 orientation: ListView.Horizontal
161− model: indicatorsModel
161+ model: root.model
162162 opacity: showRowTitle ? 0 : 1
163163 anchors {
164164 top: parent.top
@@ -184,32 +184,6 @@ Item {
184184 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
185185 }
186186
187− ListView {
188− orientation: ListView.Horizontal
189− model: indicatorsModel
190− anchors {
191− top: parent.top
192− bottom: parent.bottom
193− }
194− interactive: expanded
195−
196− // TODO: make this better
197− // when the width changes, the highlight will lag behind due to animation, so we need to disable the animation
198− // and adjust the highlight X immediately.
199− width: implicitWidth
200− Behavior on width {
201− SequentialAnimation {
202− ScriptAction {
203− script: {
204− d.forceAlignmentAnimationDisabled = true;
205− highlight.currentItemX = Qt.binding(function() { return currentItem ? currentItem.x : 0 });
206− d.forceAlignmentAnimationDisabled = false;
207− }
208− }
209− }
210− }
211− }
212−
213187 Rectangle {
214188 id: highlight
215189 objectName: "highlight"
qml/Panel/PanelMenu.qml+2−2
@@ -22,7 +22,7 @@ import "Indicators"
2222
2323Showable {
2424 id: root
25− property alias model: bar.indicatorsModel
25+ property alias model: bar.model
2626 property alias showDragHandle: __showDragHandle
2727 property alias hideDragHandle: __hideDragHandle
2828 property alias overFlowWidth: bar.overFlowWidth
@@ -100,7 +100,7 @@ Showable {
100100 top: bar.bottom
101101 }
102102 height: openedHeight - bar.height - handle.height
103− indicatorsModel: root.model
103+ model: root.model
104104 visible: root.unitProgress > 0
105105 currentMenuIndex: bar.currentItemIndex
106106 }
tests/qmltests/Panel/PanelTest.qml−5
@@ -15,11 +15,6 @@
1515 */
1616
1717import QtQuick 2.4
18−import QtQuick.Layouts 1.1
19−import QtTest 1.0
20−import "../../../qml/Panel"
21−import Ubuntu.Components 1.3
22−import Unity.Test 0.1 as UT
2318import Unity.Indicators 0.1 as Indicators
2419
2520Rectangle {
tests/qmltests/Panel/tst_Panel.qml+35−5
@@ -302,8 +302,8 @@ PanelTest {
302302 panel.fullscreenMode = data.fullscreen;
303303 callManager.foregroundCall = data.call;
304304
305− var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
306− verify(indicatorRow !== null);
305+ var panelRow = findChild(panel.indicators, "panelItemRow");
306+ verify(panelRow !== null);
307307
308308 var menuContent = findChild(panel.indicators, "menuContent");
309309 verify(menuContent !== null);
@@ -333,7 +333,7 @@ PanelTest {
333333
334334 touchRelease(panel, startXPosition, panel.height);
335335
336− compare(indicatorRow.currentItemIndex, i, "Indicator item should be activated at position " + i);
336+ compare(panelRow.currentItemIndex, i, "Indicator item should be activated at position " + i);
337337 compare(menuContent.currentMenuIndex, i, "Menu conetent should be activated for item at position " + i);
338338
339339 // init for next indicatorItem
@@ -362,8 +362,8 @@ PanelTest {
362362 panel.fullscreenMode = data.fullscreen;
363363 callManager.foregroundCall = data.call;
364364
365− var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
366− verify(indicatorRow !== null);
365+ var panelRow = findChild(panel.indicators, "panelItemRow");
366+ verify(panelRow !== null);
367367
368368 var menuContent = findChild(panel.indicators, "menuContent");
369369 verify(menuContent !== null);
@@ -591,5 +591,35 @@ PanelTest {
591591
592592 compare(item.hidden, data.hidden);
593593 }
594+
595+ function test_visibleIndicators_data() {
596+ return [
597+ { visible: [true, false, true, false, true, true, false, true] },
598+ { visible: [false, false, false, false, false, false, true, false] }
599+ ];
600+ }
601+
602+ function test_visibleIndicators(data) {
603+ for (var i = 0; i < data.visible.length; i++) {
604+ var visible = data.visible[i];
605+ root.setIndicatorVisible(i, visible);
606+
607+ var dataItem = findChild(panel, root.originalModelData[i]["identifier"] + "-panelItem");
608+ tryCompare(dataItem, "opacity", visible ? 1.0 : 0.0);
609+ tryCompareFunction(function() { return dataItem.width > 0.0; }, visible);
610+ }
611+
612+ panel.indicators.show();
613+ tryCompare(panel.indicators.showAnimation, "running", false);
614+ tryCompare(panel.indicators, "unitProgress", 1);
615+
616+ for (var i = 0; i < data.visible.length; i++) {
617+ root.setIndicatorVisible(i, data.visible[i]);
618+
619+ var dataItem = findChild(panel, root.originalModelData[i]["identifier"] + "-panelItem");
620+ tryCompareFunction(function() { return dataItem.opacity > 0.0; }, true);
621+ tryCompareFunction(function() { return dataItem.width > 0.0; }, true);
622+ }
623+ }
594624 }
595625}
tests/qmltests/Panel/tst_PanelBar.qml+24−33
@@ -21,8 +21,9 @@ import "../../../qml/Panel"
2121import Ubuntu.Components 1.3
2222import Unity.Test 0.1 as UT
2323import Unity.Indicators 0.1 as Indicators
24+import "../../../qml/Panel/Indicators"
2425
25−IndicatorTest {
26+PanelTest {
2627 id: root
2728 width: units.gu(100)
2829 height: units.gu(40)
@@ -43,14 +44,31 @@ IndicatorTest {
4344 anchors.fill: indicatorsBar
4445 }
4546
46− IndicatorsBar {
47+ PanelBar {
4748 id: indicatorsBar
4849 height: expanded ? units.gu(7) : units.gu(3)
4950 width: units.gu(widthSlider.value)
5051 anchors.centerIn: parent
51− indicatorsModel: root.indicatorsModel
52+ model: root.indicatorsModel
5253 interactive: expanded && height === units.gu(7)
5354
55+ rowItemDelegate: Item {
56+ property int ownIndex: index
57+ objectName: model.identifier + "-panelItem"
58+
59+ implicitWidth: indicatorsBar.expanded ? units.gu(5) : units.gu(3)
60+ height: parent.height
61+
62+ Rectangle {
63+ anchors {
64+ fill: parent
65+ margins: 2
66+ }
67+ color: "red"
68+ Label { anchors.centerIn: parent; text: ownIndex }
69+ }
70+ }
71+
5472 Behavior on height {
5573 NumberAnimation {
5674 id: heightAnimation
@@ -171,7 +189,7 @@ IndicatorTest {
171189 var dataItem = findChild(indicatorsBar, root.originalModelData[lastItemIndex]["identifier"] + "-panelItem");
172190 verify(dataItem !== null);
173191
174− var row = findChild(indicatorsBar, "indicatorItemRow");
192+ var row = findChild(indicatorsBar, "panelItemRow");
175193 // test will not work without these conditions
176194 verify(row.width >= indicatorsBar.width + dataItem.width);
177195
@@ -198,36 +216,9 @@ IndicatorTest {
198216 skip("Out of bounds");
199217 }
200218 mouseClick(dataItem);
201− verify(dataItem.selected === true);
202− }
203−
204− function test_visibleIndicators_data() {
205− return [
206− { visible: [true, false, true, false, true, true, false, true] },
207− { visible: [false, false, false, false, false, false, true, false] }
208− ];
209− }
210−
211− function test_visibleIndicators(data) {
212− for (var i = 0; i < data.visible.length; i++) {
213− var visible = data.visible[i];
214− root.setIndicatorVisible(i, visible);
215219
216− var dataItem = findChild(indicatorsBar, root.originalModelData[i]["identifier"] + "-panelItem");
217− tryCompare(dataItem, "opacity", visible ? 1.0 : 0.0);
218− tryCompareFunction(function() { return dataItem.width > 0.0; }, visible);
219− }
220−
221− indicatorsBar.expanded = true;
222− wait_for_expansion_to_settle();
223−
224− for (var i = 0; i < data.visible.length; i++) {
225− root.setIndicatorVisible(i, data.visible[i]);
226−
227− var dataItem = findChild(indicatorsBar, root.originalModelData[i]["identifier"] + "-panelItem");
228− tryCompareFunction(function() { return dataItem.opacity > 0.0; }, true);
229− tryCompareFunction(function() { return dataItem.width > 0.0; }, true);
230− }
220+ var row = findChild(indicatorsBar, "panelItemRow");
221+ compare(dataItem, row.currentItem, "Item should be selected");
231222 }
232223
233224 // Rough test that resizing the IndicatorsBar has the items reposition correctly
tests/qmltests/Panel/tst_PanelItemRow.qml+24−12
@@ -22,7 +22,6 @@ import Unity.Test 0.1 as UT
2222import AccountsService 0.1
2323import Unity.InputInfo 0.1
2424import "../../../qml/Panel"
25−import "../../../qml/Panel/Indicators"
2625
2726PanelTest {
2827 id: root
@@ -49,7 +48,7 @@ PanelTest {
4948 id: indicatorsRow
5049 height: expanded ? units.gu(7) : units.gu(3)
5150 anchors.centerIn: parent
52− indicatorsModel: root.indicatorsModel
51+ model: root.indicatorsModel
5352 enableLateralChanges: ma.pressed
5453
5554 Behavior on height {
@@ -59,14 +58,21 @@ PanelTest {
5958 }
6059 }
6160
62− delegate: IndicatorItem {
61+ delegate: Item {
6362 property int ownIndex: index
64− property string identifier: model.identifier
63+ objectName: model.identifier + "-panelItem"
6564
66− objectName: identifier + "-panelItem"
67− width: units.gu(3)
68− height: units.gu(3)
69− icons: [ "image://theme/settings" ]
65+ implicitWidth: indicatorsRow.expanded ? units.gu(6) : units.gu(3)
66+ height: parent.height
67+
68+ Rectangle {
69+ anchors {
70+ fill: parent
71+ margins: 2
72+ }
73+ color: "red"
74+ Label { anchors.centerIn: parent; text: ownIndex }
75+ }
7076 }
7177
7278 MouseArea {
@@ -126,7 +132,7 @@ PanelTest {
126132 }
127133
128134 UT.UnityTestCase {
129− name: "IndicatorItemRow"
135+ name: "PanelItemRow"
130136 when: windowShown
131137
132138 function init() {
@@ -171,30 +177,36 @@ PanelTest {
171177 for (i = data.remove.length-1; i >= 0; i--) {
172178 removeIndicator(data.remove[i]);
173179 }
180+ wait(50);
174181
175182 // test removals
176183 for (i = 0; i < root.originalModelData.length; i++) {
177− item = findChild(indicatorsRow, root.originalModelData[i]["identifier"] + "-panelItem");
184+ item = findChild(indicatorsRow, root.originalModelData[i]["identifier"] + "-panelItem", 0);
178185 console.log(item, i, root.originalModelData[i]["identifier"])
179186
180187 if (data.remove.indexOf(i) !== -1) {
181188 verify(item === null, "removed item should not be present");
182189 } else {
183− verify(item === null, "items not removed item should still be present");
190+ verify(item !== null, "items not removed item should still be present");
184191 }
185192 }
193+ console.log("2")
186194
187195 // test insertion
188196 for (i = 0; i < data.remove.length; i++) {
189197 insertIndicator(data.remove[i]);
190198 }
191199
200+ console.log("3")
201+
192202 for (i = 0; i < root.originalModelData.length; i++) {
193− item = findChild(indicatorsRow, root.originalModelData[i]["identifier"] + "-panelItem");
203+ item = findChild(indicatorsRow, root.originalModelData[i]["identifier"] + "-panelItem", 100);
194204 verify(item);
195205
196206 compare(item.ownIndex, i, "Item at incorrect index");
197207 }
208+
209+ console.log("4")
198210 }
199211
200212 function test_validCurrentItem_data() {
tests/qmltests/Panel/tst_PanelMenu.qml+29−10
@@ -57,8 +57,25 @@ PanelTest {
5757 minimizedPanelHeight: units.gu(3)
5858 expandedPanelHeight: units.gu(7)
5959 openedHeight: parent.height
60− indicatorsModel: root.indicatorsModel
60+ model: root.indicatorsModel
6161 shown: false
62+
63+ rowItemDelegate: Item {
64+ property int ownIndex: index
65+ objectName: model.identifier + "-panelItem"
66+
67+ implicitWidth: indicatorsMenu.expanded ? units.gu(5) : units.gu(3)
68+ height: parent.height
69+
70+ Rectangle {
71+ anchors {
72+ fill: parent
73+ margins: 2
74+ }
75+ color: "red"
76+ Label { anchors.centerIn: parent; text: ownIndex }
77+ }
78+ }
6279 }
6380 }
6481
@@ -205,8 +222,8 @@ PanelTest {
205222 // tests swiping on an indicator item activates the correct item.
206223 function test_swipeForCurrentItem()
207224 {
208− var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow");
209− verify(indicatorItemRow !== null);
225+ var panelItemRow = findChild(indicatorsMenu, "panelItemRow");
226+ verify(panelItemRow !== null);
210227
211228 for (var i = 0; i < root.originalModelData.length; i++) {
212229 var indicatorItem = get_indicator_item(i);
@@ -218,10 +235,10 @@ PanelTest {
218235 mappedPosition.x, indicatorsMenu.openedHeight / 2,
219236 true /* beginTouch */, false /* endTouch */);
220237
221− tryCompare(indicatorItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
238+ tryCompare(panelItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
222239 "Incorrect item activated at position " + i);
223240
224− touchFlick(indicatorItemRow,
241+ touchFlick(panelItemRow,
225242 mappedPosition.x, indicatorsMenu.openedHeight / 2,
226243 mappedPosition.x, mappedPosition.y,
227244 false /* beginTouch */, true /* endTouch */);
@@ -238,8 +255,8 @@ PanelTest {
238255 indicatorsMenu.verticalVelocityThreshold = 0;
239256 verify(root.originalModelData.length >= 2);
240257
241− var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow");
242− verify(indicatorItemRow !== null);
258+ var panelItemRow = findChild(indicatorsMenu, "panelItemRow");
259+ verify(panelItemRow !== null);
243260
244261 // Get the first indicator
245262 var firstItem = get_indicator_item(0);
@@ -251,12 +268,14 @@ PanelTest {
251268 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
252269 true /* beginTouch */, false /* endTouch */);
253270
254− tryCompare(indicatorItemRow, "currentItem", firstItem)
271+ tryCompare(panelItemRow, "currentItem", firstItem)
255272
256273 // next time position will have moved.
257274 var nextItem = get_indicator_item(1);
258275 var nextItemMappedPositionX = firstItemMappedPosition.x + firstItem.width;
259276
277+ firstItemMappedPosition = indicatorsMenu.mapFromItem(firstItem, firstItem.width/2, firstItem.height/2);
278+
260279 // 1) Flick mouse down to bottom
261280 touchFlick(indicatorsMenu,
262281 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
@@ -264,10 +283,10 @@ PanelTest {
264283 false /* beginTouch */, false /* endTouch */,
265284 units.gu(50) /* speed */, 5 /* iterations */); // more samples needed for accurate velocity
266285
267− tryCompare(indicatorItemRow, "currentItem", firstItem, undefined /* timeout, default */,
286+ tryCompare(panelItemRow, "currentItem", firstItem, undefined /* timeout, default */,
268287 "First indicator should still be the current item");
269288 // after waiting in the same spot with touch down, it should update to the next item.
270− tryCompare(indicatorItemRow, "currentItem", nextItem);
289+ tryCompare(panelItemRow, "currentItem", nextItem);
271290
272291 touchRelease(indicatorsMenu, nextItemMappedPositionX, indicatorsMenu.openedHeight / 3);
273292 }