on xenial help sign in
Merge trunk and fix conflicts
b7bea4cGerry Boland
debian/changelog+7
@@ -1,3 +1,10 @@
1+unity8 (8.00+14.10.20140903.1-0ubuntu1) utopic; urgency=low
2+
3+ [ Nick Dedekind ]
4+ * Support for nested prompt session. (LP: #1358388)
5+
6+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Wed, 03 Sep 2014 07:58:49 +0000
7+
1unity8 (8.00+14.10.20140828.1-0ubuntu1) utopic; urgency=low
8unity8 (8.00+14.10.20140828.1-0ubuntu1) utopic; urgency=low
2
9
3 [ Michael Terry ]
10 [ Michael Terry ]
debian/control+1−1
@@ -85,7 +85,7 @@ Depends: gsettings-desktop-schemas,
85 qmenumodel-qml (>= 0.2.8),
85 qmenumodel-qml (>= 0.2.8),
86 qml-module-qtquick-xmllistmodel,
86 qml-module-qtquick-xmllistmodel,
87 qtdeclarative5-gsettings1.0,
87 qtdeclarative5-gsettings1.0,
88− qtdeclarative5-qtmir-plugin (>= 0.4.1),
88+ qtdeclarative5-qtmir-plugin (>= 0.4.3),
89 qtdeclarative5-ubuntu-telephony0.1,
89 qtdeclarative5-ubuntu-telephony0.1,
90 unity-launcher-impl-3,
90 unity-launcher-impl-3,
91 unity8-common (= ${source:Version}),
91 unity8-common (= ${source:Version}),
plugins/AccountsService/AccountsService.qmltypes+1
@@ -26,5 +26,6 @@ Module {
26 Property { name: "backgroundFile"; type: "string"; isReadonly: true }
26 Property { name: "backgroundFile"; type: "string"; isReadonly: true }
27 Property { name: "statsWelcomeScreen"; type: "bool"; isReadonly: true }
27 Property { name: "statsWelcomeScreen"; type: "bool"; isReadonly: true }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
29+ Property { name: "failedLogins"; type: "uint" }
29 }
30 }
30}
31}
plugins/LightDM/LightDM.qmltypes+2
@@ -27,6 +27,7 @@ Module {
27 name: "showPrompt"
27 name: "showPrompt"
28 Parameter { name: "text"; type: "string" }
28 Parameter { name: "text"; type: "string" }
29 Parameter { name: "isSecret"; type: "bool" }
29 Parameter { name: "isSecret"; type: "bool" }
30+ Parameter { name: "isDefaultPrompt"; type: "bool" }
30 }
31 }
31 Signal { name: "authenticationComplete" }
32 Signal { name: "authenticationComplete" }
32 Signal {
33 Signal {
@@ -34,6 +35,7 @@ Module {
34 Parameter { name: "user"; type: "string" }
35 Parameter { name: "user"; type: "string" }
35 }
36 }
36 Signal { name: "isActiveChanged" }
37 Signal { name: "isActiveChanged" }
38+ Signal { name: "isAuthenticatedChanged" }
37 Signal { name: "showGreeter" }
39 Signal { name: "showGreeter" }
38 Signal {
40 Signal {
39 name: "requestAuthenticationUser"
41 name: "requestAuthenticationUser"
plugins/Ubuntu/SystemImage/SystemImage.qmltypes+2
@@ -11,6 +11,8 @@ Module {
11 name: "SystemImage"
11 name: "SystemImage"
12 prototype: "QObject"
12 prototype: "QObject"
13 exports: ["Ubuntu.SystemImage/SystemImage 0.1"]
13 exports: ["Ubuntu.SystemImage/SystemImage 0.1"]
14+ isCreatable: false
15+ isSingleton: true
14 exportMetaObjectRevisions: [0]
16 exportMetaObjectRevisions: [0]
15 Method { name: "factoryReset" }
17 Method { name: "factoryReset" }
16 }
18 }
plugins/Unity/Indicators/Indicators.qmltypes+6−4
@@ -219,12 +219,14 @@ Module {
219 Method {
219 Method {
220 name: "model"
220 name: "model"
221 type: "UnityMenuModel*"
221 type: "UnityMenuModel*"
222− Parameter { name: "path"; type: "string" }
222+ Parameter { name: "bus"; type: "QByteArray" }
223+ Parameter { name: "path"; type: "QByteArray" }
224+ Parameter { name: "actions"; type: "QVariantMap" }
223 }
225 }
224 Method {
226 Method {
225− name: "registerModel"
227+ name: "contains"
228+ type: "bool"
226− Parameter { name: "path"; type: "string" }
229+ Parameter { name: "path"; type: "QByteArray" }
227− Parameter { name: "menuModel"; type: "UnityMenuModel"; isPointer: true }
228 }
230 }
229 }
231 }
230 Component {
232 Component {
po/az.po+56−64
@@ -8,18 +8,18 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2014-08-26 18:24+0200\n"
10"POT-Creation-Date: 2014-08-26 18:24+0200\n"
11−"PO-Revision-Date: 2014-08-26 22:12+0000\n"
11+"PO-Revision-Date: 2014-09-03 16:39+0000\n"
12−"Last-Translator: Turan Mahmudov <turan.mahmudov@gmail.com>\n"
12+"Last-Translator: Nicat Məmmədov <n1c4t97@gmail.com>\n"
13"Language-Team: Azerbaijani <az@li.org>\n"
13"Language-Team: Azerbaijani <az@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17−"X-Launchpad-Export-Date: 2014-08-28 06:29+0000\n"
17+"X-Launchpad-Export-Date: 2014-09-04 08:35+0000\n"
18−"X-Generator: Launchpad (build 17174)\n"
18+"X-Generator: Launchpad (build 17196)\n"
19
19
20−#: plugins/LightDM/Greeter.cpp:129
20+#: plugins/LightDM/Greeter.cpp:130
21msgid "Password: "
21msgid "Password: "
22−msgstr "Parol: "
22+msgstr "Şifrә: "
23
23
24#: plugins/Unity/Launcher/launcheritem.cpp:43
24#: plugins/Unity/Launcher/launcheritem.cpp:43
25#: plugins/Unity/Launcher/launcheritem.cpp:73
25#: plugins/Unity/Launcher/launcheritem.cpp:73
@@ -32,37 +32,37 @@ msgstr "Açma qısayolu"
32
32
33#: qml/Components/Dialogs.qml:70
33#: qml/Components/Dialogs.qml:70
34msgid "Log out"
34msgid "Log out"
35−msgstr ""
35+msgstr "Çıxış"
36
36
37#: qml/Components/Dialogs.qml:71
37#: qml/Components/Dialogs.qml:71
38msgid "Are you sure you want to log out?"
38msgid "Are you sure you want to log out?"
39−msgstr ""
39+msgstr "Çıxmaq istәdiyinizdәn әminsiniz?"
40
40
41#: qml/Components/Dialogs.qml:73 qml/Components/Dialogs.qml:97
41#: qml/Components/Dialogs.qml:73 qml/Components/Dialogs.qml:97
42#: qml/Components/Dialogs.qml:122
42#: qml/Components/Dialogs.qml:122
43msgid "No"
43msgid "No"
44−msgstr ""
44+msgstr "Yox"
45
45
46#: qml/Components/Dialogs.qml:80 qml/Components/Dialogs.qml:104
46#: qml/Components/Dialogs.qml:80 qml/Components/Dialogs.qml:104
47#: qml/Components/Dialogs.qml:129
47#: qml/Components/Dialogs.qml:129
48msgid "Yes"
48msgid "Yes"
49−msgstr ""
49+msgstr "Hə"
50
50
51#: qml/Components/Dialogs.qml:94
51#: qml/Components/Dialogs.qml:94
52msgid "Shut down"
52msgid "Shut down"
53−msgstr ""
53+msgstr "Sistemi Söndür"
54
54
55#: qml/Components/Dialogs.qml:95
55#: qml/Components/Dialogs.qml:95
56msgid "Are you sure you want to shut down?"
56msgid "Are you sure you want to shut down?"
57−msgstr ""
57+msgstr "Sistemi söndürmәk istәdiyinizә әminsiniz?"
58
58
59#: qml/Components/Dialogs.qml:119
59#: qml/Components/Dialogs.qml:119
60msgid "Reboot"
60msgid "Reboot"
61−msgstr ""
61+msgstr "Yenidən yüklə"
62
62
63#: qml/Components/Dialogs.qml:120
63#: qml/Components/Dialogs.qml:120
64msgid "Are you sure you want to reboot?"
64msgid "Are you sure you want to reboot?"
65−msgstr ""
65+msgstr "Yenidәn başlatmaq istәdiyinizә әminsiniz?"
66
66
67#: qml/Components/Dialogs.qml:144
67#: qml/Components/Dialogs.qml:144
68msgid "Power"
68msgid "Power"
@@ -74,17 +74,17 @@ msgid ""
74"to power off?"
74"to power off?"
75msgstr ""
75msgstr ""
76
76
77−#: qml/Components/Dialogs.qml:144
77+#: qml/Components/Dialogs.qml:147
78msgid "Power off"
78msgid "Power off"
79msgstr "Söndür"
79msgstr "Söndür"
80
80
81−#: qml/Components/Dialogs.qml:162
81+#: qml/Components/Dialogs.qml:157
82msgid "Cancel"
82msgid "Cancel"
83msgstr "İmtina"
83msgstr "İmtina"
84
84
85#: qml/Components/EdgeDemoOverlay.qml:151
85#: qml/Components/EdgeDemoOverlay.qml:151
86msgid "Skip intro"
86msgid "Skip intro"
87−msgstr "Intro -nu keç"
87+msgstr "Tәqdimatı keç"
88
88
89#: qml/Components/EdgeDemo.qml:112
89#: qml/Components/EdgeDemo.qml:112
90msgid "Right edge"
90msgid "Right edge"
@@ -92,7 +92,7 @@ msgstr "Sağ Künc"
92
92
93#: qml/Components/EdgeDemo.qml:113
93#: qml/Components/EdgeDemo.qml:113
94msgid "Try swiping from the right edge to unlock the phone"
94msgid "Try swiping from the right edge to unlock the phone"
95−msgstr "Kilidi açmaq üçün sağ küncdən çəkin"
95+msgstr "Kilidi açmaq üçün sağ küncdən sürüşdürün"
96
96
97#: qml/Components/EdgeDemo.qml:144
97#: qml/Components/EdgeDemo.qml:144
98msgid "Top edge"
98msgid "Top edge"
@@ -100,7 +100,7 @@ msgstr "Yuxarı künc"
100
100
101#: qml/Components/EdgeDemo.qml:145
101#: qml/Components/EdgeDemo.qml:145
102msgid "Try swiping from the top edge to access the indicators"
102msgid "Try swiping from the top edge to access the indicators"
103−msgstr "Göstəricilərə keçid üçün yuxarı küncdən çəkin"
103+msgstr "Göstəriciləri görmәk üçün yuxarı küncdən sürüşdürün"
104
104
105#: qml/Components/EdgeDemo.qml:170
105#: qml/Components/EdgeDemo.qml:170
106msgid "Close"
106msgid "Close"
@@ -108,7 +108,7 @@ msgstr "Bağla"
108
108
109#: qml/Components/EdgeDemo.qml:171
109#: qml/Components/EdgeDemo.qml:171
110msgid "Swipe up again to close the settings screen"
110msgid "Swipe up again to close the settings screen"
111−msgstr "Nizamlamalar ekranını bağlamaq üçün yenidən yuxarı çəkin"
111+msgstr "Nizamlamalar ekranını bağlamaq üçün yenidən yuxarı sürüşdürün"
112
112
113#: qml/Components/EdgeDemo.qml:198
113#: qml/Components/EdgeDemo.qml:198
114msgid "Left edge"
114msgid "Left edge"
@@ -128,16 +128,16 @@ msgid ""
128"You have now mastered the edge gestures and can start using the "
128"You have now mastered the edge gestures and can start using the "
129"phone<br><br>Tap on the screen to start"
129"phone<br><br>Tap on the screen to start"
130msgstr ""
130msgstr ""
131−"Siz künc jestlərini mənimsəmisiniz və telefonu istifadə etməyə başlaya "
131+"Siz künc hәrәkәtlәrini öyrәndiniz və telefonu istifadə etməyə başlaya "
132"bilərsiniz.<br><br>Başlamaq üçün ekrana toxunun"
132"bilərsiniz.<br><br>Başlamaq üçün ekrana toxunun"
133
133
134#: qml/Components/Lockscreen.qml:167
134#: qml/Components/Lockscreen.qml:167
135msgid "Please wait"
135msgid "Please wait"
136−msgstr "Lütfən gözləyin"
136+msgstr "Xahiş edirik gözləyin"
137
137
138#: qml/Components/Lockscreen.qml:172
138#: qml/Components/Lockscreen.qml:172
139msgid "Too many incorrect attempts"
139msgid "Too many incorrect attempts"
140−msgstr "Çoxlu yanlış cəhd"
140+msgstr "Çoxlu yanlış cəhdlәr"
141
141
142#: qml/Components/Lockscreen.qml:206
142#: qml/Components/Lockscreen.qml:206
143msgid "Emergency Call"
143msgid "Emergency Call"
@@ -145,44 +145,45 @@ msgstr "Zərurət zəngi"
145
145
146#: qml/Components/Lockscreen.qml:226
146#: qml/Components/Lockscreen.qml:226
147msgid "OK"
147msgid "OK"
148−msgstr "ОК"
148+msgstr "Oldu"
149
149
150#: qml/Components/PassphraseLockscreen.qml:61
150#: qml/Components/PassphraseLockscreen.qml:61
151#, qt-format
151#, qt-format
152msgid "Hello %1"
152msgid "Hello %1"
153−msgstr "Xoş gördük %1"
153+msgstr "Salam %1"
154
154
155#: qml/Components/PassphraseLockscreen.qml:61
155#: qml/Components/PassphraseLockscreen.qml:61
156msgid "Hello"
156msgid "Hello"
157−msgstr "Xoş gördük"
157+msgstr "Salam"
158
158
159#: qml/Dash/GenericScopeView.qml:361
159#: qml/Dash/GenericScopeView.qml:361
160msgid "See less"
160msgid "See less"
161−msgstr "Daha az gör"
161+msgstr "Daha azını gör"
162
162
163#: qml/Dash/GenericScopeView.qml:361
163#: qml/Dash/GenericScopeView.qml:361
164msgid "See all"
164msgid "See all"
165msgstr "Hamısını gör"
165msgstr "Hamısını gör"
166
166
167−#: qml/Dash/GenericScopeView.qml:424 qml/Panel/SearchIndicator.qml:27
167+#: qml/Dash/GenericScopeView.qml:424 qml/Dash/PageHeader.qml:260
168+#: qml/Panel/SearchIndicator.qml:27
168msgid "Search"
169msgid "Search"
169msgstr "Axtar"
170msgstr "Axtar"
170
171
171#: qml/Dash/PageHeader.qml:270
172#: qml/Dash/PageHeader.qml:270
172msgid "Settings"
173msgid "Settings"
173−msgstr ""
174+msgstr "Tənzimləmələr"
174
175
175#: qml/Dash/PageHeader.qml:279
176#: qml/Dash/PageHeader.qml:279
176msgid "Remove from Favorites"
177msgid "Remove from Favorites"
177−msgstr ""
178+msgstr "Seçilmişlәrdәn çıxart"
178
179
179#: qml/Dash/PageHeader.qml:279
180#: qml/Dash/PageHeader.qml:279
180msgid "Add to Favorites"
181msgid "Add to Favorites"
181−msgstr ""
182+msgstr "Seçilmişlәrә әlavә et"
182
183
183#: qml/Dash/Previews/PreviewActionCombo.qml:34
184#: qml/Dash/Previews/PreviewActionCombo.qml:34
184msgid "More..."
185msgid "More..."
185−msgstr "Ətraflı..."
186+msgstr "Daha çox..."
186
187
187#: qml/Dash/Previews/PreviewActionCombo.qml:34
188#: qml/Dash/Previews/PreviewActionCombo.qml:34
188msgid "Less..."
189msgid "Less..."
@@ -190,7 +191,7 @@ msgstr "Az..."
190
191
191#: qml/Dash/Previews/PreviewRatingInput.qml:81
192#: qml/Dash/Previews/PreviewRatingInput.qml:81
192msgid "Rate this"
193msgid "Rate this"
193−msgstr "Qiymət ver"
194+msgstr "Qiymәtlәndir"
194
195
195#: qml/Dash/Previews/PreviewRatingInput.qml:126
196#: qml/Dash/Previews/PreviewRatingInput.qml:126
196msgid "Add a review"
197msgid "Add a review"
@@ -204,13 +205,13 @@ msgstr "Göndər"
204msgid "Manage Dash"
205msgid "Manage Dash"
205msgstr ""
206msgstr ""
206
207
207−#: qml/Dash/ScopesOverview.qml:408
208+#: qml/Dash/ScopesOverview.qml:417
208msgid "Done"
209msgid "Done"
209msgstr "Başa çatdı"
210msgstr "Başa çatdı"
210
211
211−#: qml/Dash/ScopesOverview.qml:434
212+#: qml/Dash/ScopesOverview.qml:443
212msgid "Store"
213msgid "Store"
213−msgstr "Saxla"
214+msgstr ""
214
215
215#: qml/Dash/ScopesOverviewTab.qml:36
216#: qml/Dash/ScopesOverviewTab.qml:36
216msgid "Favorites"
217msgid "Favorites"
@@ -224,13 +225,13 @@ msgstr "Hamısı"
224msgid "Swipe to unlock"
225msgid "Swipe to unlock"
225msgstr "Kilidi açmaq üçün sürüşdürün"
226msgstr "Kilidi açmaq üçün sürüşdürün"
226
227
227−#: qml/Hud/HudParametrizedActionsPage.qml:132
228+#: qml/Hud/HudParametrizedActionsPage.qml:139
228msgid "Confirm"
229msgid "Confirm"
229msgstr "Təsdiqlə"
230msgstr "Təsdiqlə"
230
231
231#: qml/Hud/Hud.qml:61 qml/Hud/Hud.qml:99 qml/Hud/Hud.qml:372
232#: qml/Hud/Hud.qml:61 qml/Hud/Hud.qml:99 qml/Hud/Hud.qml:372
232msgid "Type or say a command"
233msgid "Type or say a command"
233−msgstr "Əmri söyləyin və ya yazın"
234+msgstr "Bir әmr söyləyin və ya yazın"
234
235
235#: qml/Hud/Hud.qml:84
236#: qml/Hud/Hud.qml:84
236msgid "Loading. Please Wait..."
237msgid "Loading. Please Wait..."
@@ -246,15 +247,15 @@ msgstr "Danışır..."
246
247
247#: qml/Notifications/NotificationMenuItemFactory.qml:105
248#: qml/Notifications/NotificationMenuItemFactory.qml:105
248msgid "Show password"
249msgid "Show password"
249−msgstr "Parolu göstər"
250+msgstr "Şifrәni göstәr"
250
251
251#: qml/Notifications/NotificationMenuItemFactory.qml:120
252#: qml/Notifications/NotificationMenuItemFactory.qml:120
252msgid "Enter SIM PIN"
253msgid "Enter SIM PIN"
253msgstr "SIM PIN kodunuzu daxil edin"
254msgstr "SIM PIN kodunuzu daxil edin"
254
255
255−#: qml/Notifications/NotificationMenuItemFactory.qml:121 qml/Shell.qml:270
256+#: qml/Notifications/NotificationMenuItemFactory.qml:121
256msgid "Sorry, incorrect PIN"
257msgid "Sorry, incorrect PIN"
257−msgstr "Təəssüf ki, PIN yanlışdır"
258+msgstr "Bağışlayın, PIN yanlışdır"
258
259
259#: qml/Panel/ActiveCallHint.qml:77
260#: qml/Panel/ActiveCallHint.qml:77
260msgid "Tap to return to call..."
261msgid "Tap to return to call..."
@@ -274,7 +275,7 @@ msgstr "Endirilir"
274
275
275#: qml/Panel/Indicators/MenuItemFactory.qml:657
276#: qml/Panel/Indicators/MenuItemFactory.qml:657
276msgid "Paused, tap to resume"
277msgid "Paused, tap to resume"
277−msgstr "Saxlanıldı, davam etmək üçün toxunun"
278+msgstr "Dayandırıldı. Davam etmək üçün toxunun"
278
279
279#: qml/Panel/Indicators/MenuItemFactory.qml:659
280#: qml/Panel/Indicators/MenuItemFactory.qml:659
280msgid "Canceled"
281msgid "Canceled"
@@ -286,7 +287,7 @@ msgstr "Bitdi"
286
287
287#: qml/Panel/Indicators/MenuItemFactory.qml:663
288#: qml/Panel/Indicators/MenuItemFactory.qml:663
288msgid "Failed, tap to retry"
289msgid "Failed, tap to retry"
289−msgstr "Alınmadı, davam etmək üçün toxunun"
290+msgstr "Alınmadı. Yenidәn cәhd etmək üçün toxunun"
290
291
291#: qml/Panel/Indicators/ModemInfoItem.qml:105
292#: qml/Panel/Indicators/ModemInfoItem.qml:105
292msgid "Unlock SIM"
293msgid "Unlock SIM"
@@ -296,13 +297,13 @@ msgstr "SIM kilidini aç"
296msgid "Roaming"
297msgid "Roaming"
297msgstr "Rominq"
298msgstr "Rominq"
298
299
299−#: qml/Shell.qml:266
300+#: qml/Shell.qml:279
300msgid "Enter your passphrase"
301msgid "Enter your passphrase"
301msgstr "Açar sözünüzü daxil edin"
302msgstr "Açar sözünüzü daxil edin"
302
303
303−#: qml/Shell.qml:267
304+#: qml/Shell.qml:280
304msgid "Sorry, incorrect passphrase"
305msgid "Sorry, incorrect passphrase"
305−msgstr "Təəssüf ki, açar söz yanlışdır"
306+msgstr "Bağışlayın, açar söz yanlışdır"
306
307
307#: qml/Shell.qml:282
308#: qml/Shell.qml:282
308msgid "Enter your passcode"
309msgid "Enter your passcode"
@@ -312,29 +313,29 @@ msgstr ""
312msgid "Sorry, incorrect passcode"
313msgid "Sorry, incorrect passcode"
313msgstr ""
314msgstr ""
314
315
315−#: qml/Shell.qml:273
316+#: qml/Shell.qml:286
316#, qt-format
317#, qt-format
317msgid "Enter your %1"
318msgid "Enter your %1"
318msgstr "%1 daxil edin"
319msgstr "%1 daxil edin"
319
320
320−#: qml/Shell.qml:274
321+#: qml/Shell.qml:287
321#, qt-format
322#, qt-format
322msgid "Sorry, incorrect %1"
323msgid "Sorry, incorrect %1"
323−msgstr "Təəssüf ki, %1 yanlışdır"
324+msgstr "Bağışlayın, %1 yanlışdır"
324
325
325−#: qml/Shell.qml:310
326+#: qml/Shell.qml:323
326msgid "Sorry, incorrect passphrase."
327msgid "Sorry, incorrect passphrase."
327−msgstr "Təəssüf ki, açar söz yanlışdır."
328+msgstr "Bağışlayın, açar söz yanlışdır."
328
329
329−#: qml/Shell.qml:311
330+#: qml/Shell.qml:324
330msgid "Sorry, incorrect passcode."
331msgid "Sorry, incorrect passcode."
331msgstr "Təəssüf ki, açar kod yanlışdır."
332msgstr "Təəssüf ki, açar kod yanlışdır."
332
333
333−#: qml/Shell.qml:312
334+#: qml/Shell.qml:325
334msgid "This will be your last attempt."
335msgid "This will be your last attempt."
335msgstr "Bu sizin son cəhdiniz olacaq."
336msgstr "Bu sizin son cəhdiniz olacaq."
336
337
337−#: qml/Shell.qml:314
338+#: qml/Shell.qml:327
338msgid ""
339msgid ""
339"If passphrase is entered incorrectly, your phone will conduct a factory "
340"If passphrase is entered incorrectly, your phone will conduct a factory "
340"reset and all personal data will be deleted."
341"reset and all personal data will be deleted."
@@ -342,19 +343,10 @@ msgstr ""
342"Əgər açar söz yanlış daxil edilibsə, onda telefonunuz fabrika parametrlərinə "
343"Əgər açar söz yanlış daxil edilibsə, onda telefonunuz fabrika parametrlərinə "
343"geri qayıdacaq və bütün şəxsi məlumatlarınız silinəcək."
344"geri qayıdacaq və bütün şəxsi məlumatlarınız silinəcək."
344
345
345−#: qml/Shell.qml:315
346+#: qml/Shell.qml:328
346msgid ""
347msgid ""
347"If passcode is entered incorrectly, your phone will conduct a factory reset "
348"If passcode is entered incorrectly, your phone will conduct a factory reset "
348"and all personal data will be deleted."
349"and all personal data will be deleted."
349msgstr ""
350msgstr ""
350"Əgər açar kod yanlış daxil edilibsə, onda telefonunuz fabrika parametrlərinə "
351"Əgər açar kod yanlış daxil edilibsə, onda telefonunuz fabrika parametrlərinə "
351"geri qayıdacaq və bütün şəxsi məlumatlarınız silinəcək."
352"geri qayıdacaq və bütün şəxsi məlumatlarınız silinəcək."
352−
353−#~ msgid "Are you sure you would like to turn power off?"
354−#~ msgstr "Söndürmək istədiyinizə əminsiniz?"
355−
356−#~ msgid "Restart"
357−#~ msgstr "Yenidən Başlat"
358−
359−#~ msgid "Enter your PIN"
360−#~ msgstr "PIN kodunuzu daxil edin"
qml/Shell.qml+9
@@ -251,6 +251,15 @@ Item {
251 }
251 }
252 }
252 }
253 }
253 }
254+ Connections {
255+ target: SessionManager
256+ onSessionStopping: {
257+ if (!session.parentSession && !session.application) {
258+ // nothing is using it. delete it right away
259+ session.release();
260+ }
261+ }
262+ }
254
263
255 Lockscreen {
264 Lockscreen {
256 id: lockscreen
265 id: lockscreen
qml/Stages/Animations/BaseSurfaceAnimation.qml → qml/Stages/Animations/BaseSessionAnimation.qmlrenamed+23−20
@@ -37,57 +37,60 @@ import QtQuick 2.0
37 */
37 */
38Item {
38Item {
39 id: base
39 id: base
40− property Item surface: null
40+ property var container
41+ objectName: "sessionAnimation"
41
42
42− // changes applied when state changes to "in"
43+ // changes applied when state changes to "from"
43− property list<QtObject> outChanges
44+ property list<QtObject> fromChanges
44− // transition animations when changing state to "in"
45+ // transition animations when changing state to "from"
45− property list<QtObject> outAnimations
46+ property list<QtObject> fromAnimations
46
47
47− // changes applied when state changes to "out"
48+ // changes applied when state changes to "to"
48− property list<QtObject> inChanges
49+ property list<QtObject> toChanges
49− // transition animations when changing state to "out"
50+ // transition animations when changing state to "to"
50− property list<QtObject> inAnimations
51+ property list<QtObject> toAnimations
51
52
52 function start() {
53 function start() {
53− // "prep" state forces outChanges without transition animations.
54+ // "prep" state forces toChanges without transition animations.
54 state = "prep"
55 state = "prep"
55− state = "in";
56+ state = "to";
56 }
57 }
57 function end() {
58 function end() {
58− state = "out";
59+ state = "from";
59 }
60 }
60
61
62+ signal completed()
63+
61 states: [
64 states: [
62 State {
65 State {
63 name: "baseAnimation"
66 name: "baseAnimation"
64− PropertyChanges { target: base.surface; anchors.fill: undefined }
67+ PropertyChanges { target: container; anchors.fill: undefined }
65 },
68 },
66
69
67 State {
70 State {
68 name: "prep"
71 name: "prep"
69 extend: "baseAnimation"
72 extend: "baseAnimation"
70− changes: outChanges
73+ changes: fromChanges
71 },
74 },
72 State {
75 State {
73− name: "out"
76+ name: "from"
74 extend: "prep"
77 extend: "prep"
75 },
78 },
76 State {
79 State {
77 name: "in"
80 name: "in"
78 extend: "baseAnimation"
81 extend: "baseAnimation"
79− changes: inChanges
82+ changes: toChanges
80 }
83 }
81 ]
84 ]
82
85
83 transitions: [
86 transitions: [
84 Transition {
87 Transition {
85− to: "out"
88+ to: "from"
86− animations: outAnimations
89+ animations: fromAnimations
87 },
90 },
88 Transition {
91 Transition {
89− to: "in"
92+ to: "to"
90− animations: inAnimations
93+ animations: toAnimations
91 }
94 }
92 ]
95 ]
93}
96}
qml/Stages/Animations/DarkenAndFadeInAnimation.qmldeleted−48
@@ -1,48 +0,0 @@
1−/*
2− * Copyright (C) 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 Ubuntu.Components 1.1
19−
20−BaseSurfaceAnimation {
21− id: animation
22−
23− property Rectangle darkenItem: Rectangle {
24− parent: animation.surface.parent
25− anchors.fill: parent
26− color: Qt.rgba(0,0,0,0.0)
27− }
28−
29− outChanges: [ PropertyChanges { target: animation.surface; opacity: 0.0 } ]
30− outAnimations: [
31− SequentialAnimation {
32− UbuntuNumberAnimation { target: animation.surface; property: "opacity"; duration: UbuntuAnimation.FastDuration }
33− ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
34− ScriptAction { script: { if (animation.parent.removing) animation.surface.release(); } }
35− }
36− ]
37−
38− inChanges: [
39− PropertyChanges { target: darkenItem; color: Qt.rgba(0,0,0,0.7) },
40− PropertyChanges { target: animation.surface; opacity: 1.0 }
41− ]
42− inAnimations: [
43− SequentialAnimation {
44− ColorAnimation { target: darkenItem; duration: UbuntuAnimation.FastDuration }
45− UbuntuNumberAnimation { target: animation.surface; property: "opacity"; duration: UbuntuAnimation.FastDuration }
46− }
47− ]
48−}
qml/Stages/Animations/SwipeFromBottomAnimation.qml+24−19
@@ -15,34 +15,39 @@
15 */
15 */
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18+import Ubuntu.Components 1.1
18
19
19−BaseSurfaceAnimation {
20+BaseSessionAnimation {
20 id: animation
21 id: animation
21
22
23+ fromChanges: [
24+ AnchorChanges {
25+ target: container;
22− outChanges: [ AnchorChanges { target: animation.surface; anchors.top: animation.parent.bottom } ]
26+ anchors.top: container.parent.bottom
23− outAnimations: [
27+ }
28+ ]
29+ fromAnimations: [
24 SequentialAnimation {
30 SequentialAnimation {
31+ // clip so we don't go out of parent's bounds during spread
25− PropertyAction { target: animation.parent; property: "clip"; value: true }
32+ PropertyAction { target: container.parent; property: "clip"; value: true }
26− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
33+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
27− PropertyAction { target: animation.surface; property: "visible"; value: !animation.parent.removing }
28− PropertyAction { target: animation.parent; property: "clip"; value: false }
34+ PropertyAction { target: container.parent; property: "clip"; value: false }
29− ScriptAction { script: { if (animation.parent.removing) animation.surface.release(); } }
35+ ScriptAction { script: { animation.completed(); } }
30 }
36 }
31 ]
37 ]
32
38
33− inChanges: [
39+ toChanges: [
34 AnchorChanges {
40 AnchorChanges {
35− target: animation.surface;
41+ target: container;
36− anchors.top: animation.parent.top
42+ anchors.top: container.parent.top
37− anchors.right: undefined
38− anchors.bottom: undefined
39− anchors.left: undefined
40− } ]
43+ }
41− inAnimations: [
44+ ]
45+ toAnimations: [
42 SequentialAnimation {
46 SequentialAnimation {
47+ // clip so we don't go out of parent's bounds during spread
43− PropertyAction { target: animation.parent; property: "clip"; value: true }
48+ PropertyAction { target: container.parent; property: "clip"; value: true }
44− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
49+ AnchorAnimation { easing: UbuntuAnimation.StandardEasing; duration: UbuntuAnimation.BriskDuration }
45− PropertyAction { target: animation.parent; property: "clip"; value: false }
50+ PropertyAction { target: container.parent; property: "clip"; value: false }
46 }
51 }
47 ]
52 ]
48}
53}
qml/Stages/Animations/SwipeUpAnimation.qmldeleted−49
@@ -1,49 +0,0 @@
1−/*
2− * Copyright (C) 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−
19−BaseSurfaceAnimation {
20− id: animation
21−
22− outAnimations: [
23− SequentialAnimation {
24− PropertyAction { target: animation.parent; property: "clip"; value: true }
25− PropertyAction { target: animation.surface; property: "visible"; value: true }
26− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
27− PropertyAction { target: animation.parent; property: "clip"; value: false }
28− ScriptAction { script: { if (animation.parent.removing) animation.surface.release(); } }
29− }
30− ]
31−
32− inChanges: [
33− AnchorChanges {
34− target: animation.surface;
35− anchors.top: undefined
36− anchors.right: undefined
37− anchors.bottom: animation.parent.top
38− anchors.left: undefined
39− }
40− ]
41− inAnimations: [
42− SequentialAnimation {
43− PropertyAction { target: animation.parent; property: "clip"; value: true }
44− AnchorAnimation { easing.type: Easing.InOutQuad; duration: 400 }
45− PropertyAction { target: animation.surface; property: "visible"; value: false}
46− PropertyAction { target: animation.parent; property: "clip"; value: false }
47− }
48− ]
49−}
qml/Stages/ApplicationWindow.qml+51−72
@@ -23,9 +23,9 @@ Item {
23
23
24 // to be read from outside
24 // to be read from outside
25 readonly property bool fullscreen: application ? application.fullscreen : false
25 readonly property bool fullscreen: application ? application.fullscreen : false
26+ property alias interactive: sessionContainer.interactive
26
27
27 // to be set from outside
28 // to be set from outside
28− property bool interactive: true
29 property QtObject application
29 property QtObject application
30 property int orientation
30 property int orientation
31
31
@@ -36,16 +36,14 @@ Item {
36 // (in order to avoid breaking qml binding due to a javascript exception)
36 // (in order to avoid breaking qml binding due to a javascript exception)
37 readonly property string name: root.application ? root.application.name : ""
37 readonly property string name: root.application ? root.application.name : ""
38 readonly property url icon: root.application ? root.application.icon : ""
38 readonly property url icon: root.application ? root.application.icon : ""
39− readonly property Item surface: root.application ? root.application.surface : null
40 readonly property int applicationState: root.application ? root.application.state : -1
39 readonly property int applicationState: root.application ? root.application.state : -1
41− readonly property var promptSurfaces: root.application ? root.application.promptSurfaces : null
42
40
43 // Whether the Application had a surface before but lost it.
41 // Whether the Application had a surface before but lost it.
44− property bool hadSurface: false
42+ property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
45
43
46 property bool needToTakeScreenshot:
44 property bool needToTakeScreenshot:
47− d.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
45+ sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
48− && d.applicationState === ApplicationInfo.Stopped
46+ && d.applicationState === ApplicationInfoInterface.Stopped
49 onNeedToTakeScreenshotChanged: {
47 onNeedToTakeScreenshotChanged: {
50 if (needToTakeScreenshot) {
48 if (needToTakeScreenshot) {
51 screenshotImage.take();
49 screenshotImage.take();
@@ -56,13 +54,12 @@ Item {
56 // might show the UI accommodating due to surface resizes on startup.
54 // might show the UI accommodating due to surface resizes on startup.
57 // Remove this when possible
55 // Remove this when possible
58 property bool surfaceInitialized: false
56 property bool surfaceInitialized: false
59− onSurfaceChanged: {
57+
60− if (surface) {
58+ function forceSurfaceActiveFocusIfReady() {
61− surface.orientation = Qt.binding( function() { return root.orientation; } );
59+ if (sessionContainer.surface.focus &&
62− surfaceInitTimer.start();
60+ sessionContainer.surface.parent === sessionContainer.surfaceContainer &&
63− } else {
61+ sessionContainer.surface.enabled) {
64− hadSurface = true;
62+ sessionContainer.surface.forceActiveFocus();
65− surfaceInitialized = false;
66 }
63 }
67 }
64 }
68 }
65 }
@@ -70,40 +67,16 @@ Item {
70 Timer {
67 Timer {
71 id: surfaceInitTimer
68 id: surfaceInitTimer
72 interval: 100
69 interval: 100
73− onTriggered: { if (d.surface) {d.surfaceInitialized = true;} }
70+ onTriggered: { if (sessionContainer.surface) {d.surfaceInitialized = true;} }
74 }
71 }
75
72
76− Binding {
77− target: d.surface
78− when: d.surface
79− property: "enabled"
80− value: root.interactive
81− }
82− Binding {
83− target: d.surface
84− when: d.surface
85− property: "focus"
86− value: root.interactive
87− }
88 Connections {
73 Connections {
89− target: d.surface
74+ target: sessionContainer.surface
90 // FIXME: I would rather not need to do this, but currently it doesn't get
75 // FIXME: I would rather not need to do this, but currently it doesn't get
91 // active focus without it and I don't know why.
76 // active focus without it and I don't know why.
92− onFocusChanged: forceSurfaceActiveFocusIfReady();
77+ onFocusChanged: d.forceSurfaceActiveFocusIfReady();
93− onParentChanged: forceSurfaceActiveFocusIfReady();
78+ onParentChanged: d.forceSurfaceActiveFocusIfReady();
94− onEnabledChanged: forceSurfaceActiveFocusIfReady();
79+ onEnabledChanged: d.forceSurfaceActiveFocusIfReady();
95− function forceSurfaceActiveFocusIfReady() {
96− if (d.surface.focus && d.surface.parent === surfaceContainer && d.surface.enabled) {
97− d.surface.forceActiveFocus();
98− }
99− }
100− }
101−
102− SurfaceContainer {
103− id: surfaceContainer
104− objectName: "surfaceContainer"
105− anchors.fill: parent
106− surface: d.surface
107 }
80 }
108
81
109 Image {
82 Image {
@@ -128,25 +101,25 @@ Item {
128 id: splashLoader
101 id: splashLoader
129 visible: active
102 visible: active
130 active: false
103 active: false
131− anchors.fill: surfaceContainer
104+ anchors.fill: parent
132 sourceComponent: Component {
105 sourceComponent: Component {
133 Splash { name: d.name; image: d.icon }
106 Splash { name: d.name; image: d.icon }
134 }
107 }
135 }
108 }
136
109
137− Repeater {
110+ SessionContainer {
138− model: d.promptSurfaces
111+ id: sessionContainer
139−
112+ session: application ? application.session : null
140− delegate: SurfaceContainer {
141− anchors {
113+ anchors.fill: parent
142− fill: surfaceContainer
143− }
144−
145− surface: modelData
146
114
147− Component.onCompleted: {
115+ onSurfaceChanged: {
148− animateIn();
116+ if (sessionContainer.surface) {
117+ surface.orientation = Qt.binding( function() { return root.orientation; } );
118+ surfaceInitTimer.start();
119+ } else {
120+ d.surfaceInitialized = false;
149 }
121 }
122+ d.forceSurfaceActiveFocusIfReady();
150 }
123 }
151 }
124 }
152
125
@@ -156,23 +129,23 @@ Item {
156 State {
129 State {
157 name: "void"
130 name: "void"
158 when:
131 when:
159− d.hadSurface && (!d.surface || !d.surfaceInitialized)
132+ d.hadSurface && (!sessionContainer.surface || !d.surfaceInitialized)
160 &&
133 &&
161 screenshotImage.status !== Image.Ready
134 screenshotImage.status !== Image.Ready
162 },
135 },
163 State {
136 State {
164 name: "splashScreen"
137 name: "splashScreen"
165 when:
138 when:
166− !d.hadSurface && (!d.surface || !d.surfaceInitialized)
139+ !d.hadSurface && (!sessionContainer.surface || !d.surfaceInitialized)
167 &&
140 &&
168 screenshotImage.status !== Image.Ready
141 screenshotImage.status !== Image.Ready
169 },
142 },
170 State {
143 State {
171 name: "surface"
144 name: "surface"
172 when:
145 when:
173− (d.surface && d.surfaceInitialized)
146+ (sessionContainer.surface && d.surfaceInitialized)
174 &&
147 &&
175− (d.applicationState !== ApplicationInfo.Stopped
148+ (d.applicationState !== ApplicationInfoInterface.Stopped
176 || screenshotImage.status !== Image.Ready)
149 || screenshotImage.status !== Image.Ready)
177 },
150 },
178 State {
151 State {
@@ -180,8 +153,8 @@ Item {
180 when:
153 when:
181 screenshotImage.status === Image.Ready
154 screenshotImage.status === Image.Ready
182 &&
155 &&
183− (d.applicationState === ApplicationInfo.Stopped
156+ (d.applicationState === ApplicationInfoInterface.Stopped
184− || !d.surface || !d.surfaceInitialized)
157+ || !sessionContainer.surface || !d.surfaceInitialized)
185 }
158 }
186 ]
159 ]
187
160
@@ -189,14 +162,18 @@ Item {
189 Transition {
162 Transition {
190 from: ""; to: "splashScreen"
163 from: ""; to: "splashScreen"
191 PropertyAction { target: splashLoader; property: "active"; value: true }
164 PropertyAction { target: splashLoader; property: "active"; value: true }
165+ PropertyAction { target: sessionContainer.surfaceContainer
166+ property: "visible"; value: false }
192 },
167 },
193 Transition {
168 Transition {
194 from: "splashScreen"; to: "surface"
169 from: "splashScreen"; to: "surface"
195 SequentialAnimation {
170 SequentialAnimation {
196− PropertyAction { target: surfaceContainer
171+ PropertyAction { target: sessionContainer.surfaceContainer
172+ property: "opacity"; value: 0.0 }
173+ PropertyAction { target: sessionContainer.surfaceContainer
197 property: "visible"; value: true }
174 property: "visible"; value: true }
198− UbuntuNumberAnimation { target: splashLoader; property: "opacity";
175+ UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
199− from: 1.0; to: 0.0
176+ from: 0.0; to: 1.0
200 duration: UbuntuAnimation.BriskDuration }
177 duration: UbuntuAnimation.BriskDuration }
201 PropertyAction { target: splashLoader; property: "active"; value: false }
178 PropertyAction { target: splashLoader; property: "active"; value: false }
202 }
179 }
@@ -205,11 +182,13 @@ Item {
205 from: "surface"; to: "splashScreen"
182 from: "surface"; to: "splashScreen"
206 SequentialAnimation {
183 SequentialAnimation {
207 PropertyAction { target: splashLoader; property: "active"; value: true }
184 PropertyAction { target: splashLoader; property: "active"; value: true }
208− PropertyAction { target: surfaceContainer
185+ PropertyAction { target: sessionContainer.surfaceContainer
209 property: "visible"; value: true }
186 property: "visible"; value: true }
210 UbuntuNumberAnimation { target: splashLoader; property: "opacity";
187 UbuntuNumberAnimation { target: splashLoader; property: "opacity";
211 from: 0.0; to: 1.0
188 from: 0.0; to: 1.0
212 duration: UbuntuAnimation.BriskDuration }
189 duration: UbuntuAnimation.BriskDuration }
190+ PropertyAction { target: sessionContainer.surfaceContainer
191+ property: "visible"; value: false }
213 }
192 }
214 },
193 },
215 Transition {
194 Transition {
@@ -220,15 +199,15 @@ Item {
220 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
199 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
221 from: 0.0; to: 1.0
200 from: 0.0; to: 1.0
222 duration: UbuntuAnimation.BriskDuration }
201 duration: UbuntuAnimation.BriskDuration }
223− PropertyAction { target: surfaceContainer
202+ PropertyAction { target: sessionContainer.surfaceContainer
224 property: "visible"; value: false }
203 property: "visible"; value: false }
225− ScriptAction { script: { if (d.surface) { d.surface.release(); } } }
204+ ScriptAction { script: { if (sessionContainer.session) { sessionContainer.session.release(); } } }
226 }
205 }
227 },
206 },
228 Transition {
207 Transition {
229 from: "screenshot"; to: "surface"
208 from: "screenshot"; to: "surface"
230 SequentialAnimation {
209 SequentialAnimation {
231− PropertyAction { target: surfaceContainer
210+ PropertyAction { target: sessionContainer.surfaceContainer
232 property: "visible"; value: true }
211 property: "visible"; value: true }
233 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
212 UbuntuNumberAnimation { target: screenshotImage; property: "opacity";
234 from: 1.0; to: 0.0
213 from: 1.0; to: 0.0
@@ -240,16 +219,16 @@ Item {
240 Transition {
219 Transition {
241 from: "surface"; to: "void"
220 from: "surface"; to: "void"
242 SequentialAnimation {
221 SequentialAnimation {
243− PropertyAction { target: surfaceContainer; property: "visible"; value: false }
222+ PropertyAction { target: sessionContainer.surfaceContainer; property: "visible"; value: false }
244− ScriptAction { script: { if (d.surface) { d.surface.release(); } } }
223+ ScriptAction { script: { if (sessionContainer.session) { sessionContainer.session.release(); } } }
245 }
224 }
246 },
225 },
247 Transition {
226 Transition {
248 from: "void"; to: "surface"
227 from: "void"; to: "surface"
249 SequentialAnimation {
228 SequentialAnimation {
250− PropertyAction { target: surfaceContainer; property: "opacity"; value: 0.0 }
229+ PropertyAction { target: sessionContainer.surfaceContainer; property: "opacity"; value: 0.0 }
251− PropertyAction { target: surfaceContainer; property: "visible"; value: true }
230+ PropertyAction { target: sessionContainer.surfaceContainer; property: "visible"; value: true }
252− UbuntuNumberAnimation { target: surfaceContainer; property: "opacity";
231+ UbuntuNumberAnimation { target: sessionContainer.surfaceContainer; property: "opacity";
253 from: 0.0; to: 1.0
232 from: 0.0; to: 1.0
254 duration: UbuntuAnimation.BriskDuration }
233 duration: UbuntuAnimation.BriskDuration }
255 }
234 }
qml/Stages/SessionContainer.qmlnew file+143
@@ -0,0 +1,143 @@
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 Lesser 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 Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser 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 "Animations"
19+
20+Item {
21+ id: root
22+ objectName: "sessionContainer"
23+ property QtObject session
24+ readonly property var childSessions: session ? session.childSessions : null
25+ readonly property alias surface: _surfaceContainer.surface
26+ property bool interactive: true
27+
28+ readonly property alias surfaceContainer: _surfaceContainer
29+ SurfaceContainer {
30+ id: _surfaceContainer
31+ anchors.fill: parent
32+ surface: session ? session.surface : null
33+ }
34+
35+ Binding {
36+ target: surfaceContainer.surface
37+ when: surfaceContainer.surface
38+ property: "enabled"
39+ value: root.interactive
40+ }
41+ Binding {
42+ target: surfaceContainer.surface
43+ when: surfaceContainer.surface
44+ property: "focus"
45+ value: root.interactive
46+ }
47+
48+ Repeater {
49+ model: root.childSessions
50+
51+ delegate: Loader {
52+ objectName: "childDelegate" + index
53+ anchors.fill: surfaceContainer
54+
55+ // Only way to do recursive qml items.
56+ source: Qt.resolvedUrl("SessionContainer.qml")
57+
58+ Binding {
59+ target: item; when: item
60+ property: "interactive"; value: root.interactive
61+ }
62+
63+ Binding {
64+ target: item; when: item
65+ property: "session"; value: modelData
66+ }
67+
68+ Binding {
69+ target: item; when: item
70+ property: "width"; value: root.width
71+ }
72+
73+ Binding {
74+ target: item; when: item
75+ property: "height"; value: root.height
76+ }
77+ }
78+ }
79+
80+ states: [
81+ State {
82+ name: "rootSession"
83+ when: root.session && !root.session.parentSession
84+ },
85+
86+ State {
87+ name: "childSession"
88+ when: root.session && root.session.parentSession !== null && root.session.live
89+ && !root.session.surface
90+ },
91+
92+ State {
93+ name: "childSessionReady"
94+ when: root.session && root.session.parentSession !== null && root.session.live
95+ && root.session.surface !== null
96+ },
97+
98+ State {
99+ name: "childSessionZombie"
100+ when: root.session && root.session.parentSession !== null && !root.session.live
101+ }
102+ ]
103+
104+ transitions: [
105+ Transition {
106+ to: "childSessionReady"
107+ ScriptAction { script: { if (!surfaceContainer.hadSurface) { animateIn(swipeFromBottom); } } }
108+ },
109+ Transition {
110+ to: "childSessionZombie"
111+ ScriptAction { script: { animateOut(); } }
112+ }
113+ ]
114+
115+ function animateIn(component) {
116+ var animation = component.createObject(root, { "container": root, });
117+ animation.start();
118+
119+ var tmp = d.animations;
120+ tmp.push(animation);
121+ d.animations = tmp;
122+ }
123+
124+ function animateOut() {
125+ if (d.animations.length > 0) {
126+ var tmp = d.animations;
127+ var popped = tmp.pop();
128+ popped.completed.connect(function() { root.session.release(); } );
129+ popped.end();
130+ d.animations = tmp;
131+ }
132+ }
133+
134+ Component {
135+ id: swipeFromBottom
136+ SwipeFromBottomAnimation {}
137+ }
138+
139+ QtObject {
140+ id: d
141+ property var animations: []
142+ }
143+}
qml/Stages/SurfaceContainer.qml+22−67
@@ -15,86 +15,41 @@
15*/
15*/
16
16
17import QtQuick 2.0
17import QtQuick 2.0
18−import "Animations"
18+import Ubuntu.Components 1.1
19
19
20Item {
20Item {
21− id: container
21+ id: root
22+ objectName: "surfaceContainer"
22 property Item surface: null
23 property Item surface: null
23− property bool removing: false
24+ property bool hadSurface: false
24
25
25 onSurfaceChanged: {
26 onSurfaceChanged: {
26 if (surface) {
27 if (surface) {
27− surface.parent = container;
28+ surface.parent = root;
28− surface.z = 1;
29+ } else {
30+ hadSurface = true;
29 }
31 }
30 }
32 }
31 Binding {
33 Binding {
32 target: surface
34 target: surface
33− property: "anchors.fill"; value: container
35+ property: "anchors.fill"; value: root
34 }
36 }
35
37
36− Connections {
38+ states: [
37− target: surface
39+ State {
38− onRemoved: {
40+ name: "zombie"
39− container.removing = true;
41+ when: surface && !surface.live
40−
41− var childSurfaces = surface.childSurfaces;
42− for (var i=0; i<childSurfaces.length; i++) {
43− childSurfaces[i].removed();
44− }
45−
46− animateOut();
47 }
42 }
48− }
43+ ]
49−
44+ transitions: [
50− Repeater {
45+ Transition {
51− model: surface ? surface.childSurfaces : null
46+ from: ""; to: "zombie"
52−
47+ SequentialAnimation {
53− delegate: Loader {
48+ UbuntuNumberAnimation { target: surface; property: "opacity"; to: 0.0
54− z: 2
49+ duration: UbuntuAnimation.BriskDuration }
55− anchors {
50+ PropertyAction { target: surface; property: "visible"; value: false }
56− fill: container
51+ ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
57− topMargin: container.surface.anchors.topMargin
58− rightMargin: container.surface.anchors.rightMargin
59− bottomMargin: container.surface.anchors.bottomMargin
60− leftMargin: container.surface.anchors.leftMargin
61 }
52 }
62−
63− // Only way to do recursive qml items.
64− source: Qt.resolvedUrl("SurfaceContainer.qml")
65− onLoaded: {
66− item.surface = modelData;
67− item.animateIn();
68− }
69− }
70− }
71−
72− function animateIn() {
73− var animation = swipeFromBottom.createObject(container, { "surface": container.surface });
74− animation.start();
75−
76− var tmp = d.animations;
77− tmp.push(animation);
78− d.animations = tmp;
79− }
80−
81− function animateOut() {
82− if (d.animations.length > 0) {
83− var tmp = d.animations;
84− var popped = tmp.pop();
85− popped.end();
86− d.animations = tmp;
87 }
53 }
88− }
54+ ]
89−
90− QtObject {
91− id: d
92− property var animations: []
93− property var currentAnimation: animations.length > 0 ? animations[animations.length-1] : undefined
94− }
95−
96− Component {
97− id: swipeFromBottom
98− SwipeFromBottomAnimation {}
99− }
100}
55}
tests/mocks/AccountsService/AccountsService.qmltypes+1
@@ -26,5 +26,6 @@ Module {
26 Property { name: "backgroundFile"; type: "string" }
26 Property { name: "backgroundFile"; type: "string" }
27 Property { name: "statsWelcomeScreen"; type: "bool" }
27 Property { name: "statsWelcomeScreen"; type: "bool" }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
29+ Property { name: "failedLogins"; type: "uint" }
29 }
30 }
30}
31}
tests/mocks/LightDM/LightDM.qmltypes+2
@@ -27,6 +27,7 @@ Module {
27 name: "showPrompt"
27 name: "showPrompt"
28 Parameter { name: "text"; type: "string" }
28 Parameter { name: "text"; type: "string" }
29 Parameter { name: "isSecret"; type: "bool" }
29 Parameter { name: "isSecret"; type: "bool" }
30+ Parameter { name: "isDefaultPrompt"; type: "bool" }
30 }
31 }
31 Signal { name: "authenticationComplete" }
32 Signal { name: "authenticationComplete" }
32 Signal {
33 Signal {
@@ -34,6 +35,7 @@ Module {
34 Parameter { name: "user"; type: "string" }
35 Parameter { name: "user"; type: "string" }
35 }
36 }
36 Signal { name: "isActiveChanged" }
37 Signal { name: "isActiveChanged" }
38+ Signal { name: "isAuthenticatedChanged" }
37 Signal { name: "showGreeter" }
39 Signal { name: "showGreeter" }
38 Signal {
40 Signal {
39 name: "requestAuthenticationUser"
41 name: "requestAuthenticationUser"
tests/mocks/Ubuntu/SystemImage/SystemImage.qmltypes+3−1
@@ -4,13 +4,15 @@ import QtQuick.tooling 1.1
4// It is used for QML tooling purposes only.
4// It is used for QML tooling purposes only.
5//
5//
6// This file was auto-generated by:
6// This file was auto-generated by:
7−// 'qmlplugindump -notrelocatable Ubuntu.SystemImage 0.1 plugins'
7+// 'qmlplugindump -notrelocatable Ubuntu.SystemImage 0.1 tests/mocks'
8
8
9Module {
9Module {
10 Component {
10 Component {
11 name: "MockSystemImage"
11 name: "MockSystemImage"
12 prototype: "QObject"
12 prototype: "QObject"
13 exports: ["Ubuntu.SystemImage/SystemImage 0.1"]
13 exports: ["Ubuntu.SystemImage/SystemImage 0.1"]
14+ isCreatable: false
15+ isSingleton: true
14 exportMetaObjectRevisions: [0]
16 exportMetaObjectRevisions: [0]
15 Signal { name: "resettingDevice" }
17 Signal { name: "resettingDevice" }
16 Method { name: "factoryReset" }
18 Method { name: "factoryReset" }
tests/mocks/Unity/Application/Application.qmltypes+115−70
@@ -13,58 +13,24 @@ Module {
13 exports: ["Unity.Application/ApplicationInfo 0.1"]
13 exports: ["Unity.Application/ApplicationInfo 0.1"]
14 exportMetaObjectRevisions: [0]
14 exportMetaObjectRevisions: [0]
15 Property { name: "fullscreen"; type: "bool" }
15 Property { name: "fullscreen"; type: "bool" }
16− Property { name: "stage"; type: "Stage" }
17− Property { name: "surface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }
16+ Property { name: "session"; type: "Session"; isReadonly: true; isPointer: true }
18− Property { name: "promptSurfaces"; type: "MirSurfaceItem"; isList: true; isReadonly: true }
17+ Property { name: "manualSurfaceCreation"; type: "bool" }
19− Property { name: "imageQml"; type: "string" }
20− Property { name: "windowQml"; type: "string" }
21− Signal {
22− name: "appIdChanged"
23− Parameter { type: "string" }
24− }
25− Signal {
26− name: "nameChanged"
27− Parameter { type: "string" }
28− }
29− Signal {
30− name: "commentChanged"
31− Parameter { type: "string" }
32− }
33− Signal {
34− name: "iconChanged"
35− Parameter { type: "QUrl" }
36− }
37 Signal {
18 Signal {
38− name: "stageChanged"
19+ name: "sessionChanged"
39− Parameter { type: "Stage" }
20+ Parameter { type: "Session"; isPointer: true }
40− }
41− Signal {
42− name: "stateChanged"
43− Parameter { type: "State" }
44− }
45− Signal {
46− name: "focusedChanged"
47− Parameter { type: "bool" }
48 }
21 }
49 Signal {
22 Signal {
50 name: "fullscreenChanged"
23 name: "fullscreenChanged"
51− Parameter { type: "bool" }
24+ Parameter { name: "value"; type: "bool" }
52− }
53− Signal {
54− name: "imageQmlChanged"
55− Parameter { type: "string" }
56− }
57− Signal {
58− name: "windowQmlChanged"
59− Parameter { type: "string" }
60 }
25 }
61 Signal {
26 Signal {
62− name: "screenshotChanged"
27+ name: "manualSurfaceCreationChanged"
63− Parameter { type: "QUrl" }
28+ Parameter { name: "value"; type: "bool" }
64 }
29 }
65− Signal {
30+ Method { name: "createSession" }
66− name: "surfaceChanged"
31+ Method {
67− Parameter { type: "MirSurfaceItem"; isPointer: true }
32+ name: "setState"
33+ Parameter { name: "value"; type: "State" }
68 }
34 }
69 }
35 }
70 Component {
36 Component {
@@ -198,17 +164,50 @@ Module {
198 type: "bool"
164 type: "bool"
199 Parameter { name: "appId"; type: "string" }
165 Parameter { name: "appId"; type: "string" }
200 }
166 }
167+ Method { name: "availableApplications"; type: "QStringList" }
201 Method {
168 Method {
202− name: "updateScreenshot"
169+ name: "add"
203− type: "bool"
170+ type: "ApplicationInfo*"
204 Parameter { name: "appId"; type: "string" }
171 Parameter { name: "appId"; type: "string" }
205 }
172 }
206− Method { name: "availableApplications"; type: "QStringList" }
173+ }
174+ Component {
175+ name: "ApplicationTestInterface"
176+ prototype: "QDBusAbstractAdaptor"
177+ exports: ["Unity.Application/ApplicationTest 0.1"]
178+ isCreatable: false
179+ isSingleton: true
180+ exportMetaObjectRevisions: [0]
181+ Method {
182+ name: "addChildSession"
183+ type: "uint"
184+ Parameter { name: "appId"; type: "string" }
185+ Parameter { name: "existingSessionId"; type: "uint" }
186+ Parameter { name: "surfaceImage"; type: "string" }
187+ }
188+ Method {
189+ name: "removeSession"
190+ Parameter { name: "sessionId"; type: "uint" }
191+ }
192+ Method {
193+ name: "addChildSession"
194+ type: "Session*"
195+ Parameter { name: "existingSession"; type: "Session"; isPointer: true }
196+ Parameter { name: "surfaceImage"; type: "string" }
197+ }
198+ Method {
199+ name: "removeSession"
200+ Parameter { name: "existingSession"; type: "Session"; isPointer: true }
201+ }
202+ Method {
203+ name: "removeSurface"
204+ Parameter { name: "existingSurface"; type: "MirSurfaceItem"; isPointer: true }
205+ }
207 }
206 }
208 Component {
207 Component {
209 name: "MirSurfaceItem"
208 name: "MirSurfaceItem"
210 defaultProperty: "data"
209 defaultProperty: "data"
211− prototype: "QQuickPaintedItem"
210+ prototype: "QQuickItem"
212 exports: ["Unity.Application/MirSurfaceItem 0.1"]
211 exports: ["Unity.Application/MirSurfaceItem 0.1"]
213 isCreatable: false
212 isCreatable: false
214 exportMetaObjectRevisions: [0]
213 exportMetaObjectRevisions: [0]
@@ -238,8 +237,7 @@ Module {
238 Property { name: "type"; type: "Type"; isReadonly: true }
237 Property { name: "type"; type: "Type"; isReadonly: true }
239 Property { name: "state"; type: "State"; isReadonly: true }
238 Property { name: "state"; type: "State"; isReadonly: true }
240 Property { name: "name"; type: "string"; isReadonly: true }
239 Property { name: "name"; type: "string"; isReadonly: true }
241− Property { name: "parentSurface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }
240+ Property { name: "live"; type: "bool"; isReadonly: true }
242− Property { name: "childSurfaces"; type: "MirSurfaceItem"; isList: true; isReadonly: true }
243 Signal {
241 Signal {
244 name: "typeChanged"
242 name: "typeChanged"
245 Parameter { type: "Type" }
243 Parameter { type: "Type" }
@@ -249,22 +247,72 @@ Module {
249 Parameter { type: "State" }
247 Parameter { type: "State" }
250 }
248 }
251 Signal {
249 Signal {
252− name: "nameChanged"
250+ name: "liveChanged"
253− Parameter { type: "string" }
251+ Parameter { name: "live"; type: "bool" }
254− }
255− Signal {
256− name: "parentSurfaceChanged"
257− Parameter { type: "MirSurfaceItem"; isPointer: true }
258 }
252 }
259− Signal { name: "removed" }
260 Signal { name: "inputMethodRequested" }
253 Signal { name: "inputMethodRequested" }
261 Signal { name: "inputMethodDismissed" }
254 Signal { name: "inputMethodDismissed" }
255+ Signal { name: "deregister" }
262 Method {
256 Method {
263 name: "setState"
257 name: "setState"
264 Parameter { name: "newState"; type: "State" }
258 Parameter { name: "newState"; type: "State" }
265 }
259 }
266 Method { name: "release" }
260 Method { name: "release" }
267 }
261 }
262+ Component { name: "QDBusAbstractAdaptor"; prototype: "QObject" }
263+ Component {
264+ name: "Session"
265+ prototype: "QObject"
266+ exports: ["Unity.Application/Session 0.1"]
267+ isCreatable: false
268+ exportMetaObjectRevisions: [0]
269+ Property { name: "name"; type: "string"; isReadonly: true }
270+ Property { name: "surface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }
271+ Property { name: "parentSession"; type: "Session"; isReadonly: true; isPointer: true }
272+ Property { name: "childSessions"; type: "SessionModel"; isReadonly: true; isPointer: true }
273+ Property { name: "live"; type: "bool"; isReadonly: true }
274+ Signal {
275+ name: "surfaceChanged"
276+ Parameter { type: "MirSurfaceItem"; isPointer: true }
277+ }
278+ Signal {
279+ name: "parentSessionChanged"
280+ Parameter { type: "Session"; isPointer: true }
281+ }
282+ Signal {
283+ name: "liveChanged"
284+ Parameter { name: "live"; type: "bool" }
285+ }
286+ Signal { name: "deregister" }
287+ Method { name: "createSurface" }
288+ Method { name: "release" }
289+ Method {
290+ name: "addChildSession"
291+ Parameter { name: "session"; type: "Session"; isPointer: true }
292+ }
293+ }
294+ Component {
295+ name: "SessionManager"
296+ prototype: "QObject"
297+ exports: ["Unity.Application/SessionManager 0.1"]
298+ isCreatable: false
299+ isSingleton: true
300+ exportMetaObjectRevisions: [0]
301+ Signal {
302+ name: "sessionStarting"
303+ Parameter { name: "session"; type: "Session"; isPointer: true }
304+ }
305+ Signal {
306+ name: "sessionStopping"
307+ Parameter { name: "session"; type: "Session"; isPointer: true }
308+ }
309+ Method {
310+ name: "createSession"
311+ type: "Session*"
312+ Parameter { name: "name"; type: "string" }
313+ Parameter { name: "screenshot"; type: "QUrl" }
314+ }
315+ }
268 Component {
316 Component {
269 name: "SurfaceManager"
317 name: "SurfaceManager"
270 prototype: "QObject"
318 prototype: "QObject"
@@ -281,6 +329,14 @@ Module {
281 name: "surfaceDestroyed"
329 name: "surfaceDestroyed"
282 Parameter { name: "surface"; type: "MirSurfaceItem"; isPointer: true }
330 Parameter { name: "surface"; type: "MirSurfaceItem"; isPointer: true }
283 }
331 }
332+ Method {
333+ name: "createSurface"
334+ type: "MirSurfaceItem*"
335+ Parameter { name: "name"; type: "string" }
336+ Parameter { name: "type"; type: "MirSurfaceItem::Type" }
337+ Parameter { name: "state"; type: "MirSurfaceItem::State" }
338+ Parameter { name: "screenshot"; type: "QUrl" }
339+ }
284 Method { name: "inputMethodSurface"; type: "MirSurfaceItem*" }
340 Method { name: "inputMethodSurface"; type: "MirSurfaceItem*" }
285 }
341 }
286 Component {
342 Component {
@@ -312,7 +368,6 @@ Module {
312 Property { name: "stage"; type: "Stage"; isReadonly: true }
368 Property { name: "stage"; type: "Stage"; isReadonly: true }
313 Property { name: "state"; type: "State"; isReadonly: true }
369 Property { name: "state"; type: "State"; isReadonly: true }
314 Property { name: "focused"; type: "bool"; isReadonly: true }
370 Property { name: "focused"; type: "bool"; isReadonly: true }
315− Property { name: "screenshot"; type: "QUrl"; isReadonly: true }
316 Signal {
371 Signal {
317 name: "nameChanged"
372 name: "nameChanged"
318 Parameter { name: "name"; type: "string" }
373 Parameter { name: "name"; type: "string" }
@@ -337,10 +392,6 @@ Module {
337 name: "focusedChanged"
392 name: "focusedChanged"
338 Parameter { name: "focused"; type: "bool" }
393 Parameter { name: "focused"; type: "bool" }
339 }
394 }
340− Signal {
341− name: "screenshotChanged"
342− Parameter { name: "screenshot"; type: "QUrl" }
343− }
344 }
395 }
345 Component {
396 Component {
346 name: "unity::shell::application::ApplicationManagerInterface"
397 name: "unity::shell::application::ApplicationManagerInterface"
@@ -357,8 +408,7 @@ Module {
357 "RoleIcon": 259,
408 "RoleIcon": 259,
358 "RoleStage": 260,
409 "RoleStage": 260,
359 "RoleState": 261,
410 "RoleState": 261,
360− "RoleFocused": 262,
411+ "RoleFocused": 262
361− "RoleScreenshot": 263
362 }
412 }
363 }
413 }
364 Property { name: "count"; type: "int"; isReadonly: true }
414 Property { name: "count"; type: "int"; isReadonly: true }
@@ -408,10 +458,5 @@ Module {
408 type: "bool"
458 type: "bool"
409 Parameter { name: "appId"; type: "string" }
459 Parameter { name: "appId"; type: "string" }
410 }
460 }
411− Method {
412− name: "updateScreenshot"
413− type: "bool"
414− Parameter { name: "appId"; type: "string" }
415− }
416 }
461 }
417}
462}
tests/mocks/Unity/Application/ApplicationDBusAdaptor.cppdeleted−81
@@ -1,81 +0,0 @@
1−/*
2− * Copyright (C) 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−#include "ApplicationInfo.h"
18−#include "ApplicationDBusAdaptor.h"
19−#include "ApplicationManager.h"
20−#include "SurfaceManager.h"
21−#include "MirSurfaceItem.h"
22−
23−quint32 nextId = 0;
24−
25−ApplicationDBusAdaptor::ApplicationDBusAdaptor(ApplicationManager* applicationManager)
26− : QDBusAbstractAdaptor(applicationManager)
27− , m_applicationManager(applicationManager)
28−{
29−}
30−
31−MirSurfaceItem* topSurface(MirSurfaceItem* surface)
32−{
33− if (!surface)
34− return nullptr;
35−
36− MirSurfaceItem* child = nullptr;
37− Q_FOREACH (MirSurfaceItem *childSurface, surface->childSurfaceList()) {
38− child = topSurface(childSurface);
39− if (child) {
40− break;
41− }
42− }
43− return child ? child : surface;
44−}
45−
46−quint32 ApplicationDBusAdaptor::addPromptSurface(const QString &appId, const QString &surfaceImage)
47−{
48− qDebug() << "ApplicationDBusAdaptor::addPromptSurface to " << appId;
49−
50− ApplicationInfo* application = m_applicationManager->findApplication(appId);
51− if (!application) {
52− qDebug() << "ApplicationDBusAdaptor::addChildSurface - No application found for " << appId;
53− return 0;
54− }
55− quint32 surfaceId = ++nextId;
56− MirSurfaceItem* surface = new MirSurfaceItem(QString("%1-ChildSurface%2").arg(appId).arg(surfaceId),
57− MirSurfaceItem::Normal,
58− MirSurfaceItem::Maximized,
59− QUrl(surfaceImage));
60− m_childItems[surfaceId] = surface;
61−
62− if (application->promptSurfaceList().count() > 0) {
63− surface->setParentSurface(topSurface(application->promptSurfaceList()[0]));
64− } else {
65− application->addPromptSurface(surface);
66− }
67−
68− return surfaceId;
69−}
70−
71−void ApplicationDBusAdaptor::removeChildSurface(int surfaceId)
72−{
73− qDebug() << "ApplicationDBusAdaptor::removeChildSurface - " << surfaceId;
74−
75− if (!m_childItems.contains(surfaceId)) {
76− qDebug() << "ApplicationDBusAdaptor::removeChildSurface - No added surface for " << surfaceId;
77− return;
78− }
79− MirSurfaceItem* surface = m_childItems.take(surfaceId);
80− Q_EMIT surface->removed();
81−}
tests/mocks/Unity/Application/ApplicationInfo.cpp+36−85
@@ -15,8 +15,8 @@
15 */
15 */
16
16
17#include "ApplicationInfo.h"
17#include "ApplicationInfo.h"
18−#include "MirSurfaceItem.h"
18+#include "Session.h"
19−#include "SurfaceManager.h"
19+#include "SessionManager.h"
20
20
21#include <paths.h>
21#include <paths.h>
22
22
@@ -33,9 +33,8 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
33 , m_state(Starting)
33 , m_state(Starting)
34 , m_focused(false)
34 , m_focused(false)
35 , m_fullscreen(false)
35 , m_fullscreen(false)
36− , m_surface(0)
36+ , m_session(0)
37 , m_manualSurfaceCreation(false)
37 , m_manualSurfaceCreation(false)
38− , m_parentItem(0)
39{
38{
40}
39}
41
40
@@ -45,107 +44,50 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
45 , m_state(Starting)
44 , m_state(Starting)
46 , m_focused(false)
45 , m_focused(false)
47 , m_fullscreen(false)
46 , m_fullscreen(false)
48− , m_surface(0)
47+ , m_session(0)
49 , m_manualSurfaceCreation(false)
48 , m_manualSurfaceCreation(false)
50− , m_parentItem(0)
51{
49{
52}
50}
53
51
54ApplicationInfo::~ApplicationInfo()
52ApplicationInfo::~ApplicationInfo()
55{
53{
56− if (m_surface) {
54+ delete m_session;
57− Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
58− m_surface->deleteLater();
59− setSurface(nullptr);
60− }
61}
55}
62
56
63−void ApplicationInfo::createSurface()
57+void ApplicationInfo::createSession()
64{
58{
65− if (m_surface || state() == ApplicationInfo::Stopped) return;
59+ if (m_session || state() == ApplicationInfo::Stopped) { return; }
66
60
67 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
61 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
68−
62+ setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
69− setSurface(new MirSurfaceItem(name(),
70− MirSurfaceItem::Normal,
71− fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
72− screenshotUrl));
73}
63}
74
64
75−void ApplicationInfo::setSurface(MirSurfaceItem* surface)
65+void ApplicationInfo::setSession(Session* session)
76{
66{
77− qDebug() << "Application::setSurface - appId=" << appId() << "surface=" << surface;
67+ qDebug() << "Application::setSession - appId=" << appId() << "session=" << session;
78− if (m_surface == surface)
68+ if (m_session == session)
79 return;
69 return;
80
70
81− if (m_surface) {
71+ if (m_session) {
82− m_surface->setApplication(nullptr);
72+ disconnect(this, 0, m_session, 0);
83− m_surface->setParent(nullptr);
84− SurfaceManager::singleton()->unregisterSurface(m_surface);
85− }
86−
87− m_surface = surface;
88−
89− if (m_surface) {
90− m_surface->setApplication(this);
73+ m_session->setApplication(nullptr);
91− m_surface->setParent(this);
74+ m_session->setParent(nullptr);
92− SurfaceManager::singleton()->registerSurface(m_surface);
75+ Q_EMIT m_session->deregister();
93 }
76 }
94
77
95− Q_EMIT surfaceChanged(m_surface);
78+ m_session = session;
96− SurfaceManager::singleton()->registerSurface(m_surface);
97−}
98
79
99−void ApplicationInfo::addPromptSurface(MirSurfaceItem* surface)
80+ if (m_session) {
100−{
81+ m_session->setApplication(this);
101− qDebug() << "ApplicationInfo::addPromptSurface " << surface->name() << " to " << name();
82+ m_session->setParent(this);
102− if (surface == m_surface || m_promptSurfaces.contains(surface)) return;
83+ SessionManager::singleton()->registerSession(m_session);
103
84
104− surface->setApplication(this);
85+ if (!m_manualSurfaceCreation) {
105− m_promptSurfaces.append(surface);
86+ QTimer::singleShot(500, m_session, SLOT(createSurface()));
106− Q_EMIT promptSurfacesChanged();
87+ }
107−}
108−
109−void ApplicationInfo::removeSurface(MirSurfaceItem* surface)
110−{
111− if (m_surface == surface) {
112− setSurface(nullptr);
113− } else if (m_promptSurfaces.contains(surface)) {
114− qDebug() << "Application::removeSurface " << surface->name() << " from " << name();
115−
116− m_promptSurfaces.removeAll(surface);
117− surface->setApplication(nullptr);
118−
119− Q_EMIT promptSurfacesChanged();
120 }
88 }
121−}
122
89
123−QList<MirSurfaceItem*> ApplicationInfo::promptSurfaceList() const
90+ Q_EMIT sessionChanged(m_session);
124−{
125− return m_promptSurfaces;
126−}
127−
128−QQmlListProperty<MirSurfaceItem> ApplicationInfo::promptSurfaces()
129−{
130− return QQmlListProperty<MirSurfaceItem>(this,
131− 0,
132− ApplicationInfo::promptSurfaceCount,
133− ApplicationInfo::promptSurfaceAt);
134−}
135−
136−int ApplicationInfo::promptSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop)
137−{
138− ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
139− return p->m_promptSurfaces.count();
140−}
141−
142−MirSurfaceItem* ApplicationInfo::promptSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index)
143−{
144− ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
145−
146− if (index < 0 || index >= p->m_promptSurfaces.count())
147− return nullptr;
148− return p->m_promptSurfaces[index];
149}
91}
150
92
151void ApplicationInfo::setIconId(const QString &iconId)
93void ApplicationInfo::setIconId(const QString &iconId)
@@ -157,9 +99,18 @@ void ApplicationInfo::setIconId(const QString &iconId)
157
99
158void ApplicationInfo::setScreenshotId(const QString &screenshotId)
100void ApplicationInfo::setScreenshotId(const QString &screenshotId)
159{
101{
160− m_screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
102+ QString screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
161 .arg(qmlDirectory())
103 .arg(qmlDirectory())
162 .arg(screenshotId);
104 .arg(screenshotId);
105+
106+ if (screenshotFileName != m_screenshotFileName) {
107+ m_screenshotFileName = screenshotFileName;
108+
109+ QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
110+ if (m_session) {
111+ m_session->setScreenshot(screenshotUrl);
112+ }
113+ }
163}
114}
164
115
165void ApplicationInfo::setName(const QString &value)
116void ApplicationInfo::setName(const QString &value)
@@ -193,7 +144,7 @@ void ApplicationInfo::setState(State value)
193 Q_EMIT stateChanged(value);
144 Q_EMIT stateChanged(value);
194
145
195 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
146 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
196− QTimer::singleShot(1000, this, SLOT(createSurface()));
147+ QTimer::singleShot(500, this, SLOT(createSession()));
197 }
148 }
198 }
149 }
199}
150}
tests/mocks/Unity/Application/ApplicationInfo.h+11−23
@@ -17,8 +17,10 @@
17#ifndef APPLICATION_H
17#ifndef APPLICATION_H
18#define APPLICATION_H
18#define APPLICATION_H
19
19
20+#include "SurfaceManager.h"
21+#include "MirSurfaceItemModel.h"
22+
20#include <QObject>
23#include <QObject>
21−#include <QQmlComponent>
22
24
23class QQuickItem;
25class QQuickItem;
24class MirSurfaceItem;
26class MirSurfaceItem;
@@ -32,8 +34,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
32 Q_OBJECT
34 Q_OBJECT
33
35
34 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
36 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
35− Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
37+ Q_PROPERTY(Session* session READ session NOTIFY sessionChanged)
36− Q_PROPERTY(QQmlListProperty<MirSurfaceItem> promptSurfaces READ promptSurfaces NOTIFY promptSurfacesChanged DESIGNABLE false)
37
38
38 // Only exists in this fake implementation
39 // Only exists in this fake implementation
39
40
@@ -72,32 +73,23 @@ public:
72 void setFullscreen(bool value);
73 void setFullscreen(bool value);
73 bool fullscreen() const { return m_fullscreen; }
74 bool fullscreen() const { return m_fullscreen; }
74
75
75− void setSurface(MirSurfaceItem* surface);
76− MirSurfaceItem* surface() const { return m_surface; }
77−
78− void removeSurface(MirSurfaceItem* surface);
79−
80− void addPromptSurface(MirSurfaceItem* surface);
81− QList<MirSurfaceItem*> promptSurfaceList() const;
82− QQmlListProperty<MirSurfaceItem> promptSurfaces();
83−
84 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
76 bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
85 void setManualSurfaceCreation(bool value);
77 void setManualSurfaceCreation(bool value);
86
78
79+public:
80+ void setSession(Session* session);
81+ Session* session() const { return m_session; }
82+
87Q_SIGNALS:
83Q_SIGNALS:
88− void surfaceChanged(MirSurfaceItem*);
84+ void sessionChanged(Session*);
89− void promptSurfacesChanged();
90 void fullscreenChanged(bool value);
85 void fullscreenChanged(bool value);
91 void manualSurfaceCreationChanged(bool value);
86 void manualSurfaceCreationChanged(bool value);
92
87
93public Q_SLOTS:
88public Q_SLOTS:
94− Q_INVOKABLE void createSurface();
89+ Q_INVOKABLE void createSession();
95
90
96private:
91private:
97− static int promptSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop);
98− static MirSurfaceItem* promptSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index);
99 void setIcon(const QUrl &value);
92 void setIcon(const QUrl &value);
100− void setScreenshot(const QUrl &value);
101
93
102 QString m_screenshotFileName;
94 QString m_screenshotFileName;
103
95
@@ -108,15 +100,11 @@ private:
108 State m_state;
100 State m_state;
109 bool m_focused;
101 bool m_focused;
110 bool m_fullscreen;
102 bool m_fullscreen;
111− MirSurfaceItem* m_surface;
103+ Session* m_session;
112
104
113 bool m_manualSurfaceCreation;
105 bool m_manualSurfaceCreation;
114−
115− QQuickItem *m_parentItem;
116− QList<MirSurfaceItem*> m_promptSurfaces;
117};
106};
118
107
119Q_DECLARE_METATYPE(ApplicationInfo*)
108Q_DECLARE_METATYPE(ApplicationInfo*)
120−Q_DECLARE_METATYPE(QQmlListProperty<MirSurfaceItem>)
121
109
122#endif // APPLICATION_H
110#endif // APPLICATION_H
tests/mocks/Unity/Application/ApplicationManager.cpp+9−16
@@ -15,9 +15,9 @@
15 */
15 */
16
16
17#include "ApplicationManager.h"
17#include "ApplicationManager.h"
18−#include "ApplicationDBusAdaptor.h"
19#include "ApplicationInfo.h"
18#include "ApplicationInfo.h"
20−#include "MirSurfaceItem.h"
19+#include "Session.h"
20+#include "ApplicationTestInterface.h"
21
21
22#include <paths.h>
22#include <paths.h>
23
23
@@ -36,11 +36,6 @@ ApplicationManager *ApplicationManager::singleton()
36{
36{
37 if (!the_application_manager) {
37 if (!the_application_manager) {
38 the_application_manager = new ApplicationManager();
38 the_application_manager = new ApplicationManager();
39− new ApplicationDBusAdaptor(the_application_manager);
40−
41− QDBusConnection connection = QDBusConnection::sessionBus();
42− connection.registerService("com.canonical.Unity8");
43− connection.registerObject("/com/canonical/Unity8/Mocks", the_application_manager);
44 }
39 }
45 return the_application_manager;
40 return the_application_manager;
46}
41}
@@ -49,9 +44,8 @@ ApplicationManager::ApplicationManager(QObject *parent)
49 : ApplicationManagerInterface(parent)
44 : ApplicationManagerInterface(parent)
50 , m_suspended(false)
45 , m_suspended(false)
51{
46{
52− m_roleNames.insert(RoleSurface, "surface");
47+ m_roleNames.insert(RoleSession, "session");
53 m_roleNames.insert(RoleFullscreen, "fullscreen");
48 m_roleNames.insert(RoleFullscreen, "fullscreen");
54− m_roleNames.insert(RoleApplication, "application");
55
49
56 buildListOfAvailableApplications();
50 buildListOfAvailableApplications();
57
51
@@ -105,12 +99,10 @@ QVariant ApplicationManager::data(const QModelIndex& index, int role) const {
105 return app->state();
99 return app->state();
106 case RoleFocused:
100 case RoleFocused:
107 return app->focused();
101 return app->focused();
108− case RoleSurface:
102+ case RoleSession:
109− return QVariant::fromValue(app->surface());
103+ return QVariant::fromValue(app->session());
110 case RoleFullscreen:
104 case RoleFullscreen:
111 return app->fullscreen();
105 return app->fullscreen();
112− case RoleApplication:
113− return QVariant::fromValue(app);
114 default:
106 default:
115 return QVariant();
107 return QVariant();
116 }
108 }
@@ -154,10 +146,10 @@ void ApplicationManager::add(ApplicationInfo *application) {
154 Q_EMIT countChanged();
146 Q_EMIT countChanged();
155 if (count() == 1) Q_EMIT emptyChanged(isEmpty()); // was empty but not anymore
147 if (count() == 1) Q_EMIT emptyChanged(isEmpty()); // was empty but not anymore
156
148
157− connect(application, &ApplicationInfo::surfaceChanged, this, [application, this]() {
149+ connect(application, &ApplicationInfo::sessionChanged, this, [application, this]() {
158 QModelIndex appIndex = findIndex(application);
150 QModelIndex appIndex = findIndex(application);
159 if (!appIndex.isValid()) return;
151 if (!appIndex.isValid()) return;
160− Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << ApplicationManager::RoleSurface);
152+ Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << ApplicationManager::RoleSession);
161 });
153 });
162 connect(application, &ApplicationInfo::focusedChanged, this, [application, this]() {
154 connect(application, &ApplicationInfo::focusedChanged, this, [application, this]() {
163 QModelIndex appIndex = findIndex(application);
155 QModelIndex appIndex = findIndex(application);
@@ -181,7 +173,7 @@ void ApplicationManager::remove(ApplicationInfo *application) {
181 Q_EMIT countChanged();
173 Q_EMIT countChanged();
182 if (isEmpty()) Q_EMIT emptyChanged(isEmpty());
174 if (isEmpty()) Q_EMIT emptyChanged(isEmpty());
183 }
175 }
184− disconnect(application, 0, this, 0);
176+ application->disconnect(this);
185}
177}
186
178
187void ApplicationManager::move(int from, int to) {
179void ApplicationManager::move(int from, int to) {
@@ -464,6 +456,7 @@ void ApplicationManager::buildListOfAvailableApplications()
464 m_availableApplications.append(application);
456 m_availableApplications.append(application);
465}
457}
466
458
459+
467QStringList ApplicationManager::availableApplications()
460QStringList ApplicationManager::availableApplications()
468{
461{
469 QStringList appIds;
462 QStringList appIds;
tests/mocks/Unity/Application/ApplicationManager.h+1−2
@@ -52,9 +52,8 @@ class ApplicationManager : public ApplicationManagerInterface {
52 static ApplicationManager *singleton();
52 static ApplicationManager *singleton();
53
53
54 enum MoreRoles {
54 enum MoreRoles {
55− RoleSurface = RoleFocused+1,
55+ RoleSession = RoleFocused+1,
56 RoleFullscreen,
56 RoleFullscreen,
57− RoleApplication,
58 };
57 };
59 enum Role {
58 enum Role {
60 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,
59 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,
tests/mocks/Unity/Application/ApplicationTestInterface.cppnew file+117
@@ -0,0 +1,117 @@
1+/*
2+ * Copyright (C) 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+#include "ApplicationInfo.h"
18+#include "ApplicationTestInterface.h"
19+#include "ApplicationManager.h"
20+#include "SessionManager.h"
21+#include "SurfaceManager.h"
22+#include "Session.h"
23+#include "MirSurfaceItem.h"
24+
25+#include <paths.h>
26+
27+#include <QtDBus/QtDBus>
28+
29+quint32 nextId = 0;
30+
31+ApplicationTestInterface::ApplicationTestInterface(QObject* parent)
32+ : QDBusAbstractAdaptor(parent)
33+{
34+ QDBusConnection connection = QDBusConnection::sessionBus();
35+ connection.registerService("com.canonical.Unity8");
36+ connection.registerObject("/com/canonical/Unity8/Mocks", parent);
37+}
38+
39+Session* ApplicationTestInterface::addChildSession(Session* existingSession, const QString& surfaceImage)
40+{
41+ if (!existingSession) return nullptr;
42+
43+ QUrl screenshotUrl = QString("file://%1/Dash/graphics/phone/screenshots/%2@12.png")
44+ .arg(qmlDirectory())
45+ .arg(surfaceImage);
46+
47+ Session* session = SessionManager::singleton()->createSession(
48+ QString("%1-Child%2").arg(existingSession->name())
49+ .arg(existingSession->childSessions()->count()),
50+ screenshotUrl);
51+ existingSession->addChildSession(session);
52+ session->createSurface();
53+
54+ return session;
55+}
56+
57+void ApplicationTestInterface::removeSession(Session* existingSession)
58+{
59+ qDebug() << "ApplicationTestInterface::removeSession - " << existingSession;
60+
61+ if (existingSession)
62+ existingSession->setLive(false);
63+}
64+
65+void ApplicationTestInterface::removeSurface(MirSurfaceItem* existingSurface)
66+{
67+ qDebug() << "ApplicationTestInterface::removeSurface - " << existingSurface;
68+
69+ if (existingSurface)
70+ existingSurface->setLive(false);
71+}
72+
73+quint32 ApplicationTestInterface::addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage)
74+{
75+ qDebug() << "ApplicationTestInterface::addChildSession to " << appId;
76+
77+ ApplicationInfo* application = ApplicationManager::singleton()->findApplication(appId);
78+ if (!application) {
79+ qDebug() << "ApplicationTestInterface::addChildSession - No application found for " << appId;
80+ return 0;
81+ }
82+
83+ Session* parentSession = nullptr;
84+ if (m_childSessions.contains(existingSessionId)) {
85+ parentSession = m_childSessions[existingSessionId];
86+ } else if (application->session()) {
87+ parentSession = application->session();
88+ } else {
89+ qDebug() << "ApplicationTestInterface::addChildSession - No session for " << appId << ":" << existingSessionId;
90+ return 0;
91+ }
92+
93+ QUrl screenshotUrl = QString("file://%1/Dash/graphics/phone/screenshots/%2@12.png")
94+ .arg(qmlDirectory())
95+ .arg(surfaceImage);
96+
97+ quint32 sessionId = ++nextId;
98+ Session* session = SessionManager::singleton()->createSession(
99+ QString("%1-Child%2").arg(parentSession->name())
100+ .arg(parentSession->childSessions()->count()),
101+ screenshotUrl);
102+ parentSession->addChildSession(session);
103+ session->createSurface();
104+ m_childSessions[sessionId] = session;
105+
106+ return sessionId;
107+}
108+
109+void ApplicationTestInterface::removeSession(quint32 sessionId)
110+{
111+ if (!m_childSessions.contains(sessionId)) {
112+ qDebug() << "ApplicationTestInterface::removeSession - No added session for " << sessionId;
113+ return;
114+ }
115+ Session* session = m_childSessions.take(sessionId);
116+ removeSession(session);
117+}
tests/mocks/Unity/Application/ApplicationDBusAdaptor.h → tests/mocks/Unity/Application/ApplicationTestInterface.hrenamed+13−11
@@ -14,30 +14,32 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef APPLICATIONDBUSADAPTOR_H
17+#ifndef APPLICATIONTESTINTERFACE_H
18−#define APPLICATIONDBUSADAPTOR_H
18+#define APPLICATIONTESTINTERFACE_H
19
19
20#include <QtDBus/QtDBus>
20#include <QtDBus/QtDBus>
21
21
22class ApplicationManager;
22class ApplicationManager;
23−class SurfaceManager;
23+class Session;
24class MirSurfaceItem;
24class MirSurfaceItem;
25
25
26−class ApplicationDBusAdaptor : public QDBusAbstractAdaptor
26+class ApplicationTestInterface : public QDBusAbstractAdaptor
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity8.Mocks.Application")
29 Q_CLASSINFO("D-Bus Interface", "com.canonical.Unity8.Mocks.Application")
30public:
30public:
31− ApplicationDBusAdaptor(ApplicationManager* applicationManager);
31+ ApplicationTestInterface(QObject* parent = 0);
32+
33+ Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage);
34+ Q_INVOKABLE void removeSession(Session* existingSession);
35+ Q_INVOKABLE void removeSurface(MirSurfaceItem* existingSurface);
32
36
33public Q_SLOTS:
37public Q_SLOTS:
34− quint32 addPromptSurface(const QString& appId, const QString& surfaceImage);
38+ quint32 addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage);
35− void removeChildSurface(int surfaceId);
39+ void removeSession(quint32 sessionId);
36
40
37private:
41private:
38− ApplicationManager* m_applicationManager;
42+ QHash<quint32, Session*> m_childSessions;
39−
40− QHash<quint32, MirSurfaceItem*> m_childItems;
41};
43};
42
44
43−#endif // APPLICATIONDBUSADAPTOR_H
45+#endif // APPLICATIONTESTINTERFACE_H
tests/mocks/Unity/Application/CMakeLists.txt+6−1
@@ -2,12 +2,17 @@ pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=3)
2
2
3set(FakeUnityApplicationQml_SOURCES
3set(FakeUnityApplicationQml_SOURCES
4 plugin.cpp
4 plugin.cpp
5− ApplicationDBusAdaptor.cpp
6 ApplicationInfo.cpp
5 ApplicationInfo.cpp
7 ApplicationManager.cpp
6 ApplicationManager.cpp
8 ApplicationScreenshotProvider.cpp
7 ApplicationScreenshotProvider.cpp
8+ ApplicationTestInterface.cpp
9 MirSurfaceItem.cpp
9 MirSurfaceItem.cpp
10+ MirSurfaceItemModel.h
11+ ObjectListModel.h
12+ Session.cpp
13+ SessionManager.cpp
10 SurfaceManager.cpp
14 SurfaceManager.cpp
15+ SessionModel.h
11 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
16 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
12 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
17 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
13)
18)
tests/mocks/Unity/Application/MirSurfaceItem.cpp+19−79
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17#include "MirSurfaceItem.h"
17#include "MirSurfaceItem.h"
18−#include "ApplicationInfo.h"
18+#include "Session.h"
19
19
20#include <paths.h>
20#include <paths.h>
21
21
@@ -34,12 +34,12 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
34 const QString &qmlFilePath,
34 const QString &qmlFilePath,
35 QQuickItem *parent)
35 QQuickItem *parent)
36 : QQuickItem(parent)
36 : QQuickItem(parent)
37− , m_application(nullptr)
37+ , m_session(nullptr)
38 , m_name(name)
38 , m_name(name)
39 , m_type(type)
39 , m_type(type)
40 , m_state(state)
40 , m_state(state)
41+ , m_live(true)
41 , m_orientation(Qt::PortraitOrientation)
42 , m_orientation(Qt::PortraitOrientation)
42− , m_parentSurface(nullptr)
43 , m_qmlItem(nullptr)
43 , m_qmlItem(nullptr)
44 , m_screenshotUrl(screenshot)
44 , m_screenshotUrl(screenshot)
45{
45{
@@ -84,16 +84,9 @@ MirSurfaceItem::MirSurfaceItem(const QString& name,
84MirSurfaceItem::~MirSurfaceItem()
84MirSurfaceItem::~MirSurfaceItem()
85{
85{
86 qDebug() << "MirSurfaceItem::~MirSurfaceItem() " << name();
86 qDebug() << "MirSurfaceItem::~MirSurfaceItem() " << name();
87−
87+ if (m_session) {
88− QList<MirSurfaceItem*> children(m_children);
88+ m_session->setSurface(nullptr);
89− for (MirSurfaceItem* child : children) {
90− child->setParentSurface(nullptr);
91 }
89 }
92− if (m_parentSurface)
93− m_parentSurface->removeChildSurface(this);
94−
95− if (m_application)
96− m_application->removeSurface(this);
97}
90}
98
91
99void MirSurfaceItem::printComponentErrors()
92void MirSurfaceItem::printComponentErrors()
@@ -106,16 +99,10 @@ void MirSurfaceItem::printComponentErrors()
106
99
107void MirSurfaceItem::release()
100void MirSurfaceItem::release()
108{
101{
109− QList<MirSurfaceItem*> children(m_children);
102+ qDebug() << "MirSurfaceItem::release " << name();
110− for (MirSurfaceItem* child : children) {
111− child->release();
112− }
113− if (m_parentSurface) {
114− m_parentSurface->removeChildSurface(this);
115− }
116
103
117− if (m_application) {
104+ if (m_session) {
118− m_application->removeSurface(this);
105+ m_session->setSurface(nullptr);
119 }
106 }
120 if (!parent()) {
107 if (!parent()) {
121 deleteLater();
108 deleteLater();
@@ -135,75 +122,28 @@ void MirSurfaceItem::setOrientation(const Qt::ScreenOrientation orientation)
135 Q_EMIT orientationChanged();
122 Q_EMIT orientationChanged();
136}
123}
137
124
138−void MirSurfaceItem::setApplication(ApplicationInfo* application)
125+void MirSurfaceItem::setSession(Session* session)
139{
126{
140− m_application = application;
127+ m_session = session;
141}
128}
142
129
143−void MirSurfaceItem::setParentSurface(MirSurfaceItem* surface)
130+void MirSurfaceItem::setScreenshot(const QUrl& screenshot)
144{
131{
145− if (m_parentSurface == surface || surface == this)
132+ m_screenshotUrl = screenshot;
146− return;
133+ if (m_qmlItem) {
147−
134+ QQmlProperty screenshotSource(m_qmlItem, "screenshotSource");
148− if (m_parentSurface) {
135+ screenshotSource.write(QVariant::fromValue(m_screenshotUrl));
149− m_parentSurface->removeChildSurface(this);
150− }
151−
152− m_parentSurface = surface;
153−
154− if (m_parentSurface) {
155− m_parentSurface->addChildSurface(this);
156 }
136 }
157− Q_EMIT parentSurfaceChanged(surface);
158−}
159−
160−void MirSurfaceItem::addChildSurface(MirSurfaceItem* surface)
161−{
162− qDebug() << "MirSurfaceItem::addChildSurface " << surface->name() << " to " << name();
163−
164− m_children.append(surface);
165− Q_EMIT childSurfacesChanged();
166}
137}
167
138
168−void MirSurfaceItem::removeChildSurface(MirSurfaceItem* surface)
139+void MirSurfaceItem::setLive(bool live)
169{
140{
170− qDebug() << "MirSurfaceItem::removeChildSurface " << surface->name() << " from " << name();
141+ if (m_live != live) {
171−
142+ m_live = live;
172− if (m_children.contains(surface)) {
143+ Q_EMIT liveChanged(m_live);
173− m_children.removeOne(surface);
174− Q_EMIT childSurfacesChanged();
175 }
144 }
176}
145}
177
146
178−QList<MirSurfaceItem*> MirSurfaceItem::childSurfaceList()
179−{
180− return m_children;
181−}
182−
183−QQmlListProperty<MirSurfaceItem> MirSurfaceItem::childSurfaces()
184−{
185− return QQmlListProperty<MirSurfaceItem>(this,
186− 0,
187− MirSurfaceItem::childSurfaceCount,
188− MirSurfaceItem::childSurfaceAt);
189−}
190−
191−int MirSurfaceItem::childSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop)
192−{
193− MirSurfaceItem *p = qobject_cast<MirSurfaceItem*>(prop->object);
194− return p->m_children.count();
195−}
196−
197−MirSurfaceItem* MirSurfaceItem::childSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index)
198−{
199− MirSurfaceItem *p = qobject_cast<MirSurfaceItem*>(prop->object);
200−
201− if (index < 0 || index >= p->m_children.count())
202− return nullptr;
203− return p->m_children[index];
204−}
205−
206−
207void MirSurfaceItem::onQmlWantInputMethodChanged()
147void MirSurfaceItem::onQmlWantInputMethodChanged()
208{
148{
209 QQmlProperty prop(m_qmlItem, "wantInputMethod");
149 QQmlProperty prop(m_qmlItem, "wantInputMethod");
tests/mocks/Unity/Application/MirSurfaceItem.h+25−31
@@ -17,11 +17,12 @@
17#ifndef MIRSURFACEITEM_H
17#ifndef MIRSURFACEITEM_H
18#define MIRSURFACEITEM_H
18#define MIRSURFACEITEM_H
19
19
20+#include "MirSurfaceItemModel.h"
21+
20#include <QQuickItem>
22#include <QQuickItem>
21−#include <QQmlComponent>
22#include <QUrl>
23#include <QUrl>
23
24
24−class ApplicationInfo;
25+class Session;
25
26
26class MirSurfaceItem : public QQuickItem
27class MirSurfaceItem : public QQuickItem
27{
28{
@@ -31,10 +32,9 @@ class MirSurfaceItem : public QQuickItem
31
32
32 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
33 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
33 Q_PROPERTY(State state READ state NOTIFY stateChanged)
34 Q_PROPERTY(State state READ state NOTIFY stateChanged)
34− Q_PROPERTY(QString name READ name NOTIFY nameChanged)
35+ Q_PROPERTY(QString name READ name CONSTANT)
36+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
35 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
37 Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged DESIGNABLE false)
36− Q_PROPERTY(MirSurfaceItem* parentSurface READ parentSurface NOTIFY parentSurfaceChanged)
37− Q_PROPERTY(QQmlListProperty<MirSurfaceItem> childSurfaces READ childSurfaces NOTIFY childSurfacesChanged DESIGNABLE false)
38
38
39public:
39public:
40 enum Type {
40 enum Type {
@@ -57,26 +57,21 @@ public:
57 Fullscreen,
57 Fullscreen,
58 };
58 };
59
59
60− explicit MirSurfaceItem(const QString& name,
61− Type type,
62− State state,
63− const QUrl& screenshot,
64− const QString &qmlFilePath = QString(),
65− QQuickItem *parent = 0);
66 ~MirSurfaceItem();
60 ~MirSurfaceItem();
67
61
68 //getters
62 //getters
69− ApplicationInfo* application() const { return m_application; }
63+ Session* session() const { return m_session; }
70 Type type() const { return m_type; }
64 Type type() const { return m_type; }
71 State state() const { return m_state; }
65 State state() const { return m_state; }
72 QString name() const { return m_name; }
66 QString name() const { return m_name; }
67+ bool live() const { return m_live; }
73 Qt::ScreenOrientation orientation() const { return m_orientation; }
68 Qt::ScreenOrientation orientation() const { return m_orientation; }
74− MirSurfaceItem* parentSurface() const { return m_parentSurface; }
75− QList<MirSurfaceItem*> childSurfaceList();
76
69
77 void setOrientation(const Qt::ScreenOrientation orientation);
70 void setOrientation(const Qt::ScreenOrientation orientation);
78− void setApplication(ApplicationInfo* item);
71+
79− void setParentSurface(MirSurfaceItem* item);
72+ void setSession(Session* item);
73+ void setScreenshot(const QUrl& screenshot);
74+ void setLive(bool live);
80
75
81 Q_INVOKABLE void setState(State newState);
76 Q_INVOKABLE void setState(State newState);
82 Q_INVOKABLE void release();
77 Q_INVOKABLE void release();
@@ -84,44 +79,43 @@ public:
84Q_SIGNALS:
79Q_SIGNALS:
85 void typeChanged(Type);
80 void typeChanged(Type);
86 void stateChanged(State);
81 void stateChanged(State);
87− void nameChanged(QString);
82+ void liveChanged(bool live);
88 void orientationChanged();
83 void orientationChanged();
89− void parentSurfaceChanged(MirSurfaceItem*);
90− void childSurfacesChanged();
91−
92− void removed();
93
84
94 void inputMethodRequested();
85 void inputMethodRequested();
95 void inputMethodDismissed();
86 void inputMethodDismissed();
96
87
88+ // internal mock use
89+ void deregister();
90+
97private Q_SLOTS:
91private Q_SLOTS:
98 void onFocusChanged();
92 void onFocusChanged();
99 void onComponentStatusChanged(QQmlComponent::Status status);
93 void onComponentStatusChanged(QQmlComponent::Status status);
100 void onQmlWantInputMethodChanged();
94 void onQmlWantInputMethodChanged();
101
95
102private:
96private:
103− void addChildSurface(MirSurfaceItem* surface);
97+ explicit MirSurfaceItem(const QString& name,
104− void removeChildSurface(MirSurfaceItem* surface);
98+ Type type,
105−
99+ State state,
106− QQmlListProperty<MirSurfaceItem> childSurfaces();
100+ const QUrl& screenshot,
107− static int childSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop);
101+ const QString &qmlFilePath = QString(),
108− static MirSurfaceItem* childSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index);
102+ QQuickItem *parent = 0);
109
103
110 void createQmlContentItem();
104 void createQmlContentItem();
111 void printComponentErrors();
105 void printComponentErrors();
112
106
113− ApplicationInfo* m_application;
107+ Session* m_session;
114 const QString m_name;
108 const QString m_name;
115 const Type m_type;
109 const Type m_type;
116 State m_state;
110 State m_state;
111+ bool m_live;
117 Qt::ScreenOrientation m_orientation;
112 Qt::ScreenOrientation m_orientation;
118
113
119− MirSurfaceItem* m_parentSurface;
120− QList<MirSurfaceItem*> m_children;
121−
122 QQmlComponent *m_qmlContentComponent;
114 QQmlComponent *m_qmlContentComponent;
123 QQuickItem *m_qmlItem;
115 QQuickItem *m_qmlItem;
124 QUrl m_screenshotUrl;
116 QUrl m_screenshotUrl;
117+
118+ friend class SurfaceManager;
125};
119};
126
120
127Q_DECLARE_METATYPE(MirSurfaceItem*)
121Q_DECLARE_METATYPE(MirSurfaceItem*)
tests/mocks/Unity/Application/MirSurfaceItemModel.hnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MIRSURFACEITEMMODEL_H
18+#define MIRSURFACEITEMMODEL_H
19+
20+// Local
21+#include "ObjectListModel.h"
22+
23+class MirSurfaceItem;
24+class MirSurfaceItemModel: public ObjectListModel<MirSurfaceItem>
25+{
26+ Q_OBJECT
27+public:
28+ MirSurfaceItemModel(QObject *parent = 0): ObjectListModel(parent) {}
29+
30+ Q_INVOKABLE int count() const { return rowCount(); }
31+};
32+
33+Q_DECLARE_METATYPE(MirSurfaceItemModel*)
34+
35+#endif // MIRSURFACEITEMMODEL_H
tests/mocks/Unity/Application/ObjectListModel.hnew file+106
@@ -0,0 +1,106 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef OBJECTLISTMODEL_H
18+#define OBJECTLISTMODEL_H
19+
20+// Qt
21+#include <QAbstractListModel>
22+
23+template<class TYPE>
24+class ObjectListModel : public QAbstractListModel
25+{
26+public:
27+ ObjectListModel(QObject *parent = 0)
28+ : QAbstractListModel(parent)
29+ {}
30+
31+ enum Roles {
32+ RoleModelData = Qt::UserRole,
33+ };
34+
35+ const QList<TYPE*>& list() const { return m_items; }
36+ bool contains(TYPE* item) const { return m_items.contains(item); }
37+
38+ void insert(uint index, TYPE* item)
39+ {
40+ index = qMin(index, (uint)m_items.count());
41+
42+ int existingIndex = m_items.indexOf(item);
43+ if (existingIndex != -1) {
44+ move(existingIndex, qMin(index, (uint)(m_items.count()-1)));
45+ } else {
46+ beginInsertRows(QModelIndex(), index, index);
47+ m_items.insert(index, item);
48+ endInsertRows();
49+ }
50+ }
51+
52+ void remove(TYPE* item)
53+ {
54+ int existingIndex = m_items.indexOf(item);
55+ if (existingIndex != -1) {
56+ beginRemoveRows(QModelIndex(), existingIndex, existingIndex);
57+ m_items.removeAt(existingIndex);
58+ endRemoveRows();
59+ }
60+ }
61+
62+ // from QAbstractItemModel
63+ int rowCount(const QModelIndex& = QModelIndex()) const override
64+ {
65+ return m_items.count();
66+ }
67+
68+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override
69+ {
70+ if (index.row() >= 0 && index.row() < m_items.count()) {
71+ if (role == RoleModelData) {
72+ TYPE *item = m_items.at(index.row());
73+ return QVariant::fromValue(item);
74+ }
75+ }
76+ return QVariant();
77+ }
78+
79+ QHash<int, QByteArray> roleNames() const
80+ {
81+ QHash<int, QByteArray> roleNames;
82+ roleNames.insert(RoleModelData, "modelData");
83+ return roleNames;
84+ }
85+
86+protected:
87+ void move(int from, int to)
88+ {
89+ if (from == to) return;
90+
91+ if (from >= 0 && from < m_items.size() && to >= 0 && to < m_items.size()) {
92+ QModelIndex parent;
93+ /* When moving an item down, the destination index needs to be incremented
94+ by one, as explained in the documentation:
95+ http://qt-project.org/doc/qt-5.0/qtcore/qabstractitemmodel.html#beginMoveRows */
96+
97+ beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0));
98+ m_items.move(from, to);
99+ endMoveRows();
100+ }
101+ }
102+
103+ QList<TYPE*> m_items;
104+};
105+
106+#endif // OBJECTLISTMODEL_H
tests/mocks/Unity/Application/Session.cppnew file+174
@@ -0,0 +1,174 @@
1+/*
2+ * Copyright (C) 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+#include "Session.h"
18+#include "ApplicationInfo.h"
19+#include "SessionManager.h"
20+#include "SurfaceManager.h"
21+
22+#include <QPainter>
23+#include <QQmlEngine>
24+#include <QTimer>
25+
26+Session::Session(const QString &name,
27+ const QUrl& screenshot,
28+ QObject *parent)
29+ : QObject(parent)
30+ , m_name(name)
31+ , m_live(true)
32+ , m_screenshot(screenshot)
33+ , m_application(nullptr)
34+ , m_surface(nullptr)
35+ , m_parentSession(nullptr)
36+ , m_children(new SessionModel(this))
37+{
38+ qDebug() << "Session::Session() " << this->name();
39+
40+ QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
41+}
42+
43+Session::~Session()
44+{
45+ qDebug() << "Session::~Session() " << name();
46+
47+ QList<Session*> children(m_children->list());
48+ for (Session* child : children) {
49+ delete child;
50+ }
51+ if (m_parentSession) {
52+ m_parentSession->removeChildSession(this);
53+ }
54+ if (m_application) {
55+ m_application->setSession(nullptr);
56+ }
57+ delete m_surface;
58+ delete m_children;
59+}
60+
61+void Session::release()
62+{
63+ qDebug() << "Session::release " << name();
64+
65+ if (m_parentSession) {
66+ m_parentSession->removeChildSession(this);
67+ }
68+ if (m_application) {
69+ m_application->setSession(nullptr);
70+ }
71+ if (!parent()) {
72+ deleteLater();
73+ }
74+}
75+
76+void Session::setApplication(ApplicationInfo* application)
77+{
78+ if (m_application == application)
79+ return;
80+
81+ m_application = application;
82+ Q_EMIT applicationChanged(application);
83+}
84+
85+void Session::setSurface(MirSurfaceItem* surface)
86+{
87+ qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
88+ if (m_surface == surface)
89+ return;
90+
91+ if (m_surface) {
92+ m_surface->setSession(nullptr);
93+ m_surface->setParent(nullptr);
94+ Q_EMIT m_surface->deregister();
95+ }
96+
97+ m_surface = surface;
98+
99+ if (m_surface) {
100+ m_surface->setSession(this);
101+ m_surface->setParent(this);
102+ SurfaceManager::singleton()->registerSurface(m_surface);
103+ }
104+
105+ Q_EMIT surfaceChanged(m_surface);
106+}
107+
108+void Session::setScreenshot(const QUrl& screenshot)
109+{
110+ if (screenshot != m_screenshot) {
111+ m_screenshot = screenshot;
112+ if (m_surface) {
113+ m_surface->setScreenshot(m_screenshot);
114+ }
115+ }
116+}
117+
118+void Session::setLive(bool live)
119+{
120+ if (m_live != live) {
121+ m_live = live;
122+ Q_EMIT liveChanged(m_live);
123+ }
124+}
125+
126+void Session::setParentSession(Session* session)
127+{
128+ if (m_parentSession == session || session == this)
129+ return;
130+
131+ m_parentSession = session;
132+ Q_EMIT parentSessionChanged(session);
133+}
134+
135+void Session::createSurface()
136+{
137+ if (m_surface) return;
138+
139+ setSurface(SurfaceManager::singleton()->createSurface(name(),
140+ MirSurfaceItem::Normal,
141+ m_application && m_application->fullscreen() ? MirSurfaceItem::Fullscreen :
142+ MirSurfaceItem::Maximized,
143+ m_screenshot));
144+}
145+
146+void Session::addChildSession(Session* session)
147+{
148+ insertChildSession(m_children->rowCount(), session);
149+}
150+
151+void Session::insertChildSession(uint index, Session* session)
152+{
153+ qDebug() << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
154+
155+ session->setParentSession(this);
156+ m_children->insert(index, session);
157+ SessionManager::singleton()->registerSession(session);
158+}
159+
160+void Session::removeChildSession(Session* session)
161+{
162+ qDebug() << "Session::removeChildSession - " << session->name() << " from " << name();
163+
164+ if (m_children->contains(session)) {
165+ m_children->remove(session);
166+ session->setParentSession(nullptr);
167+ Q_EMIT session->deregister();
168+ }
169+}
170+
171+SessionModel* Session::childSessions() const
172+{
173+ return m_children;
174+}
tests/mocks/Unity/Application/Session.hnew file+90
@@ -0,0 +1,90 @@
1+/*
2+ * Copyright (C) 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+#ifndef SESSION_H
18+#define SESSION_H
19+
20+#include "SessionModel.h"
21+
22+#include <QQuickItem>
23+
24+class ApplicationInfo;
25+class MirSurfaceItem;
26+
27+class Session : public QObject
28+{
29+ Q_OBJECT
30+ Q_PROPERTY(QString name READ name CONSTANT)
31+ Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
32+ Q_PROPERTY(ApplicationInfo* application READ application NOTIFY applicationChanged)
33+ Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
34+ Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
35+ Q_PROPERTY(bool live READ live NOTIFY liveChanged)
36+
37+public:
38+ explicit Session(const QString &name,
39+ const QUrl& screenshot,
40+ QObject *parent = 0);
41+ ~Session();
42+
43+ Q_INVOKABLE void release();
44+
45+ //getters
46+ QString name() const { return m_name; }
47+ bool live() const { return m_live; }
48+ ApplicationInfo* application() const { return m_application; }
49+ MirSurfaceItem* surface() const { return m_surface; }
50+ Session* parentSession() const { return m_parentSession; }
51+
52+ void setApplication(ApplicationInfo* item);
53+ void setSurface(MirSurfaceItem* surface);
54+ void setScreenshot(const QUrl& m_screenshot);
55+ void setLive(bool live);
56+
57+ Q_INVOKABLE void addChildSession(Session* session);
58+ void insertChildSession(uint index, Session* session);
59+ void removeChildSession(Session* session);
60+
61+Q_SIGNALS:
62+ void applicationChanged(ApplicationInfo*);
63+ void surfaceChanged(MirSurfaceItem*);
64+ void parentSessionChanged(Session*);
65+ void liveChanged(bool live);
66+
67+ // internal mock use
68+ void deregister();
69+
70+public Q_SLOTS:
71+ Q_INVOKABLE void createSurface();
72+
73+private:
74+ SessionModel* childSessions() const;
75+ void setParentSession(Session* session);
76+
77+ QString m_name;
78+ bool m_live;
79+ QUrl m_screenshot;
80+ ApplicationInfo* m_application;
81+ MirSurfaceItem* m_surface;
82+ Session* m_parentSession;
83+ SessionModel* m_children;
84+
85+ friend class ApplicationTestInterface;
86+};
87+
88+Q_DECLARE_METATYPE(Session*)
89+
90+#endif // SESSION_H
tests/mocks/Unity/Application/SessionManager.cppnew file+55
@@ -0,0 +1,55 @@
1+/*
2+ * Copyright (C) 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+#include "SessionManager.h"
18+
19+#include "Session.h"
20+
21+SessionManager *SessionManager::the_session_manager = nullptr;
22+
23+SessionManager *SessionManager::singleton()
24+{
25+ if (!the_session_manager) {
26+ the_session_manager = new SessionManager();
27+ }
28+ return the_session_manager;
29+}
30+
31+SessionManager::SessionManager(QObject *parent) :
32+ QObject(parent)
33+{
34+}
35+
36+
37+Session *SessionManager::createSession(const QString& name,
38+ const QUrl& screenshot)
39+{
40+ Session* session = new Session(name, screenshot);
41+ Q_EMIT sessionStarting(session);
42+ return session;
43+}
44+
45+void SessionManager::registerSession(Session *session)
46+{
47+ connect(session, &Session::deregister, this, [this] {
48+ Session* session = qobject_cast<Session*>(sender());
49+
50+ disconnect(session, 0, this, 0);
51+
52+ session->setLive(false);
53+ Q_EMIT sessionStopping(session);
54+ });
55+}
tests/mocks/Unity/Application/SessionManager.hnew file+44
@@ -0,0 +1,44 @@
1+/*
2+ * Copyright (C) 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+#ifndef SESSIONMANAGER_H
18+#define SESSIONMANAGER_H
19+
20+#include <QObject>
21+
22+class Session;
23+
24+class SessionManager : public QObject
25+{
26+ Q_OBJECT
27+public:
28+ explicit SessionManager(QObject *parent = 0);
29+
30+ static SessionManager *singleton();
31+
32+ Q_INVOKABLE Session* createSession(const QString& name, const QUrl& screenshot);
33+
34+ void registerSession(Session *session);
35+
36+Q_SIGNALS:
37+ void sessionStarting(Session *session);
38+ void sessionStopping(Session *session);
39+
40+private:
41+ static SessionManager *the_session_manager;
42+};
43+
44+#endif // SESSIONMANAGER_H
tests/mocks/Unity/Application/SessionModel.hnew file+35
@@ -0,0 +1,35 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software: you can redistribute it and/or modify it under
5+ * the terms of the GNU Lesser General Public License version 3, as published by
6+ * the Free Software Foundation.
7+ *
8+ * This program is distributed in the hope that it will be useful, but WITHOUT
9+ * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10+ * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+ * Lesser General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU Lesser General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef SESSIONMODEL_H
18+#define SESSIONMODEL_H
19+
20+// Local
21+#include "ObjectListModel.h"
22+
23+class Session;
24+class SessionModel: public ObjectListModel<Session>
25+{
26+ Q_OBJECT
27+public:
28+ SessionModel(QObject *parent = 0): ObjectListModel(parent) {}
29+
30+ Q_INVOKABLE int count() const { return rowCount(); }
31+};
32+
33+Q_DECLARE_METATYPE(SessionModel*)
34+
35+#endif // SESSIONMODEL_H
tests/mocks/Unity/Application/SurfaceManager.cpp+20−7
@@ -35,19 +35,32 @@ SurfaceManager::SurfaceManager(QObject *parent) :
35{
35{
36}
36}
37
37
38+MirSurfaceItem *SurfaceManager::createSurface(const QString& name,
39+ MirSurfaceItem::Type type,
40+ MirSurfaceItem::State state,
41+ const QUrl& screenshot)
42+{
43+ MirSurfaceItem* surface = new MirSurfaceItem(name,
44+ type,
45+ state,
46+ screenshot);
47+ Q_EMIT surfaceCreated(surface);
48+ return surface;
49+}
50+
38void SurfaceManager::registerSurface(MirSurfaceItem *surface)
51void SurfaceManager::registerSurface(MirSurfaceItem *surface)
39{
52{
53+ connect(surface, &MirSurfaceItem::deregister, this, [this] {
54+ MirSurfaceItem* surface = qobject_cast<MirSurfaceItem*>(sender());
55+ disconnect(surface, 0, this, 0);
56+
57+ surface->setLive(false);
58+ Q_EMIT surfaceDestroyed(surface);
59+ });
40 connect(surface, &MirSurfaceItem::inputMethodRequested,
60 connect(surface, &MirSurfaceItem::inputMethodRequested,
41 this, &SurfaceManager::showInputMethod);
61 this, &SurfaceManager::showInputMethod);
42 connect(surface, &MirSurfaceItem::inputMethodDismissed,
62 connect(surface, &MirSurfaceItem::inputMethodDismissed,
43 this, &SurfaceManager::hideInputMethod);
63 this, &SurfaceManager::hideInputMethod);
44− Q_EMIT surfaceCreated(surface);
45−}
46−
47−void SurfaceManager::unregisterSurface(MirSurfaceItem *surface)
48−{
49− disconnect(surface, 0, this, 0);
50− Q_EMIT surfaceDestroyed(surface);
51}
64}
52
65
53void SurfaceManager::showInputMethod()
66void SurfaceManager::showInputMethod()
tests/mocks/Unity/Application/SurfaceManager.h+6−2
@@ -19,7 +19,7 @@
19
19
20#include <QObject>
20#include <QObject>
21
21
22−class MirSurfaceItem;
22+#include "MirSurfaceItem.h"
23
23
24class SurfaceManager : public QObject
24class SurfaceManager : public QObject
25{
25{
@@ -29,9 +29,13 @@ public:
29
29
30 static SurfaceManager *singleton();
30 static SurfaceManager *singleton();
31
31
32+ Q_INVOKABLE MirSurfaceItem *createSurface(const QString& name,
33+ MirSurfaceItem::Type type,
34+ MirSurfaceItem::State state,
35+ const QUrl& screenshot);
36+
32 // Internal mock use
37 // Internal mock use
33 void registerSurface(MirSurfaceItem *surface);
38 void registerSurface(MirSurfaceItem *surface);
34− void unregisterSurface(MirSurfaceItem *surface);
35
39
36 // To be used in the tests
40 // To be used in the tests
37 Q_INVOKABLE MirSurfaceItem *inputMethodSurface();
41 Q_INVOKABLE MirSurfaceItem *inputMethodSurface();
tests/mocks/Unity/Application/plugin.cpp+37−4
@@ -18,8 +18,12 @@
18#include "ApplicationInfo.h"
18#include "ApplicationInfo.h"
19#include "ApplicationManager.h"
19#include "ApplicationManager.h"
20#include "ApplicationScreenshotProvider.h"
20#include "ApplicationScreenshotProvider.h"
21+#include "Session.h"
21#include "MirSurfaceItem.h"
22#include "MirSurfaceItem.h"
23+#include "MirSurfaceItemModel.h"
22#include "SurfaceManager.h"
24#include "SurfaceManager.h"
25+#include "SessionManager.h"
26+#include "ApplicationTestInterface.h"
23
27
24#include <qqml.h>
28#include <qqml.h>
25#include <QQmlEngine>
29#include <QQmlEngine>
@@ -36,18 +40,45 @@ static QObject* surfaceManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEng
36 return SurfaceManager::singleton();
40 return SurfaceManager::singleton();
37}
41}
38
42
43+static QObject* sessionManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
44+ Q_UNUSED(engine);
45+ Q_UNUSED(scriptEngine);
46+ return SessionManager::singleton();
47+}
48+
49+ApplicationTestInterface* s_appTestInterface = nullptr;
50+
51+static QObject* applicationTestInterface(QQmlEngine* engine, QJSEngine* scriptEngine) {
52+ Q_UNUSED(engine);
53+ Q_UNUSED(scriptEngine);
54+ if (!s_appTestInterface) {
55+ s_appTestInterface = new ApplicationTestInterface(engine);
56+ }
57+ return s_appTestInterface;
58+}
59+
39void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
60void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
40{
61{
62+ qRegisterMetaType<Session*>("Session*");
63+ qRegisterMetaType<ApplicationInfo*>("ApplicationInfo*");
64+ qRegisterMetaType<MirSurfaceItemModel*>("SessionModel*");
41 qRegisterMetaType<MirSurfaceItem*>("MirSurfaceItem*");
65 qRegisterMetaType<MirSurfaceItem*>("MirSurfaceItem*");
66+ qRegisterMetaType<MirSurfaceItemModel*>("MirSurfaceItemModel*");
42
67
43 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
68 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
44− qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
45− qmlRegisterSingletonType<SurfaceManager>(uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
46−
47 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
69 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
70+ qmlRegisterUncreatableType<Session>(uri, 0, 1, "Session", "Session can't be instantiated from QML");
71+ qmlRegisterUncreatableType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem", "MirSurfaceItem can't be instantiated from QML");
72+
48 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
73 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
49
74
50− qmlRegisterUncreatableType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem", "MirSurfaceItem can't be instantiated from QML");
75+ qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
76+ qmlRegisterSingletonType<SurfaceManager>(uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
77+ qmlRegisterSingletonType<SessionManager>(uri, 0, 1, "SessionManager", sessionManagerSingleton);
78+ qmlRegisterSingletonType<ApplicationTestInterface>(uri, 0, 1, "ApplicationTest", applicationTestInterface);
79+
80+ qRegisterMetaType<MirSurfaceItem::Type>("MirSurfaceItem::Type");
81+ qRegisterMetaType<MirSurfaceItem::State>("MirSurfaceItem::State");
51}
82}
52
83
53void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
84void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
@@ -55,4 +86,6 @@ void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const c
55 QQmlExtensionPlugin::initializeEngine(engine, uri);
86 QQmlExtensionPlugin::initializeEngine(engine, uri);
56
87
57 engine->addImageProvider(QLatin1String("application"), new ApplicationScreenshotProvider(ApplicationManager::singleton()));
88 engine->addImageProvider(QLatin1String("application"), new ApplicationScreenshotProvider(ApplicationManager::singleton()));
89+ // make sure we initialise our test interface.
90+ applicationTestInterface(engine, nullptr);
58}
91}
tests/mocks/Unity/Indicators/Indicators.qmltypes+20
@@ -159,6 +159,26 @@ Module {
159 Property { name: "sourceModel"; type: "QAbstractItemModel"; isPointer: true }
159 Property { name: "sourceModel"; type: "QAbstractItemModel"; isPointer: true }
160 }
160 }
161 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }
161 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }
162+ Component {
163+ name: "UnityMenuModelCache"
164+ prototype: "QObject"
165+ exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
166+ isCreatable: false
167+ isSingleton: true
168+ exportMetaObjectRevisions: [0]
169+ Method {
170+ name: "model"
171+ type: "UnityMenuModel*"
172+ Parameter { name: "bus"; type: "QByteArray" }
173+ Parameter { name: "path"; type: "QByteArray" }
174+ Parameter { name: "actions"; type: "QVariantMap" }
175+ }
176+ Method {
177+ name: "contains"
178+ type: "bool"
179+ Parameter { name: "path"; type: "QByteArray" }
180+ }
181+ }
162 Component {
182 Component {
163 name: "UnityMenuModelStack"
183 name: "UnityMenuModelStack"
164 prototype: "QObject"
184 prototype: "QObject"
tests/mocks/Unity/Unity.qmltypes+30−2
@@ -36,6 +36,10 @@ Module {
36 prototype: "unity::shell::scopes::PreviewModelInterface"
36 prototype: "unity::shell::scopes::PreviewModelInterface"
37 exports: ["Unity/FakePreviewModel 0.2"]
37 exports: ["Unity/FakePreviewModel 0.2"]
38 exportMetaObjectRevisions: [0]
38 exportMetaObjectRevisions: [0]
39+ Method {
40+ name: "setLoaded"
41+ Parameter { type: "bool" }
42+ }
39 }
43 }
40 Component {
44 Component {
41 name: "PreviewStack"
45 name: "PreviewStack"
@@ -59,9 +63,9 @@ Module {
59 Component {
63 Component {
60 name: "ResultsModel"
64 name: "ResultsModel"
61 prototype: "unity::shell::scopes::ResultsModelInterface"
65 prototype: "unity::shell::scopes::ResultsModelInterface"
62− exports: ["Unity/ResultsModel 0.2"]
66+ exports: ["Unity/FakeResultsModel 0.2", "Unity/ResultsModel 0.2"]
63 isCreatable: false
67 isCreatable: false
64− exportMetaObjectRevisions: [0]
68+ exportMetaObjectRevisions: [0, 0]
65 }
69 }
66 Component {
70 Component {
67 name: "Scope"
71 name: "Scope"
@@ -134,7 +138,13 @@ Module {
134 }
138 }
135 Method { name: "clear" }
139 Method { name: "clear" }
136 Method { name: "load" }
140 Method { name: "load" }
141+ Method {
142+ name: "getScopeFromAll"
143+ type: "Scope*"
144+ Parameter { name: "scope_id"; type: "string" }
145+ }
137 }
146 }
147+ Component { name: "SettingsModel"; prototype: "unity::shell::scopes::SettingsModelInterface" }
138 Component {
148 Component {
139 name: "unity::shell::scopes::CategoriesInterface"
149 name: "unity::shell::scopes::CategoriesInterface"
140 prototype: "QAbstractListModel"
150 prototype: "QAbstractListModel"
@@ -402,4 +412,22 @@ Module {
402 Parameter { name: "scopeId"; type: "string" }
412 Parameter { name: "scopeId"; type: "string" }
403 }
413 }
404 }
414 }
415+ Component {
416+ name: "unity::shell::scopes::SettingsModelInterface"
417+ prototype: "QAbstractListModel"
418+ exports: ["Unity/SettingsModel 0.2"]
419+ isCreatable: false
420+ exportMetaObjectRevisions: [0]
421+ Enum {
422+ name: "Roles"
423+ values: {
424+ "RoleSettingId": 0,
425+ "RoleDisplayName": 1,
426+ "RoleType": 2,
427+ "RoleProperties": 3,
428+ "RoleValue": 4
429+ }
430+ }
431+ Property { name: "count"; type: "int"; isReadonly: true }
432+ }
405}
433}
tests/qmltests/CMakeLists.txt+1
@@ -86,3 +86,4 @@ add_qml_test(Stages ApplicationWindow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINAR
86add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
86add_qml_test(Stages PhoneStage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
87add_qml_test(Stages SpreadDelegate ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
87add_qml_test(Stages SpreadDelegate ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
88add_qml_test(Stages SurfaceContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
88add_qml_test(Stages SurfaceContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
89+add_qml_test(Stages SessionContainer ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/libusermetrics:${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
tests/qmltests/Panel/tst_ActiveCallHint.qml+1−1
@@ -97,7 +97,7 @@ Item {
97 var application = ApplicationManager.startApplication("dialer-app");
97 var application = ApplicationManager.startApplication("dialer-app");
98 ApplicationManager.focusApplication("dialer-app");
98 ApplicationManager.focusApplication("dialer-app");
99 tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
99 tryCompare(ApplicationManager, "focusedApplicationId", "dialer-app");
100− tryCompare(application, "state", ApplicationInfo.Running);
100+ tryCompare(application, "state", ApplicationInfoInterface.Running);
101
101
102 if (!data.focused) { ApplicationManager.unfocusCurrentApplication(); }
102 if (!data.focused) { ApplicationManager.unfocusCurrentApplication(); }
103 }
103 }
tests/qmltests/Stages/RecursingChildSessionControl.qmlnew file+142
@@ -0,0 +1,142 @@
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.1
18+import QtQuick.Layouts 1.1
19+import Ubuntu.Components 0.1
20+import Unity.Application 0.1
21+
22+ColumnLayout {
23+ id: root
24+
25+ property var session
26+ property var childSessions: session ? session.childSessions : 0
27+ property bool removable: false
28+ property alias surfaceCheckbox: _surfaceCheckbox
29+
30+ property var screenshotIds: [ "gallery", "map", "facebook", "camera", "browser", "music", "twitter"]
31+
32+ onSessionChanged: {
33+ if (!session) surfaceCheckbox.checked = false;
34+ }
35+
36+ Column {
37+ id: column
38+ Layout.fillWidth: true
39+ visible: repeater.count
40+ spacing: units.gu(1)
41+
42+ Repeater {
43+ id: repeater
44+ model: root.childSessions
45+ delegate: Rectangle {
46+ border {
47+ color: "black"
48+ width: 1
49+ }
50+ anchors {
51+ left: column.left
52+ right: column.right
53+ leftMargin: units.gu(1)
54+ rightMargin: units.gu(1)
55+ }
56+ height: loader.height
57+
58+ Rectangle {
59+ anchors.fill: parent
60+ color: Qt.rgba(Math.random(), Math.random(), Math.random(), 0.4 )
61+ }
62+
63+ Loader {
64+ id: loader
65+ visible: status == Loader.Ready
66+ source: Qt.resolvedUrl("RecursingChildSessionControl.qml")
67+
68+ anchors {
69+ left: parent.left
70+ right: parent.right
71+ }
72+
73+ onLoaded: {
74+ item.session = modelData;
75+ item.removable = true;
76+ }
77+ }
78+ }
79+ }
80+ }
81+
82+ ColumnLayout {
83+ Layout.fillWidth: true
84+ spacing: units.gu(1)
85+
86+ RowLayout {
87+ Layout.fillWidth: true
88+
89+ CheckBox {
90+ id: _surfaceCheckbox;
91+ checked: false;
92+ enabled: root.session
93+ onCheckedChanged: {
94+ if (checked) {
95+ root.session.createSurface();
96+ } else if (root.session.surface) {
97+ ApplicationTest.removeSurface(root.session.surface);
98+ }
99+ }
100+
101+ Connections {
102+ target: root.session ? root.session : null
103+ onSurfaceChanged: {
104+ surfaceCheckbox.checked = root.session.surface !== null
105+ }
106+ }
107+ }
108+
109+ Label {
110+ text: "Surface"
111+ anchors.verticalCenter: parent.verticalCenter
112+ }
113+ }
114+
115+ RowLayout {
116+ id: buttonLayout
117+
118+ Button {
119+ enabled: root.session
120+ text: removable ? "Remove" : "Release"
121+ onClicked: {
122+ if (removable) {
123+ // release the surface first. simulates mir app closing
124+ if (root.session.surface) ApplicationTest.removeSurface(root.session.surface);
125+ ApplicationTest.removeSession(root.session);
126+ } else {
127+ root.session.release();
128+ }
129+ }
130+ }
131+
132+ Button {
133+ enabled: root.session !== null
134+ text: "Add Child"
135+ onClicked: {
136+ var screenshot = Math.round(Math.random()*100 % (screenshotIds.length-1));
137+ var session = ApplicationTest.addChildSession(root.session, root.screenshotIds[screenshot]);
138+ }
139+ }
140+ }
141+ }
142+}
tests/qmltests/Stages/tst_ApplicationWindow.qml+99−47
@@ -14,7 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−import QtQuick 2.0
17+import QtQuick 2.1
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import Unity.Test 0.1 as UT
20import Unity.Test 0.1 as UT
20import ".."
21import ".."
@@ -32,14 +33,15 @@ Rectangle {
32 Component.onCompleted: {
33 Component.onCompleted: {
33 root.fakeApplication = ApplicationManager.add("gallery-app");
34 root.fakeApplication = ApplicationManager.add("gallery-app");
34 root.fakeApplication.manualSurfaceCreation = true;
35 root.fakeApplication.manualSurfaceCreation = true;
35− root.fakeApplication.setState(ApplicationInfo.Starting);
36+ root.fakeApplication.setState(ApplicationInfoInterface.Starting);
36 }
37 }
37 property QtObject fakeApplication: null
38 property QtObject fakeApplication: null
39+ readonly property var fakeSession: fakeApplication ? fakeApplication.session : null
38
40
39 Connections {
41 Connections {
40 target: fakeApplication
42 target: fakeApplication
41− onSurfaceChanged: {
43+ onSessionChanged: {
42− surfaceCheckbox.checked = fakeApplication.surface !== null;
44+ sessionCheckbox.checked = fakeApplication.session !== null
43 }
45 }
44 }
46 }
45
47
@@ -50,15 +52,20 @@ Rectangle {
50 application: fakeApplication
52 application: fakeApplication
51 }
53 }
52 }
54 }
53− Loader {
55+ FocusScope {
54− id: applicationWindowLoader
56+ id: appFocus
55 anchors {
57 anchors {
56 top: parent.top
58 top: parent.top
57 bottom: parent.bottom
59 bottom: parent.bottom
58 left: parent.left
60 left: parent.left
59 }
61 }
60 width: units.gu(40)
62 width: units.gu(40)
63+
64+ Loader {
65+ id: applicationWindowLoader
66+ anchors.fill: parent
61− sourceComponent: applicationWindowComponent
67+ sourceComponent: applicationWindowComponent
68+ }
62 }
69 }
63
70
64 Rectangle {
71 Rectangle {
@@ -66,30 +73,55 @@ Rectangle {
66 anchors {
73 anchors {
67 top: parent.top
74 top: parent.top
68 bottom: parent.bottom
75 bottom: parent.bottom
69− left: applicationWindowLoader.right
76+ left: appFocus.right
70 right: parent.right
77 right: parent.right
71 }
78 }
72
79
73− Column {
80+ ColumnLayout {
74 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
81 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
75 spacing: units.gu(1)
82 spacing: units.gu(1)
76− Row {
83+
77− anchors { left: parent.left; right: parent.right }
84+ RowLayout {
85+ Layout.fillWidth: true
86+
78 CheckBox {
87 CheckBox {
79− id: surfaceCheckbox; checked: false
88+ id: sessionCheckbox; checked: false
80 onCheckedChanged: {
89 onCheckedChanged: {
81 if (applicationWindowLoader.status !== Loader.Ready)
90 if (applicationWindowLoader.status !== Loader.Ready)
82 return;
91 return;
83
92
84− if (checked && !fakeApplication.surface) {
93+ if (checked && !fakeApplication.session) {
85− fakeApplication.createSurface();
94+ fakeApplication.createSession();
86− } else if (!checked && fakeApplication.surface) {
95+ } else if (!checked && fakeApplication.session) {
87− fakeApplication.surface.release();
96+ fakeApplication.session.release();
88 }
97 }
89 }
98 }
90 }
99 }
91− Label { text: "Surface" }
100+ Label {
101+ text: "Session"
102+ anchors.verticalCenter: parent.verticalCenter
103+ }
92 }
104 }
105+
106+ Rectangle {
107+ border {
108+ color: "black"
109+ width: 1
110+ }
111+ anchors {
112+ left: parent.left
113+ right: parent.right
114+ }
115+ Layout.preferredHeight: sessionControl.height
116+
117+ RecursingChildSessionControl {
118+ id: sessionControl
119+ anchors { left: parent.left; right: parent.right; }
120+
121+ session: fakeSession
122+ }
123+ }
124+
93 ListItem.ItemSelector {
125 ListItem.ItemSelector {
94 id: appStateSelector
126 id: appStateSelector
95 anchors { left: parent.left; right: parent.right }
127 anchors { left: parent.left; right: parent.right }
@@ -100,13 +132,13 @@ Rectangle {
100 "Stopped"]
132 "Stopped"]
101 property int selectedApplicationState: {
133 property int selectedApplicationState: {
102 if (model[selectedIndex] === "Starting") {
134 if (model[selectedIndex] === "Starting") {
103− return ApplicationInfo.Starting;
135+ return ApplicationInfoInterface.Starting;
104 } else if (model[selectedIndex] === "Running") {
136 } else if (model[selectedIndex] === "Running") {
105− return ApplicationInfo.Running;
137+ return ApplicationInfoInterface.Running;
106 } else if (model[selectedIndex] === "Suspended") {
138 } else if (model[selectedIndex] === "Suspended") {
107− return ApplicationInfo.Suspended;
139+ return ApplicationInfoInterface.Suspended;
108 } else {
140 } else {
109− return ApplicationInfo.Stopped;
141+ return ApplicationInfoInterface.Stopped;
110 }
142 }
111 }
143 }
112 onSelectedApplicationStateChanged: {
144 onSelectedApplicationStateChanged: {
@@ -114,6 +146,7 @@ Rectangle {
114 fakeApplication.setState(selectedApplicationState);
146 fakeApplication.setState(selectedApplicationState);
115 }
147 }
116 }
148 }
149+
117 }
150 }
118 }
151 }
119
152
@@ -123,10 +156,10 @@ Rectangle {
123 when: windowShown
156 when: windowShown
124
157
125 // just to make them shorter
158 // just to make them shorter
126− property int appStarting: ApplicationInfo.Starting
159+ property int appStarting: ApplicationInfoInterface.Starting
127− property int appRunning: ApplicationInfo.Running
160+ property int appRunning: ApplicationInfoInterface.Running
128− property int appSuspended: ApplicationInfo.Suspended
161+ property int appSuspended: ApplicationInfoInterface.Suspended
129− property int appStopped: ApplicationInfo.Stopped
162+ property int appStopped: ApplicationInfoInterface.Stopped
130
163
131 function setApplicationState(appState) {
164 function setApplicationState(appState) {
132 switch (appState) {
165 switch (appState) {
@@ -170,6 +203,14 @@ Rectangle {
170 findInterestingApplicationWindowChildren();
203 findInterestingApplicationWindowChildren();
171 }
204 }
172
205
206+ function initSession() {
207+ sessionCheckbox.checked = true;
208+ sessionControl.surfaceCheckbox.checked = true;
209+ }
210+ function cleanupSession() {
211+ sessionCheckbox.checked = false;
212+ }
213+
173 function cleanup() {
214 function cleanup() {
174 forgetApplicationWindowChildren();
215 forgetApplicationWindowChildren();
175
216
@@ -177,10 +218,10 @@ Rectangle {
177 applicationWindowLoader.active = false;
218 applicationWindowLoader.active = false;
178
219
179 appStateSelector.selectedIndex = 0;
220 appStateSelector.selectedIndex = 0;
180− surfaceCheckbox.checked = false;
221+ cleanupSession();
181
222
182− if (fakeApplication.surface)
223+ if (fakeApplication.session)
183− fakeApplication.surface.release();
224+ fakeApplication.session.release();
184
225
185 applicationWindowLoader.active = true;
226 applicationWindowLoader.active = true;
186 }
227 }
@@ -197,7 +238,7 @@ Rectangle {
197 verify(stateGroup.state === "splashScreen");
238 verify(stateGroup.state === "splashScreen");
198
239
199 if (data.swapInitOrder) {
240 if (data.swapInitOrder) {
200− surfaceCheckbox.checked = true;
241+ initSession();
201 } else {
242 } else {
202 setApplicationState(appRunning);
243 setApplicationState(appRunning);
203 }
244 }
@@ -207,14 +248,14 @@ Rectangle {
207 if (data.swapInitOrder) {
248 if (data.swapInitOrder) {
208 setApplicationState(appRunning);
249 setApplicationState(appRunning);
209 } else {
250 } else {
210− surfaceCheckbox.checked = true;
251+ initSession();
211 }
252 }
212
253
213 tryCompare(stateGroup, "state", "surface");
254 tryCompare(stateGroup, "state", "surface");
214 }
255 }
215
256
216 function test_suspendedAppShowsSurface() {
257 function test_suspendedAppShowsSurface() {
217− surfaceCheckbox.checked = true;
258+ initSession();
218 setApplicationState(appRunning);
259 setApplicationState(appRunning);
219
260
220 tryCompare(stateGroup, "state", "surface");
261 tryCompare(stateGroup, "state", "surface");
@@ -228,7 +269,7 @@ Rectangle {
228 }
269 }
229
270
230 function test_killedAppShowsScreenshot() {
271 function test_killedAppShowsScreenshot() {
231− surfaceCheckbox.checked = true;
272+ initSession();
232 setApplicationState(appRunning);
273 setApplicationState(appRunning);
233 tryCompare(stateGroup, "state", "surface");
274 tryCompare(stateGroup, "state", "surface");
234
275
@@ -241,13 +282,13 @@ Rectangle {
241 setApplicationState(appStopped);
282 setApplicationState(appStopped);
242
283
243 tryCompare(stateGroup, "state", "screenshot");
284 tryCompare(stateGroup, "state", "screenshot");
244− tryCompare(fakeApplication, "surface", null);
285+ tryCompare(fakeApplication, "session", null);
245 }
286 }
246
287
247 function test_restartApp() {
288 function test_restartApp() {
248 var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
289 var screenshotImage = findChild(applicationWindowLoader.item, "screenshotImage");
249
290
250− surfaceCheckbox.checked = true;
291+ initSession();
251 setApplicationState(appRunning);
292 setApplicationState(appRunning);
252 tryCompare(stateGroup, "state", "surface");
293 tryCompare(stateGroup, "state", "surface");
253 waitUntilTransitionsEnd();
294 waitUntilTransitionsEnd();
@@ -259,28 +300,28 @@ Rectangle {
259
300
260 tryCompare(stateGroup, "state", "screenshot");
301 tryCompare(stateGroup, "state", "screenshot");
261 waitUntilTransitionsEnd();
302 waitUntilTransitionsEnd();
262− tryCompare(fakeApplication, "surface", null);
303+ tryCompare(fakeApplication, "session", null);
263
304
264 // and restart it
305 // and restart it
265 setApplicationState(appStarting);
306 setApplicationState(appStarting);
266
307
267 waitUntilTransitionsEnd();
308 waitUntilTransitionsEnd();
268 verify(stateGroup.state === "screenshot");
309 verify(stateGroup.state === "screenshot");
269− verify(fakeApplication.surface === null);
310+ verify(fakeSession === null);
270
311
271 setApplicationState(appRunning);
312 setApplicationState(appRunning);
272
313
273 waitUntilTransitionsEnd();
314 waitUntilTransitionsEnd();
274 verify(stateGroup.state === "screenshot");
315 verify(stateGroup.state === "screenshot");
275
316
276− surfaceCheckbox.checked = true;
317+ initSession();
277
318
278 tryCompare(stateGroup, "state", "surface");
319 tryCompare(stateGroup, "state", "surface");
279 tryCompare(screenshotImage, "status", Image.Null);
320 tryCompare(screenshotImage, "status", Image.Null);
280 }
321 }
281
322
282 function test_appCrashed() {
323 function test_appCrashed() {
283− surfaceCheckbox.checked = true;
324+ initSession();
284 setApplicationState(appRunning);
325 setApplicationState(appRunning);
285 tryCompare(stateGroup, "state", "surface");
326 tryCompare(stateGroup, "state", "surface");
286 waitUntilTransitionsEnd();
327 waitUntilTransitionsEnd();
@@ -289,39 +330,39 @@ Rectangle {
289 setApplicationState(appStopped);
330 setApplicationState(appStopped);
290
331
291 tryCompare(stateGroup, "state", "screenshot");
332 tryCompare(stateGroup, "state", "screenshot");
292− tryCompare(fakeApplication, "surface", null);
333+ tryCompare(fakeApplication, "session", null);
293 }
334 }
294
335
295 function test_keepSurfaceWhileInvisible() {
336 function test_keepSurfaceWhileInvisible() {
296− surfaceCheckbox.checked = true;
337+ initSession();
297 setApplicationState(appRunning);
338 setApplicationState(appRunning);
298 tryCompare(stateGroup, "state", "surface");
339 tryCompare(stateGroup, "state", "surface");
299 waitUntilTransitionsEnd();
340 waitUntilTransitionsEnd();
300− verify(fakeApplication.surface !== null);
341+ verify(fakeSession.surface !== null);
301
342
302 applicationWindowLoader.item.visible = false;
343 applicationWindowLoader.item.visible = false;
303
344
304 waitUntilTransitionsEnd();
345 waitUntilTransitionsEnd();
305 verify(stateGroup.state === "surface");
346 verify(stateGroup.state === "surface");
306− verify(fakeApplication.surface !== null);
347+ verify(fakeSession.surface !== null);
307
348
308 applicationWindowLoader.item.visible = true;
349 applicationWindowLoader.item.visible = true;
309
350
310 waitUntilTransitionsEnd();
351 waitUntilTransitionsEnd();
311 verify(stateGroup.state === "surface");
352 verify(stateGroup.state === "surface");
312− verify(fakeApplication.surface !== null);
353+ verify(fakeSession.surface !== null);
313 }
354 }
314
355
315 function test_touchesReachSurfaceWhenItsShown() {
356 function test_touchesReachSurfaceWhenItsShown() {
316 setApplicationState(appRunning);
357 setApplicationState(appRunning);
317− surfaceCheckbox.checked = true;
358+ initSession();
318
359
319 tryCompare(stateGroup, "state", "surface");
360 tryCompare(stateGroup, "state", "surface");
320
361
321 waitUntilTransitionsEnd();
362 waitUntilTransitionsEnd();
322
363
323 // Because doing stuff in C++ is a PITA we keep the counter in the interal qml impl.
364 // Because doing stuff in C++ is a PITA we keep the counter in the interal qml impl.
324− var fakeSurface = findChild(fakeApplication.surface, "fakeSurfaceQML");
365+ var fakeSurface = findChild(fakeSession.surface, "fakeSurfaceQML");
325 fakeSurface.touchPressCount = 0;
366 fakeSurface.touchPressCount = 0;
326 fakeSurface.touchReleaseCount = 0;
367 fakeSurface.touchReleaseCount = 0;
327
368
@@ -333,14 +374,25 @@ Rectangle {
333 }
374 }
334
375
335 function test_showNothingOnSuddenSurfaceLoss() {
376 function test_showNothingOnSuddenSurfaceLoss() {
336− surfaceCheckbox.checked = true;
377+ initSession();
337 setApplicationState(appRunning);
378 setApplicationState(appRunning);
338 tryCompare(stateGroup, "state", "surface");
379 tryCompare(stateGroup, "state", "surface");
339 waitUntilTransitionsEnd();
380 waitUntilTransitionsEnd();
340
381
341− surfaceCheckbox.checked = false;
382+ cleanupSession();
342
383
343 verify(stateGroup.state === "void");
384 verify(stateGroup.state === "void");
344 }
385 }
386+
387+ // should be forcing active focus when interactive changes,
388+ // which will cause a FocusScope higher in the object hierarchy tp be given the focus
389+ function test_forceActiveFocusFollowsInterative() {
390+ fakeApplication.createSession();
391+ applicationWindowLoader.item.interactive = false;
392+ applicationWindowLoader.item.interactive = true;
393+ fakeSession.createSurface();
394+
395+ compare(appFocus.focus, true);
396+ }
345 }
397 }
346}
398}
tests/qmltests/Stages/tst_PhoneStage.qml+1−1
@@ -65,7 +65,7 @@ Item {
65 anchors { left: parent.left; right: parent.right }
65 anchors { left: parent.left; right: parent.right }
66 text: "Stop Selected"
66 text: "Stop Selected"
67 onClicked: {
67 onClicked: {
68− ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfo.Stopped);
68+ ApplicationManager.get(appList.selectedAppIndex).setState(ApplicationInfoInterface.Stopped);
69 }
69 }
70 }
70 }
71 Button {
71 Button {
tests/qmltests/Stages/tst_SessionContainer.qmlnew file+267
@@ -0,0 +1,267 @@
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.1
18+import QtQuick.Layouts 1.1
19+import QtTest 1.0
20+import Unity.Test 0.1 as UT
21+import Ubuntu.Components 0.1
22+import Unity.Application 0.1
23+import "../../../qml/Stages"
24+
25+Rectangle {
26+ color: "red"
27+ id: root
28+ width: units.gu(80)
29+ height: units.gu(70)
30+
31+ Connections {
32+ target: sessionContainerLoader.status === Loader.Ready ? sessionContainerLoader.item : null
33+ onSessionChanged: {
34+ sessionCheckbox.checked = sessionContainerLoader.item.session !== null
35+ }
36+ }
37+
38+ Component {
39+ id: sessionContainerComponent
40+
41+ SessionContainer {
42+ id: sessionContainer
43+ anchors.fill: parent
44+ }
45+ }
46+
47+ Loader {
48+ id: sessionContainerLoader
49+ anchors {
50+ top: parent.top
51+ bottom: parent.bottom
52+ left: parent.left
53+ }
54+ width: units.gu(40)
55+ sourceComponent: sessionContainerComponent
56+ }
57+
58+ Rectangle {
59+ color: "white"
60+ anchors {
61+ top: parent.top
62+ bottom: parent.bottom
63+ left: sessionContainerLoader.right
64+ right: parent.right
65+ }
66+
67+ ColumnLayout {
68+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
69+ spacing: units.gu(1)
70+
71+ RowLayout {
72+ Layout.fillWidth: true
73+
74+ CheckBox {
75+ id: sessionCheckbox;
76+ checked: false;
77+ onCheckedChanged: {
78+ if (sessionContainerLoader.status !== Loader.Ready)
79+ return;
80+
81+ if (checked) {
82+ var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
83+ sessionContainerLoader.item.session = fakeSession;
84+ fakeSession.createSurface();
85+ } else {
86+ sessionContainerLoader.item.session.release();
87+ }
88+ }
89+ }
90+
91+ Label {
92+ text: "session"
93+ anchors.verticalCenter: parent.verticalCenter
94+ }
95+ }
96+
97+ Rectangle {
98+ border {
99+ color: "black"
100+ width: 1
101+ }
102+ anchors {
103+ left: parent.left
104+ right: parent.right
105+ }
106+ Layout.preferredHeight: sessionChildrenControl.height
107+
108+ RecursingChildSessionControl {
109+ id: sessionChildrenControl
110+ anchors { left: parent.left; right: parent.right; }
111+
112+ session: sessionContainerLoader.item ? sessionContainerLoader.item.session : null
113+ }
114+ }
115+ }
116+ }
117+
118+ SignalSpy {
119+ id: sessionSpy
120+ target: SessionManager
121+ signalName: "sessionStopping"
122+ }
123+
124+ UT.UnityTestCase {
125+ id: testCase
126+ name: "SessionContainer"
127+
128+ function init() {
129+ // reload our test subject to get it in a fresh state once again
130+ sessionContainerLoader.active = false;
131+ sessionCheckbox.checked = false;
132+ sessionContainerLoader.active = true;
133+
134+ tryCompare(sessionContainerLoader.item, "session", null);
135+ sessionSpy.clear();
136+ }
137+
138+ when: windowShown
139+
140+ function test_addChildSession_data() {
141+ return [ { tag: "count=1", count: 1 },
142+ { tag: "count=4", count: 4 } ];
143+ }
144+
145+ function test_addChildSession(data) {
146+ sessionCheckbox.checked = true;
147+ var sessionContainer = sessionContainerLoader.item;
148+ compare(sessionContainer.childSessions.count(), 0);
149+
150+ var i;
151+ var sessions = [];
152+ for (i = 0; i < data.count; i++) {
153+ var session = ApplicationTest.addChildSession(sessionContainer.session,
154+ "gallery");
155+ session.createSurface();
156+ sessionContainer.session.addChildSession(session);
157+ compare(sessionContainer.childSessions.count(), i+1);
158+
159+ sessions.push(session);
160+ }
161+
162+ for (i = data.count-1; i >= 0; i--) {
163+ ApplicationTest.removeSession(sessions[i]);
164+ tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, i);
165+ }
166+ tryCompare(sessionSpy, "count", data.count);
167+ }
168+
169+ function test_nestedChildSessions_data() {
170+ return [ { tag: "depth=2", depth: 2 },
171+ { tag: "depth=8", depth: 8 }
172+ ];
173+ }
174+
175+ function test_nestedChildSessions(data) {
176+ sessionCheckbox.checked = true;
177+ var sessionContainer = sessionContainerLoader.item;
178+ compare(sessionContainer.childSessions.count(), 0);
179+
180+ var i;
181+ var sessions = [];
182+ var lastSession = sessionContainer.session;
183+ var delegate;
184+ var container = sessionContainer;
185+ for (i = 0; i < data.depth; i++) {
186+ var session = ApplicationTest.addChildSession(lastSession,
187+ "gallery");
188+ session.createSurface();
189+ lastSession.addChildSession(session);
190+ compare(container.childSessions.count(), 1);
191+ sessions.push(session);
192+
193+ delegate = findChild(container, "childDelegate0");
194+ container = findChild(delegate, "sessionContainer");
195+ lastSession = session;
196+ }
197+
198+ for (i = data.depth-1; i >= 0; i--) {
199+ ApplicationTest.removeSession(sessions[i]);
200+ }
201+
202+ tryCompareFunction(function() { return sessionContainer.childSessions.count(); }, 0);
203+ tryCompare(sessionSpy, "count", data.depth);
204+ }
205+
206+ function test_childrenAdjustForParentSize() {
207+ sessionCheckbox.checked = true;
208+ var sessionContainer = sessionContainerLoader.item;
209+
210+ var session = ApplicationTest.addChildSession(sessionContainer.session,
211+ "gallery");
212+ session.createSurface();
213+ sessionContainer.session.addChildSession(session);
214+
215+ var delegate = findChild(sessionContainer, "childDelegate0");
216+ var childContainer = findChild(delegate, "sessionContainer");
217+
218+ tryCompareFunction(function() { return childContainer.height === sessionContainer.height; }, true);
219+ tryCompareFunction(function() { return childContainer.width === sessionContainer.width; }, true);
220+ tryCompareFunction(function() { return childContainer.x === 0; }, true);
221+ tryCompareFunction(function() { return childContainer.y === 0; }, true);
222+
223+ sessionContainer.anchors.margins = units.gu(2);
224+
225+ tryCompareFunction(function() { return childContainer.height === sessionContainer.height; }, true);
226+ tryCompareFunction(function() { return childContainer.width === sessionContainer.width; }, true);
227+ tryCompareFunction(function() { return childContainer.x === 0; }, true);
228+ tryCompareFunction(function() { return childContainer.y === 0; }, true);
229+ }
230+
231+ function isContainerAnimating(container) {
232+ var animation = findInvisibleChild(container, "sessionAnimation");
233+ if (!animation) return false;
234+
235+ var animating = false;
236+ for (var i = 0; i < animation.transitions.length; ++i) {
237+ if (animation.transitions[i].running) {
238+ return true;
239+ }
240+ }
241+ return false;
242+ }
243+
244+ function test_childrenAnimate() {
245+ sessionCheckbox.checked = true;
246+ var sessionContainer = sessionContainerLoader.item;
247+
248+ var session = ApplicationTest.addChildSession(sessionContainer.session,
249+ "gallery");
250+
251+ var delegate = findChild(sessionContainer, "childDelegate0");
252+ var childContainer = findChild(delegate, "sessionContainer");
253+
254+ // wait for animation to begin
255+ tryCompareFunction(function() { return isContainerAnimating(childContainer); }, true);
256+ // wait for animation to end
257+ tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
258+
259+ ApplicationTest.removeSession(session);
260+
261+ // wait for animation to begin
262+ tryCompareFunction(function() { return isContainerAnimating(childContainer); }, true);
263+ // wait for animation to end
264+ tryCompareFunction(function() { return isContainerAnimating(childContainer); }, false);
265+ }
266+ }
267+}
tests/qmltests/Stages/tst_SurfaceContainer.qml+28−43
@@ -28,43 +28,6 @@ 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: fakeSurfaceComponent
33− Rectangle {
34− color: "green"
35−
36− Rectangle {
37− color: "blue"
38− anchors.fill: parent
39− anchors.margins: units.gu(2)
40− Text {
41− anchors.fill: parent
42− text: "Surface"
43− color: "green"
44− font.bold: true
45− fontSizeMode: Text.Fit
46− minimumPixelSize: 10; font.pixelSize: 200
47− verticalAlignment: Text.AlignVCenter
48− }
49− }
50−
51− width: units.gu(1)
52− height: units.gu(1)
53−
54− property int type: MirSurfaceItem.Normal
55− property int state: MirSurfaceItem.Restored
56− property string name: "Fake Surface"
57− property Item parentSurface: null
58− property list<Item> childSurfaces
59− function release() {}
60− signal removed();
61− }
62− }
63−
64− Item {
65− id: tempSurfaceHolder
66− }
67−
68 Component {
31 Component {
69 id: surfaceContainerComponent
32 id: surfaceContainerComponent
70 SurfaceContainer {
33 SurfaceContainer {
@@ -98,19 +61,20 @@ Rectangle {
98 Row {
61 Row {
99 anchors { left: parent.left; right: parent.right }
62 anchors { left: parent.left; right: parent.right }
100 CheckBox {
63 CheckBox {
101− id: surfaceCheckbox; checked: false;
64+ id: surfaceCheckbox;
65+ checked: false;
102 onCheckedChanged: {
66 onCheckedChanged: {
103 if (surfaceContainerLoader.status !== Loader.Ready)
67 if (surfaceContainerLoader.status !== Loader.Ready)
104 return;
68 return;
105
69
106 if (checked) {
70 if (checked) {
107− var fakeSurface = fakeSurfaceComponent.createObject(tempSurfaceHolder);
71+ var fakeSurface = SurfaceManager.createSurface("fake-surface",
72+ MirSurfaceItem.Normal,
73+ MirSurfaceItem.Restored,
74+ Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
108 surfaceContainerLoader.item.surface = fakeSurface;
75 surfaceContainerLoader.item.surface = fakeSurface;
109 } else {
76 } else {
110− var fakeSurface = surfaceContainerLoader.item.surface;
77+ ApplicationTest.removeSurface(surfaceContainerLoader.item.surface);
111− surfaceContainerLoader.item.surface = null;
112− fakeSurface.parent = null;
113− fakeSurface.destroy();
114 }
78 }
115 }
79 }
116 }
80 }
@@ -124,6 +88,12 @@ Rectangle {
124 }
88 }
125 }
89 }
126
90
91+ SignalSpy {
92+ id: surfaceSpy
93+ target: SurfaceManager
94+ signalName: "surfaceDestroyed"
95+ }
96+
127 UT.UnityTestCase {
97 UT.UnityTestCase {
128 id: testCase
98 id: testCase
129 name: "SurfaceContainer"
99 name: "SurfaceContainer"
@@ -134,6 +104,9 @@ Rectangle {
134 surfaceContainerLoader.active = false;
104 surfaceContainerLoader.active = false;
135 surfaceCheckbox.checked = false;
105 surfaceCheckbox.checked = false;
136 surfaceContainerLoader.active = true;
106 surfaceContainerLoader.active = true;
107+
108+ tryCompare(surfaceContainerLoader.item, "surface", null);
109+ surfaceSpy.clear();
137 }
110 }
138
111
139 /*
112 /*
@@ -150,5 +123,17 @@ Rectangle {
150 compare(fakeSurface.width, surfaceContainerLoader.item.width);
123 compare(fakeSurface.width, surfaceContainerLoader.item.width);
151 compare(fakeSurface.height, surfaceContainerLoader.item.height);
124 compare(fakeSurface.height, surfaceContainerLoader.item.height);
152 }
125 }
126+
127+ function test_animateRemoval() {
128+ surfaceCheckbox.checked = true;
129+ var surfaceContainer = surfaceContainerLoader.item;
130+
131+ verify(surfaceContainer.surface !== null);
132+
133+ ApplicationTest.removeSurface(surfaceContainer.surface);
134+
135+ compare(surfaceContainer.state, "zombie");
136+ tryCompare(surfaceContainer, "surface", null);
137+ }
153 }
138 }
154}
139}
tests/qmltests/tst_Shell.qml+9−9
@@ -144,7 +144,7 @@ Item {
144 verify(mainAppId != "");
144 verify(mainAppId != "");
145 var mainApp = ApplicationManager.findApplication(mainAppId);
145 var mainApp = ApplicationManager.findApplication(mainAppId);
146 verify(mainApp);
146 verify(mainApp);
147− tryCompare(mainApp, "state", ApplicationInfo.Running);
147+ tryCompare(mainApp, "state", ApplicationInfoInterface.Running);
148
148
149 // Try to suspend while proximity is engaged...
149 // Try to suspend while proximity is engaged...
150 Powerd.displayPowerStateChange(Powerd.Off, Powerd.Proximity);
150 Powerd.displayPowerStateChange(Powerd.Off, Powerd.Proximity);
@@ -157,7 +157,7 @@ Item {
157 tryCompare(greeter, "showProgress", 1);
157 tryCompare(greeter, "showProgress", 1);
158
158
159 tryCompare(ApplicationManager, "suspended", true);
159 tryCompare(ApplicationManager, "suspended", true);
160− compare(mainApp.state, ApplicationInfo.Suspended);
160+ compare(mainApp.state, ApplicationInfoInterface.Suspended);
161
161
162 // And wake up
162 // And wake up
163 Powerd.displayPowerStateChange(Powerd.On, 0);
163 Powerd.displayPowerStateChange(Powerd.On, 0);
@@ -166,7 +166,7 @@ Item {
166 // Swipe away greeter to focus app
166 // Swipe away greeter to focus app
167 swipeAwayGreeter();
167 swipeAwayGreeter();
168 tryCompare(ApplicationManager, "suspended", false);
168 tryCompare(ApplicationManager, "suspended", false);
169− compare(mainApp.state, ApplicationInfo.Running);
169+ compare(mainApp.state, ApplicationInfoInterface.Running);
170 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
170 tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
171 }
171 }
172
172
@@ -237,9 +237,9 @@ Item {
237 function test_surfaceLosesFocusWhilePanelIsOpen() {
237 function test_surfaceLosesFocusWhilePanelIsOpen() {
238 var app = ApplicationManager.startApplication("dialer-app");
238 var app = ApplicationManager.startApplication("dialer-app");
239 // wait until the app is fully loaded (ie, real surface replaces splash screen)
239 // wait until the app is fully loaded (ie, real surface replaces splash screen)
240− tryCompareFunction(function() { return app.surface != null }, true);
240+ tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
241
241
242− tryCompare(app.surface, "focus", true);
242+ tryCompare(app.session.surface, "focus", true);
243
243
244 // Drag the indicators panel half-open
244 // Drag the indicators panel half-open
245 var touchX = shell.width / 2;
245 var touchX = shell.width / 2;
@@ -250,7 +250,7 @@ Item {
250 true /* beginTouch */, false /* endTouch */);
250 true /* beginTouch */, false /* endTouch */);
251 verify(indicators.partiallyOpened);
251 verify(indicators.partiallyOpened);
252
252
253− tryCompare(app.surface, "focus", false);
253+ tryCompare(app.session.surface, "focus", false);
254
254
255 // And finish getting it open
255 // And finish getting it open
256 touchFlick(indicators,
256 touchFlick(indicators,
@@ -259,11 +259,11 @@ Item {
259 false /* beginTouch */, true /* endTouch */);
259 false /* beginTouch */, true /* endTouch */);
260 tryCompare(indicators, "fullyOpened", true);
260 tryCompare(indicators, "fullyOpened", true);
261
261
262− tryCompare(app.surface, "focus", false);
262+ tryCompare(app.session.surface, "focus", false);
263
263
264 dragToCloseIndicatorsPanel();
264 dragToCloseIndicatorsPanel();
265
265
266− tryCompare(app.surface, "focus", true);
266+ tryCompare(app.session.surface, "focus", true);
267 }
267 }
268
268
269 // Wait for the whole UI to settle down
269 // Wait for the whole UI to settle down
@@ -361,7 +361,7 @@ Item {
361
361
362 var app = ApplicationManager.startApplication("dialer-app");
362 var app = ApplicationManager.startApplication("dialer-app");
363 // wait until the app is fully loaded (ie, real surface replaces splash screen)
363 // wait until the app is fully loaded (ie, real surface replaces splash screen)
364− tryCompareFunction(function() { return app.surface != null }, true);
364+ tryCompareFunction(function() { return app.session !== null && app.session.surface !== null }, true);
365
365
366 // Minimize the application we just launched
366 // Minimize the application we just launched
367 swipeFromLeftEdge(units.gu(26) + 1);
367 swipeFromLeftEdge(units.gu(26) + 1);