on xenial help sign in
more test fixes
86d4415Nick Dedekind
qml/Panel/MenuContent.qml+2−2
@@ -25,7 +25,7 @@ import "Indicators"
25Rectangle {
25Rectangle {
26 id: content
26 id: content
27
27
28− property QtObject indicatorsModel: null
28+ property QtObject model: null
29 property int currentMenuIndex: -1
29 property int currentMenuIndex: -1
30 property Component pageDelegate
30 property Component pageDelegate
31
31
@@ -42,7 +42,7 @@ Rectangle {
42 id: listViewContent
42 id: listViewContent
43 objectName: "indicatorsContentListView"
43 objectName: "indicatorsContentListView"
44 anchors.fill: parent
44 anchors.fill: parent
45− model: content.indicatorsModel
45+ model: content.model
46
46
47 highlightFollowsCurrentItem: true
47 highlightFollowsCurrentItem: true
48 interactive: false
48 interactive: false
qml/Panel/Panel.qml−4
@@ -409,10 +409,6 @@ Item {
409 showOnClick: true
409 showOnClick: true
410 panelColor: panelAreaBackground.color
410 panelColor: panelAreaBackground.color
411
411
412− onShownChanged: {
413− if (d.menuBar) d.menuBar.close();
414− }
415−
416 rowItemDelegate: IndicatorItem {
412 rowItemDelegate: IndicatorItem {
417 id: indicatorItem
413 id: indicatorItem
418 objectName: identifier+"-panelItem"
414 objectName: identifier+"-panelItem"
qml/Panel/PanelBar.qml+2−2
@@ -22,7 +22,7 @@ Item {
22 id: root
22 id: root
23 property alias expanded: row.expanded
23 property alias expanded: row.expanded
24 property alias interactive: flickable.interactive
24 property alias interactive: flickable.interactive
25− property alias indicatorsModel: row.indicatorsModel
25+ property alias model: row.model
26 property alias unitProgress: row.unitProgress
26 property alias unitProgress: row.unitProgress
27 property alias enableLateralChanges: row.enableLateralChanges
27 property alias enableLateralChanges: row.enableLateralChanges
28 property alias overFlowWidth: row.overFlowWidth
28 property alias overFlowWidth: row.overFlowWidth
@@ -169,7 +169,7 @@ Item {
169
169
170 PanelItemRow {
170 PanelItemRow {
171 id: row
171 id: row
172− objectName: "indicatorItemRow"
172+ objectName: "panelItemRow"
173 anchors {
173 anchors {
174 top: parent.top
174 top: parent.top
175 bottom: parent.bottom
175 bottom: parent.bottom
qml/Panel/PanelItemRow.qml+2−28
@@ -25,7 +25,7 @@ Item {
25
25
26 property bool showRowTitle: false
26 property bool showRowTitle: false
27 property alias rowTitle: rowLabel.text
27 property alias rowTitle: rowLabel.text
28− property QtObject indicatorsModel: null
28+ property QtObject model: null
29 property real overFlowWidth: width
29 property real overFlowWidth: width
30 property bool expanded: false
30 property bool expanded: false
31 readonly property alias currentItem: row.currentItem
31 readonly property alias currentItem: row.currentItem
@@ -158,7 +158,7 @@ Item {
158 ListView {
158 ListView {
159 id: row
159 id: row
160 orientation: ListView.Horizontal
160 orientation: ListView.Horizontal
161− model: indicatorsModel
161+ model: root.model
162 opacity: showRowTitle ? 0 : 1
162 opacity: showRowTitle ? 0 : 1
163 anchors {
163 anchors {
164 top: parent.top
164 top: parent.top
@@ -184,32 +184,6 @@ Item {
184 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
184 Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.SnapDuration } }
185 }
185 }
186
186
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−
213 Rectangle {
187 Rectangle {
214 id: highlight
188 id: highlight
215 objectName: "highlight"
189 objectName: "highlight"
qml/Panel/PanelMenu.qml+2−2
@@ -22,7 +22,7 @@ import "Indicators"
22
22
23Showable {
23Showable {
24 id: root
24 id: root
25− property alias model: bar.indicatorsModel
25+ property alias model: bar.model
26 property alias showDragHandle: __showDragHandle
26 property alias showDragHandle: __showDragHandle
27 property alias hideDragHandle: __hideDragHandle
27 property alias hideDragHandle: __hideDragHandle
28 property alias overFlowWidth: bar.overFlowWidth
28 property alias overFlowWidth: bar.overFlowWidth
@@ -100,7 +100,7 @@ Showable {
100 top: bar.bottom
100 top: bar.bottom
101 }
101 }
102 height: openedHeight - bar.height - handle.height
102 height: openedHeight - bar.height - handle.height
103− indicatorsModel: root.model
103+ model: root.model
104 visible: root.unitProgress > 0
104 visible: root.unitProgress > 0
105 currentMenuIndex: bar.currentItemIndex
105 currentMenuIndex: bar.currentItemIndex
106 }
106 }
tests/qmltests/Panel/PanelTest.qml−5
@@ -15,11 +15,6 @@
15 */
15 */
16
16
17import QtQuick 2.4
17import 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
23import Unity.Indicators 0.1 as Indicators
18import Unity.Indicators 0.1 as Indicators
24
19
25Rectangle {
20Rectangle {
tests/qmltests/Panel/tst_Panel.qml+35−5
@@ -302,8 +302,8 @@ PanelTest {
302 panel.fullscreenMode = data.fullscreen;
302 panel.fullscreenMode = data.fullscreen;
303 callManager.foregroundCall = data.call;
303 callManager.foregroundCall = data.call;
304
304
305− var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
305+ var panelRow = findChild(panel.indicators, "panelItemRow");
306− verify(indicatorRow !== null);
306+ verify(panelRow !== null);
307
307
308 var menuContent = findChild(panel.indicators, "menuContent");
308 var menuContent = findChild(panel.indicators, "menuContent");
309 verify(menuContent !== null);
309 verify(menuContent !== null);
@@ -333,7 +333,7 @@ PanelTest {
333
333
334 touchRelease(panel, startXPosition, panel.height);
334 touchRelease(panel, startXPosition, panel.height);
335
335
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);
337 compare(menuContent.currentMenuIndex, i, "Menu conetent should be activated for item at position " + i);
337 compare(menuContent.currentMenuIndex, i, "Menu conetent should be activated for item at position " + i);
338
338
339 // init for next indicatorItem
339 // init for next indicatorItem
@@ -362,8 +362,8 @@ PanelTest {
362 panel.fullscreenMode = data.fullscreen;
362 panel.fullscreenMode = data.fullscreen;
363 callManager.foregroundCall = data.call;
363 callManager.foregroundCall = data.call;
364
364
365− var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
365+ var panelRow = findChild(panel.indicators, "panelItemRow");
366− verify(indicatorRow !== null);
366+ verify(panelRow !== null);
367
367
368 var menuContent = findChild(panel.indicators, "menuContent");
368 var menuContent = findChild(panel.indicators, "menuContent");
369 verify(menuContent !== null);
369 verify(menuContent !== null);
@@ -591,5 +591,35 @@ PanelTest {
591
591
592 compare(item.hidden, data.hidden);
592 compare(item.hidden, data.hidden);
593 }
593 }
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+ }
594 }
624 }
595}
625}
tests/qmltests/Panel/tst_PanelBar.qml+24−33
@@ -21,8 +21,9 @@ import "../../../qml/Panel"
21import Ubuntu.Components 1.3
21import Ubuntu.Components 1.3
22import Unity.Test 0.1 as UT
22import Unity.Test 0.1 as UT
23import Unity.Indicators 0.1 as Indicators
23import Unity.Indicators 0.1 as Indicators
24+import "../../../qml/Panel/Indicators"
24
25
25−IndicatorTest {
26+PanelTest {
26 id: root
27 id: root
27 width: units.gu(100)
28 width: units.gu(100)
28 height: units.gu(40)
29 height: units.gu(40)
@@ -43,14 +44,31 @@ IndicatorTest {
43 anchors.fill: indicatorsBar
44 anchors.fill: indicatorsBar
44 }
45 }
45
46
46− IndicatorsBar {
47+ PanelBar {
47 id: indicatorsBar
48 id: indicatorsBar
48 height: expanded ? units.gu(7) : units.gu(3)
49 height: expanded ? units.gu(7) : units.gu(3)
49 width: units.gu(widthSlider.value)
50 width: units.gu(widthSlider.value)
50 anchors.centerIn: parent
51 anchors.centerIn: parent
51− indicatorsModel: root.indicatorsModel
52+ model: root.indicatorsModel
52 interactive: expanded && height === units.gu(7)
53 interactive: expanded && height === units.gu(7)
53
54
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+
54 Behavior on height {
72 Behavior on height {
55 NumberAnimation {
73 NumberAnimation {
56 id: heightAnimation
74 id: heightAnimation
@@ -171,7 +189,7 @@ IndicatorTest {
171 var dataItem = findChild(indicatorsBar, root.originalModelData[lastItemIndex]["identifier"] + "-panelItem");
189 var dataItem = findChild(indicatorsBar, root.originalModelData[lastItemIndex]["identifier"] + "-panelItem");
172 verify(dataItem !== null);
190 verify(dataItem !== null);
173
191
174− var row = findChild(indicatorsBar, "indicatorItemRow");
192+ var row = findChild(indicatorsBar, "panelItemRow");
175 // test will not work without these conditions
193 // test will not work without these conditions
176 verify(row.width >= indicatorsBar.width + dataItem.width);
194 verify(row.width >= indicatorsBar.width + dataItem.width);
177
195
@@ -198,36 +216,9 @@ IndicatorTest {
198 skip("Out of bounds");
216 skip("Out of bounds");
199 }
217 }
200 mouseClick(dataItem);
218 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);
215
219
216− var dataItem = findChild(indicatorsBar, root.originalModelData[i]["identifier"] + "-panelItem");
220+ var row = findChild(indicatorsBar, "panelItemRow");
217− tryCompare(dataItem, "opacity", visible ? 1.0 : 0.0);
221+ compare(dataItem, row.currentItem, "Item should be selected");
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− }
231 }
222 }
232
223
233 // Rough test that resizing the IndicatorsBar has the items reposition correctly
224 // 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
22import AccountsService 0.1
22import AccountsService 0.1
23import Unity.InputInfo 0.1
23import Unity.InputInfo 0.1
24import "../../../qml/Panel"
24import "../../../qml/Panel"
25−import "../../../qml/Panel/Indicators"
26
25
27PanelTest {
26PanelTest {
28 id: root
27 id: root
@@ -49,7 +48,7 @@ PanelTest {
49 id: indicatorsRow
48 id: indicatorsRow
50 height: expanded ? units.gu(7) : units.gu(3)
49 height: expanded ? units.gu(7) : units.gu(3)
51 anchors.centerIn: parent
50 anchors.centerIn: parent
52− indicatorsModel: root.indicatorsModel
51+ model: root.indicatorsModel
53 enableLateralChanges: ma.pressed
52 enableLateralChanges: ma.pressed
54
53
55 Behavior on height {
54 Behavior on height {
@@ -59,14 +58,21 @@ PanelTest {
59 }
58 }
60 }
59 }
61
60
62− delegate: IndicatorItem {
61+ delegate: Item {
63 property int ownIndex: index
62 property int ownIndex: index
64− property string identifier: model.identifier
63+ objectName: model.identifier + "-panelItem"
65
64
66− objectName: identifier + "-panelItem"
65+ implicitWidth: indicatorsRow.expanded ? units.gu(6) : units.gu(3)
67− width: units.gu(3)
66+ height: parent.height
68− height: units.gu(3)
67+
69− icons: [ "image://theme/settings" ]
68+ Rectangle {
69+ anchors {
70+ fill: parent
71+ margins: 2
72+ }
73+ color: "red"
74+ Label { anchors.centerIn: parent; text: ownIndex }
75+ }
70 }
76 }
71
77
72 MouseArea {
78 MouseArea {
@@ -126,7 +132,7 @@ PanelTest {
126 }
132 }
127
133
128 UT.UnityTestCase {
134 UT.UnityTestCase {
129− name: "IndicatorItemRow"
135+ name: "PanelItemRow"
130 when: windowShown
136 when: windowShown
131
137
132 function init() {
138 function init() {
@@ -171,30 +177,36 @@ PanelTest {
171 for (i = data.remove.length-1; i >= 0; i--) {
177 for (i = data.remove.length-1; i >= 0; i--) {
172 removeIndicator(data.remove[i]);
178 removeIndicator(data.remove[i]);
173 }
179 }
180+ wait(50);
174
181
175 // test removals
182 // test removals
176 for (i = 0; i < root.originalModelData.length; i++) {
183 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);
178 console.log(item, i, root.originalModelData[i]["identifier"])
185 console.log(item, i, root.originalModelData[i]["identifier"])
179
186
180 if (data.remove.indexOf(i) !== -1) {
187 if (data.remove.indexOf(i) !== -1) {
181 verify(item === null, "removed item should not be present");
188 verify(item === null, "removed item should not be present");
182 } else {
189 } 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");
184 }
191 }
185 }
192 }
193+ console.log("2")
186
194
187 // test insertion
195 // test insertion
188 for (i = 0; i < data.remove.length; i++) {
196 for (i = 0; i < data.remove.length; i++) {
189 insertIndicator(data.remove[i]);
197 insertIndicator(data.remove[i]);
190 }
198 }
191
199
200+ console.log("3")
201+
192 for (i = 0; i < root.originalModelData.length; i++) {
202 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);
194 verify(item);
204 verify(item);
195
205
196 compare(item.ownIndex, i, "Item at incorrect index");
206 compare(item.ownIndex, i, "Item at incorrect index");
197 }
207 }
208+
209+ console.log("4")
198 }
210 }
199
211
200 function test_validCurrentItem_data() {
212 function test_validCurrentItem_data() {
tests/qmltests/Panel/tst_PanelMenu.qml+29−10
@@ -57,8 +57,25 @@ PanelTest {
57 minimizedPanelHeight: units.gu(3)
57 minimizedPanelHeight: units.gu(3)
58 expandedPanelHeight: units.gu(7)
58 expandedPanelHeight: units.gu(7)
59 openedHeight: parent.height
59 openedHeight: parent.height
60− indicatorsModel: root.indicatorsModel
60+ model: root.indicatorsModel
61 shown: false
61 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+ }
62 }
79 }
63 }
80 }
64
81
@@ -205,8 +222,8 @@ PanelTest {
205 // tests swiping on an indicator item activates the correct item.
222 // tests swiping on an indicator item activates the correct item.
206 function test_swipeForCurrentItem()
223 function test_swipeForCurrentItem()
207 {
224 {
208− var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow");
225+ var panelItemRow = findChild(indicatorsMenu, "panelItemRow");
209− verify(indicatorItemRow !== null);
226+ verify(panelItemRow !== null);
210
227
211 for (var i = 0; i < root.originalModelData.length; i++) {
228 for (var i = 0; i < root.originalModelData.length; i++) {
212 var indicatorItem = get_indicator_item(i);
229 var indicatorItem = get_indicator_item(i);
@@ -218,10 +235,10 @@ PanelTest {
218 mappedPosition.x, indicatorsMenu.openedHeight / 2,
235 mappedPosition.x, indicatorsMenu.openedHeight / 2,
219 true /* beginTouch */, false /* endTouch */);
236 true /* beginTouch */, false /* endTouch */);
220
237
221− tryCompare(indicatorItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
238+ tryCompare(panelItemRow, "currentItem", indicatorItem, undefined /*timeout, default */,
222 "Incorrect item activated at position " + i);
239 "Incorrect item activated at position " + i);
223
240
224− touchFlick(indicatorItemRow,
241+ touchFlick(panelItemRow,
225 mappedPosition.x, indicatorsMenu.openedHeight / 2,
242 mappedPosition.x, indicatorsMenu.openedHeight / 2,
226 mappedPosition.x, mappedPosition.y,
243 mappedPosition.x, mappedPosition.y,
227 false /* beginTouch */, true /* endTouch */);
244 false /* beginTouch */, true /* endTouch */);
@@ -238,8 +255,8 @@ PanelTest {
238 indicatorsMenu.verticalVelocityThreshold = 0;
255 indicatorsMenu.verticalVelocityThreshold = 0;
239 verify(root.originalModelData.length >= 2);
256 verify(root.originalModelData.length >= 2);
240
257
241− var indicatorItemRow = findChild(indicatorsMenu, "indicatorItemRow");
258+ var panelItemRow = findChild(indicatorsMenu, "panelItemRow");
242− verify(indicatorItemRow !== null);
259+ verify(panelItemRow !== null);
243
260
244 // Get the first indicator
261 // Get the first indicator
245 var firstItem = get_indicator_item(0);
262 var firstItem = get_indicator_item(0);
@@ -251,12 +268,14 @@ PanelTest {
251 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
268 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
252 true /* beginTouch */, false /* endTouch */);
269 true /* beginTouch */, false /* endTouch */);
253
270
254− tryCompare(indicatorItemRow, "currentItem", firstItem)
271+ tryCompare(panelItemRow, "currentItem", firstItem)
255
272
256 // next time position will have moved.
273 // next time position will have moved.
257 var nextItem = get_indicator_item(1);
274 var nextItem = get_indicator_item(1);
258 var nextItemMappedPositionX = firstItemMappedPosition.x + firstItem.width;
275 var nextItemMappedPositionX = firstItemMappedPosition.x + firstItem.width;
259
276
277+ firstItemMappedPosition = indicatorsMenu.mapFromItem(firstItem, firstItem.width/2, firstItem.height/2);
278+
260 // 1) Flick mouse down to bottom
279 // 1) Flick mouse down to bottom
261 touchFlick(indicatorsMenu,
280 touchFlick(indicatorsMenu,
262 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
281 firstItemMappedPosition.x, indicatorsMenu.minimizedPanelHeight * 2,
@@ -264,10 +283,10 @@ PanelTest {
264 false /* beginTouch */, false /* endTouch */,
283 false /* beginTouch */, false /* endTouch */,
265 units.gu(50) /* speed */, 5 /* iterations */); // more samples needed for accurate velocity
284 units.gu(50) /* speed */, 5 /* iterations */); // more samples needed for accurate velocity
266
285
267− tryCompare(indicatorItemRow, "currentItem", firstItem, undefined /* timeout, default */,
286+ tryCompare(panelItemRow, "currentItem", firstItem, undefined /* timeout, default */,
268 "First indicator should still be the current item");
287 "First indicator should still be the current item");
269 // after waiting in the same spot with touch down, it should update to the next item.
288 // 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);
271
290
272 touchRelease(indicatorsMenu, nextItemMappedPositionX, indicatorsMenu.openedHeight / 3);
291 touchRelease(indicatorsMenu, nextItemMappedPositionX, indicatorsMenu.openedHeight / 3);
273 }
292 }