on xenial help sign in
fixed qmltests
commit8f2ddc574ec04d52b82b7fa25e5c6bb826de205e authorNick Dedekind <nick.dedekind@canonical.com> dateTue 30 Sep 2014, 19:28 (12 years ago) parent96bb7e5
12 files changed+441−14
qml/Panel/Indicators/client/IndicatorsTree.qml+1−3 tests/qmltests/Panel/IndicatorTest.qml+1−1 tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml+1−1 tests/qmltests/Panel/tst_ActiveCallHint.qml−1 tests/qmltests/Panel/tst_IndicatorItem.qml+196 tests/qmltests/Panel/tst_IndicatorItemRow.qml+1−1 tests/qmltests/Panel/tst_IndicatorsBar.qml+1−1 tests/qmltests/Panel/tst_IndicatorsMenu.qml+1−1 tests/qmltests/Panel/tst_MenuContent.qml+1−2 tests/qmltests/Panel/tst_Panel.qml+236 tests/qmltests/Panel/tst_SearchIndicator.qml−1 tests/qmltests/tst_Shell.qml+2−2
qml/Panel/Indicators/client/IndicatorsTree.qml+1−3
@@ -31,8 +31,6 @@ Page {
3131 property string actionsObjectPath
3232 property string menuObjectPath
3333
34− property string deviceMenuObjectPath: menuObjectPath
35−
3634 function start() {
3735 }
3836
@@ -40,7 +38,7 @@ Page {
4038 id: unityModel
4139 busName: page.busName
4240 actions: { "indicator": page.actionsObjectPath }
43− menuObjectPath: page.deviceMenuObjectPath
41+ menuObjectPath: page.menuObjectPath
4442 }
4543
4644 Indicators.RootActionState {
tests/qmltests/Panel/IndicatorTest.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.1
1818import QtQuick.Layouts 1.1
1919import QtTest 1.0
20−import "../../../../qml/Panel"
20+import "../../../qml/Panel"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1 as UT
2323import Unity.Indicators 0.1 as Indicators
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml+1−1
@@ -36,7 +36,7 @@ Item {
3636 menuModel: UnityMenuModel {}
3737 busName: "test"
3838 actionsObjectPath: "test"
39− deviceMenuObjectPath: "test"
39+ menuObjectPath: "test"
4040
4141 rootMenuType: ""
4242
tests/qmltests/Panel/tst_ActiveCallHint.qml−1
@@ -19,7 +19,6 @@ import QtTest 1.0
1919import Unity.Test 0.1 as UT
2020import Ubuntu.Telephony 0.1 as Telephony
2121import Unity.Application 0.1
22−import ".."
2322import "../../../qml/Panel"
2423
2524Item {
tests/qmltests/Panel/tst_IndicatorItem.qmlnew file+196
@@ -0,0 +1,196 @@
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.1
18+import QtQuick.Layouts 1.1
19+import QtTest 1.0
20+import Ubuntu.Components 0.1
21+import Unity.Test 0.1 as UT
22+import "../../../qml/Panel"
23+
24+Rectangle {
25+ width: units.gu(80)
26+ height: units.gu(30)
27+ color: "white"
28+
29+ RowLayout {
30+ anchors.fill: parent
31+ anchors.margins: units.gu(1)
32+
33+ Rectangle {
34+ id: itemArea
35+ color: "blue"
36+ Layout.fillWidth: true
37+ Layout.fillHeight: true
38+
39+ Rectangle {
40+ color: "black"
41+ anchors.fill: indicatorItem
42+ }
43+
44+ IndicatorItem {
45+ id: indicatorItem
46+ height: expanded ? units.gu(7) : units.gu(3)
47+ anchors.centerIn: parent
48+ identifier: "indicator-test"
49+
50+ rootActionState {
51+ title: titleLabel.text
52+ leftLabel : leftLabel.text
53+ rightLabel : rightLabel.text
54+ icons : {
55+ var icons = [];
56+ var i = 0;
57+ if (iconEnabled.checked) {
58+ for (i = 0; i < String(iconCount.text); i++) {
59+ icons.push("image://theme/audio-volume-high");
60+ }
61+ }
62+ return icons;
63+ }
64+ }
65+
66+ Behavior on height {
67+ NumberAnimation {
68+ id: heightAnimation
69+ duration: UbuntuAnimation.SnapDuration; easing: UbuntuAnimation.StandardEasing
70+ }
71+ }
72+ }
73+ }
74+
75+ ColumnLayout {
76+ Layout.alignment: Qt.AlignTop
77+ Layout.fillWidth: false
78+
79+ Button {
80+ id: expandButton
81+ Layout.fillWidth: true
82+ text: indicatorItem.expanded ? "Collapse" : "Expand"
83+ onClicked: indicatorItem.expanded = !indicatorItem.expanded
84+ }
85+
86+ Button {
87+ id: selectButton
88+ Layout.fillWidth: true
89+ text: indicatorItem.selected ? "Unselect" : "Select"
90+ onClicked: indicatorItem.selected = !indicatorItem.selected
91+ }
92+
93+ Rectangle {
94+ Layout.preferredHeight: units.dp(1);
95+ Layout.fillWidth: true;
96+ color: "black"
97+ }
98+
99+ RowLayout {
100+ CheckBox { id: iconEnabled; checked: true }
101+ Label { text: "icons Count:" }
102+ TextField { id: iconCount; text: "1"; enabled: iconEnabled.checked }
103+ }
104+
105+ RowLayout {
106+ Label { text: "Left Label:" }
107+ TextField { id: leftLabel; text: "Left"}
108+ }
109+
110+ RowLayout {
111+ Label { text: "Right Label:" }
112+ TextField { id: rightLabel; text: "Right"}
113+ }
114+
115+ RowLayout {
116+ Label { text: "Title:" }
117+ TextField { id: titleLabel; text: "Title"}
118+ }
119+ }
120+ }
121+
122+ UT.UnityTestCase {
123+ name: "IndicatorItem"
124+ when: windowShown
125+
126+ function init() {
127+ indicatorItem.selected = false;
128+ indicatorItem.expanded = false;
129+ indicatorItem.rootActionState.title = "Test Title";
130+ indicatorItem.rootActionState.leftLabel = "TestRightLabel";
131+ indicatorItem.rootActionState.rightLabel = "TestRightLabel";
132+ indicatorItem.rootActionState.icons = [ "image://theme/audio-volume-high" ];
133+
134+ tryCompare(heightAnimation, "running", false);
135+ }
136+
137+ function test_expand() {
138+ indicatorItem.expanded = true;
139+ tryCompare(indicatorItem, "height", units.gu(7));
140+ indicatorItem.expanded = false;
141+ tryCompare(indicatorItem, "height", units.gu(3));
142+ }
143+
144+ function test_minimizedVisibility() {
145+ compare(findChild(indicatorItem, "leftLabel").opacity, 1.0);
146+ compare(findChild(indicatorItem, "rightLabel").opacity, 1.0);
147+ compare(findChild(indicatorItem, "icons").opacity, 1.0);
148+ compare(findChild(indicatorItem, "indicatorName").opacity, 0.0);
149+ }
150+
151+ function test_expandcon() {
152+ indicatorItem.expanded = true;
153+
154+ tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
155+ tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 0.0);
156+ tryCompare(findChild(indicatorItem, "icons"), "opacity", 1.0);
157+ tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
158+ }
159+
160+ function test_expandRightLabel() {
161+ indicatorItem.expanded = true;
162+
163+ indicatorItem.rootActionState.icons = [];
164+
165+ tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 0.0);
166+ tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 1.0);
167+ tryCompare(findChild(indicatorItem, "icons"), "opacity", 0.0);
168+ tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
169+ }
170+
171+ function test_expandLeftLabel() {
172+ indicatorItem.expanded = true;
173+
174+ indicatorItem.rootActionState.rightLabel = "";
175+ indicatorItem.rootActionState.icons = [];
176+
177+ tryCompare(findChild(indicatorItem, "rightLabel"), "opacity", 0.0);
178+ tryCompare(findChild(indicatorItem, "leftLabel"), "opacity", 1.0);
179+ tryCompare(findChild(indicatorItem, "icons"), "opacity", 0.0);
180+ tryCompare(findChild(indicatorItem, "indicatorName"), "opacity", 1.0);
181+ }
182+
183+ function test_select() {
184+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
185+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
186+
187+ indicatorItem.expanded = true;
188+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.selected.backgroundText);
189+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.selected.backgroundText);
190+
191+ indicatorItem.selected = true;
192+ tryCompare(findChild(indicatorItem, "leftLabel"), "color", Theme.palette.normal.foregroundText);
193+ tryCompare(findChild(indicatorItem, "rightLabel"), "color", Theme.palette.normal.foregroundText);
194+ }
195+ }
196+}
tests/qmltests/Panel/tst_IndicatorItemRow.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.1
1818import QtQuick.Layouts 1.1
1919import QtTest 1.0
20−import "../../../../qml/Panel"
20+import "../../../qml/Panel"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1 as UT
2323import Unity.Indicators 0.1 as Indicators
tests/qmltests/Panel/tst_IndicatorsBar.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.1
1818import QtQuick.Layouts 1.1
1919import QtTest 1.0
20−import "../../../../qml/Panel"
20+import "../../../qml/Panel"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1 as UT
2323import Unity.Indicators 0.1 as Indicators
tests/qmltests/Panel/tst_IndicatorsMenu.qml+1−1
@@ -17,7 +17,7 @@
1717import QtQuick 2.1
1818import QtQuick.Layouts 1.1
1919import QtTest 1.0
20−import "../../../../qml/Panel"
20+import "../../../qml/Panel"
2121import Ubuntu.Components 0.1
2222import Unity.Test 0.1 as UT
2323import Unity.Indicators 0.1 as Indicators
tests/qmltests/Panel/tst_MenuContent.qml+1−2
@@ -17,8 +17,7 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20−import ".."
21−import "../../../qml/Panel"
20+import "../../qml/Panel"
2221import Unity.Indicators 0.1 as Indicators
2322
2423Item {
tests/qmltests/Panel/tst_Panel.qmlnew file+236
@@ -0,0 +1,236 @@
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.1
18+import QtQuick.Layouts 1.1
19+import QtTest 1.0
20+import Unity.Test 0.1 as UT
21+import Ubuntu.Components 0.1
22+import Unity.Indicators 0.1 as Indicators
23+import Ubuntu.Telephony 0.1 as Telephony
24+import "../../../qml/Panel"
25+
26+IndicatorTest {
27+ id: root
28+ width: units.gu(100)
29+ height: units.gu(71)
30+ color: "white"
31+
32+ property string indicatorProfile: "phone"
33+
34+ RowLayout {
35+ anchors.fill: parent
36+ anchors.margins: units.gu(1)
37+ clip: true
38+
39+ Rectangle {
40+ Layout.fillWidth: true
41+ Layout.fillHeight: true
42+
43+ id: itemArea
44+ color: "blue"
45+
46+ Panel {
47+ id: panel
48+ anchors.fill: parent
49+ indicators {
50+ width: parent.width > units.gu(60) ? units.gu(40) : parent.width
51+ indicatorsModel: root.indicatorsModel
52+ }
53+
54+ property real panelAndSeparatorHeight: panel.indicators.minimizedPanelHeight + units.dp(2)
55+ }
56+ }
57+
58+ ColumnLayout {
59+ Layout.alignment: Qt.AlignTop
60+ Layout.fillWidth: false
61+
62+ Button {
63+ Layout.fillWidth: true
64+ text: panel.indicators.shown ? "Hide" : "Show"
65+ onClicked: {
66+ if (panel.indicators.shown) {
67+ panel.indicators.hide();
68+ } else {
69+ panel.indicators.show();
70+ }
71+ }
72+ }
73+
74+ Button {
75+ text: panel.fullscreenMode ? "Maximize" : "FullScreen"
76+ Layout.fillWidth: true
77+ onClicked: panel.fullscreenMode = !panel.fullscreenMode
78+ }
79+
80+ Button {
81+ Layout.fillWidth: true
82+ text: callManager.hasCalls ? "Called" : "No Calls"
83+ onClicked: {
84+ if (callManager.foregroundCall) {
85+ callManager.foregroundCall = null;
86+ } else {
87+ callManager.foregroundCall = phoneCall;
88+ }
89+ }
90+ }
91+
92+ Rectangle {
93+ Layout.preferredHeight: units.dp(1);
94+ Layout.fillWidth: true;
95+ color: "black"
96+ }
97+
98+ Repeater {
99+ model: indicatorsModel.originalModelData
100+ RowLayout {
101+ CheckBox {
102+ checked: true
103+ onCheckedChanged: checked ? insertIndicator(index) : removeIndicator(index);
104+ }
105+ Label { text: modelData["identifier"] }
106+ }
107+ }
108+ }
109+ }
110+
111+ Telephony.CallEntry {
112+ id: phoneCall
113+ phoneNumber: "+447812221111"
114+ }
115+
116+ UT.UnityTestCase {
117+ name: "Panel"
118+ when: windowShown
119+
120+ function init() {
121+ panel.fullscreenMode = false;
122+ callManager.foregroundCall = null;
123+
124+ panel.indicators.hide();
125+ // Wait for animation to complete
126+ tryCompare(panel.indicators.hideAnimation, "running", false);
127+
128+ // Wait for the indicators to get into position.
129+ // (switches between normal and fullscreen modes are animated)
130+ var indicatorArea = findChild(panel, "indicatorArea");
131+ tryCompare(indicatorArea, "y", 0);
132+ }
133+
134+ function get_indicator_item(index) {
135+ var indicatorItem = findChild(panel, indicatorsModel.originalModelData[index]["identifier"]+"-panelItem");
136+ verify(indicatorItem !== null);
137+
138+ return indicatorItem;
139+ }
140+
141+ function test_drag_show_data() {
142+ return [
143+ { tag: "pinned", fullscreen: false, call: null,
144+ indicatorY: 0 },
145+ { tag: "fullscreen", fullscreen: true, call: null,
146+ indicatorY: -panel.panelAndSeparatorHeight },
147+ { tag: "pinned-callActive", fullscreen: false, call: phoneCall,
148+ indicatorY: 0},
149+ { tag: "fullscreen-callActive", fullscreen: true, call: phoneCall,
150+ indicatorY: -panel.panelAndSeparatorHeight }
151+ ];
152+ }
153+
154+ // Dragging from a indicator item in the panel will gradually expose the
155+ // indicators, first by running the hint animation, then after dragging down will
156+ // expose more of the panel, binding it to the selected indicator and opening it's menu.
157+ function test_drag_show(data) {
158+ panel.fullscreenMode = data.fullscreen;
159+ callManager.foregroundCall = data.call;
160+
161+ var indicatorRow = findChild(panel.indicators, "indicatorItemRow");
162+ verify(indicatorRow !== null);
163+
164+ var menuContent = findChild(panel.indicators, "menuContent");
165+ verify(menuContent !== null);
166+
167+ var indicatorArea = findChild(panel, "indicatorArea");
168+ verify(indicatorArea !== null);
169+
170+ // Wait for the indicators to get into position.
171+ // (switches between normal and fullscreen modes are animated)
172+ tryCompareFunction(function() { return indicatorArea.y }, data.indicatorY);
173+
174+ for (var i = 0; i < indicatorsModel.originalModelData.length; i++) {
175+ var indicatorItem = get_indicator_item(i);
176+ var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width / 2, indicatorItem.height / 2);
177+
178+ touchFlick(panel,
179+ mappedPosition.x, panel.indicators.minimizedPanelHeight / 2,
180+ mappedPosition.x, panel.height,
181+ true /* beginTouch */, false /* endTouch */, units.gu(5), 15);
182+
183+ // Indicators height should follow the drag, and therefore increase accordingly.
184+ // They should be at least half-way through the screen
185+ tryCompareFunction(
186+ function() {return panel.indicators.height >= panel.height * 0.5},
187+ true);
188+
189+ touchRelease(panel, mappedPosition.x, panel.height);
190+
191+ compare(indicatorRow.currentItemIndex, i, "Indicator item should be activated at position " + i);
192+ compare(menuContent.currentMenuIndex, i, "Menu conetent should be activated for item at position " + i);
193+
194+ // init for next indicatorItem
195+ panel.indicators.hide();
196+ tryCompare(panel.indicators.hideAnimation, "running", false);
197+ tryCompare(panel.indicators, "state", "initial");
198+ }
199+ }
200+
201+ function test_hint_data() {
202+ return [
203+ { tag: "normal", fullscreen: false, call: null, hintExpected: true},
204+ { tag: "fullscreen", fullscreen: true, call: null, hintExpected: false},
205+ { tag: "call hint", fullscreen: false, call: phoneCall, hintExpected: false},
206+ ];
207+ }
208+
209+ function test_hint(data) {
210+ panel.fullscreenMode = data.fullscreen;
211+ callManager.foregroundCall = data.call;
212+
213+ if (data.fullscreen) {
214+ // Wait for the indicators to get into position.
215+ // (switches between normal and fullscreen modes are animated)
216+ var indicatorArea = findChild(panel, "indicatorArea");
217+ tryCompare(indicatorArea, "y", -panel.panelHeight);
218+ }
219+
220+ var indicatorItem = get_indicator_item(0);
221+ var mappedPosition = root.mapFromItem(indicatorItem, indicatorItem.width / 2, indicatorItem.height / 2);
222+
223+ touchPress(panel, mappedPosition.x, panel.indicators.minimizedPanelHeight / 2);
224+
225+ // Give some time for a hint animation to change things, if any
226+ wait(500);
227+
228+ // no hint animation when fullscreen
229+ compare(panel.indicators.fullyClosed, !data.hintExpected, "Indicator should be fully closed");
230+ compare(panel.indicators.partiallyOpened, data.hintExpected, "Indicator should be partialy opened");
231+ compare(panel.indicators.fullyOpened, false, "Indicator should not be fully opened");
232+
233+ touchRelease(panel, mappedPosition.x, panel.minimizedPanelHeight / 2);
234+ }
235+ }
236+}
tests/qmltests/Panel/tst_SearchIndicator.qml−1
@@ -16,7 +16,6 @@
1616
1717import QtQuick 2.0
1818import QtTest 1.0
19−import ".."
2019import "../../../qml/Panel"
2120import Ubuntu.Components 0.1
2221import Unity.Test 0.1 as UT
tests/qmltests/tst_Shell.qml+2−2
@@ -332,7 +332,7 @@ Row {
332332 var touchX = shell.width / 2;
333333 var indicators = findChild(shell, "indicators");
334334 touchFlick(indicators,
335− touchX /* fromX */, indicators.panelHeight * 0.5 /* fromY */,
335+ touchX /* fromX */, indicators.minimizedPanelHeight * 0.5 /* fromY */,
336336 touchX /* toX */, shell.height * 0.5 /* toY */,
337337 true /* beginTouch */, false /* endTouch */);
338338 verify(indicators.partiallyOpened);
@@ -369,7 +369,7 @@ Row {
369369 var indicators = findChild(shell, "indicators");
370370
371371 var touchStartX = shell.width / 2;
372− var touchStartY = shell.height - (indicators.panelHeight * 0.5);
372+ var touchStartY = shell.height - (indicators.minimizedPanelHeight * 0.5);
373373 touchFlick(shell,
374374 touchStartX, touchStartY,
375375 touchStartX, shell.height * 0.1);