on xenial help sign in
moved tests for surface container to separate files
commit2276543067becb6af5a22f8fb0f2dbb2b7af4af6 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 13 Aug 2014, 12:56 (12 years ago) parent2917119
4 files changed+222−128
tests/qmltests/CMakeLists.txt+2 tests/qmltests/Stages/tst_AppSurfaceContainer.qml+101 tests/qmltests/Stages/tst_SurfaceContainer.qml+119 tests/qmltests/tst_Shell.qml−128
tests/qmltests/CMakeLists.txt+2
@@ -75,3 +75,5 @@ add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=
7575add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
7676add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
7777add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
78+add_qml_test(Stages SurfaceContainer)
79+add_qml_test(Stages AppSurfaceContainer)
tests/qmltests/Stages/tst_AppSurfaceContainer.qmlnew file+101
@@ -0,0 +1,101 @@
1+/*
2+ * Copyright 2014 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 Unity.Application 0.1
21+import "../../../qml/Stages"
22+
23+Item {
24+ id: shell
25+ width: units.gu(40)
26+ height: units.gu(80)
27+
28+ Repeater {
29+ anchors.fill: parent
30+ model: ApplicationManager
31+
32+ delegate: AppSurfaceContainer {
33+ id: container
34+ anchors.fill: parent
35+ objectName: application.appId
36+
37+ surface: model.surface
38+ promptSurfaces: model.application.promptSurfaces
39+ }
40+ }
41+
42+ SignalSpy {
43+ id: surfaceSpy
44+ target: SurfaceManager
45+ signalName: "surfaceDestroyed"
46+ }
47+
48+ UT.UnityTestCase {
49+ id: testCase
50+ name: "AppSurfaceContainer"
51+ when: windowShown
52+
53+ function test_promptSurfaces_data() {
54+ return [ { tag: "1", count: 1 },
55+ { tag: "4", count: 4 } ];
56+ }
57+
58+ function test_promptSurfaces(data) {
59+ var unity8dash = findChild(shell, "unity8-dash");
60+ verify(unity8dash !== null);
61+ compare(unity8dash.promptSurfaces.count, 0);
62+
63+ var i;
64+ var surfaces = [];
65+ for (i = 0; i < data.count; i++) {
66+ surfaces.push(ApplicationTest.addPromptSurface("unity8-dash", Qt.resolvedUrl("../Dash/artwork/music-player-design.png")));
67+ compare(unity8dash.promptSurfaces.count, i+1);
68+ }
69+
70+ surfaceSpy.clear();
71+ for (i = data.count-1; i >= 0; i--) {
72+ ApplicationTest.removeSurface(surfaces[i]);
73+ tryCompare(unity8dash.promptSurfaces, "count", i);
74+ }
75+ tryCompare(surfaceSpy, "count", data.count)
76+ }
77+
78+ function test_removeFirstPromptSurface_data() {
79+ return [ { tag: "1", count: 1 },
80+ { tag: "4", count: 4 } ];
81+ }
82+
83+ function test_removeFirstPromptSurface(data) {
84+ var unity8dash = findChild(shell, "unity8-dash");
85+ verify(unity8dash !== null);
86+ compare(unity8dash.promptSurfaces.count, 0);
87+
88+ var i;
89+ var surfaces = [];
90+ for (i = 0; i < data.count; i++) {
91+ surfaces.push(ApplicationTest.addPromptSurface("unity8-dash", Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
92+ compare(unity8dash.promptSurfaces.count, i+1);
93+ }
94+
95+ surfaceSpy.clear();
96+ ApplicationTest.removeSurface(surfaces[0]);
97+ tryCompare(unity8dash.promptSurfaces, "count", 0);
98+ tryCompare(surfaceSpy, "count", data.count)
99+ }
100+ }
101+}
tests/qmltests/Stages/tst_SurfaceContainer.qmlnew file+119
@@ -0,0 +1,119 @@
1+/*
2+ * Copyright 2014 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 Unity.Application 0.1
21+import "../../../qml/Stages"
22+
23+Item {
24+ id: shell
25+ width: units.gu(40)
26+ height: units.gu(80)
27+
28+ Repeater {
29+ anchors.fill: parent
30+ model: ApplicationManager
31+
32+ delegate: SurfaceContainer {
33+ id: container
34+ anchors.fill: parent
35+ objectName: application.appId
36+
37+ surface: model.surface
38+ }
39+ }
40+
41+ SignalSpy {
42+ id: surfaceSpy
43+ target: SurfaceManager
44+ signalName: "surfaceDestroyed"
45+ }
46+
47+ UT.UnityTestCase {
48+ id: testCase
49+ name: "SurfaceContainer"
50+ when: windowShown
51+
52+ function initTestCase() {
53+ var unity8dash = findChild(shell, "unity8-dash");
54+ verify(unity8dash !== null);
55+
56+ tryCompareFunction(function() { return unity8dash.surface !== null; }, true);
57+ }
58+
59+ function test_childSurfaces_data() {
60+ return [ { tag: "1", count: 1 },
61+ { tag: "4", count: 4 } ];
62+ }
63+
64+ function test_childSurfaces(data) {
65+ var unity8dash = findChild(shell, "unity8-dash");
66+ compare(unity8dash.childSurfaces.count, 0);
67+
68+ var i;
69+ var surfaces = [];
70+ for (i = 0; i < data.count; i++) {
71+ surfaces.push(ApplicationTest.addChildSurface("unity8-dash", 0, Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
72+ compare(unity8dash.childSurfaces.count, i+1);
73+ }
74+
75+ surfaceSpy.clear();
76+ for (i = data.count-1; i >= 0; i--) {
77+ ApplicationTest.removeSurface(surfaces[i]);
78+ tryCompare(unity8dash.childSurfaces, "count", i);
79+ }
80+ tryCompare(surfaceSpy, "count", data.count)
81+ }
82+
83+ function test_tieredChildSurfaces_data() {
84+ return [
85+ { tag: "2", count: 2 },
86+ { tag: "10", count: 10 }
87+ ];
88+ }
89+
90+ function test_tieredChildSurfaces(data) {
91+ var unity8dash = findChild(shell, "unity8-dash");
92+ compare(unity8dash.childSurfaces.count, 0);
93+
94+ var i;
95+ var surfaces = [];
96+ var lastSurfaceId = 0;
97+ var delegate;
98+ var surfaceContainer = unity8dash;
99+ for (i = 0; i < data.count; i++) {
100+ lastSurfaceId = ApplicationTest.addChildSurface("unity8-dash", lastSurfaceId, Qt.resolvedUrl("Dash/artwork/music-player-design.png"))
101+ surfaces.push(lastSurfaceId);
102+
103+ compare(surfaceContainer.childSurfaces.count, 1);
104+
105+ delegate = findChild(surfaceContainer, "childDelegate0");
106+ console.log("XXX " + delegate)
107+ surfaceContainer = findChild(delegate, "surfaceContainer");
108+ }
109+
110+ surfaceSpy.clear();
111+ for (i = data.count-1; i >= 0; i--) {
112+ ApplicationTest.removeSurface(surfaces[i]);
113+ }
114+
115+ compare(unity8dash.childSurfaces.count, 0);
116+ tryCompare(surfaceSpy, "count", data.count)
117+ }
118+ }
119+}
tests/qmltests/tst_Shell.qml−128
@@ -61,12 +61,6 @@ Item {
6161 signalName: "setCurrentScopeCalled"
6262 }
6363
64− SignalSpy {
65− id: surfaceSpy
66− target: SurfaceManager
67− signalName: "surfaceDestroyed"
68− }
69−
7064 UT.UnityTestCase {
7165 name: "Shell"
7266 when: windowShown
@@ -437,127 +431,5 @@ Item {
437431
438432 touchRelease(shell);
439433 }
440−
441− function test_promptSurfaces_data() {
442− return [ { tag: "1", count: 1 },
443− { tag: "4", count: 4 } ];
444− }
445−
446− function test_promptSurfaces(data) {
447− ApplicationManager.requestFocusApplication("unity8-dash");
448− waitUntilDashIsFocused();
449−
450− var appDelegate = findChild(shell, "appDelegate0")
451− var surfaceContainer = findChild(appDelegate, "surfaceContainer");
452−
453− var i;
454− var surfaces = [];
455− compare(surfaceContainer.promptSurfaces.count, 0);
456− for (i = 0; i < data.count; i++) {
457− surfaces.push(ApplicationTest.addPromptSurface("unity8-dash", Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
458− compare(surfaceContainer.promptSurfaces.count, i+1);
459− }
460−
461− surfaceSpy.clear();
462− for (i = data.count-1; i >= 0; i--) {
463− ApplicationTest.removeSurface(surfaces[i]);
464− tryCompare(surfaceContainer.promptSurfaces, "count", i);
465− }
466− tryCompare(surfaceSpy, "count", data.count)
467− }
468−
469− function test_removeFirstPromptSurface_data() {
470− return [ { tag: "1", count: 1 },
471− { tag: "4", count: 4 } ];
472− }
473−
474− function test_removeFirstPromptSurface(data) {
475− ApplicationManager.requestFocusApplication("unity8-dash");
476− waitUntilDashIsFocused();
477−
478− var appDelegate = findChild(shell, "appDelegate0")
479− var surfaceContainer = findChild(appDelegate, "surfaceContainer");
480−
481− var i;
482− var surfaces = [];
483− compare(surfaceContainer.promptSurfaces.count, 0);
484− for (i = 0; i < data.count; i++) {
485− surfaces.push(ApplicationTest.addPromptSurface("unity8-dash", Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
486− compare(surfaceContainer.promptSurfaces.count, i+1);
487− }
488−
489− surfaceSpy.clear();
490− ApplicationTest.removeSurface(surfaces[0]);
491− tryCompare(surfaceContainer.promptSurfaces, "count", 0);
492− tryCompare(surfaceSpy, "count", data.count)
493− }
494−
495− function test_childSurfaces_data() {
496− return [ { tag: "1", count: 1 },
497− { tag: "4", count: 4 } ];
498− }
499−
500− function test_childSurfaces(data) {
501− ApplicationManager.requestFocusApplication("unity8-dash");
502− waitUntilDashIsFocused();
503−
504− var appDelegate = findChild(shell, "appDelegate0")
505− var surfaceContainer = findChild(appDelegate, "surfaceContainer");
506−
507− var i;
508− var surfaces = [];
509− compare(surfaceContainer.childSurfaces.count, 0);
510− for (i = 0; i < data.count; i++) {
511− surfaces.push(ApplicationTest.addChildSurface("unity8-dash", 0, Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
512− compare(surfaceContainer.childSurfaces.count, i+1);
513− }
514−
515− surfaceSpy.clear();
516− for (i = data.count-1; i >= 0; i--) {
517− ApplicationTest.removeSurface(surfaces[i]);
518− tryCompare(surfaceContainer.childSurfaces, "count", i);
519− }
520− tryCompare(surfaceSpy, "count", data.count)
521− }
522−
523− function test_tieredChildSurfaces_data() {
524− return [
525− { tag: "2", count: 2 },
526− { tag: "10", count: 10 }
527− ];
528− }
529−
530− function test_tieredChildSurfaces(data) {
531− ApplicationManager.requestFocusApplication("unity8-dash");
532− waitUntilDashIsFocused();
533−
534− var delegate = findChild(shell, "appDelegate0")
535− var surfaceContainer = findChild(delegate, "surfaceContainer");
536−
537− var i;
538− var surfaces = [];
539− var lastSurfaceId = 0;
540− compare(surfaceContainer.childSurfaces.count, 0);
541− for (i = 0; i < data.count; i++) {
542− lastSurfaceId = ApplicationTest.addChildSurface("unity8-dash", lastSurfaceId, Qt.resolvedUrl("Dash/artwork/music-player-design.png"))
543− surfaces.push(lastSurfaceId);
544−
545− compare(surfaceContainer.childSurfaces.count, 1);
546−
547− delegate = findChild(surfaceContainer, "childDelegate0");
548− surfaceContainer = findChild(delegate, "surfaceContainer");
549− }
550−
551− surfaceSpy.clear();
552− for (i = data.count-1; i >= 0; i--) {
553− ApplicationTest.removeSurface(surfaces[i]);
554− }
555−
556− delegate = findChild(shell, "appDelegate0")
557− surfaceContainer = findChild(delegate, "surfaceContainer");
558−
559− compare(surfaceContainer.childSurfaces.count, 0);
560− tryCompare(surfaceSpy, "count", data.count)
561− }
562434 }
563435}