on xenial help sign in
tests & fixes for session-in-session
commit86ea5bedbcecb27a7bb2c00ef09e50a963f85397 authorNick Dedekind <nicholas.dedekind@gmail.com> dateFri 22 Aug 2014, 11:33 (12 years ago) parent8183eb1
22 files changed+198−175
qml/Stages/Animations/BaseSurfaceAnimation.qml → qml/Stages/Animations/BaseSessionAnimation.qml qml/Stages/Animations/DarkenAndFadeInAnimation.qml+6−6 qml/Stages/Animations/SwipeFromBottomAnimation.qml+1−1 qml/Stages/Animations/SwipeUpAnimation.qml+1−1 qml/Stages/SessionContainer.qml+4−9 qml/Stages/SpreadDelegate.qml+3−3 qml/Stages/SurfaceContainer.qml−1 tests/mocks/Unity/Application/ApplicationInfo.cpp+1−1 tests/mocks/Unity/Application/ApplicationManager.cpp+18−36 tests/mocks/Unity/Application/CMakeLists.txt+3 tests/mocks/Unity/Application/MirItemModel.h+1−1 tests/mocks/Unity/Application/MirSessionItem.cpp+1 tests/mocks/Unity/Application/MirSessionItem.h+1 tests/mocks/Unity/Application/MirSessionItemModel.h+8−1 tests/mocks/Unity/Application/MirSurfaceItemModel.h+8−1 tests/mocks/Unity/Application/SessionManager.cpp+5−2 tests/mocks/Unity/Application/SessionManager.h+4 tests/mocks/Unity/Application/plugin.cpp+8 tests/qmltests/CMakeLists.txt+1−1 tests/qmltests/Stages/tst_AppSurfaceContainer.qml−101 tests/qmltests/Stages/tst_SessionContainer.qml+114 tests/qmltests/Stages/tst_SurfaceContainer.qml+10−10
qml/Stages/Animations/BaseSurfaceAnimation.qml → qml/Stages/Animations/BaseSessionAnimation.qmlrenamed

The content is the same.

