on xenial help sign in
test fixes. + merge tweaks
commitd4503856e9effeff73e6a9338b7728e1ca5d66f4 authorNick Dedekind <nicholas.dedekind@gmail.com> dateWed 27 Aug 2014, 16:54 (12 years ago) parenta5d616e
8 files changed+115−42
qml/Stages/ApplicationWindow.qml+2−2 qml/Stages/SessionContainer.qml+4−2 tests/mocks/Unity/Application/ApplicationInfo.cpp+1−2 tests/mocks/Unity/Application/ApplicationInfo.h−2 tests/mocks/Unity/Application/CMakeLists.txt+1−1 tests/qmltests/Stages/tst_ApplicationWindow.qml+9−9 tests/qmltests/Stages/tst_SessionContainer.qml+72−13 tests/qmltests/Stages/tst_SurfaceContainer.qml+26−11
qml/Stages/ApplicationWindow.qml+2−2
@@ -183,7 +183,7 @@ SessionContainer {
183183 duration: UbuntuAnimation.BriskDuration }
184184 PropertyAction { target: surfaceContainer
185185 property: "visible"; value: false }
186− ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
186+ ScriptAction { script: { if (root.session) { root.session.release(); } } }
187187 }
188188 },
189189 Transition {
@@ -202,7 +202,7 @@ SessionContainer {
202202 from: "surface"; to: "void"
203203 SequentialAnimation {
204204 PropertyAction { target: surfaceContainer; property: "visible"; value: false }
205− ScriptAction { script: { if (d.surface) { d.surface.release(); } } }
205+ ScriptAction { script: { if (root.session) { d.session.release(); } } }
206206 }
207207 },
208208 Transition {
qml/Stages/SessionContainer.qml+4−2
@@ -67,12 +67,15 @@ Item {
6767 onLoaded: {
6868 item.session = modelData;
6969 item.interactive = Qt.binding(function() { return root.interactive; } );
70+ if (modelData.surface) {
71+ item.animateIn(swipeFromBottom);
72+ }
7073 }
7174
7275 Connections {
7376 target: modelData
7477 onSurfaceChanged: {
75− item.animateIn(swipeFromBottom);
78+ if (surface) item.animateIn(swipeFromBottom);
7679 }
7780 onRemoved: {
7881 item.removing = true;
@@ -112,6 +115,5 @@ Item {
112115 QtObject {
113116 id: d
114117 property var animations: []
115− property var currentAnimation: animations.length > 0 ? animations[animations.length-1] : undefined
116118 }
117119}
tests/mocks/Unity/Application/ApplicationInfo.cpp+1−2
@@ -44,7 +44,6 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
4444 , m_state(Starting)
4545 , m_focused(false)
4646 , m_fullscreen(false)
47− , m_parentItem(0)
4847 , m_session(0)
4948 , m_manualSessionCreation(false)
5049{
@@ -57,7 +56,7 @@ ApplicationInfo::~ApplicationInfo()
5756
5857void ApplicationInfo::createSession()
5958{
60− if (m_session) { return; }
59+ if (m_session || state() == ApplicationInfo::Stopped) { return; }
6160
6261 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
6362 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
tests/mocks/Unity/Application/ApplicationInfo.h−2
@@ -99,8 +99,6 @@ private:
9999 State m_state;
100100 bool m_focused;
101101 bool m_fullscreen;
102−
103− QQuickItem *m_parentItem;
104102 Session* m_session;
105103
106104 bool m_manualSessionCreation;
tests/mocks/Unity/Application/CMakeLists.txt+1−1
@@ -1,4 +1,4 @@
1−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application)
1+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=3)
22
33set(FakeUnityApplicationQml_SOURCES
44 plugin.cpp
tests/qmltests/Stages/tst_ApplicationWindow.qml+9−9
@@ -32,8 +32,6 @@ Rectangle {
3232 Component.onCompleted: {
3333 root.fakeApplication = ApplicationManager.add("gallery-app");
3434 root.fakeApplication.manualSessionCreation = true;
35− root.fakeApplication.createSession();
36− root.fakeApplication.session.manualSessionCreation = true;
3735 root.fakeApplication.setState(ApplicationInfo.Starting);
3836 }
3937 property QtObject fakeApplication: null
@@ -84,10 +82,12 @@ Rectangle {
8482 if (applicationWindowLoader.status !== Loader.Ready)
8583 return;
8684
87− if (checked && !fakeSession.surface) {
85+ if (checked && !fakeApplication.session) {
86+ fakeApplication.createSession();
87+ fakeSession.manualSurfaceCreation = true;
8888 fakeSession.createSurface();
89− } else if (!checked && fakeSession.surface) {
90− fakeSession.surface.release();
89+ } else if (!checked && fakeApplication.session) {
90+ fakeApplication.session.release();
9191 }
9292 }
9393 }
@@ -182,8 +182,8 @@ Rectangle {
182182 appStateSelector.selectedIndex = 0;
183183 surfaceCheckbox.checked = false;
184184
185− if (fakeApplication.surface)
186− fakeApplication.surface.release();
185+ if (fakeApplication.session)
186+ fakeApplication.session.release();
187187
188188 applicationWindowLoader.active = true;
189189 }
@@ -244,7 +244,7 @@ Rectangle {
244244 setApplicationState(appStopped);
245245
246246 tryCompare(stateGroup, "state", "screenshot");
247− tryCompare(fakeSession, "surface", null);
247+ tryCompare(fakeApplication, "session", null);
248248 }
249249
250250 function test_restartApp() {
@@ -292,7 +292,7 @@ Rectangle {
292292 setApplicationState(appStopped);
293293
294294 tryCompare(stateGroup, "state", "screenshot");
295− tryCompare(fakeSession, "surface", null);
295+ tryCompare(fakeApplication, "session", null);
296296 }
297297
298298 function test_keepSurfaceWhileInvisible() {
tests/qmltests/Stages/tst_SessionContainer.qml+72−13
@@ -17,25 +17,72 @@
1717import QtQuick 2.0
1818import QtTest 1.0
1919import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1
2021import Unity.Application 0.1
2122import "../../../qml/Stages"
2223
23−Item {
24+Rectangle {
25+ color: "red"
2426 id: root
25− width: units.gu(40)
26− height: units.gu(80)
27−
27+ width: units.gu(70)
28+ height: units.gu(70)
2829
2930 property QtObject fakeApplication: null
3031
31− SessionContainer {
32− id: sessionContainer
33− anchors.fill: parent
3432
35− session: SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
36− onSessionChanged: {
37− session.manualSurfaceCreation = true;
38− session.createSurface();
33+ Component {
34+ id: sessionContainerComponent
35+
36+ SessionContainer {
37+ id: sessionContainer
38+ anchors.fill: parent
39+ }
40+ }
41+
42+ Loader {
43+ id: sessionContainerLoader
44+ anchors {
45+ top: parent.top
46+ bottom: parent.bottom
47+ left: parent.left
48+ }
49+ width: units.gu(40)
50+ sourceComponent: sessionContainerComponent
51+ }
52+
53+ Rectangle {
54+ color: "white"
55+ anchors {
56+ top: parent.top
57+ bottom: parent.bottom
58+ left: sessionContainerLoader.right
59+ right: parent.right
60+ }
61+
62+ Column {
63+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
64+ spacing: units.gu(1)
65+ Row {
66+ anchors { left: parent.left; right: parent.right }
67+ CheckBox {
68+ id: sessionCheckbox;
69+ checked: false;
70+ onCheckedChanged: {
71+ if (sessionContainerLoader.status !== Loader.Ready)
72+ return;
73+
74+ if (checked) {
75+ var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
76+ fakeSession.manualSurfaceCreation = true;
77+ fakeSession.createSurface();
78+ sessionContainerLoader.item.session = fakeSession;
79+ } else {
80+ sessionContainerLoader.item.session.release();
81+ }
82+ }
83+ }
84+ Label { text: "session" }
85+ }
3986 }
4087 }
4188
@@ -50,6 +97,12 @@ Item {
5097 name: "SessionContainer"
5198
5299 function init() {
100+ // reload our test subject to get it in a fresh state once again
101+ sessionContainerLoader.active = false;
102+ sessionCheckbox.checked = false;
103+ sessionContainerLoader.active = true;
104+
105+ tryCompare(sessionContainerLoader.item, "session", null);
53106 sessionSpy.clear();
54107 }
55108
@@ -61,13 +114,16 @@ Item {
61114 }
62115
63116 function test_addChildSession(data) {
117+ sessionCheckbox.checked = true;
118+ var sessionContainer = sessionContainerLoader.item;
64119 compare(sessionContainer.childSessions.count(), 0);
65120
66121 var i;
67122 var sessions = [];
68123 for (i = 0; i < data.count; i++) {
69124 var session = SessionManager.createSession(sessionContainer.session.name + "-Child" + i,
70− Qt.resolvedUrl("../Dash/artwork/music-player-design.png"))
125+ Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
126+ session.createSurface();
71127 sessionContainer.session.addChildSession(session);
72128 compare(sessionContainer.childSessions.count(), i+1);
73129
@@ -88,6 +144,8 @@ Item {
88144 }
89145
90146 function test_nestedChildSessions(data) {
147+ sessionCheckbox.checked = true;
148+ var sessionContainer = sessionContainerLoader.item;
91149 compare(sessionContainer.childSessions.count(), 0);
92150
93151 var i;
@@ -97,7 +155,8 @@ Item {
97155 var container = sessionContainer;
98156 for (i = 0; i < data.depth; i++) {
99157 var session = SessionManager.createSession(lastSession.name + "-Child" + i,
100− Qt.resolvedUrl("../Dash/artwork/music-player-design.png"))
158+ Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
159+ session.createSurface();
101160 lastSession.addChildSession(session);
102161 compare(container.childSessions.count(), 1);
103162 sessions.push(session);
tests/qmltests/Stages/tst_SurfaceContainer.qml+26−11
@@ -28,15 +28,22 @@ Rectangle {
2828 width: units.gu(70)
2929 height: units.gu(70)
3030
31− SurfaceContainer {
32− id: surfaceContainer
31+ Component {
32+ id: surfaceContainerComponent
33+ SurfaceContainer {
34+ anchors.fill: parent
35+ }
36+ }
37+ Loader {
38+ id: surfaceContainerLoader
3339 anchors {
3440 top: parent.top
41+ topMargin: fullscreenCheckbox.checked ? 0 : units.gu(3) + units.dp(2)
3542 bottom: parent.bottom
3643 left: parent.left
37− topMargin: fullscreenCheckbox.checked ? 0 : units.gu(3) + units.dp(2)
3844 }
3945 width: units.gu(40)
46+ sourceComponent: surfaceContainerComponent
4047 }
4148
4249 Rectangle {
@@ -44,7 +51,7 @@ Rectangle {
4451 anchors {
4552 top: parent.top
4653 bottom: parent.bottom
47− left: surfaceContainer.right
54+ left: surfaceContainerLoader.right
4855 right: parent.right
4956 }
5057
@@ -57,13 +64,17 @@ Rectangle {
5764 id: surfaceCheckbox;
5865 checked: false;
5966 onCheckedChanged: {
67+ if (surfaceContainerLoader.status !== Loader.Ready)
68+ return;
69+
6070 if (checked) {
61− surfaceContainer.surface = SurfaceManager.createSurface("fake-surface",
71+ var fakeSurface = SurfaceManager.createSurface("fake-surface",
6272 MirSurfaceItem.Normal,
6373 MirSurfaceItem.Restored,
6474 Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
75+ surfaceContainerLoader.item.surface = fakeSurface;
6576 } else {
66− surfaceContainer.surface.release();
77+ surfaceContainerLoader.item.surface.release();
6778 }
6879 }
6980 }
@@ -90,10 +101,12 @@ Rectangle {
90101
91102 function cleanup() {
92103 // reload our test subject to get it in a fresh state once again
104+ surfaceContainerLoader.active = false;
93105 surfaceCheckbox.checked = false;
94− tryCompare(surfaceContainer, "surface", null);
95− surfaceSpy.clear();
106+ surfaceContainerLoader.active = true;
96107
108+ tryCompare(surfaceContainerLoader.item, "surface", null);
109+ surfaceSpy.clear();
97110 }
98111
99112 /*
@@ -106,9 +119,9 @@ Rectangle {
106119 surfaceCheckbox.checked = true;
107120 surfaceCheckbox.checked = false;
108121 surfaceCheckbox.checked = true;
109− var fakeSurface = surfaceContainer.surface;
110− compare(fakeSurface.width, surfaceContainer.width);
111− compare(fakeSurface.height, surfaceContainer.height);
122+ var fakeSurface = surfaceContainerLoader.item.surface;
123+ compare(fakeSurface.width, surfaceContainerLoader.item.width);
124+ compare(fakeSurface.height, surfaceContainerLoader.item.height);
112125 }
113126
114127 function test_childSurfaces_data() {
@@ -117,6 +130,7 @@ Rectangle {
117130 }
118131
119132 function test_childSurfaces(data) {
133+ var surfaceContainer = surfaceContainerLoader.item;
120134 surfaceCheckbox.checked = true;
121135
122136 var i;
@@ -147,6 +161,7 @@ Rectangle {
147161 }
148162
149163 function test_nestedChildSurfaces(data) {
164+ var surfaceContainer = surfaceContainerLoader.item;
150165 surfaceCheckbox.checked = true;
151166
152167 var i;