on xenial help sign in
test fixes. + merge tweaks
d450385Nick Dedekind
qml/Stages/ApplicationWindow.qml+2−2
@@ -183,7 +183,7 @@ SessionContainer {
183 duration: UbuntuAnimation.BriskDuration }
183 duration: UbuntuAnimation.BriskDuration }
184 PropertyAction { target: surfaceContainer
184 PropertyAction { target: surfaceContainer
185 property: "visible"; value: false }
185 property: "visible"; value: false }
186− ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
186+ ScriptAction { script: { if (root.session) { root.session.release(); } } }
187 }
187 }
188 },
188 },
189 Transition {
189 Transition {
@@ -202,7 +202,7 @@ SessionContainer {
202 from: "surface"; to: "void"
202 from: "surface"; to: "void"
203 SequentialAnimation {
203 SequentialAnimation {
204 PropertyAction { target: surfaceContainer; property: "visible"; value: false }
204 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(); } } }
206 }
206 }
207 },
207 },
208 Transition {
208 Transition {
qml/Stages/SessionContainer.qml+4−2
@@ -67,12 +67,15 @@ Item {
67 onLoaded: {
67 onLoaded: {
68 item.session = modelData;
68 item.session = modelData;
69 item.interactive = Qt.binding(function() { return root.interactive; } );
69 item.interactive = Qt.binding(function() { return root.interactive; } );
70+ if (modelData.surface) {
71+ item.animateIn(swipeFromBottom);
72+ }
70 }
73 }
71
74
72 Connections {
75 Connections {
73 target: modelData
76 target: modelData
74 onSurfaceChanged: {
77 onSurfaceChanged: {
75− item.animateIn(swipeFromBottom);
78+ if (surface) item.animateIn(swipeFromBottom);
76 }
79 }
77 onRemoved: {
80 onRemoved: {
78 item.removing = true;
81 item.removing = true;
@@ -112,6 +115,5 @@ Item {
112 QtObject {
115 QtObject {
113 id: d
116 id: d
114 property var animations: []
117 property var animations: []
115− property var currentAnimation: animations.length > 0 ? animations[animations.length-1] : undefined
116 }
118 }
117}
119}
tests/mocks/Unity/Application/ApplicationInfo.cpp+1−2
@@ -44,7 +44,6 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
44 , m_state(Starting)
44 , m_state(Starting)
45 , m_focused(false)
45 , m_focused(false)
46 , m_fullscreen(false)
46 , m_fullscreen(false)
47− , m_parentItem(0)
48 , m_session(0)
47 , m_session(0)
49 , m_manualSessionCreation(false)
48 , m_manualSessionCreation(false)
50{
49{
@@ -57,7 +56,7 @@ ApplicationInfo::~ApplicationInfo()
57
56
58void ApplicationInfo::createSession()
57void ApplicationInfo::createSession()
59{
58{
60− if (m_session) { return; }
59+ if (m_session || state() == ApplicationInfo::Stopped) { return; }
61
60
62 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
61 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
63 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
62 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
tests/mocks/Unity/Application/ApplicationInfo.h−2
@@ -99,8 +99,6 @@ private:
99 State m_state;
99 State m_state;
100 bool m_focused;
100 bool m_focused;
101 bool m_fullscreen;
101 bool m_fullscreen;
102−
103− QQuickItem *m_parentItem;
104 Session* m_session;
102 Session* m_session;
105
103
106 bool m_manualSessionCreation;
104 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)
2
2
3set(FakeUnityApplicationQml_SOURCES
3set(FakeUnityApplicationQml_SOURCES
4 plugin.cpp
4 plugin.cpp
tests/qmltests/Stages/tst_ApplicationWindow.qml+9−9
@@ -32,8 +32,6 @@ Rectangle {
32 Component.onCompleted: {
32 Component.onCompleted: {
33 root.fakeApplication = ApplicationManager.add("gallery-app");
33 root.fakeApplication = ApplicationManager.add("gallery-app");
34 root.fakeApplication.manualSessionCreation = true;
34 root.fakeApplication.manualSessionCreation = true;
35− root.fakeApplication.createSession();
36− root.fakeApplication.session.manualSessionCreation = true;
37 root.fakeApplication.setState(ApplicationInfo.Starting);
35 root.fakeApplication.setState(ApplicationInfo.Starting);
38 }
36 }
39 property QtObject fakeApplication: null
37 property QtObject fakeApplication: null
@@ -84,10 +82,12 @@ Rectangle {
84 if (applicationWindowLoader.status !== Loader.Ready)
82 if (applicationWindowLoader.status !== Loader.Ready)
85 return;
83 return;
86
84
87− if (checked && !fakeSession.surface) {
85+ if (checked && !fakeApplication.session) {
86+ fakeApplication.createSession();
87+ fakeSession.manualSurfaceCreation = true;
88 fakeSession.createSurface();
88 fakeSession.createSurface();
89− } else if (!checked && fakeSession.surface) {
89+ } else if (!checked && fakeApplication.session) {
90− fakeSession.surface.release();
90+ fakeApplication.session.release();
91 }
91 }
92 }
92 }
93 }
93 }
@@ -182,8 +182,8 @@ Rectangle {
182 appStateSelector.selectedIndex = 0;
182 appStateSelector.selectedIndex = 0;
183 surfaceCheckbox.checked = false;
183 surfaceCheckbox.checked = false;
184
184
185− if (fakeApplication.surface)
185+ if (fakeApplication.session)
186− fakeApplication.surface.release();
186+ fakeApplication.session.release();
187
187
188 applicationWindowLoader.active = true;
188 applicationWindowLoader.active = true;
189 }
189 }
@@ -244,7 +244,7 @@ Rectangle {
244 setApplicationState(appStopped);
244 setApplicationState(appStopped);
245
245
246 tryCompare(stateGroup, "state", "screenshot");
246 tryCompare(stateGroup, "state", "screenshot");
247− tryCompare(fakeSession, "surface", null);
247+ tryCompare(fakeApplication, "session", null);
248 }
248 }
249
249
250 function test_restartApp() {
250 function test_restartApp() {
@@ -292,7 +292,7 @@ Rectangle {
292 setApplicationState(appStopped);
292 setApplicationState(appStopped);
293
293
294 tryCompare(stateGroup, "state", "screenshot");
294 tryCompare(stateGroup, "state", "screenshot");
295− tryCompare(fakeSession, "surface", null);
295+ tryCompare(fakeApplication, "session", null);
296 }
296 }
297
297
298 function test_keepSurfaceWhileInvisible() {
298 function test_keepSurfaceWhileInvisible() {
tests/qmltests/Stages/tst_SessionContainer.qml+72−13
@@ -17,25 +17,72 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
19import Unity.Test 0.1 as UT
20+import Ubuntu.Components 0.1
20import Unity.Application 0.1
21import Unity.Application 0.1
21import "../../../qml/Stages"
22import "../../../qml/Stages"
22
23
23−Item {
24+Rectangle {
25+ color: "red"
24 id: root
26 id: root
25− width: units.gu(40)
27+ width: units.gu(70)
26− height: units.gu(80)
28+ height: units.gu(70)
27−
28
29
29 property QtObject fakeApplication: null
30 property QtObject fakeApplication: null
30
31
31− SessionContainer {
32− id: sessionContainer
33− anchors.fill: parent
34
32
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) {
35− session: SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
75+ var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
36− onSessionChanged: {
37− session.manualSurfaceCreation = true;
76+ fakeSession.manualSurfaceCreation = true;
38− session.createSurface();
77+ fakeSession.createSurface();
78+ sessionContainerLoader.item.session = fakeSession;
79+ } else {
80+ sessionContainerLoader.item.session.release();
81+ }
82+ }
83+ }
84+ Label { text: "session" }
85+ }
39 }
86 }
40 }
87 }
41
88
@@ -50,6 +97,12 @@ Item {
50 name: "SessionContainer"
97 name: "SessionContainer"
51
98
52 function init() {
99 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);
53 sessionSpy.clear();
106 sessionSpy.clear();
54 }
107 }
55
108
@@ -61,13 +114,16 @@ Item {
61 }
114 }
62
115
63 function test_addChildSession(data) {
116 function test_addChildSession(data) {
117+ sessionCheckbox.checked = true;
118+ var sessionContainer = sessionContainerLoader.item;
64 compare(sessionContainer.childSessions.count(), 0);
119 compare(sessionContainer.childSessions.count(), 0);
65
120
66 var i;
121 var i;
67 var sessions = [];
122 var sessions = [];
68 for (i = 0; i < data.count; i++) {
123 for (i = 0; i < data.count; i++) {
69 var session = SessionManager.createSession(sessionContainer.session.name + "-Child" + i,
124 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();
71 sessionContainer.session.addChildSession(session);
127 sessionContainer.session.addChildSession(session);
72 compare(sessionContainer.childSessions.count(), i+1);
128 compare(sessionContainer.childSessions.count(), i+1);
73
129
@@ -88,6 +144,8 @@ Item {
88 }
144 }
89
145
90 function test_nestedChildSessions(data) {
146 function test_nestedChildSessions(data) {
147+ sessionCheckbox.checked = true;
148+ var sessionContainer = sessionContainerLoader.item;
91 compare(sessionContainer.childSessions.count(), 0);
149 compare(sessionContainer.childSessions.count(), 0);
92
150
93 var i;
151 var i;
@@ -97,7 +155,8 @@ Item {
97 var container = sessionContainer;
155 var container = sessionContainer;
98 for (i = 0; i < data.depth; i++) {
156 for (i = 0; i < data.depth; i++) {
99 var session = SessionManager.createSession(lastSession.name + "-Child" + i,
157 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();
101 lastSession.addChildSession(session);
160 lastSession.addChildSession(session);
102 compare(container.childSessions.count(), 1);
161 compare(container.childSessions.count(), 1);
103 sessions.push(session);
162 sessions.push(session);
tests/qmltests/Stages/tst_SurfaceContainer.qml+26−11
@@ -28,15 +28,22 @@ Rectangle {
28 width: units.gu(70)
28 width: units.gu(70)
29 height: units.gu(70)
29 height: units.gu(70)
30
30
31+ Component {
32+ id: surfaceContainerComponent
31− SurfaceContainer {
33+ SurfaceContainer {
32− id: surfaceContainer
34+ anchors.fill: parent
35+ }
36+ }
37+ Loader {
38+ id: surfaceContainerLoader
33 anchors {
39 anchors {
34 top: parent.top
40 top: parent.top
41+ topMargin: fullscreenCheckbox.checked ? 0 : units.gu(3) + units.dp(2)
35 bottom: parent.bottom
42 bottom: parent.bottom
36 left: parent.left
43 left: parent.left
37− topMargin: fullscreenCheckbox.checked ? 0 : units.gu(3) + units.dp(2)
38 }
44 }
39 width: units.gu(40)
45 width: units.gu(40)
46+ sourceComponent: surfaceContainerComponent
40 }
47 }
41
48
42 Rectangle {
49 Rectangle {
@@ -44,7 +51,7 @@ Rectangle {
44 anchors {
51 anchors {
45 top: parent.top
52 top: parent.top
46 bottom: parent.bottom
53 bottom: parent.bottom
47− left: surfaceContainer.right
54+ left: surfaceContainerLoader.right
48 right: parent.right
55 right: parent.right
49 }
56 }
50
57
@@ -57,13 +64,17 @@ Rectangle {
57 id: surfaceCheckbox;
64 id: surfaceCheckbox;
58 checked: false;
65 checked: false;
59 onCheckedChanged: {
66 onCheckedChanged: {
67+ if (surfaceContainerLoader.status !== Loader.Ready)
68+ return;
69+
60 if (checked) {
70 if (checked) {
61− surfaceContainer.surface = SurfaceManager.createSurface("fake-surface",
71+ var fakeSurface = SurfaceManager.createSurface("fake-surface",
62 MirSurfaceItem.Normal,
72 MirSurfaceItem.Normal,
63 MirSurfaceItem.Restored,
73 MirSurfaceItem.Restored,
64 Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
74 Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
75+ surfaceContainerLoader.item.surface = fakeSurface;
65 } else {
76 } else {
66− surfaceContainer.surface.release();
77+ surfaceContainerLoader.item.surface.release();
67 }
78 }
68 }
79 }
69 }
80 }
@@ -90,10 +101,12 @@ Rectangle {
90
101
91 function cleanup() {
102 function cleanup() {
92 // reload our test subject to get it in a fresh state once again
103 // reload our test subject to get it in a fresh state once again
104+ surfaceContainerLoader.active = false;
93 surfaceCheckbox.checked = false;
105 surfaceCheckbox.checked = false;
94− tryCompare(surfaceContainer, "surface", null);
106+ surfaceContainerLoader.active = true;
95− surfaceSpy.clear();
96
107
108+ tryCompare(surfaceContainerLoader.item, "surface", null);
109+ surfaceSpy.clear();
97 }
110 }
98
111
99 /*
112 /*
@@ -106,9 +119,9 @@ Rectangle {
106 surfaceCheckbox.checked = true;
119 surfaceCheckbox.checked = true;
107 surfaceCheckbox.checked = false;
120 surfaceCheckbox.checked = false;
108 surfaceCheckbox.checked = true;
121 surfaceCheckbox.checked = true;
109− var fakeSurface = surfaceContainer.surface;
122+ var fakeSurface = surfaceContainerLoader.item.surface;
110− compare(fakeSurface.width, surfaceContainer.width);
123+ compare(fakeSurface.width, surfaceContainerLoader.item.width);
111− compare(fakeSurface.height, surfaceContainer.height);
124+ compare(fakeSurface.height, surfaceContainerLoader.item.height);
112 }
125 }
113
126
114 function test_childSurfaces_data() {
127 function test_childSurfaces_data() {
@@ -117,6 +130,7 @@ Rectangle {
117 }
130 }
118
131
119 function test_childSurfaces(data) {
132 function test_childSurfaces(data) {
133+ var surfaceContainer = surfaceContainerLoader.item;
120 surfaceCheckbox.checked = true;
134 surfaceCheckbox.checked = true;
121
135
122 var i;
136 var i;
@@ -147,6 +161,7 @@ Rectangle {
147 }
161 }
148
162
149 function test_nestedChildSurfaces(data) {
163 function test_nestedChildSurfaces(data) {
164+ var surfaceContainer = surfaceContainerLoader.item;
150 surfaceCheckbox.checked = true;
165 surfaceCheckbox.checked = true;
151
166
152 var i;
167 var i;