on xenial help sign in
more fixes to tests
9327250Nick Dedekind
qml/Panel/IndicatorItem.qml+9−9
@@ -91,13 +91,6 @@ IndicatorDelegate {
91 verticalCenter: parent.verticalCenter
91 verticalCenter: parent.verticalCenter
92 }
92 }
93
93
94− opacity: {
95− if (!expanded) return 1.0;
96− if (!selected) return 0.6;
97− return 1.0;
98− }
99− Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
100−
101 Row {
94 Row {
102 id: iconRow
95 id: iconRow
103 anchors.centerIn: iconsItem
96 anchors.centerIn: iconsItem
@@ -111,11 +104,19 @@ IndicatorDelegate {
111
104
112 StatusIcon {
105 StatusIcon {
113 id: itemImage
106 id: itemImage
107+ objectName: "icon"+index
114 height: iconHeight
108 height: iconHeight
115 source: modelData
109 source: modelData
116 sets: ["status", "actions"]
110 sets: ["status", "actions"]
117 color: root.color
111 color: root.color
118 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
112 Behavior on color { ColorAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
113+
114+ opacity: {
115+ if (!expanded) return 1.0;
116+ if (!selected) return 0.6;
117+ return 1.0;
118+ }
119+ Behavior on opacity { NumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing } }
119 }
120 }
120 }
121 }
121 }
122 }
@@ -230,13 +231,12 @@ IndicatorDelegate {
230 transitions: [
231 transitions: [
231 Transition {
232 Transition {
232 PropertyAction { target: d; property: "useFallbackIcon" }
233 PropertyAction { target: d; property: "useFallbackIcon" }
233− PropertyAction { target: iconsItem; property: "opacity" }
234 AnchorAnimation {
234 AnchorAnimation {
235 targets: [ mainItems, iconsItem, leftLabelItem, rightLabelItem ]
235 targets: [ mainItems, iconsItem, leftLabelItem, rightLabelItem ]
236 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
236 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
237 }
237 }
238 PropertyAnimation {
238 PropertyAnimation {
239− targets: [ root, mainItems, leftLabelItem, rightLabelItem, indicatorName ]
239+ targets: [ root, mainItems, iconsItem, leftLabelItem, rightLabelItem, indicatorName ]
240 properties: "width, opacity, anchors.verticalCenterOffset";
240 properties: "width, opacity, anchors.verticalCenterOffset";
241 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
241 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
242 }
242 }
qml/Panel/IndicatorItemRow.qml+2−1
@@ -181,6 +181,7 @@ Item {
181
181
182 width: currentItem ? currentItem.width : 0
182 width: currentItem ? currentItem.width : 0
183 Behavior on width {
183 Behavior on width {
184+ enabled: !d.firstItemSwitch && expanded
184 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
185 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
185 }
186 }
186
187
@@ -209,7 +210,7 @@ Item {
209 return shiftPercentageOffset * units.gu(1);
210 return shiftPercentageOffset * units.gu(1);
210 }
211 }
211 Behavior on highlightCenterOffset {
212 Behavior on highlightCenterOffset {
212− SmoothedAnimation { duration:UbuntuAnimation.FastDuration; velocity: 50; easing: UbuntuAnimation.StandardEasin }
213+ SmoothedAnimation { duration:UbuntuAnimation.FastDuration; velocity: 50; easing: UbuntuAnimation.StandardEasing }
213 }
214 }
214
215
215 property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
216 property real currentItemX: currentItem ? currentItem.x : 0 // having Behavior
qml/Panel/Indicators/DefaultIndicatorWidget.qmldeleted−119
@@ -1,119 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU Lesser General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU Lesser General Public License for more details.
12− *
13− * You should have received a copy of the GNU Lesser General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Authors:
17− * Nick Dedekind <nick.dedekind@canonical.com>
18− */
19−
20−import QtQuick 2.0
21−import Ubuntu.Components 0.1
22−import Ubuntu.Settings.Components 0.1
23−
24−IndicatorBase {
25− id: indicatorWidget
26−
27− property int iconSize: units.gu(2)
28− property alias leftLabel: itemLeftLabel.text
29− property alias rightLabel: itemRightLabel.text
30− property var icons: undefined
31−
32− width: itemRow.width
33− enabled: false
34−
35− // FIXME: For now we will enable led indicator support only for messaging indicator
36− // in the future we should export a led API insted of doing that,
37− Loader {
38− id: indicatorLed
39− // only load source Component if the icons contains the new message icon
40− source: (indicatorWidget.icons && (String(indicatorWidget.icons).indexOf("indicator-messages-new") != -1)) ? Qt.resolvedUrl("IndicatorsLight.qml") : ""
41− }
42−
43− Row {
44− id: itemRow
45− objectName: "itemRow"
46− anchors {
47− top: parent.top
48− bottom: parent.bottom
49− horizontalCenter: parent.horizontalCenter
50− }
51−
52− Label {
53− id: itemLeftLabel
54− width: contentWidth + units.gu(1)
55− objectName: "leftLabel"
56− color: Theme.palette.selected.backgroundText
57− opacity: 0.8
58− font.family: "Ubuntu"
59− fontSize: "medium"
60− anchors.verticalCenter: parent.verticalCenter
61− visible: text != ""
62− horizontalAlignment: Text.AlignHCenter
63− }
64−
65− Row {
66− id: iconRow
67− anchors {
68− top: parent.top
69− bottom: parent.bottom
70− }
71−
72− Repeater {
73− model: indicatorWidget.icons
74−
75− Item {
76− width: itemImage.width + units.gu(1)
77− height: iconRow.height
78−
79− StatusIcon {
80− id: itemImage
81− height: indicatorWidget.iconSize
82− anchors.centerIn: parent
83− source: modelData
84− sets: ["status", "actions"]
85− color: "#CCCCCC"
86− }
87− }
88− }
89− }
90−
91− Label {
92− id: itemRightLabel
93− width: contentWidth + units.gu(1)
94− objectName: "rightLabel"
95− color: Theme.palette.selected.backgroundText
96− opacity: 0.8
97− font.family: "Ubuntu"
98− fontSize: "medium"
99− anchors.verticalCenter: parent.verticalCenter
100− visible: text != ""
101− horizontalAlignment: Text.AlignHCenter
102− }
103− }
104−
105− onRootActionStateChanged: {
106− if (rootActionState == undefined) {
107− leftLabel = "";
108− rightLabel = "";
109− icons = undefined;
110− enabled = false;
111− return;
112− }
113−
114− leftLabel = rootActionState.leftLabel ? rootActionState.leftLabel : "";
115− rightLabel = rootActionState.rightLabel ? rootActionState.rightLabel : "";
116− icons = rootActionState.icons;
117− enabled = rootActionState.visible;
118− }
119−}
tests/qmltests/CMakeLists.txt−1
@@ -74,7 +74,6 @@ add_qml_test(Panel IndicatorItemRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_
74add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
74add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
75add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
75add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
76add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
76add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77−add_qml_test(Panel/Indicators DefaultIndicatorWidget ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
78add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
79# These MenuItemFactory tests need the test/mocks/ to come before plugins/
78# These MenuItemFactory tests need the test/mocks/ to come before plugins/
80add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
79add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml+15−18
@@ -17,7 +17,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
19import Unity.Test 0.1 as UT
20−import QMenuModel 0.1
20+import Unity.Indicators 0.1 as Indicators
21import "../../../../qml/Panel/Indicators"
21import "../../../../qml/Panel/Indicators"
22
22
23Item {
23Item {
@@ -27,16 +27,12 @@ Item {
27
27
28 DefaultIndicatorPage {
28 DefaultIndicatorPage {
29 id: page
29 id: page
30−
31 anchors.fill: parent
30 anchors.fill: parent
32
31
33− menuModel: UnityMenuModel {}
34− busName: "test"
35− actionsObjectPath: "test"
36− menuObjectPath: "test"
37−
38 identifier: "test-indicator"
32 identifier: "test-indicator"
39− rootMenuType: "com.canonical.indicator.root"
33+ busName: "com.caninical.indicator.test"
34+ actionsObjectPath: "/com/canonical/indicator/test"
35+ menuObjectPath: "/com/canonical/indicator/test"
40 }
36 }
41
37
42 property var fullMenuData: [{
38 property var fullMenuData: [{
@@ -113,29 +109,30 @@ Item {
113 "submenu": []
109 "submenu": []
114 }]; // end row 1
110 }]; // end row 1
115
111
112+ function initMenuData(data) {
113+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.test",
114+ "/com/canonical/indicator/test",
115+ "/com/canonical/indicator/test",
116+ data);
117+ }
118+
116 UT.UnityTestCase {
119 UT.UnityTestCase {
117 name: "DefaultIndicatorPage"
120 name: "DefaultIndicatorPage"
118
121
119 function init() {
122 function init() {
120− var mainMenu = findChild(page, "mainMenu");
123+ initMenuData([]);
121− page.menuModel.modelData = [];
122− verify(mainMenu.model !== null);
123 }
124 }
124
125
125 function test_reloadData() {
126 function test_reloadData() {
126 var mainMenu = findChild(page, "mainMenu");
127 var mainMenu = findChild(page, "mainMenu");
127
128
128− page.menuModel.modelData = [];
129 tryCompare(mainMenu, "count", 0);
129 tryCompare(mainMenu, "count", 0);
130
130
131− page.menuModel.modelData = fullMenuData;
131+ initMenuData(fullMenuData);
132 tryCompare(mainMenu, "count", 3);
132 tryCompare(mainMenu, "count", 3);
133
133
134− page.menuModel.modelData = [];
134+ initMenuData([]);
135 tryCompare(mainMenu, "count", 0);
135 tryCompare(mainMenu, "count", 0);
136−
137− page.menuModel.modelData = fullMenuData;
138− tryCompare(mainMenu, "count", 3);
139 }
136 }
140
137
141 function test_traverse_rootMenuType_data() {
138 function test_traverse_rootMenuType_data() {
@@ -147,7 +144,7 @@ Item {
147
144
148 function test_traverse_rootMenuType(data) {
145 function test_traverse_rootMenuType(data) {
149 page.rootMenuType = data.rootMenuType;
146 page.rootMenuType = data.rootMenuType;
150− page.menuModel.modelData = fullMenuData;
147+ initMenuData(fullMenuData);
151
148
152 var mainMenu = findChild(page, "mainMenu");
149 var mainMenu = findChild(page, "mainMenu");
153 tryCompare(mainMenu, "count", data.expectedCount);
150 tryCompare(mainMenu, "count", data.expectedCount);
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qmldeleted−59
@@ -1,59 +0,0 @@
1−/*
2− * Copyright 2013 Canonical Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import Unity.Test 0.1 as UT
20−import QMenuModel 0.1
21−import "../../../../qml/Panel/Indicators"
22−
23−Item {
24− id: testView
25− width: units.gu(40)
26− height: units.gu(70)
27−
28− DefaultIndicatorWidget {
29− id: widget
30−
31− anchors {
32− left: parent.left
33− top: parent.top
34− }
35−
36− busName: "test"
37− actionsObjectPath: "test"
38− menuObjectPath: "test"
39−
40− rootMenuType: ""
41−
42− iconSize: units.gu(3.2)
43− height: units.gu(3)
44− }
45−
46− UT.UnityTestCase {
47− name: "DefaultIndicatorWidget"
48− when: windowShown
49−
50− function init() {
51− widget.rootActionState.icons = [];
52− widget.rootActionState.leftLabel = "";
53− widget.rootActionState.rightLabel = "";
54− waitForRendering(widget)
55− }
56−
57− // FIXME: add tests
58− }
59−}
tests/qmltests/Panel/tst_IndicatorItem.qml+17−8
@@ -127,7 +127,7 @@ Rectangle {
127 indicatorItem.selected = false;
127 indicatorItem.selected = false;
128 indicatorItem.expanded = false;
128 indicatorItem.expanded = false;
129 indicatorItem.rootActionState.title = "Test Title";
129 indicatorItem.rootActionState.title = "Test Title";
130− indicatorItem.rootActionState.leftLabel = "TestRightLabel";
130+ indicatorItem.rootActionState.leftLabel = "TestLeftLabel";
131 indicatorItem.rootActionState.rightLabel = "TestRightLabel";
131 indicatorItem.rootActionState.rightLabel = "TestRightLabel";
132 indicatorItem.rootActionState.icons = [ "image://theme/audio-volume-high" ];
132 indicatorItem.rootActionState.icons = [ "image://theme/audio-volume-high" ];
133
133
@@ -148,7 +148,7 @@ Rectangle {
148 compare(findChild(indicatorItem, "indicatorName").opacity, 0.0);
148 compare(findChild(indicatorItem, "indicatorName").opacity, 0.0);
149 }
149 }
150
150
151− function test_expandcon() {
151+ function test_expandIcon() {
152 indicatorItem.expanded = true;
152 indicatorItem.expanded = true;
153
153
154 tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
154 tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
@@ -181,16 +181,25 @@ Rectangle {
181 }
181 }
182
182
183 function test_select() {
183 function test_select() {
184− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
184+ tryCompare(findChild(indicatorItem, "icon0"), "color", "#ededed");
185+ tryCompare(findChild(indicatorItem, "icon0"), "opacity", 1.0);
186+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", "#ededed");
185− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
187+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#ededed");
188+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#ededed");
186
189
187 indicatorItem.expanded = true;
190 indicatorItem.expanded = true;
188− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.selected.backgroundText);
191+ tryCompare(findChild(indicatorItem, "icon0"), "color", "#4c4c4c");
192+ tryCompare(findChild(indicatorItem, "icon0"), "opacity", 0.6);
193+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", "#4c4c4c");
189− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.selected.backgroundText);
194+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#4c4c4c");
195+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#4c4c4c");
190
196
191 indicatorItem.selected = true;
197 indicatorItem.selected = true;
192− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
198+ tryCompare(findChild(indicatorItem, "icon0"), "color", "#ededed");
199+ tryCompare(findChild(indicatorItem, "icon0"), "opacity", 1.0);
200+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", "#ededed");
193− tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
201+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#ededed");
202+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#ededed");
194 }
203 }
195 }
204 }
196}
205}
tests/qmltests/Panel/tst_IndicatorsBar.qml+3−3
@@ -128,9 +128,7 @@ IndicatorTest {
128
128
129 indicatorsBar.selectItemAt(mappedPosition.x);
129 indicatorsBar.selectItemAt(mappedPosition.x);
130 indicatorsBar.expanded = true;
130 indicatorsBar.expanded = true;
131−
131+ wait_for_expansion_to_settle();
132− // wait for animations to finish
133− tryCompare(heightAnimation, "running", false);
134
132
135 var mappedRect = indicatorsBar.mapFromItem(dataItem, 0, 0, dataItem.width, dataItem.height);
133 var mappedRect = indicatorsBar.mapFromItem(dataItem, 0, 0, dataItem.width, dataItem.height);
136
134
@@ -141,6 +139,8 @@ IndicatorTest {
141
139
142 function test_scrollOffset() {
140 function test_scrollOffset() {
143 indicatorsBar.expanded = true;
141 indicatorsBar.expanded = true;
142+ wait_for_expansion_to_settle();
143+
144 var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[indicatorsModel.originalModelData.length-1]["identifier"]+"-panelItem");
144 var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[indicatorsModel.originalModelData.length-1]["identifier"]+"-panelItem");
145 verify(dataItem !== null);
145 verify(dataItem !== null);
146
146