qml/Stages/Animations/DarkenAndFadeInAnimation.qml+6−6
@@ -17,19 +17,19 @@
1717import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919
20−BaseSurfaceAnimation {
20+BaseSessionAnimation {
2121 id: animation
2222
2323 property Rectangle darkenItem: Rectangle {
24− parent: animation.surface.parent
24+ parent: animation.session.parent
2525 anchors.fill: parent
2626 color: Qt.rgba(0,0,0,0.0)
2727 }
2828
29− outChanges: [ PropertyChanges { target: animation.surface; opacity: 0.0 } ]
29+ outChanges: [ PropertyChanges { target: animation.session; opacity: 0.0 } ]
3030 outAnimations: [
3131 SequentialAnimation {
32− UbuntuNumberAnimation { target: animation.surface; property: "opacity"; duration: UbuntuAnimation.FastDuration }
32+ UbuntuNumberAnimation { target: animation.session; property: "opacity"; duration: UbuntuAnimation.FastDuration }
3333 ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
3434 ScriptAction { script: { if (animation.parent.removing) animation.surface.release(); } }
3535 }
@@ -37,12 +37,12 @@ BaseSurfaceAnimation {
3737
3838 inChanges: [
3939 PropertyChanges { target: darkenItem; color: Qt.rgba(0,0,0,0.7) },
40− PropertyChanges { target: animation.surface; opacity: 1.0 }
40+ PropertyChanges { target: animation.session; opacity: 1.0 }
4141 ]
4242 inAnimations: [
4343 SequentialAnimation {
4444 ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
45− UbuntuNumberAnimation { target: animation.surface; property: "opacity"; duration: UbuntuAnimation.FastDuration }
45+ UbuntuNumberAnimation { target: animation.session; property: "opacity"; duration: UbuntuAnimation.FastDuration }
4646 }
4747 ]
4848}
qml/Stages/Animations/SwipeFromBottomAnimation.qml+1−1
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818
19−BaseSurfaceAnimation {
19+BaseSessionAnimation {
2020 id: animation
2121
2222 outChanges: [ AnchorChanges { target: animation.session; anchors.top: animation.parent.bottom } ]
qml/Stages/Animations/SwipeUpAnimation.qml+1−1
@@ -16,7 +16,7 @@
1616
1717import QtQuick 2.0
1818
19−BaseSurfaceAnimation {
19+BaseSessionAnimation {
2020 id: animation
2121
2222 outAnimations: [
qml/Stages/SessionContainer.qml+4−9
@@ -21,7 +21,7 @@ Item {
2121 id: root
2222 objectName: "sessionContainer"
2323 property Item session
24− property var children: session ? session.childSessions : 0
24+ property var childSessions: session ? session.childSessions : 0
2525 property bool removing: false
2626 property alias surface: surfaceContainer.surface
2727
@@ -45,17 +45,11 @@ Item {
4545 }
4646
4747 Repeater {
48− model: root.children
48+ model: root.childSessions
4949
5050 delegate: Loader {
5151 objectName: "childDelegate" + index
52− anchors {
53− fill: root
54− topMargin: root.surface.anchors.topMargin
55− rightMargin: root.surface.anchors.rightMargin
56− bottomMargin: root.surface.anchors.bottomMargin
57− leftMargin: root.surface.anchors.leftMargin
58− }
52+ anchors.fill: surfaceContainer
5953 z: 4
6054
6155 // Only way to do recursive qml items.
@@ -67,6 +61,7 @@ Item {
6761 Connections {
6862 target: modelData
6963 onRemoved: {
64+ item.removing = true;
7065 item.animateOut();
7166 }
7267 }
qml/Stages/SpreadDelegate.qml+3−3
@@ -31,7 +31,7 @@ Item {
3131 property alias swipeToCloseEnabled: dragArea.enabled
3232 property alias surface: surfaceContainer.surface
3333
34− readonly property bool isFullscreen: surface !== null && session.anchors.topMargin == 0
34+ readonly property bool isFullscreen: session.anchors.topMargin === 0
3535
3636 signal clicked()
3737 signal closed()
@@ -43,11 +43,11 @@ Item {
4343 session: model.session
4444
4545 Binding {
46− target: surface
46+ target: session
4747 property: "anchors.topMargin"
4848 value: {
4949 return surface == null ||
50− surfaceContainer.surface.state === MirSurfaceItem.Fullscreen ? 0 : maximizedAppTopMargin;
50+ surface.state === MirSurfaceItem.Fullscreen ? 0 : maximizedAppTopMargin;
5151 }
5252 }
5353
qml/Stages/SurfaceContainer.qml−1
@@ -22,7 +22,6 @@ Item {
2222 objectName: "surfaceContainer"
2323 property Item surface: null
2424 property var childSurfaces: surface ? surface.childSurfaces : 0
25− property bool removing: false
2625
2726 onSurfaceChanged: {
2827 console.log("SURFACE " + surface)
tests/mocks/Unity/Application/ApplicationInfo.cpp+1−1
@@ -55,7 +55,7 @@ ApplicationInfo::~ApplicationInfo()
5555
5656void ApplicationInfo::createSession()
5757{
58− setSession(SessionManager::singleton()->createSession(name(), screenshot()));
58+ setSession(SessionManager::singleton()->createSession(appId(), screenshot()));
5959}
6060
6161void ApplicationInfo::setSession(MirSessionItem* session)
tests/mocks/Unity/Application/ApplicationManager.cpp+18−36
@@ -343,129 +343,111 @@ void ApplicationManager::buildListOfAvailableApplications()
343343{
344344 ApplicationInfo *application;
345345
346− application = new ApplicationInfo(this);
347− application->setAppId("unity8-dash");
346+ application = new ApplicationInfo("unity8-dash", this);
348347 application->setName("Unity 8 Mock Dash");
349348 application->setIcon(QUrl("unity8-dash"));
350349 application->setStage(ApplicationInfo::MainStage);
351350 generateQmlStrings(application);
352351 m_availableApplications.append(application);
353352
354− application = new ApplicationInfo(this);
355− application->setAppId("dialer-app");
353+ application = new ApplicationInfo("dialer-app", this);
356354 application->setName("Dialer");
357355 application->setIcon(QUrl("dialer"));
358356 application->setStage(ApplicationInfo::SideStage);
359357 generateQmlStrings(application);
360358 m_availableApplications.append(application);
361359
362− application = new ApplicationInfo(this);
363− application->setAppId("camera-app");
360+ application = new ApplicationInfo("camera-app", this);
364361 application->setName("Camera");
365362 application->setIcon(QUrl("camera"));
366363 application->setFullscreen(true);
367364 generateQmlStrings(application);
368365 m_availableApplications.append(application);
369366
370− application = new ApplicationInfo(this);
371− application->setAppId("gallery-app");
367+ application = new ApplicationInfo("gallery-app", this);
372368 application->setName("Gallery");
373369 application->setIcon(QUrl("gallery"));
374370 generateQmlStrings(application);
375371 m_availableApplications.append(application);
376372
377− application = new ApplicationInfo(this);
378− application->setAppId("facebook-webapp");
373+ application = new ApplicationInfo("facebook-webapp", this);
379374 application->setName("Facebook");
380375 application->setIcon(QUrl("facebook"));
381376 application->setStage(ApplicationInfo::SideStage);
382377 generateQmlStrings(application);
383378 m_availableApplications.append(application);
384379
385− application = new ApplicationInfo(this);
386− application->setAppId("webbrowser-app");
380+ application = new ApplicationInfo("webbrowser-app", this);
387381 application->setFullscreen(true);
388382 application->setName("Browser");
389383 application->setIcon(QUrl("browser"));
390384 generateQmlStrings(application);
391385 m_availableApplications.append(application);
392386
393− application = new ApplicationInfo(this);
394− application->setAppId("twitter-webapp");
387+ application = new ApplicationInfo("twitter-webapp", this);
395388 application->setName("Twitter");
396389 application->setIcon(QUrl("twitter"));
397390 application->setStage(ApplicationInfo::SideStage);
398391 generateQmlStrings(application);
399392 m_availableApplications.append(application);
400393
401− application = new ApplicationInfo(this);
402− application->setAppId("gmail-webapp");
394+ application = new ApplicationInfo("gmail-webapp", this);
403395 application->setName("GMail");
404396 application->setIcon(QUrl("gmail"));
405397 m_availableApplications.append(application);
406398
407− application = new ApplicationInfo(this);
408− application->setAppId("ubuntu-weather-app");
399+ application = new ApplicationInfo("ubuntu-weather-app", this);
409400 application->setName("Weather");
410401 application->setIcon(QUrl("weather"));
411402 application->setStage(ApplicationInfo::SideStage);
412403 generateQmlStrings(application);
413404 m_availableApplications.append(application);
414405
415− application = new ApplicationInfo(this);
416− application->setAppId("notes-app");
406+ application = new ApplicationInfo("notes-app", this);
417407 application->setName("Notepad");
418408 application->setIcon(QUrl("notepad"));
419409 application->setStage(ApplicationInfo::SideStage);
420410 m_availableApplications.append(application);
421411
422− application = new ApplicationInfo(this);
423− application->setAppId("calendar-app");
412+ application = new ApplicationInfo("calendar-app", this);
424413 application->setName("Calendar");
425414 application->setIcon(QUrl("calendar"));
426415 application->setStage(ApplicationInfo::SideStage);
427416 m_availableApplications.append(application);
428417
429− application = new ApplicationInfo(this);
430− application->setAppId("mediaplayer-app");
418+ application = new ApplicationInfo("mediaplayer-app", this);
431419 application->setName("Media Player");
432420 application->setIcon(QUrl("mediaplayer-app"));
433421 application->setFullscreen(true);
434422 m_availableApplications.append(application);
435423
436− application = new ApplicationInfo(this);
437− application->setAppId("evernote");
424+ application = new ApplicationInfo("evernote", this);
438425 application->setName("Evernote");
439426 application->setIcon(QUrl("evernote"));
440427 m_availableApplications.append(application);
441428
442− application = new ApplicationInfo(this);
443− application->setAppId("map");
429+ application = new ApplicationInfo("map", this);
444430 application->setName("Map");
445431 application->setIcon(QUrl("map"));
446432 generateQmlStrings(application);
447433 m_availableApplications.append(application);
448434
449− application = new ApplicationInfo(this);
450− application->setAppId("pinterest");
435+ application = new ApplicationInfo("pinterest", this);
451436 application->setName("Pinterest");
452437 application->setIcon(QUrl("pinterest"));
453438 m_availableApplications.append(application);
454439
455− application = new ApplicationInfo(this);
456− application->setAppId("soundcloud");
440+ application = new ApplicationInfo("soundcloud", this);
457441 application->setName("SoundCloud");
458442 application->setIcon(QUrl("soundcloud"));
459443 m_availableApplications.append(application);
460444
461− application = new ApplicationInfo(this);
462− application->setAppId("wikipedia");
445+ application = new ApplicationInfo("wikipedia", this);
463446 application->setName("Wikipedia");
464447 application->setIcon(QUrl("wikipedia"));
465448 m_availableApplications.append(application);
466449
467− application = new ApplicationInfo(this);
468− application->setAppId("youtube");
450+ application = new ApplicationInfo("youtube", this);
469451 application->setName("YouTube");
470452 application->setIcon(QUrl("youtube"));
471453 m_availableApplications.append(application);
tests/mocks/Unity/Application/CMakeLists.txt+3
@@ -12,6 +12,9 @@ set(FakeUnityApplicationQml_SOURCES
1212 SessionManager.cpp
1313 SurfaceManager.cpp
1414 VirtualKeyboard.cpp
15+ MirItemModel.h
16+ MirSurfaceItemModel.h
17+ MirSessionItemModel.h
1518 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
1619 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
1720)
tests/mocks/Unity/Application/MirItemModel.h+1−1
@@ -85,7 +85,7 @@ public:
8585 return roleNames;
8686 }
8787
88−private:
88+protected:
8989 void move(int from, int to)
9090 {
9191 if (from == to) return;
tests/mocks/Unity/Application/MirSessionItem.cpp+1
@@ -59,6 +59,7 @@ MirSessionItem::~MirSessionItem()
5959void MirSessionItem::release()
6060{
6161 qDebug() << "MirSessionItem::release " << name();
62+ Q_EMIT aboutToBeDestroyed();
6263
6364 if (m_parentSession) {
6465 m_parentSession->removeChildSession(this);
tests/mocks/Unity/Application/MirSessionItem.h+1
@@ -56,6 +56,7 @@ Q_SIGNALS:
5656 void surfaceChanged(MirSurfaceItem*);
5757 void parentSessionChanged(MirSessionItem*);
5858 void removed();
59+ void aboutToBeDestroyed();
5960
6061public Q_SLOTS:
6162 void createSurface();
tests/mocks/Unity/Application/MirSessionItemModel.h+8−1
@@ -21,7 +21,14 @@
2121#include "MirItemModel.h"
2222
2323class MirSessionItem;
24−typedef MirItemModel<MirSessionItem> MirSessionItemModel;
24+class MirSessionItemModel: public MirItemModel<MirSessionItem>
25+{
26+ Q_OBJECT
27+public:
28+ MirSessionItemModel(QObject *parent = 0): MirItemModel(parent) {}
29+
30+ Q_INVOKABLE int count() const { return rowCount(); }
31+};
2532
2633Q_DECLARE_METATYPE(MirSessionItemModel*)
2734
tests/mocks/Unity/Application/MirSurfaceItemModel.h+8−1
@@ -21,7 +21,14 @@
2121#include "MirItemModel.h"
2222
2323class MirSurfaceItem;
24−typedef MirItemModel<MirSurfaceItem> MirSurfaceItemModel;
24+class MirSurfaceItemModel: public MirItemModel<MirSurfaceItem>
25+{
26+ Q_OBJECT
27+public:
28+ MirSurfaceItemModel(QObject *parent = 0): MirItemModel(parent) {}
29+
30+ Q_INVOKABLE int count() const { return rowCount(); }
31+};
2532
2633Q_DECLARE_METATYPE(MirSurfaceItemModel*)
2734
tests/mocks/Unity/Application/SessionManager.cpp+5−2
@@ -39,7 +39,10 @@ MirSessionItem *SessionManager::createSession(const QString& name,
3939 const QUrl& screenshot)
4040{
4141 MirSessionItem* session = new MirSessionItem(name, screenshot);
42− connect(session, &MirSessionItem::destroyed, this, [&](QObject*) {
42+ connect(session, &MirSessionItem::aboutToBeDestroyed, this, [&] {
43+ Q_EMIT sessionDestroyed(qobject_cast<MirSessionItem*>(sender()));
4344 });
45+
46+ Q_EMIT sessionCreated(session);
4447 return session;
45−}
48+}
tests/mocks/Unity/Application/SessionManager.h+4
@@ -31,6 +31,10 @@ public:
3131
3232 MirSessionItem* createSession(const QString& name, const QUrl& screenshot);
3333
34+Q_SIGNALS:
35+ void sessionCreated(MirSessionItem *session);
36+ void sessionDestroyed(MirSessionItem *session);
37+
3438private:
3539 static SessionManager *the_session_manager;
3640};
tests/mocks/Unity/Application/plugin.cpp+8
@@ -23,6 +23,7 @@
2323#include "MirSurfaceItem.h"
2424#include "MirSurfaceItemModel.h"
2525#include "SurfaceManager.h"
26+#include "SessionManager.h"
2627#include "ApplicationTestInterface.h"
2728
2829#include <qqml.h>
@@ -40,6 +41,12 @@ static QObject* surfaceManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEng
4041 return SurfaceManager::singleton();
4142}
4243
44+static QObject* sessionManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
45+ Q_UNUSED(engine);
46+ Q_UNUSED(scriptEngine);
47+ return SessionManager::singleton();
48+}
49+
4350ApplicationTestInterface* s_appTestInterface = nullptr;
4451
4552static QObject* applicationTestInterface(QQmlEngine* engine, QJSEngine* scriptEngine) {
@@ -68,6 +75,7 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
6875
6976 qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
7077 qmlRegisterSingletonType<SurfaceManager>(uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
78+ qmlRegisterSingletonType<SessionManager>(uri, 0, 1, "SessionManager", sessionManagerSingleton);
7179 qmlRegisterSingletonType<ApplicationTestInterface>(uri, 0, 1, "ApplicationTest", applicationTestInterface);
7280}
7381
tests/qmltests/CMakeLists.txt+1−1
@@ -77,4 +77,4 @@ add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/t
7777add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
7878add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
7979add_qml_test(Stages SurfaceContainer)
80−add_qml_test(Stages AppSurfaceContainer)
80+add_qml_test(Stages SessionContainer)
tests/qmltests/Stages/tst_AppSurfaceContainer.qmldeleted−101
@@ -1,101 +0,0 @@
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_SessionContainer.qmlnew file+114
@@ -0,0 +1,114 @@
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: SessionContainer {
33+ id: container
34+ anchors.fill: parent
35+ objectName: appId
36+
37+ session: model.session
38+ }
39+ }
40+
41+ SignalSpy {
42+ id: sessionSpy
43+ target: SessionManager
44+ signalName: "sessionDestroyed"
45+ }
46+
47+ UT.UnityTestCase {
48+ id: testCase
49+ name: "SessionContainer"
50+
51+ function init() {
52+ sessionSpy.clear();
53+ }
54+
55+ when: windowShown
56+
57+ function test_add_child_session_data() {
58+ return [ { tag: "count=1", count: 1 },
59+ { tag: "count=4", count: 4 } ];
60+ }
61+
62+ function test_add_child_session(data) {
63+ var unity8dash = findChild(shell, "unity8-dash");
64+ verify(unity8dash !== null);
65+ compare(unity8dash.childSessions.count(), 0);
66+
67+ var i;
68+ var sessions = [];
69+ for (i = 0; i < data.count; i++) {
70+ sessions.push(ApplicationTest.addChildSession("unity8-dash", 0, Qt.resolvedUrl("../Dash/artwork/music-player-design.png")));
71+ compare(unity8dash.childSessions.count(), i+1);
72+ }
73+
74+ for (i = data.count-1; i >= 0; i--) {
75+ ApplicationTest.removeSession(sessions[i]);
76+ tryCompareFunction(function() { return unity8dash.childSessions.count(); }, i);
77+ }
78+ tryCompare(sessionSpy, "count", data.count)
79+ }
80+
81+ function test_nest_child_sessions_data() {
82+ return [ { tag: "depth=2", depth: 2 },
83+ { tag: "depth=8", depth: 8 }
84+ ];
85+ }
86+
87+ function test_nest_child_sessions(data) {
88+ var unity8dash = findChild(shell, "unity8-dash");
89+ verify(unity8dash !== null);
90+ compare(unity8dash.childSessions.count(), 0);
91+
92+ var i;
93+ var sessions = [];
94+ var lastSessionId = 0;
95+ var delegate;
96+ var sessionContainer = unity8dash;
97+ for (i = 0; i < data.depth; i++) {
98+ lastSessionId = ApplicationTest.addChildSession("unity8-dash", lastSessionId, Qt.resolvedUrl("Dash/artwork/music-player-design.png"))
99+ sessions.push(lastSessionId);
100+ compare(sessionContainer.childSessions.count(), 1);
101+
102+ delegate = findChild(sessionContainer, "childDelegate0");
103+ sessionContainer = findChild(delegate, "sessionContainer");
104+ }
105+
106+ for (i = data.depth-1; i >= 0; i--) {
107+ ApplicationTest.removeSession(sessions[i]);
108+ }
109+
110+ tryCompareFunction(function() { return unity8dash.childSessions.count(); }, 0);
111+ tryCompare(sessionSpy, "count", data.depth)
112+ }
113+ }
114+}
tests/qmltests/Stages/tst_SurfaceContainer.qml+10−10
@@ -32,9 +32,9 @@ Item {
3232 delegate: SurfaceContainer {
3333 id: container
3434 anchors.fill: parent
35− objectName: application.appId
35+ objectName: appId
3636
37− surface: model.surface
37+ surface: model.session && model.session.surface ? model.session.surface : null
3838 }
3939 }
4040
@@ -63,19 +63,19 @@ Item {
6363
6464 function test_childSurfaces(data) {
6565 var unity8dash = findChild(shell, "unity8-dash");
66− compare(unity8dash.childSurfaces.count, 0);
66+ compare(unity8dash.childSurfaces.count(), 0);
6767
6868 var i;
6969 var surfaces = [];
7070 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);
71+ surfaces.push(ApplicationTest.addChildSurface("unity8-dash", 0, 0, Qt.resolvedUrl("Dash/artwork/music-player-design.png")));
72+ compare(unity8dash.childSurfaces.count(), i+1);
7373 }
7474
7575 surfaceSpy.clear();
7676 for (i = data.count-1; i >= 0; i--) {
7777 ApplicationTest.removeSurface(surfaces[i]);
78− tryCompare(unity8dash.childSurfaces, "count", i);
78+ tryCompareFunction(function() { return unity8dash.childSurfaces.count(); }, i);
7979 }
8080 tryCompare(surfaceSpy, "count", data.count)
8181 }
@@ -89,7 +89,7 @@ Item {
8989
9090 function test_tieredChildSurfaces(data) {
9191 var unity8dash = findChild(shell, "unity8-dash");
92− compare(unity8dash.childSurfaces.count, 0);
92+ compare(unity8dash.childSurfaces.count(), 0);
9393
9494 var i;
9595 var surfaces = [];
@@ -97,10 +97,10 @@ Item {
9797 var delegate;
9898 var surfaceContainer = unity8dash;
9999 for (i = 0; i < data.count; i++) {
100− lastSurfaceId = ApplicationTest.addChildSurface("unity8-dash", lastSurfaceId, Qt.resolvedUrl("Dash/artwork/music-player-design.png"))
100+ lastSurfaceId = ApplicationTest.addChildSurface("unity8-dash", 0, lastSurfaceId, Qt.resolvedUrl("Dash/artwork/music-player-design.png"))
101101 surfaces.push(lastSurfaceId);
102102
103− compare(surfaceContainer.childSurfaces.count, 1);
103+ compare(surfaceContainer.childSurfaces.count(), 1);
104104
105105 delegate = findChild(surfaceContainer, "childDelegate0");
106106 surfaceContainer = findChild(delegate, "surfaceContainer");
@@ -111,7 +111,7 @@ Item {
111111 ApplicationTest.removeSurface(surfaces[i]);
112112 }
113113
114− compare(unity8dash.childSurfaces.count, 0);
114+ compare(unity8dash.childSurfaces.count(), 0);
115115 tryCompare(surfaceSpy, "count", data.count)
116116 }
117117 }