on xenial help sign in
fixed tests
4bf584dNick Dedekind
qml/Panel/IndicatorRow.qml+1−1
@@ -84,7 +84,7 @@ Item {
84 id: itemWrapper
84 id: itemWrapper
85 objectName: "item" + index
85 objectName: "item" + index
86 height: indicatorRow.height
86 height: indicatorRow.height
87− width: visible ? indicatorItem.width : 0
87+ width: indicatorItem.width
88 opacity: 1 - indicatorRow.unitProgress
88 opacity: 1 - indicatorRow.unitProgress
89 y: 0
89 y: 0
90 state: "standard"
90 state: "standard"
qml/Panel/Indicators.qml+4−4
@@ -181,7 +181,7 @@ Showable {
181 }
181 }
182
182
183 VisibleIndicatorsModel {
183 VisibleIndicatorsModel {
184− id: indicatorsModel
184+ id: visibleIndicators
185 }
185 }
186
186
187 MenuContent {
187 MenuContent {
@@ -194,7 +194,7 @@ Showable {
194 top: indicatorRow.bottom
194 top: indicatorRow.bottom
195 bottom: handle.top
195 bottom: handle.top
196 }
196 }
197− indicatorsModel: indicatorsModel
197+ indicatorsModel: visibleIndicators.model
198 clip: !indicators.fullyOpened
198 clip: !indicators.fullyOpened
199 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
199 activeHeader: indicators.state == "hint" || indicators.state == "reveal"
200 enabled: contentEnabled
200 enabled: contentEnabled
@@ -255,7 +255,7 @@ Showable {
255 right: parent.right
255 right: parent.right
256 }
256 }
257 height: indicators.panelHeight
257 height: indicators.panelHeight
258− indicatorsModel: indicatorsModel
258+ indicatorsModel: visibleIndicators.model
259 state: indicators.state
259 state: indicators.state
260 unitProgress: indicators.unitProgress
260 unitProgress: indicators.unitProgress
261
261
@@ -429,6 +429,6 @@ Showable {
429
429
430 Component.onCompleted: initialise();
430 Component.onCompleted: initialise();
431 function initialise() {
431 function initialise() {
432− indicatorsModel.load();
432+ visibleIndicators.load();
433 }
433 }
434}
434}
qml/Panel/Indicators/VisibleIndicatorsModel.qml+40−37
@@ -21,56 +21,59 @@ import QtQuick 2.0
21import Unity.Indicators 0.1 as Indicators
21import Unity.Indicators 0.1 as Indicators
22import Utils 0.1
22import Utils 0.1
23
23
24−SortFilterProxyModel {
24+Item {
25− id: filteredIndicators
25+ property SortFilterProxyModel model: filterModel
26
26
27+ SortFilterProxyModel {
28+ id: filterModel
29+ filterRole: Indicators.IndicatorsModelRole.IsVisible
30+ filterRegExp: RegExp("^true$")
31+ dynamicSortFilter: true
32+
27− model: Indicators.VisibleIndicatorsModel {
33+ model: Indicators.VisibleIndicatorsModel {
28− id: visibleIndicatorsModel
34+ id: visibleIndicatorsModel
29− model: indicatorsModel
35+ model: indicatorsModel
36+ }
30 }
37 }
31
38
32− filterRole: Indicators.IndicatorsModelRole.IsVisible
33− filterRegExp: RegExp("^true$")
34− dynamicSortFilter: true
35
39
36− property Item __container: Item {
37− Indicators.IndicatorsModel {
40+ Indicators.IndicatorsModel {
38− id: indicatorsModel
41+ id: indicatorsModel
39− }
42+ }
40
43
41− Repeater {
44+ Repeater {
42− id: repeater
45+ id: repeater
43− model: indicatorsModel
46+ model: indicatorsModel
44
47
45− property var visibleIndicators: undefined
48+ property var visibleIndicators: undefined
46− onVisibleIndicatorsChanged: {
49+ onVisibleIndicatorsChanged: {
47− if (visibleIndicators !== undefined) {
50+ if (visibleIndicators !== undefined) {
48− visibleIndicatorsModel.visible = visibleIndicators;
51+ visibleIndicatorsModel.visible = visibleIndicators;
49− }
50 }
52 }
53+ }
51
54
52− delegate: IndicatorDelegate {
55+ delegate: IndicatorDelegate {
53− id: item
56+ id: item
57+ objectName: model.identifier + "-delegate"
54− Component.onCompleted: {
58+ Component.onCompleted: {
55− for(var pName in indicatorProperties) {
59+ for(var pName in indicatorProperties) {
56− if (item.hasOwnProperty(pName)) {
60+ if (item.hasOwnProperty(pName)) {
57− item[pName] = indicatorProperties[pName];
61+ item[pName] = indicatorProperties[pName];
58− }
59 }
62 }
60− updateVisibility();
61 }
63 }
64+ updateVisibility();
65+ }
62
66
63− onEnabledChanged: {
67+ onEnabledChanged: {
64− updateVisibility()
68+ updateVisibility()
65− }
69+ }
66
70
67− function updateVisibility() {
71+ function updateVisibility() {
68− if (repeater.visibleIndicators === undefined) {
72+ if (repeater.visibleIndicators === undefined) {
69− repeater.visibleIndicators = {}
73+ repeater.visibleIndicators = {}
70− }
71− repeater.visibleIndicators[model.identifier] = enabled;
72− repeater.visibleIndicatorsChanged();
73 }
74 }
75+ repeater.visibleIndicators[model.identifier] = enabled;
76+ repeater.visibleIndicatorsChanged();
74 }
77 }
75 }
78 }
76 }
79 }
qml/Panel/MenuContent.qml+7−1
@@ -70,7 +70,7 @@ MainView {
70
70
71 Repeater {
71 Repeater {
72 id: repeater
72 id: repeater
73− model: indicatorsModel ? indicatorsModel : null
73+ model: content.indicatorsModel ? content.indicatorsModel : null
74 objectName: "tabsRepeater"
74 objectName: "tabsRepeater"
75
75
76 // FIXME: This is needed because tabs dont handle repeaters well.
76 // FIXME: This is needed because tabs dont handle repeaters well.
@@ -126,6 +126,12 @@ MainView {
126 property: "title"
126 property: "title"
127 value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
127 value: loader.item && loader.item.hasOwnProperty("title") && loader.item.title !== "" ? loader.item.title : model.identifier
128 }
128 }
129+
130+ Binding {
131+ target: loader.item
132+ property: "objectName"
133+ value: identifier + "-page"
134+ }
129 }
135 }
130 }
136 }
131 }
137 }
tests/mocks/Unity/Indicators/IndicatorsModel.qml+5−5
@@ -28,35 +28,35 @@ ListModel {
28 "position": 0,
28 "position": 0,
29 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
29 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
30 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
30 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
31− "indicatorProperties": ""
31+ "indicatorProperties": { enabled: true }
32 });
32 });
33
33
34 append({ "identifier": "indicator-fake2",
34 append({ "identifier": "indicator-fake2",
35 "position": 1,
35 "position": 1,
36 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
36 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
37 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
37 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
38− "indicatorProperties": ""
38+ "indicatorProperties": { enabled: true }
39 });
39 });
40
40
41 append({ "identifier": "indicator-fake3",
41 append({ "identifier": "indicator-fake3",
42 "position": 2,
42 "position": 2,
43 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
43 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
44 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
44 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
45− "indicatorProperties": ""
45+ "indicatorProperties": { enabled: true }
46 });
46 });
47
47
48 append({ "identifier": "indicator-fake4",
48 append({ "identifier": "indicator-fake4",
49 "position": 3,
49 "position": 3,
50 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
50 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
51 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
51 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
52− "indicatorProperties": ""
52+ "indicatorProperties": { enabled: true }
53 });
53 });
54
54
55 append({ "identifier": "indicator-fake5",
55 append({ "identifier": "indicator-fake5",
56 "position": 4,
56 "position": 4,
57 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
57 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
58 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
58 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
59− "indicatorProperties": ""
59+ "indicatorProperties": { enabled: true }
60 });
60 });
61 }
61 }
62}
62}
tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin1
21 id: menu_plugin1
22− objectName: "menu_page1"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin2
21 id: menu_plugin2
22− objectName: "menu_page2"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin3
21 id: menu_plugin3
22− objectName: "menu_page3"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin4
21 id: menu_plugin4
22− objectName: "menu_page4"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml−1
@@ -19,7 +19,6 @@ import Unity.Indicators 0.1 as Indicators
19
19
20Indicators.FakeMenuPage {
20Indicators.FakeMenuPage {
21 id: menu_plugin5
21 id: menu_plugin5
22− objectName: "menu_page5"
23
22
24 Rectangle {
23 Rectangle {
25 id: contents
24 id: contents
tests/qmltests/Panel/tst_IndicatorRow.qml+3−1
@@ -51,6 +51,8 @@ Item {
51 }
51 }
52
52
53 indicatorsModel: indicatorModel
53 indicatorsModel: indicatorModel
54+
55+ Component.onCompleted: indicatorModel.load()
54 }
56 }
55
57
56 Indicators.IndicatorsModel {
58 Indicators.IndicatorsModel {
@@ -122,7 +124,7 @@ Item {
122 indicatorRow.unitProgress = data.progress;
124 indicatorRow.unitProgress = data.progress;
123 indicatorRow.setCurrentItemIndex(data.index);
125 indicatorRow.setCurrentItemIndex(data.index);
124
126
125− compare(indicatorRow.currentItem.opacity, data.current, "Indicator opacity did not match for current item");
127+ tryCompare(indicatorRow.currentItem, "opacity", data.current);
126
128
127 for (var i = 0; i < indicatorRow.row.count; i++) {
129 for (var i = 0; i < indicatorRow.row.count; i++) {
128 tryCompare(get_indicator_item_at(i), "opacity", i === data.index ? data.current: data.other);
130 tryCompare(get_indicator_item_at(i), "opacity", i === data.index ? data.current: data.other);
tests/qmltests/Panel/tst_Indicators.qml+27−20
@@ -104,9 +104,11 @@ Item {
104
104
105 var indicatorRow = findChild(indicators, "indicatorRow")
105 var indicatorRow = findChild(indicators, "indicatorRow")
106 verify(indicatorRow !== undefined)
106 verify(indicatorRow !== undefined)
107+ var indicatorRowItems = findChild(indicatorRow, "indicatorRowItems");
108+ verify(indicatorRowItems !== undefined)
107
109
108− for (var i = 0; i < indicatorRow.row.count; i++) {
110+ for (var i = 0; i < indicatorRowItems.count; i++) {
109− var indicatorItem = findChild(indicatorRow.row, "item" + i);
111+ var indicatorItem = findChild(indicatorRowItems, "item" + i);
110
112
111 if (!indicatorItem.visible)
113 if (!indicatorItem.visible)
112 continue;
114 continue;
@@ -164,8 +166,8 @@ Item {
164 }
166 }
165
167
166 function init_invisible_indicator(identifier) {
168 function init_invisible_indicator(identifier) {
167− tryCompareFunction(function() { return findChild(indicators, identifier+"-widget") !== undefined }, true);
169+ tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
168− var item = findChild(indicators, identifier+"-widget");
170+ var item = findChild(indicators, identifier+"-delegate");
169
171
170 item.enabled = false;
172 item.enabled = false;
171 }
173 }
@@ -183,32 +185,36 @@ Item {
183 indicators.show();
185 indicators.show();
184
186
185 var indicatorTabs = findChild(indicators, "tabs");
187 var indicatorTabs = findChild(indicators, "tabs");
186− var indicatorRow = findChild(indicators, "indicatorRow");
188+ var indicatorRowItems = findChild(indicators, "indicatorRowItems");
187
189
188
190
191+ var count = data.visible.length
189 for (var i = 0; i< data.visible.length; i++) {
192 for (var i = 0; i< data.visible.length; i++) {
190− if (data.visible[i] === false)
193+ if (data.visible[i] === false) {
191 init_invisible_indicator("indicator-fake" + (i + 1));
194 init_invisible_indicator("indicator-fake" + (i + 1));
195+ count--;
196+ }
192 }
197 }
193
198
199+ tryCompare(indicatorRowItems, "count", count);
200+
194 for (i = 0; i < data.visible.length; i++) {
201 for (i = 0; i < data.visible.length; i++) {
195− var shouldBeVisible = data.visible[i];
202+ var widgetName = "indicator-fake" + (i + 1 + "-widget");
203+ var pageName = "indicator-fake" + (i + 1 + "-page");
196
204
197− // check item visibility
205+ // check for item
198− var indicatorItem = findChild(indicatorRow.row, "item" + i);
206+ tryCompareFunction(function() { return findChild(indicatorRowItems, widgetName) !== undefined }, data.visible[i]);
199− verify(indicatorItem !== undefined);
200− tryCompare(indicatorItem, "visible", shouldBeVisible);
201
207
202− // check tab visibility
208+ // check for tab
203− tryCompareFunction(function() { return findChild(indicatorTabs, "indicator-fake" + (i + 1)) !== undefined }, shouldBeVisible);
209+ tryCompareFunction(function() { return findChild(indicatorTabs, pageName) !== undefined }, data.visible[i]);
204 }
210 }
205 }
211 }
206
212
207 function test_indicator_visible_correct_tabs_data() { return [
213 function test_indicator_visible_correct_tabs_data() { return [
208− {tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expected: 1 },
214+ {tag: "current-first", currentIndex: 0, visible: [false, true, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake2" },
209− {tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expected: 3 },
215+ {tag: "current-last", currentIndex: 4, visible: [true, true, true, true, false], expectedIndex: 3, expectedTab: "indicator-fake4" },
210− {tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expected: 0 },
216+ {tag: "after", currentIndex: 0, visible: [true, false, true, true, true], expectedIndex: 0, expectedTab: "indicator-fake1" },
211− {tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expected: 1 }];
217+ {tag: "before", currentIndex: 1, visible: [false, true, true, true, true], expectedIndex: 1, expectedTab: "indicator-fake2" }];
212 }
218 }
213
219
214 function test_indicator_visible_correct_tabs(data) {
220 function test_indicator_visible_correct_tabs(data) {
@@ -221,15 +227,16 @@ Item {
221 tryCompare(indicators, "fullyOpened", true);
227 tryCompare(indicators, "fullyOpened", true);
222
228
223 for (var i = 0; i< data.visible.length; i++) {
229 for (var i = 0; i< data.visible.length; i++) {
224− if (data.visible[i] === false)
230+ if (data.visible[i] === false) {
225 init_invisible_indicator("indicator-fake" + (i + 1));
231 init_invisible_indicator("indicator-fake" + (i + 1));
232+ }
226 }
233 }
227
234
228 // check for current selected item
235 // check for current selected item
229− tryCompare(indicatorRow, "currentItemIndex", data.expected);
236+ tryCompare(indicatorRow, "currentItemIndex", data.expectedIndex);
230
237
231 // check for current selected tab
238 // check for current selected tab
232− tryCompareFunction(function() { return findChild(indicatorTabs, "indicator-fake" + (data.expected + 1)) === indicatorTabs.selectedTab }, true);
239+ tryCompareFunction(function() { return findChild(indicatorTabs, data.expectedTab) === indicatorTabs.selectedTab }, true);
233
240
234 }
241 }
235 }
242 }
tests/qmltests/Panel/tst_MenuContent.qml+6−14
@@ -27,11 +27,11 @@ Item {
27 height: units.gu(70)
27 height: units.gu(70)
28
28
29 property var indicator_status: {
29 property var indicator_status: {
30− 'menu_page1': { 'started': false, 'reset': 0 },
30+ 'indicator-fake1-page': { 'started': false, 'reset': 0 },
31− 'menu_page2': { 'started': false, 'reset': 0 },
31+ 'indicator-fake2-page': { 'started': false, 'reset': 0 },
32− 'menu_page3': { 'started': false, 'reset': 0 },
32+ 'indicator-fake3-page': { 'started': false, 'reset': 0 },
33− 'menu_page4': { 'started': false, 'reset': 0 },
33+ 'indicator-fake4-page': { 'started': false, 'reset': 0 },
34− 'menu_page5': { 'started': false, 'reset': 0 }
34+ 'indicator-fake5-page': { 'started': false, 'reset': 0 }
35 }
35 }
36
36
37 // Dummy objects
37 // Dummy objects
@@ -49,14 +49,6 @@ Item {
49 indicatorsModel: indicatorsModel
49 indicatorsModel: indicatorsModel
50 contentReleaseInterval: 50
50 contentReleaseInterval: 50
51 height: parent.height - 50
51 height: parent.height - 50
52−
53− visibleIndicators: {
54− 'indicator-fake1': true,
55− 'indicator-fake2': true,
56− 'indicator-fake3': true,
57− 'indicator-fake4': true,
58− 'indicator-fake5': true
59− }
60 }
52 }
61
53
62 Rectangle {
54 Rectangle {
@@ -96,7 +88,7 @@ Item {
96 }
88 }
97
89
98 function get_test_menu_objecName(index) {
90 function get_test_menu_objecName(index) {
99− return "menu_page"+(index+1);
91+ return "indicator-fake" + (index + 1) + "-page";
100 }
92 }
101
93
102 property string testTabObjectName : ""
94 property string testTabObjectName : ""