on xenial help sign in
drop obsolete file from merge
commita38e61faf47acaedfd0503d12c9f1ad747f78460 authorMichael Zanetti <michael.zanetti@canonical.com> dateWed 27 May 2015, 13:37 (11 years ago) parent2d75060
1 file changed−387
tests/qmltests/tst_DesktopShell.qml.THIS−387
tests/qmltests/tst_DesktopShell.qml.THISdeleted−387
@@ -1,387 +0,0 @@
1−/*
2− * Copyright (C) 2013,2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import QtTest 1.0
19−import AccountsService 0.1
20−import GSettings 1.0
21−import LightDM 0.1 as LightDM
22−import Ubuntu.Components 1.1
23−import Ubuntu.Telephony 0.1 as Telephony
24−import Unity.Application 0.1
25−import Unity.Connectivity 0.1
26−import Unity.Test 0.1
27−import Powerd 0.1
28−import Utils 0.1
29−
30−import "../../qml"
31−
32−Item {
33− id: root
34− width: units.gu(140)
35− height: units.gu(90)
36−
37− Binding {
38− target: MouseTouchAdaptor
39− property: "enabled"
40− value: false
41− }
42−
43− Component.onCompleted: {
44− GSettingsController.setUsageMode("com.canonical.Unity8", "Windowed")
45− // must set the mock mode before loading the Shell
46− LightDM.Greeter.mockMode = "full";
47− LightDM.Users.mockMode = "full";
48−
49− // ensures apps which are tested decorations are in view.
50− WindowStateStorage.geometry = {
51− 'unity8-dash': Qt.rect(0, units.gu(3), units.gu(50), units.gu(40)),
52− 'dialer-app': Qt.rect(units.gu(51), units.gu(3), units.gu(50), units.gu(40)),
53− 'camera-app': Qt.rect(0, units.gu(44), units.gu(50), units.gu(40)),
54− }
55−
56− shellLoader.active = true;
57− }
58−
59− QtObject {
60− id: applicationArguments
61−
62− function hasGeometry() {
63− return false
64− }
65−
66− function width() {
67− return 0
68− }
69−
70− function height() {
71− return 0
72− }
73− }
74−
75− Row {
76− anchors.fill: parent
77− Loader {
78− id: shellLoader
79−
80− active: false
81− width: parent.width - units.gu(30)
82− height: parent.height
83−
84− property bool itemDestroyed: false
85− sourceComponent: Component {
86− Shell {
87− property string indicatorProfile: "desktop"
88−
89− Component.onDestruction: {
90− shellLoader.itemDestroyed = true
91− }
92− }
93− }
94− }
95−
96− Rectangle {
97− color: "white"
98− width: units.gu(30)
99− height: parent.height
100−
101− Column {
102− anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
103− spacing: units.gu(1)
104− Button {
105− text: "Show Greeter"
106− onClicked: {
107− if (shellLoader.status !== Loader.Ready)
108− return
109−
110− var greeter = testCase.findChild(shellLoader.item, "greeter")
111− if (!greeter.shown) {
112− greeter.show()
113− }
114− }
115− }
116− Button {
117− text: "Hide Greeter"
118− onClicked: {
119− if (shellLoader.status !== Loader.Ready)
120− return
121−
122− var greeter = testCase.findChild(shellLoader.item, "greeter")
123− if (greeter.shown) {
124− greeter.hide()
125− }
126− }
127− }
128−
129− Button {
130− text: "Start all apps"
131− onClicked: {
132− for (var i = 0; i < ApplicationManager.availableApplications.length; i++) {
133− var appId = ApplicationManager.availableApplications[i];
134− if (ApplicationManager.findApplication(appId) == null) {
135− print("starting", appId)
136− ApplicationManager.startApplication(appId)
137− }
138− }
139− }
140− }
141−
142− Repeater {
143− id: apps
144− model: ApplicationManager.availableApplications
145− anchors {
146− left: parent.left
147− right: parent.right
148− }
149− height: childrenRect.height
150−
151− Row {
152− id: appColumn
153− enabled: modelData != "unity8-dash"
154− property var application: null
155−
156− Component.onCompleted: {
157− application = ApplicationManager.findApplication(modelData);
158− }
159−
160− Connections {
161− target: ApplicationManager
162− onCountChanged: {
163− appColumn.application = ApplicationManager.findApplication(modelData);
164− }
165− }
166−
167− CheckBox {
168− id: appCheckBox
169− onTriggered: {
170− if (checked) ApplicationManager.startApplication(modelData);
171− else ApplicationManager.stopApplication(modelData);
172− }
173− Binding {
174− target: appCheckBox
175− property: "checked"
176− value: appColumn.application != null
177− }
178− }
179−
180− Label {
181− text: appColumn.application ? appColumn.application.name : modelData
182− color: "black"
183− }
184− }
185− }
186− }
187− }
188− }
189−
190− SignalSpy {
191− id: sessionSpy
192− signalName: "sessionStarted"
193− }
194−
195− SignalSpy {
196− id: dashCommunicatorSpy
197− signalName: "setCurrentScopeCalled"
198− }
199−
200− SignalSpy {
201− id: unlockAllModemsSpy
202− target: Connectivity
203− signalName: "unlockingAllModems"
204− }
205−
206− UnityTestCase {
207− id: testCase
208− name: "DesktopShell"
209− when: windowShown
210−
211− property Item shell: shellLoader.status === Loader.Ready ? shellLoader.item : null
212−
213− function init() {
214− tryCompare(shell, "enabled", true); // will be enabled when greeter is all ready
215− var userList = findChild(shell, "userList");
216− tryCompare(userList, "movingInternally", false);
217− sessionSpy.clear()
218− sessionSpy.target = findChild(shell, "greeter")
219− dashCommunicatorSpy.target = findInvisibleChild(shell, "dashCommunicator")
220− }
221−
222− function cleanup() {
223− tryCompare(shell, "enabled", true); // make sure greeter didn't leave us in disabled state
224−
225− shellLoader.itemDestroyed = false
226−
227− shellLoader.active = false
228−
229− tryCompare(shellLoader, "status", Loader.Null)
230− tryCompare(shellLoader, "item", null)
231− // Loader.status might be Loader.Null and Loader.item might be null but the Loader
232− // item might still be alive. So if we set Loader.active back to true
233− // again right now we will get the very same Shell instance back. So no reload
234− // actually took place. Likely because Loader waits until the next event loop
235− // iteration to do its work. So to ensure the reload, we will wait until the
236− // Shell instance gets destroyed.
237− tryCompare(shellLoader, "itemDestroyed", true)
238−
239− // kill all (fake) running apps
240− killApps()
241−
242− unlockAllModemsSpy.clear()
243− AccountsService.demoEdges = false
244− LightDM.Greeter.authenticate(""); // reset greeter
245−
246− // reload our test subject to get it in a fresh state once again
247− shellLoader.active = true
248−
249− tryCompare(shellLoader, "status", Loader.Ready)
250− removeTimeConstraintsFromDirectionalDragAreas(shellLoader.item)
251− }
252−
253− function killApps() {
254− while (ApplicationManager.count > 1) {
255− var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
256− ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId)
257− }
258− compare(ApplicationManager.count, 1)
259− }
260−
261− function selectIndex(i) {
262− // We could be anywhere in list; find target index to know which direction
263− var greeter = findChild(shell, "greeter")
264− var userlist = findChild(greeter, "userList")
265− if (userlist.currentIndex == i)
266− keyClick(Qt.Key_Escape) // Reset state if we're not moving
267− while (userlist.currentIndex != i) {
268− var next = userlist.currentIndex + 1
269− if (userlist.currentIndex > i) {
270− next = userlist.currentIndex - 1
271− }
272− tap(findChild(greeter, "username"+next));
273− tryCompare(userlist, "currentIndex", next)
274− tryCompare(userlist, "movingInternally", false)
275− }
276− }
277−
278− function selectUser(name) {
279− // Find index of user with the right name
280− for (var i = 0; i < LightDM.Users.count; i++) {
281− if (LightDM.Users.data(i, LightDM.UserRoles.NameRole) == name) {
282− break
283− }
284− }
285− if (i == LightDM.Users.count) {
286− fail("Didn't find name")
287− return -1
288− }
289− selectIndex(i)
290− return i
291− }
292−
293− function clickPasswordInput(isButton) {
294− var greeter = findChild(shell, "greeter")
295− tryCompare(greeter, "fullyShown", true);
296−
297− var passwordMouseArea = findChild(shell, "passwordMouseArea")
298− tryCompare(passwordMouseArea, "enabled", isButton)
299−
300− var passwordInput = findChild(shell, "passwordInput")
301− mouseClick(passwordInput)
302− }
303−
304− function confirmLoggedIn(loggedIn) {
305− var greeter = findChild(shell, "greeter");
306− tryCompare(greeter, "shown", loggedIn ? false : true);
307− verify(loggedIn ? sessionSpy.count > 0 : sessionSpy.count === 0);
308− }
309−
310− function swipeFromLeftEdge(swipeLength) {
311− var touchStartX = 2
312− var touchStartY = shell.height / 2
313− touchFlick(shell, touchStartX, touchStartY, swipeLength, touchStartY)
314− }
315−
316− function waitUntilAppSurfaceShowsUp(appId) {
317− var appWindow = findChild(shell, "appWindow_" + appId);
318− verify(appWindow);
319− var appWindowStates = findInvisibleChild(appWindow, "applicationWindowStateGroup");
320− verify(appWindowStates);
321− tryCompare(appWindowStates, "state", "surface");
322− }
323−
324− function startApplication(appId) {
325− var app = ApplicationManager.findApplication(appId);
326− if (!app) {
327− app = ApplicationManager.startApplication(appId);
328− }
329− verify(app);
330− waitUntilAppSurfaceShowsUp(appId);
331− verify(app.session.surface);
332− return app;
333− }
334−
335− function test_appFocusSwitch_data() {
336− return [
337− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 0, focusTo: 1 },
338− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 1, focusTo: 0 },
339− ]
340− }
341−
342− function test_appFocusSwitch(data) {
343− selectUser("no-password");
344− clickPasswordInput(true)
345− confirmLoggedIn(true);
346−
347− var i;
348− for (i = 0; i < data.apps.length; i++) {
349− startApplication(data.apps[i]);
350− }
351−
352− ApplicationManager.requestFocusApplication(data.apps[data.focusfrom]);
353− tryCompare(ApplicationManager.findApplication(data.apps[data.focusfrom]).session.surface, "activeFocus", true);
354−
355− ApplicationManager.requestFocusApplication(data.apps[data.focusTo]);
356− tryCompare(ApplicationManager.findApplication(data.apps[data.focusTo]).session.surface, "activeFocus", true);
357− }
358−
359− function test_decorationPressFocusesApplication_data() {
360− return [
361− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 0, focusTo: 1 },
362− {tag: "dash", apps: [ "unity8-dash", "dialer-app", "camera-app" ], focusfrom: 1, focusTo: 0 },
363− ]
364− }
365−
366− function test_decorationPressFocusesApplication(data) {
367− selectUser("no-password");
368− clickPasswordInput(true)
369− confirmLoggedIn(true);
370−
371− var i;
372− for (i = 0; i < data.apps.length; i++) {
373− startApplication(data.apps[i]);
374− }
375−
376− var fromAppDecoration = findChild(shell, "appWindowDecoration_" + data.apps[data.focusfrom]);
377− verify(fromAppDecoration);
378− mouseClick(fromAppDecoration);
379− tryCompare(ApplicationManager.findApplication(data.apps[data.focusfrom]).session.surface, "activeFocus", true);
380−
381− var toAppDecoration = findChild(shell, "appWindowDecoration_" + data.apps[data.focusTo]);
382− verify(toAppDecoration);
383− mouseClick(toAppDecoration);
384− tryCompare(ApplicationManager.findApplication(data.apps[data.focusTo]).session.surface, "activeFocus", true);
385− }
386− }
387−}