on xenial help sign in
more fixes to tests
commit93272507bd0d38b280c2523d69c8af28a48b18da authorNick Dedekind <nick.dedekind@canonical.com> dateWed 1 Oct 2014, 20:59 (12 years ago) parentbb1ad2e
8 files changed+46−218
qml/Panel/IndicatorItem.qml+9−9 qml/Panel/IndicatorItemRow.qml+2−1 qml/Panel/Indicators/DefaultIndicatorWidget.qml−119 tests/qmltests/CMakeLists.txt−1 tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml+15−18 tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml−59 tests/qmltests/Panel/tst_IndicatorItem.qml+17−8 tests/qmltests/Panel/tst_IndicatorsBar.qml+3−3
qml/Panel/IndicatorItem.qml+9−9
@@ -91,13 +91,6 @@ IndicatorDelegate {
9191 verticalCenter: parent.verticalCenter
9292 }
9393
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−
10194 Row {
10295 id: iconRow
10396 anchors.centerIn: iconsItem
@@ -111,11 +104,19 @@ IndicatorDelegate {
111104
112105 StatusIcon {
113106 id: itemImage
107+ objectName: "icon"+index
114108 height: iconHeight
115109 source: modelData
116110 sets: ["status", "actions"]
117111 color: root.color
118112 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 } }
119120 }
120121 }
121122 }
@@ -230,13 +231,12 @@ IndicatorDelegate {
230231 transitions: [
231232 Transition {
232233 PropertyAction { target: d; property: "useFallbackIcon" }
233− PropertyAction { target: iconsItem; property: "opacity" }
234234 AnchorAnimation {
235235 targets: [ mainItems, iconsItem, leftLabelItem, rightLabelItem ]
236236 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
237237 }
238238 PropertyAnimation {
239− targets: [ root, mainItems, leftLabelItem, rightLabelItem, indicatorName ]
239+ targets: [ root, mainItems, iconsItem, leftLabelItem, rightLabelItem, indicatorName ]
240240 properties: "width, opacity, anchors.verticalCenterOffset";
241241 duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
242242 }
qml/Panel/IndicatorItemRow.qml+2−1
@@ -181,6 +181,7 @@ Item {
181181
182182 width: currentItem ? currentItem.width : 0
183183 Behavior on width {
184+ enabled: !d.firstItemSwitch && expanded
184185 UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration; easing: UbuntuAnimation.StandardEasing }
185186 }
186187
@@ -209,7 +210,7 @@ Item {
209210 return shiftPercentageOffset * units.gu(1);
210211 }
211212 Behavior on highlightCenterOffset {
212− SmoothedAnimation { duration:UbuntuAnimation.FastDuration; velocity: 50; easing: UbuntuAnimation.StandardEasin }
213+ SmoothedAnimation { duration:UbuntuAnimation.FastDuration; velocity: 50; easing: UbuntuAnimation.StandardEasing }
213214 }
214215
215216 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_
7474add_qml_test(Panel IndicatorsBar ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7575add_qml_test(Panel IndicatorsMenu ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7676add_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")
7877add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
7978# These MenuItemFactory tests need the test/mocks/ to come before plugins/
8079add_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 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20−import QMenuModel 0.1
20+import Unity.Indicators 0.1 as Indicators
2121import "../../../../qml/Panel/Indicators"
2222
2323Item {
@@ -27,16 +27,12 @@ Item {
2727
2828 DefaultIndicatorPage {
2929 id: page
30−
3130 anchors.fill: parent
3231
33− menuModel: UnityMenuModel {}
34− busName: "test"
35− actionsObjectPath: "test"
36− menuObjectPath: "test"
37−
3832 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"
4036 }
4137
4238 property var fullMenuData: [{
@@ -113,29 +109,30 @@ Item {
113109 "submenu": []
114110 }]; // end row 1
115111
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+
116119 UT.UnityTestCase {
117120 name: "DefaultIndicatorPage"
118121
119122 function init() {
120− var mainMenu = findChild(page, "mainMenu");
121− page.menuModel.modelData = [];
122− verify(mainMenu.model !== null);
123+ initMenuData([]);
123124 }
124125
125126 function test_reloadData() {
126127 var mainMenu = findChild(page, "mainMenu");
127128
128− page.menuModel.modelData = [];
129129 tryCompare(mainMenu, "count", 0);
130130
131− page.menuModel.modelData = fullMenuData;
131+ initMenuData(fullMenuData);
132132 tryCompare(mainMenu, "count", 3);
133133
134− page.menuModel.modelData = [];
134+ initMenuData([]);
135135 tryCompare(mainMenu, "count", 0);
136−
137− page.menuModel.modelData = fullMenuData;
138− tryCompare(mainMenu, "count", 3);
139136 }
140137
141138 function test_traverse_rootMenuType_data() {
@@ -147,7 +144,7 @@ Item {
147144
148145 function test_traverse_rootMenuType(data) {
149146 page.rootMenuType = data.rootMenuType;
150− page.menuModel.modelData = fullMenuData;
147+ initMenuData(fullMenuData);
151148
152149 var mainMenu = findChild(page, "mainMenu");
153150 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 {
127127 indicatorItem.selected = false;
128128 indicatorItem.expanded = false;
129129 indicatorItem.rootActionState.title = "Test Title";
130− indicatorItem.rootActionState.leftLabel = "TestRightLabel";
130+ indicatorItem.rootActionState.leftLabel = "TestLeftLabel";
131131 indicatorItem.rootActionState.rightLabel = "TestRightLabel";
132132 indicatorItem.rootActionState.icons = [ "image://theme/audio-volume-high" ];
133133
@@ -148,7 +148,7 @@ Rectangle {
148148 compare(findChild(indicatorItem, "indicatorName").opacity, 0.0);
149149 }
150150
151− function test_expandcon() {
151+ function test_expandIcon() {
152152 indicatorItem.expanded = true;
153153
154154 tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
@@ -181,16 +181,25 @@ Rectangle {
181181 }
182182
183183 function test_select() {
184− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
185− tryCompare(findChild(indicatorItem, "rightLabel"), "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");
187+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#ededed");
188+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#ededed");
186189
187190 indicatorItem.expanded = true;
188− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.selected.backgroundText);
189− tryCompare(findChild(indicatorItem, "rightLabel"), "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");
194+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#4c4c4c");
195+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#4c4c4c");
190196
191197 indicatorItem.selected = true;
192− tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
193− tryCompare(findChild(indicatorItem, "rightLabel"), "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");
201+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", "#ededed");
202+ tryCompare(findChild(indicatorItem, "indicatorName"), "color", "#ededed");
194203 }
195204 }
196205}
tests/qmltests/Panel/tst_IndicatorsBar.qml+3−3
@@ -128,9 +128,7 @@ IndicatorTest {
128128
129129 indicatorsBar.selectItemAt(mappedPosition.x);
130130 indicatorsBar.expanded = true;
131−
132− // wait for animations to finish
133− tryCompare(heightAnimation, "running", false);
131+ wait_for_expansion_to_settle();
134132
135133 var mappedRect = indicatorsBar.mapFromItem(dataItem, 0, 0, dataItem.width, dataItem.height);
136134
@@ -141,6 +139,8 @@ IndicatorTest {
141139
142140 function test_scrollOffset() {
143141 indicatorsBar.expanded = true;
142+ wait_for_expansion_to_settle();
143+
144144 var dataItem = findChild(indicatorsBar, indicatorsModel.originalModelData[indicatorsModel.originalModelData.length-1]["identifier"]+"-panelItem");
145145 verify(dataItem !== null);
146146