on xenial help sign in
share code between tests
commitb92dd9144b7ce9412c7a521134489790a1c6ab9f authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateMon 5 Dec 2016, 11:29 (10 years ago) parentf1f0776
5 files changed+48−58
tests/qmltests/Stage/tst_DesktopStage.qml+3−13 tests/qmltests/tst_Shell.qml+3−22 tests/qmltests/tst_ShellWithPin.qml+3−22 tests/utils/modules/Unity/Test/StageTestCase.qml+37 tests/utils/modules/Unity/Test/qmldir+2−1
tests/qmltests/Stage/tst_DesktopStage.qml+3−13
@@ -157,12 +157,12 @@ Item {
157157 target: clickThroughTester
158158 }
159159
160− UnityTestCase {
160+ StageTestCase {
161161 id: testCase
162162 name: "DesktopStage"
163163 when: windowShown
164164
165− property Item stage: stageLoader.status === Loader.Ready ? stageLoader.item : null
165+ stage: stageLoader.status === Loader.Ready ? stageLoader.item : null
166166
167167 function init() {
168168 // wait until unity8-dash is up and running.
@@ -200,16 +200,6 @@ Item {
200200 mouseEaterSpy.clear();
201201 }
202202
203− function waitUntilAppSurfaceShowsUp(surfaceId) {
204− var appDelegate = findChild(stage, "appDelegate_" + surfaceId);
205− verify(appDelegate);
206− var appWindow = findChild(appDelegate, "appWindow");
207− verify(appWindow);
208− var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
209− verify(appWindowStates);
210− tryCompare(appWindowStates, "state", "surface");
211− }
212−
213203 /*
214204 Returns the appDelegate of the first surface created by the app with the specified appId
215205 */
@@ -229,7 +219,7 @@ Item {
229219 var surfaceId = topSurfaceList.nextId;
230220 app = ApplicationManager.startApplication(appId);
231221 verify(app);
232− waitUntilAppSurfaceShowsUp(surfaceId);
222+ waitUntilAppWindowIsFullyLoaded(surfaceId);
233223 compare(app.surfaceList.count, 1);
234224
235225 return findChild(stage, "appDelegate_" + surfaceId);
tests/qmltests/tst_Shell.qml+3−22
@@ -547,7 +547,7 @@ Rectangle {
547547 }
548548 }
549549
550− UnityTestCase {
550+ StageTestCase {
551551 id: testCase
552552 name: "Shell"
553553 when: windowShown
@@ -595,6 +595,8 @@ Rectangle {
595595 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
596596 verify(topLevelSurfaceList);
597597
598+ stage = findChild(shell, "stage"); // from StageTestCase
599+
598600 // wait until unity8-dash is fully loaded
599601 tryCompare(topLevelSurfaceList, "count", 1);
600602 waitUntilAppWindowIsFullyLoaded(topLevelSurfaceList.idAt(0));
@@ -1042,27 +1044,6 @@ Rectangle {
10421044 tryCompare(item, "visible", false);
10431045 }
10441046
1045− function findAppWindowForSurfaceId(surfaceId) {
1046− // for PhoneStage and TabletStage
1047− var delegate = findChild(shell, "spreadDelegate_" + surfaceId, 0 /* timeout */);
1048− if (!delegate) {
1049− // for DesktopStage
1050− delegate = findChild(shell, "appDelegate_" + surfaceId);
1051− }
1052− verify(delegate);
1053− var appWindow = findChild(delegate, "appWindow");
1054− return appWindow;
1055− }
1056−
1057− // Wait until the ApplicationWindow for the given Application object is fully loaded
1058− // (ie, the real surface has replaced the splash screen)
1059− function waitUntilAppWindowIsFullyLoaded(surfaceId) {
1060− var appWindow = findAppWindowForSurfaceId(surfaceId);
1061− var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
1062− tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
1063− waitUntilTransitionsEnd(appWindowStateGroup);
1064− }
1065−
10661047 function test_surfaceLosesActiveFocusWhilePanelIsOpen() {
10671048 loadShell("phone");
10681049 swipeAwayGreeter();
tests/qmltests/tst_ShellWithPin.qml+3−22
@@ -142,7 +142,7 @@ Item {
142142 }
143143 }
144144
145− UT.UnityTestCase {
145+ UT.StageTestCase {
146146 id: testCase
147147 name: "ShellWithPin"
148148 when: windowShown
@@ -163,6 +163,8 @@ Item {
163163 verify(!!panel);
164164 panel.dismissTimer = fakeDismissTimer;
165165
166+ stage = findChild(shell, "stage"); // from StageTestCase
167+
166168 topLevelSurfaceList = findInvisibleChild(shell, "topLevelSurfaceList");
167169 verify(topLevelSurfaceList);
168170
@@ -224,27 +226,6 @@ Item {
224226 }
225227 }
226228
227− function findAppWindowForSurfaceId(surfaceId) {
228− // for PhoneStage and TabletStage
229− var delegate = findChild(shell, "spreadDelegate_" + surfaceId, 0 /* timeout */);
230− if (!delegate) {
231− // for DesktopStage
232− delegate = findChild(shell, "appDelegate_" + surfaceId);
233− }
234− verify(delegate);
235− var appWindow = findChild(delegate, "appWindow");
236− return appWindow;
237− }
238−
239− // Wait until the ApplicationWindow for the given Application object is fully loaded
240− // (ie, the real surface has replaced the splash screen)
241− function waitUntilAppWindowIsFullyLoaded(surfaceId) {
242− var appWindow = findAppWindowForSurfaceId(surfaceId);
243− var appWindowStateGroup = findInvisibleChild(appWindow, "applicationWindowStateGroup");
244− tryCompareFunction(function() { return appWindowStateGroup.state === "surface" }, true);
245− waitUntilTransitionsEnd(appWindowStateGroup);
246− }
247−
248229 function enterPin(pin) {
249230 typeString(pin);
250231 }
tests/utils/modules/Unity/Test/StageTestCase.qmlnew file+37
@@ -0,0 +1,37 @@
1+/*
2+ * Copyright 2016 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.4
18+import Unity.Application 0.1
19+import Ubuntu.Components 1.3
20+
21+UnityTestCase {
22+ // set from outside
23+ property Item stage
24+
25+ // Wait until the ApplicationWindow for the given surface id (from TopLevelWindowModel) is fully loaded
26+ // (ie, the real surface has replaced the splash screen)
27+ function waitUntilAppWindowIsFullyLoaded(surfaceId) {
28+ var appDelegate = findChild(stage, "appDelegate_" + surfaceId);
29+ verify(appDelegate);
30+ var appWindow = findChild(appDelegate, "appWindow");
31+ verify(appWindow);
32+ var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
33+ verify(appWindowStates);
34+ tryCompare(appWindowStates, "state", "surface");
35+ waitUntilTransitionsEnd(appWindowStates);
36+ }
37+}
tests/utils/modules/Unity/Test/qmldir+2−1
@@ -3,4 +3,5 @@ plugin UnityTestQml
33typeinfo Test.qmltypes
44
55UnityTestCase 0.1 UnityTestCase.qml
6−MouseTouchEmulationCheckbox 0.1 MouseTouchEmulationCheckbox.qml
6+StageTestCase 0.1 StageTestCase.qml
7+MouseTouchEmulationCheckbox 0.1 MouseTouchEmulationCheckbox.qml