on xenial help sign in
Merge overlay
commit630d2453e0ec2041378dffee21079ecd486eea69 authorAlbert Astals Cid <albert.astals@canonical.com> dateMon 31 Aug 2015, 15:16 (11 years ago) parentbadcef42492baf
29 files changed+796−456
CMakeLists.txt+1−1 debian/changelog+8 debian/control+1−1 qml/Components/InputMethod.qml+26−21 qml/Shell.qml−19 qml/Stages/ApplicationWindow.qml+2−1 qml/Stages/SurfaceContainer.qml+38−21 tests/mocks/Unity/Application/ApplicationInfo.cpp+9−1 tests/mocks/Unity/Application/ApplicationInfo.h+4−6 tests/mocks/Unity/Application/ApplicationTestInterface.cpp+3−3 tests/mocks/Unity/Application/ApplicationTestInterface.h+3−3 tests/mocks/Unity/Application/CMakeLists.txt+4−1 tests/mocks/Unity/Application/MirSurface.cpp+182 tests/mocks/Unity/Application/MirSurface.h+113 tests/mocks/Unity/Application/MirSurfaceItem.cpp+178−85 tests/mocks/Unity/Application/MirSurfaceItem.h+40−75 tests/mocks/Unity/Application/MirSurfaceItem.qml+2 tests/mocks/Unity/Application/MirSurfaceItemModel.h−35 tests/mocks/Unity/Application/Session.cpp+22−22 tests/mocks/Unity/Application/Session.h+10−6 tests/mocks/Unity/Application/SurfaceManager.cpp+14−17 tests/mocks/Unity/Application/SurfaceManager.h+8−11 tests/mocks/Unity/Application/VirtualKeyboard.cpp+5−11 tests/mocks/Unity/Application/VirtualKeyboard.h+3−11 tests/mocks/Unity/Application/plugin.cpp+11−8 tests/qmltests/Stages/tst_ApplicationWindow.qml+39−29 tests/qmltests/Stages/tst_SurfaceContainer.qml+26−32 tests/qmltests/tst_OrientedShell.qml+28−20 tests/qmltests/tst_Shell.qml+16−16
CMakeLists.txt+1−1
@@ -56,7 +56,7 @@ find_package(Qt5DBus 5.2 REQUIRED)
5656find_package(Qt5Concurrent 5.2 REQUIRED)
5757find_package(Qt5Sql 5.2 REQUIRED)
5858
59−pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=7)
59+pkg_check_modules(APPLICATION_API REQUIRED unity-shell-application=8)
6060
6161# Standard install paths
6262include(GNUInstallDirs)
debian/changelog+8
@@ -1,3 +1,11 @@
1+unity8 (8.11+15.04.20150827.1-0ubuntu1) vivid; urgency=medium
2+
3+ [ Daniel d'Andrada ]
4+ * MirSurfaceItem is now a view+controller instantiated from QML (LP:
5+ #1483752)
6+
7+ -- CI Train Bot <ci-train-bot@canonical.com> Thu, 27 Aug 2015 14:00:05 +0000
8+
19unity8 (8.11+15.04.20150821-0ubuntu1) vivid; urgency=medium
210
311 [ Michael Terry ]
debian/control+1−1
@@ -28,7 +28,7 @@ Build-Depends: cmake,
2828 libqt5xmlpatterns5-dev,
2929 libsystemsettings-dev,
3030 libudev-dev,
31− libunity-api-dev (>= 7.99),
31+ libunity-api-dev (>= 7.100),
3232 libusermetricsoutput1-dev,
3333 libxcb1-dev,
3434 pkg-config,
qml/Components/InputMethod.qml+26−21
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -22,24 +22,44 @@ import Ubuntu.Gestures 0.1
2222Item {
2323 id: root
2424
25− property var surface: null
25+ Connections {
26+ target: SurfaceManager
27+ onSurfaceCreated: {
28+ if (surface.type == Mir.InputMethodType) {
29+ surfaceItem.surface = surface;
30+ }
31+ }
32+ }
2633
2734 property int transitionDuration: UbuntuAnimation.FastDuration
2835
29− Binding { target: surface; property: "z"; value: 0 }
36+ MirSurfaceItem {
37+ id: surfaceItem
38+ anchors.fill: parent
39+
40+ consumesInput: true
41+
42+ surfaceWidth: width
43+ surfaceHeight: height
44+
45+ onLiveChanged: {
46+ if (surface !== null && !live) {
47+ surface = null;
48+ }
49+ }
50+ }
3051
3152 TouchGate {
3253 x: UbuntuKeyboardInfo.x
3354 y: UbuntuKeyboardInfo.y
34− z: 1
3555 width: UbuntuKeyboardInfo.width
3656 height: UbuntuKeyboardInfo.height
3757
38− targetItem: root.surface
58+ targetItem: surfaceItem
3959 }
4060
4161 state: {
42− if (surface && surface.state != MirSurfaceItem.Minimized) {
62+ if (surfaceItem.surface && surfaceItem.surfaceState != Mir.MinimizedState) {
4363 return "shown";
4464 } else {
4565 return "hidden";
@@ -74,19 +94,4 @@ Item {
7494 UbuntuNumberAnimation { property: "y"; duration: transitionDuration }
7595 }
7696 ]
77−
78− onSurfaceChanged: {
79− if (surface) {
80− surface.parent = root;
81− surface.anchors.fill = root;
82− }
83− }
84−
85− Component.onDestruction: {
86− if (surface) {
87− surface.parent = null;
88− surface.release();
89− surface = null;
90− }
91− }
9297}
qml/Shell.qml−19
@@ -395,25 +395,6 @@ Item {
395395 z: notifications.useModal || panel.indicators.shown || wizard.active ? overlay.z + 1 : overlay.z - 1
396396 }
397397
398− Connections {
399− target: SurfaceManager
400− onSurfaceCreated: {
401− if (surface.type == MirSurfaceItem.InputMethod) {
402− inputMethod.surface = surface;
403− }
404− }
405−
406− onSurfaceDestroyed: {
407− if (inputMethod.surface == surface) {
408− inputMethod.surface = null;
409− surface.parent = null;
410− }
411− if (!surface.parent) {
412− // there's no one displaying it. delete it right away
413− surface.release();
414− }
415− }
416− }
417398 Connections {
418399 target: SessionManager
419400 onSessionStopping: {
qml/Stages/ApplicationWindow.qml+2−1
@@ -50,7 +50,8 @@ FocusScope {
5050 property bool hadSurface: sessionContainer.surfaceContainer.hadSurface
5151
5252 property bool needToTakeScreenshot:
53− sessionContainer.surface && d.surfaceInitialized && screenshotImage.status === Image.Null
53+ ((sessionContainer.surface && d.surfaceInitialized) || d.hadSurface)
54+ && screenshotImage.status === Image.Null
5455 && d.applicationState === ApplicationInfoInterface.Stopped
5556 onNeedToTakeScreenshotChanged: {
5657 if (needToTakeScreenshot) {
qml/Stages/SurfaceContainer.qml+38−21
@@ -18,34 +18,26 @@ import QtQuick 2.0
1818import Ubuntu.Components 1.1
1919import Ubuntu.Gestures 0.1 // For TouchGate
2020import Utils 0.1 // for InputWatcher
21+import Unity.Application 0.1 // for MirSurfaceItem
2122
2223FocusScope {
2324 id: root
2425 objectName: "surfaceContainer"
25− property Item surface: null
26+
27+ property var surface: null
2628 property bool hadSurface: false
2729 property bool interactive
2830 property int surfaceOrientationAngle: 0
2931
3032 onSurfaceChanged: {
3133 if (surface) {
32− // Set the surface focus *after* it is added to the scene to
33− // ensure an update to the scene's active focus.
34− surface.focus = false;
35− surface.parent = root;
36− surface.focus = true;
37− } else {
38− hadSurface = true;
34+ surfaceItem.surface = surface;
35+ root.hadSurface = false;
3936 }
4037 }
41− Binding { target: surface; property: "anchors.fill"; value: root }
42− Binding { target: surface; property: "z"; value: 1 }
43− Binding { target: surface; property: "enabled"; value: root.interactive; when: surface }
44− Binding { target: surface; property: "antialiasing"; value: !root.interactive; when: surface }
45− Binding { target: surface; property: "orientationAngle"; value: root.surfaceOrientationAngle; when: surface }
4638
4739 InputWatcher {
48− target: root.surface
40+ target: surfaceItem
4941 onTargetPressedChanged: {
5042 if (targetPressed && root.interactive) {
5143 root.focus = true;
@@ -54,28 +46,53 @@ FocusScope {
5446 }
5547 }
5648
49+ MirSurfaceItem {
50+ id: surfaceItem
51+ objectName: "surfaceItem"
52+
53+ consumesInput: true
54+
55+ surfaceWidth: width
56+ surfaceHeight: height
57+
58+ anchors.fill: root
59+ enabled: root.interactive
60+ focus: true
61+ antialiasing: !root.interactive
62+ orientationAngle: root.surfaceOrientationAngle
63+ }
64+
5765 TouchGate {
58− targetItem: surface
66+ targetItem: surfaceItem
5967 anchors.fill: root
60− enabled: root.surface ? root.surface.enabled : false
61− z: 2
68+ enabled: surfaceItem.enabled
6269 }
6370
6471 states: [
6572 State {
6673 name: "zombie"
67− when: surface && !surface.live
74+ when: surfaceItem.surface && !surfaceItem.live
6875 }
6976 ]
7077 transitions: [
7178 Transition {
7279 from: ""; to: "zombie"
7380 SequentialAnimation {
74− UbuntuNumberAnimation { target: surface; property: "opacity"; to: 0.0
81+ UbuntuNumberAnimation { target: surfaceItem; property: "opacity"; to: 0.0
7582 duration: UbuntuAnimation.BriskDuration }
76− PropertyAction { target: surface; property: "visible"; value: false }
77− ScriptAction { script: { if (root.surface) { root.surface.release(); } } }
83+ PropertyAction { target: surfaceItem; property: "visible"; value: false }
84+ ScriptAction { script: {
85+ surfaceItem.surface = null;
86+ root.hadSurface = true;
87+ } }
7888 }
89+ },
90+ Transition {
91+ from: "zombie"; to: ""
92+ ScriptAction { script: {
93+ surfaceItem.opacity = 1.0;
94+ surfaceItem.visible = true;
95+ } }
7996 }
8097 ]
8198}
tests/mocks/Unity/Application/ApplicationInfo.cpp+9−1
@@ -15,6 +15,7 @@
1515 */
1616
1717#include "ApplicationInfo.h"
18+#include "MirSurface.h"
1819#include "Session.h"
1920#include "SessionManager.h"
2021
@@ -74,6 +75,13 @@ void ApplicationInfo::createSession()
7475 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
7576}
7677
78+void ApplicationInfo::destroySession()
79+{
80+ Session *session = this->session();
81+ setSession(nullptr);
82+ delete session;
83+}
84+
7785void ApplicationInfo::setSession(Session* session)
7886{
7987 if (m_session == session)
@@ -237,7 +245,7 @@ void ApplicationInfo::setRequestedState(RequestedState value)
237245 }
238246}
239247
240−void ApplicationInfo::onSessionSurfaceChanged(MirSurfaceItem* surface)
248+void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
241249{
242250 if (surface != nullptr && m_state == Starting) {
243251 if (m_requestedState == RequestedRunning) {
tests/mocks/Unity/Application/ApplicationInfo.h+4−6
@@ -17,13 +17,10 @@
1717#ifndef APPLICATION_H
1818#define APPLICATION_H
1919
20−#include "SurfaceManager.h"
21−#include "MirSurfaceItemModel.h"
22−
2320#include <QObject>
2421
25−class QQuickItem;
26−class MirSurfaceItem;
22+class MirSurface;
23+class Session;
2724
2825// unity-api
2926#include <unity/shell/application/ApplicationInfoInterface.h>
@@ -103,9 +100,10 @@ Q_SIGNALS:
103100
104101public Q_SLOTS:
105102 Q_INVOKABLE void createSession();
103+ Q_INVOKABLE void destroySession();
106104
107105private Q_SLOTS:
108− void onSessionSurfaceChanged(MirSurfaceItem*);
106+ void onSessionSurfaceChanged(MirSurface*);
109107
110108private:
111109 void setIcon(const QUrl &value);
tests/mocks/Unity/Application/ApplicationTestInterface.cpp+3−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
2020#include "SessionManager.h"
2121#include "SurfaceManager.h"
2222#include "Session.h"
23−#include "MirSurfaceItem.h"
23+#include "MirSurface.h"
2424
2525#include <paths.h>
2626
@@ -62,7 +62,7 @@ void ApplicationTestInterface::removeSession(Session* existingSession)
6262 existingSession->setLive(false);
6363}
6464
65−void ApplicationTestInterface::removeSurface(MirSurfaceItem* existingSurface)
65+void ApplicationTestInterface::removeSurface(MirSurface* existingSurface)
6666{
6767 qDebug() << "ApplicationTestInterface::removeSurface - " << existingSurface;
6868
tests/mocks/Unity/Application/ApplicationTestInterface.h+3−3
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014,2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
2121
2222class ApplicationManager;
2323class Session;
24−class MirSurfaceItem;
24+class MirSurface;
2525
2626class ApplicationTestInterface : public QDBusAbstractAdaptor
2727{
@@ -32,7 +32,7 @@ public:
3232
3333 Q_INVOKABLE Session* addChildSession(Session* existingSession, const QString& surfaceImage);
3434 Q_INVOKABLE void removeSession(Session* existingSession);
35− Q_INVOKABLE void removeSurface(MirSurfaceItem* existingSurface);
35+ Q_INVOKABLE void removeSurface(MirSurface* existingSurface);
3636
3737public Q_SLOTS:
3838 quint32 addChildSession(const QString& appId, quint32 existingSessionId, const QString& surfaceImage);
tests/mocks/Unity/Application/CMakeLists.txt+4−1
@@ -4,8 +4,8 @@ set(FakeUnityApplicationQml_SOURCES
44 ApplicationManager.cpp
55 ApplicationScreenshotProvider.cpp
66 ApplicationTestInterface.cpp
7+ MirSurface.cpp
78 MirSurfaceItem.cpp
8− MirSurfaceItemModel.h
99 ObjectListModel.h
1010 Session.cpp
1111 SessionManager.cpp
@@ -15,6 +15,9 @@ set(FakeUnityApplicationQml_SOURCES
1515 VirtualKeyboard.cpp
1616 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
1717 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
18+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/Mir.h
19+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceInterface.h
20+ ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/MirSurfaceItemInterface.h
1821)
1922
2023add_library(FakeUnityApplicationQml MODULE ${FakeUnityApplicationQml_SOURCES})
tests/mocks/Unity/Application/MirSurface.cppnew file+182
@@ -0,0 +1,182 @@
1+/*
2+ * Copyright (C) 2015 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 "MirSurface.h"
18+
19+#include <QDebug>
20+
21+MirSurface::MirSurface(const QString& name,
22+ Mir::Type type,
23+ Mir::State state,
24+ const QUrl& screenshot,
25+ const QString &qmlFilePath)
26+ : unity::shell::application::MirSurfaceInterface(nullptr)
27+ , m_name(name)
28+ , m_type(type)
29+ , m_state(state)
30+ , m_orientationAngle(Mir::Angle0)
31+ , m_screenshotUrl(screenshot)
32+ , m_qmlFilePath(qmlFilePath)
33+ , m_live(true)
34+ , m_viewCount(0)
35+ , m_activeFocus(false)
36+ , m_width(-1)
37+ , m_height(-1)
38+{
39+ qDebug() << "MirSurface::MirSurface() " << name;
40+}
41+
42+MirSurface::~MirSurface()
43+{
44+ qDebug() << "MirSurface::~MirSurface() " << name();
45+}
46+
47+QString MirSurface::name() const
48+{
49+ return m_name;
50+}
51+
52+Mir::Type MirSurface::type() const
53+{
54+ return m_type;
55+}
56+
57+Mir::State MirSurface::state() const
58+{
59+ return m_state;
60+}
61+
62+void MirSurface::setState(Mir::State state)
63+{
64+ if (state == m_state)
65+ return;
66+
67+ m_state = state;
68+ Q_EMIT stateChanged(state);
69+}
70+
71+bool MirSurface::live() const
72+{
73+ return m_live;
74+}
75+
76+void MirSurface::setLive(bool live)
77+{
78+ qDebug().nospace() << "MirSurface::setLive("<<live<<") " << name();
79+ if (live == m_live)
80+ return;
81+
82+ m_live = live;
83+ Q_EMIT liveChanged(live);
84+
85+ if (!m_live && m_viewCount == 0) {
86+ deleteLater();
87+ }
88+}
89+
90+QString MirSurface::qmlFilePath() const
91+{
92+ return m_qmlFilePath;
93+}
94+
95+QUrl MirSurface::screenshotUrl() const
96+{
97+ return m_screenshotUrl;
98+}
99+
100+void MirSurface::setScreenshotUrl(QUrl screenshotUrl)
101+{
102+ if (screenshotUrl == m_screenshotUrl)
103+ return;
104+
105+ m_screenshotUrl = screenshotUrl;
106+ Q_EMIT screenshotUrlChanged(screenshotUrl);
107+}
108+
109+Mir::OrientationAngle MirSurface::orientationAngle() const
110+{
111+ return m_orientationAngle;
112+}
113+
114+void MirSurface::setOrientationAngle(Mir::OrientationAngle angle)
115+{
116+ if (angle == m_orientationAngle)
117+ return;
118+
119+ m_orientationAngle = angle;
120+ Q_EMIT orientationAngleChanged(angle);
121+}
122+
123+void MirSurface::incrementViewCount()
124+{
125+ ++m_viewCount;
126+ qDebug().nospace() << "MirSurface::incrementViewCount() viewCount(after)=" << m_viewCount << " " << name();
127+}
128+
129+void MirSurface::decrementViewCount()
130+{
131+ --m_viewCount;
132+ qDebug().nospace() << "MirSurface::decrementViewCount() viewCount(after)=" << m_viewCount << " " << name();
133+
134+ Q_ASSERT(m_viewCount >= 0);
135+
136+ if (!m_live && m_viewCount == 0) {
137+ deleteLater();
138+ }
139+}
140+
141+int MirSurface::viewCount() const
142+{
143+ return m_viewCount;
144+}
145+
146+bool MirSurface::activeFocus() const
147+{
148+ return m_activeFocus;
149+}
150+
151+void MirSurface::setActiveFocus(bool value)
152+{
153+ if (m_activeFocus == value)
154+ return;
155+
156+ m_activeFocus = value;
157+
158+ Q_EMIT activeFocusChanged(value);
159+}
160+
161+int MirSurface::width() const
162+{
163+ return m_width;
164+}
165+
166+int MirSurface::height() const
167+{
168+ return m_height;
169+}
170+
171+void MirSurface::resize(int width, int height)
172+{
173+ if (width != m_width) {
174+ m_width = width;
175+ Q_EMIT widthChanged();
176+ }
177+
178+ if (m_height != height) {
179+ m_height = height;
180+ Q_EMIT heightChanged();
181+ }
182+}
tests/mocks/Unity/Application/MirSurface.hnew file+113
@@ -0,0 +1,113 @@
1+/*
2+ * Copyright (C) 2015 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 MOCK_MIR_SURFACE_H
18+#define MOCK_MIR_SURFACE_H
19+
20+#include <QObject>
21+#include <QUrl>
22+
23+// unity-api
24+#include <unity/shell/application/MirSurfaceInterface.h>
25+
26+class MirSurface : public unity::shell::application::MirSurfaceInterface
27+{
28+ Q_OBJECT
29+
30+ ////
31+ // for use in qml tests
32+ Q_PROPERTY(int width READ width NOTIFY widthChanged)
33+ Q_PROPERTY(int height READ height NOTIFY heightChanged)
34+ Q_PROPERTY(bool activeFocus READ activeFocus NOTIFY activeFocusChanged)
35+
36+public:
37+ MirSurface(const QString& name,
38+ Mir::Type type,
39+ Mir::State state,
40+ const QUrl& screenshot,
41+ const QString &qmlFilePath = QString());
42+ virtual ~MirSurface();
43+
44+ ////
45+ // unity.shell.application.MirSurface
46+
47+ Mir::Type type() const override;
48+
49+ QString name() const override;
50+
51+ QSize size() const override { return QSize(width(),height()); }
52+ void resize(int width, int height) override;
53+ void resize(const QSize &size) override { resize(size.width(), size.height()); }
54+
55+
56+ Mir::State state() const override;
57+ Q_INVOKABLE void setState(Mir::State) override;
58+
59+ bool live() const override;
60+
61+ Mir::OrientationAngle orientationAngle() const override;
62+ void setOrientationAngle(Mir::OrientationAngle) override;
63+
64+ ////
65+ // API for tests
66+
67+ Q_INVOKABLE void setLive(bool live);
68+
69+ void incrementViewCount();
70+ void decrementViewCount();
71+ int viewCount() const;
72+
73+ int width() const;
74+ int height() const;
75+
76+ /////
77+ // internal mock stuff
78+
79+ QString qmlFilePath() const;
80+
81+ QUrl screenshotUrl() const;
82+ void setScreenshotUrl(QUrl);
83+
84+ bool activeFocus() const;
85+ void setActiveFocus(bool);
86+
87+Q_SIGNALS:
88+ void stateChanged(Mir::State);
89+ void liveChanged(bool live);
90+ void orientationAngleChanged(Mir::OrientationAngle angle);
91+ void widthChanged();
92+ void heightChanged();
93+
94+ ////
95+ // internal mock stuff
96+ void screenshotUrlChanged(QUrl);
97+ void activeFocusChanged(bool);
98+
99+private:
100+ const QString m_name;
101+ const Mir::Type m_type;
102+ Mir::State m_state;
103+ Mir::OrientationAngle m_orientationAngle;
104+ QUrl m_screenshotUrl;
105+ QString m_qmlFilePath;
106+ bool m_live;
107+ int m_viewCount;
108+ bool m_activeFocus;
109+ int m_width;
110+ int m_height;
111+};
112+
113+#endif // MOCK_MIR_SURFACE_H
tests/mocks/Unity/Application/MirSurfaceItem.cpp+178−85
@@ -15,7 +15,6 @@
1515 */
1616
1717#include "MirSurfaceItem.h"
18−#include "Session.h"
1918
2019#include <paths.h>
2120
@@ -27,69 +26,30 @@
2726
2827#include <QDebug>
2928
30−MirSurfaceItem::MirSurfaceItem(const QString& name,
31− MirSurfaceItem::Type type,
32− MirSurfaceItem::State state,
33− const QUrl& screenshot,
34− const QString &qmlFilePath,
35− QQuickItem *parent)
36− : QQuickItem(parent)
37− , m_session(nullptr)
38− , m_name(name)
39− , m_type(type)
40− , m_state(state)
41− , m_live(true)
42− , m_orientationAngle(Angle0)
29+using namespace unity::shell::application;
30+
31+MirSurfaceItem::MirSurfaceItem(QQuickItem *parent)
32+ : MirSurfaceItemInterface(parent)
33+ , m_qmlSurface(nullptr)
4334 , m_qmlItem(nullptr)
44− , m_screenshotUrl(screenshot)
35+ , m_consumesInput(false)
36+ , m_surfaceWidth(0)
37+ , m_surfaceHeight(0)
4538 , m_touchPressCount(0)
4639 , m_touchReleaseCount(0)
4740{
41+ qDebug() << "MirSurfaceItem::MirSurfaceItem() " << (void*)(this) << name();
4842 setAcceptedMouseButtons(Qt::LeftButton | Qt::MiddleButton | Qt::RightButton |
4943 Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::ExtraButton3 | Qt::ExtraButton4 |
5044 Qt::ExtraButton5 | Qt::ExtraButton6 | Qt::ExtraButton7 | Qt::ExtraButton8 |
5145 Qt::ExtraButton9 | Qt::ExtraButton10 | Qt::ExtraButton11 |
5246 Qt::ExtraButton12 | Qt::ExtraButton13);
53−
54− QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
55−
56− // The assumptions I make here really should hold.
57− QQuickView *quickView =
58− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
59−
60− QString qmlComponentFilePath;
61− if (!qmlFilePath.isEmpty()) {
62− qmlComponentFilePath.append(qmlFilePath);
63− } else {
64− qmlComponentFilePath = QString("%1/Unity/Application/MirSurfaceItem.qml")
65− .arg(mockPluginsDir());
66− }
67−
68− m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlComponentFilePath);
69−
70− switch (m_qmlContentComponent->status()) {
71− case QQmlComponent::Ready:
72− createQmlContentItem();
73− break;
74− case QQmlComponent::Loading:
75− connect(m_qmlContentComponent, &QQmlComponent::statusChanged,
76− this, &MirSurfaceItem::onComponentStatusChanged);
77− break;
78− case QQmlComponent::Error:
79− printComponentErrors();
80− qFatal("MirSurfaceItem: failed to create content component.");
81− break;
82− default:
83− qFatal("MirSurfaceItem: Unhandled component status");
84− }
8547}
8648
8749MirSurfaceItem::~MirSurfaceItem()
8850{
89− qDebug() << "MirSurfaceItem::~MirSurfaceItem() " << name();
90− if (m_session) {
91− m_session->setSurface(nullptr);
92− }
51+ qDebug() << "MirSurfaceItem::~MirSurfaceItem() " << (void*)(this) << name();
52+ setSurface(nullptr);
9353}
9454
9555void MirSurfaceItem::printComponentErrors()
@@ -100,58 +60,70 @@ void MirSurfaceItem::printComponentErrors()
10060 }
10161}
10262
103−void MirSurfaceItem::release()
63+Mir::Type MirSurfaceItem::type() const
10464{
105− qDebug() << "MirSurfaceItem::release " << name();
106−
107− if (m_session) {
108− m_session->setSurface(nullptr);
109− }
110− if (!parent()) {
111− deleteLater();
65+ if (m_qmlSurface) {
66+ return m_qmlSurface->type();
67+ } else {
68+ return Mir::UnknownType;
11269 }
11370}
11471
115−void MirSurfaceItem::setOrientationAngle(OrientationAngle angle)
72+Mir::State MirSurfaceItem::surfaceState() const
11673{
117− if (m_orientationAngle == angle)
118− return;
119−
120− m_orientationAngle = angle;
121−
122− QQmlProperty orientationProp(m_qmlItem, "orientationAngle");
123− orientationProp.write(QVariant::fromValue(m_orientationAngle));
124−
125− Q_EMIT orientationAngleChanged(m_orientationAngle);
74+ if (m_qmlSurface) {
75+ return m_qmlSurface->state();
76+ } else {
77+ return Mir::UnknownState;
78+ }
12679}
12780
128−void MirSurfaceItem::setSession(Session* session)
81+QString MirSurfaceItem::name() const
12982{
130− m_session = session;
83+ if (m_qmlSurface) {
84+ return m_qmlSurface->name();
85+ } else {
86+ return QString();
87+ }
13188}
13289
133−void MirSurfaceItem::setScreenshot(const QUrl& screenshot)
90+bool MirSurfaceItem::live() const
13491{
135− m_screenshotUrl = screenshot;
136− if (m_qmlItem) {
137− QQmlProperty screenshotSource(m_qmlItem, "screenshotSource");
138− screenshotSource.write(QVariant::fromValue(m_screenshotUrl));
92+ if (m_qmlSurface) {
93+ return m_qmlSurface->live();
94+ } else {
95+ return false;
13996 }
14097}
14198
142−void MirSurfaceItem::setLive(bool live)
99+Mir::OrientationAngle MirSurfaceItem::orientationAngle() const
143100{
144− if (m_live != live) {
145− m_live = live;
146− Q_EMIT liveChanged(m_live);
101+ if (m_qmlSurface) {
102+ return m_qmlSurface->orientationAngle();
103+ } else {
104+ return Mir::Angle0;
147105 }
148106}
149107
150−void MirSurfaceItem::setState(MirSurfaceItem::State newState)
108+void MirSurfaceItem::setOrientationAngle(Mir::OrientationAngle angle)
151109{
152− if (newState != m_state) {
153− m_state = newState;
154− Q_EMIT stateChanged(newState);
110+ if (!m_qmlSurface)
111+ return;
112+
113+ if (m_qmlSurface->orientationAngle() == angle)
114+ return;
115+
116+ m_qmlSurface->setOrientationAngle(angle);
117+
118+ QQmlProperty orientationProp(m_qmlItem, "orientationAngle");
119+ orientationProp.write(QVariant::fromValue(m_qmlSurface->orientationAngle()));
120+}
121+
122+void MirSurfaceItem::updateScreenshot(QUrl screenshotUrl)
123+{
124+ if (m_qmlItem) {
125+ QQmlProperty screenshotSource(m_qmlItem, "screenshotSource");
126+ screenshotSource.write(QVariant::fromValue(screenshotUrl));
155127 }
156128}
157129
@@ -174,7 +146,7 @@ void MirSurfaceItem::createQmlContentItem()
174146
175147 {
176148 QQmlProperty screenshotSource(m_qmlItem, "screenshotSource");
177− screenshotSource.write(QVariant::fromValue(m_screenshotUrl));
149+ screenshotSource.write(QVariant::fromValue(m_qmlSurface->screenshotUrl()));
178150 }
179151}
180152
@@ -188,3 +160,124 @@ void MirSurfaceItem::touchEvent(QTouchEvent * event)
188160 Q_EMIT touchReleaseCountChanged(m_touchReleaseCount);
189161 }
190162}
163+
164+void MirSurfaceItem::setSurface(MirSurfaceInterface* surface)
165+{
166+ qDebug().nospace() << "MirSurfaceItem::setSurface() this=" << (void*)(this)
167+ << " name=" << name()
168+ << " surface=" << surface;
169+
170+ if (m_qmlSurface == surface) {
171+ return;
172+ }
173+
174+ if (m_qmlSurface) {
175+ delete m_qmlItem;
176+ m_qmlItem = nullptr;
177+
178+ delete m_qmlContentComponent;
179+ m_qmlContentComponent = nullptr;
180+
181+ disconnect(m_qmlSurface, nullptr, this, nullptr);
182+ m_qmlSurface->decrementViewCount();
183+ }
184+
185+ m_qmlSurface = static_cast<MirSurface*>(surface);
186+
187+ if (m_qmlSurface) {
188+ m_qmlSurface->incrementViewCount();
189+
190+ m_qmlSurface->setActiveFocus(hasActiveFocus());
191+
192+ updateSurfaceSize();
193+
194+ connect(m_qmlSurface, &MirSurface::orientationAngleChanged, this, &MirSurfaceItem::orientationAngleChanged);
195+ connect(m_qmlSurface, &MirSurface::screenshotUrlChanged, this, &MirSurfaceItem::updateScreenshot);
196+ connect(m_qmlSurface, &MirSurface::liveChanged, this, &MirSurfaceItem::liveChanged);
197+ connect(m_qmlSurface, &MirSurface::stateChanged, this, &MirSurfaceItem::surfaceStateChanged);
198+
199+ // The assumptions I make here really should hold.
200+ QQuickView *quickView =
201+ qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
202+
203+ QString qmlComponentFilePath;
204+ if (!m_qmlSurface->qmlFilePath().isEmpty()) {
205+ qmlComponentFilePath.append(m_qmlSurface->qmlFilePath());
206+ } else {
207+ qmlComponentFilePath = QString("%1/Unity/Application/MirSurfaceItem.qml")
208+ .arg(mockPluginsDir());
209+ }
210+
211+ m_qmlContentComponent = new QQmlComponent(quickView->engine(), qmlComponentFilePath);
212+
213+ switch (m_qmlContentComponent->status()) {
214+ case QQmlComponent::Ready:
215+ createQmlContentItem();
216+ break;
217+ case QQmlComponent::Loading:
218+ connect(m_qmlContentComponent, &QQmlComponent::statusChanged,
219+ this, &MirSurfaceItem::onComponentStatusChanged);
220+ break;
221+ case QQmlComponent::Error:
222+ printComponentErrors();
223+ qFatal("MirSurfaceItem: failed to create content component.");
224+ break;
225+ default:
226+ qFatal("MirSurfaceItem: Unhandled component status");
227+ }
228+ }
229+
230+ Q_EMIT surfaceChanged(m_qmlSurface);
231+}
232+
233+void MirSurfaceItem::itemChange(ItemChange change, const ItemChangeData & value)
234+{
235+ if (change == QQuickItem::ItemActiveFocusHasChanged) {
236+ if (m_qmlSurface) {
237+ m_qmlSurface->setActiveFocus(value.boolValue);
238+ }
239+ }
240+}
241+
242+void MirSurfaceItem::setConsumesInput(bool value)
243+{
244+ if (m_consumesInput != value) {
245+ m_consumesInput = value;
246+ Q_EMIT consumesInputChanged(value);
247+ }
248+}
249+
250+int MirSurfaceItem::surfaceWidth() const
251+{
252+ return m_surfaceWidth;
253+}
254+
255+void MirSurfaceItem::setSurfaceWidth(int value)
256+{
257+ if (m_surfaceWidth != value) {
258+ m_surfaceWidth = value;
259+ Q_EMIT surfaceWidthChanged(m_surfaceWidth);
260+ updateSurfaceSize();
261+ }
262+}
263+
264+int MirSurfaceItem::surfaceHeight() const
265+{
266+ return m_surfaceHeight;
267+}
268+
269+void MirSurfaceItem::setSurfaceHeight(int value)
270+{
271+ if (m_surfaceHeight != value) {
272+ m_surfaceHeight = value;
273+ Q_EMIT surfaceHeightChanged(m_surfaceHeight);
274+ updateSurfaceSize();
275+ }
276+}
277+
278+void MirSurfaceItem::updateSurfaceSize()
279+{
280+ if (m_qmlSurface && m_surfaceWidth > 0 && m_surfaceHeight > 0) {
281+ m_qmlSurface->resize(m_surfaceWidth, m_surfaceHeight);
282+ }
283+}
tests/mocks/Unity/Application/MirSurfaceItem.h+40−75
@@ -17,73 +17,54 @@
1717#ifndef MIRSURFACEITEM_H
1818#define MIRSURFACEITEM_H
1919
20−#include "MirSurfaceItemModel.h"
20+#include "MirSurface.h"
2121
2222#include <QQuickItem>
2323#include <QUrl>
2424
25−class Session;
25+// unity-api
26+#include <unity/shell/application/MirSurfaceItemInterface.h>
2627
27−class MirSurfaceItem : public QQuickItem
28+class MirSurfaceItem : public unity::shell::application::MirSurfaceItemInterface
2829{
2930 Q_OBJECT
30− Q_ENUMS(Type)
31− Q_ENUMS(State)
32− Q_ENUMS(OrientationAngle)
33−
34− Q_PROPERTY(Type type READ type NOTIFY typeChanged)
35− Q_PROPERTY(State state READ state NOTIFY stateChanged)
36− Q_PROPERTY(QString name READ name CONSTANT)
37− Q_PROPERTY(bool live READ live NOTIFY liveChanged)
38− Q_PROPERTY(OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
39− NOTIFY orientationAngleChanged DESIGNABLE false)
31+
32+ ////
33+ // for use in qml tests
4034 Q_PROPERTY(int touchPressCount READ touchPressCount WRITE setTouchPressCount
4135 NOTIFY touchPressCountChanged DESIGNABLE false)
4236 Q_PROPERTY(int touchReleaseCount READ touchReleaseCount WRITE setTouchReleaseCount
4337 NOTIFY touchReleaseCountChanged DESIGNABLE false)
4438
4539public:
46− enum Type {
47− Normal,
48− Utility,
49− Dialog,
50− Overlay,
51− Freestyle,
52− Popover,
53− InputMethod,
54− };
55−
56− enum State {
57− Unknown,
58− Restored,
59− Minimized,
60− Maximized,
61− VertMaximized,
62− /* SemiMaximized, */
63− Fullscreen,
64− };
65−
66− enum OrientationAngle {
67− Angle0 = 0,
68− Angle90 = 90,
69− Angle180 = 180,
70− Angle270 = 270
71− };
72−
40+ explicit MirSurfaceItem(QQuickItem *parent = 0);
7341 ~MirSurfaceItem();
7442
75− //getters
76− Session* session() const { return m_session; }
77− Type type() const { return m_type; }
78− State state() const { return m_state; }
79− QString name() const { return m_name; }
80− bool live() const { return m_live; }
81− OrientationAngle orientationAngle() const { return m_orientationAngle; }
43+ Mir::Type type() const override;
44+ QString name() const override;
45+ bool live() const override;
46+
47+ Mir::State surfaceState() const override;
48+ void setSurfaceState(Mir::State) override {}
49+
50+ Mir::OrientationAngle orientationAngle() const override;
51+ void setOrientationAngle(Mir::OrientationAngle angle) override;
52+
53+ unity::shell::application::MirSurfaceInterface* surface() const override { return m_qmlSurface; }
54+ void setSurface(unity::shell::application::MirSurfaceInterface*) override;
55+
56+ bool consumesInput() const override { return m_consumesInput; }
57+ void setConsumesInput(bool value) override;
58+
59+ int surfaceWidth() const override;
60+ void setSurfaceWidth(int value) override;
8261
83− void setOrientationAngle(OrientationAngle angle);
62+ int surfaceHeight() const override;
63+ void setSurfaceHeight(int value) override;
64+
65+ /////
66+ // For use in qml tests
8467
85− void setSession(Session* item);
86− void setScreenshot(const QUrl& screenshot);
8768 void setLive(bool live);
8869
8970 int touchPressCount() const { return m_touchPressCount; }
@@ -92,47 +73,32 @@ public:
9273 int touchReleaseCount() const { return m_touchReleaseCount; }
9374 void setTouchReleaseCount(int count) { m_touchReleaseCount = count; Q_EMIT touchReleaseCountChanged(count); }
9475
95− Q_INVOKABLE void setState(State newState);
96− Q_INVOKABLE void release();
97−
9876Q_SIGNALS:
99− void typeChanged(Type);
100− void stateChanged(State);
101− void liveChanged(bool live);
102− void orientationAngleChanged(OrientationAngle angle);
10377 void touchPressCountChanged(int count);
10478 void touchReleaseCountChanged(int count);
10579
106− // internal mock use
107− void deregister();
108−
10980protected:
110− explicit MirSurfaceItem(const QString& name,
111− Type type,
112− State state,
113− const QUrl& screenshot,
114− const QString &qmlFilePath = QString(),
115− QQuickItem *parent = 0);
116−
11781 void touchEvent(QTouchEvent * event) override;
82+ void itemChange(ItemChange change, const ItemChangeData & value) override;
11883
11984private Q_SLOTS:
12085 void onComponentStatusChanged(QQmlComponent::Status status);
86+ void updateScreenshot(QUrl screenshot);
12187
12288private:
12389 void createQmlContentItem();
12490 void printComponentErrors();
91+ void updateSurfaceSize();
12592
126− Session* m_session;
127− const QString m_name;
128− const Type m_type;
129− State m_state;
130− bool m_live;
131− OrientationAngle m_orientationAngle;
93+ MirSurface* m_qmlSurface;
13294
13395 QQmlComponent *m_qmlContentComponent;
13496 QQuickItem *m_qmlItem;
135− QUrl m_screenshotUrl;
97+
98+ bool m_consumesInput;
99+
100+ int m_surfaceWidth;
101+ int m_surfaceHeight;
136102
137103 int m_touchPressCount;
138104 int m_touchReleaseCount;
@@ -142,6 +108,5 @@ private:
142108
143109Q_DECLARE_METATYPE(MirSurfaceItem*)
144110Q_DECLARE_METATYPE(QList<MirSurfaceItem*>)
145−Q_DECLARE_METATYPE(MirSurfaceItem::OrientationAngle)
146111
147112#endif // MIRSURFACEITEM_H
tests/mocks/Unity/Application/MirSurfaceItem.qml+2
@@ -47,6 +47,7 @@ Rectangle {
4747 y: surfaceText.y
4848 width: surfaceText.width
4949 height: surfaceText.height
50+ clip: true
5051
5152 transform: Translate { x: -2; y: -2 }
5253 }
@@ -58,6 +59,7 @@ Rectangle {
5859 fontSizeMode: Text.Fit
5960 minimumPixelSize: 10; font.pixelSize: 200
6061 verticalAlignment: Text.AlignVCenter
62+ clip: true
6163
6264 rotation: root.orientationAngle
6365 x: (parent.width - width) / 2
tests/mocks/Unity/Application/MirSurfaceItemModel.hdeleted−35
@@ -1,35 +0,0 @@
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/Session.cpp+22−22
@@ -54,23 +54,21 @@ Session::~Session()
5454 if (m_application) {
5555 m_application->setSession(nullptr);
5656 }
57− delete m_surface;
5857 delete m_children;
58+
59+ if (m_surface) {
60+ if (m_surface->viewCount() == 0) {
61+ delete m_surface;
62+ } else {
63+ m_surface->setLive(false);
64+ }
65+ }
5966}
6067
6168void Session::release()
6269{
6370 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− }
71+ deleteLater();
7472}
7573
7674void Session::setApplication(ApplicationInfo* application)
@@ -82,35 +80,37 @@ void Session::setApplication(ApplicationInfo* application)
8280 Q_EMIT applicationChanged(application);
8381}
8482
85−void Session::setSurface(MirSurfaceItem* surface)
83+void Session::setSurface(MirSurface* surface)
8684{
8785 qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
8886 if (m_surface == surface)
8987 return;
9088
9189 if (m_surface) {
92− m_surface->setSession(nullptr);
93− m_surface->setParent(nullptr);
94− Q_EMIT m_surface->deregister();
90+ disconnect(m_surface, nullptr, this, nullptr);
9591 }
9692
9793 m_surface = surface;
9894
9995 if (m_surface) {
100− m_surface->setSession(this);
101− m_surface->setParent(this);
102− SurfaceManager::singleton()->registerSurface(m_surface);
96+ connect(m_surface, &QObject::destroyed, this, &Session::onSurfaceDestroyed);
10397 }
10498
10599 Q_EMIT surfaceChanged(m_surface);
106100}
107101
102+void Session::onSurfaceDestroyed()
103+{
104+ m_surface = nullptr;
105+ Q_EMIT surfaceChanged(nullptr);
106+}
107+
108108void Session::setScreenshot(const QUrl& screenshot)
109109{
110110 if (screenshot != m_screenshot) {
111111 m_screenshot = screenshot;
112112 if (m_surface) {
113− m_surface->setScreenshot(m_screenshot);
113+ m_surface->setScreenshotUrl(m_screenshot);
114114 }
115115 }
116116}
@@ -137,9 +137,9 @@ void Session::createSurface()
137137 if (m_surface) return;
138138
139139 setSurface(SurfaceManager::singleton()->createSurface(name(),
140− MirSurfaceItem::Normal,
141− m_application && m_application->fullscreen() ? MirSurfaceItem::Fullscreen :
142− MirSurfaceItem::Maximized,
140+ Mir::NormalType,
141+ m_application && m_application->fullscreen() ? Mir::FullscreenState :
142+ Mir::MaximizedState,
143143 m_screenshot));
144144}
145145
tests/mocks/Unity/Application/Session.h+10−6
@@ -22,13 +22,13 @@
2222#include <QQuickItem>
2323
2424class ApplicationInfo;
25−class MirSurfaceItem;
25+class MirSurface;
2626
2727class Session : public QObject
2828{
2929 Q_OBJECT
3030 Q_PROPERTY(QString name READ name CONSTANT)
31− Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
31+ Q_PROPERTY(MirSurface* surface READ surface NOTIFY surfaceChanged)
3232 Q_PROPERTY(ApplicationInfo* application READ application NOTIFY applicationChanged)
3333 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
3434 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
@@ -46,11 +46,11 @@ public:
4646 QString name() const { return m_name; }
4747 bool live() const { return m_live; }
4848 ApplicationInfo* application() const { return m_application; }
49− MirSurfaceItem* surface() const { return m_surface; }
49+ MirSurface* surface() const { return m_surface; }
5050 Session* parentSession() const { return m_parentSession; }
5151
5252 void setApplication(ApplicationInfo* item);
53− void setSurface(MirSurfaceItem* surface);
53+ void setSurface(MirSurface* surface);
5454 void setScreenshot(const QUrl& m_screenshot);
5555 void setLive(bool live);
5656
@@ -60,7 +60,7 @@ public:
6060
6161Q_SIGNALS:
6262 void applicationChanged(ApplicationInfo*);
63− void surfaceChanged(MirSurfaceItem*);
63+ void surfaceChanged(MirSurface*);
6464 void parentSessionChanged(Session*);
6565 void liveChanged(bool live);
6666
@@ -70,6 +70,10 @@ Q_SIGNALS:
7070public Q_SLOTS:
7171 Q_INVOKABLE void createSurface();
7272
73+
74+private Q_SLOTS:
75+ void onSurfaceDestroyed();
76+
7377private:
7478 SessionModel* childSessions() const;
7579 void setParentSession(Session* session);
@@ -78,7 +82,7 @@ private:
7882 bool m_live;
7983 QUrl m_screenshot;
8084 ApplicationInfo* m_application;
81− MirSurfaceItem* m_surface;
85+ MirSurface* m_surface;
8286 Session* m_parentSession;
8387 SessionModel* m_children;
8488
tests/mocks/Unity/Application/SurfaceManager.cpp+14−17
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -36,31 +36,28 @@ SurfaceManager::SurfaceManager(QObject *parent) :
3636{
3737}
3838
39−MirSurfaceItem *SurfaceManager::createSurface(const QString& name,
40− MirSurfaceItem::Type type,
41− MirSurfaceItem::State state,
39+MirSurface *SurfaceManager::createSurface(const QString& name,
40+ Mir::Type type,
41+ Mir::State state,
4242 const QUrl& screenshot)
4343{
44− MirSurfaceItem* surface = new MirSurfaceItem(name, type, state, screenshot);
45− Q_EMIT surfaceCreated(surface);
46− return surface;
47−}
48−
49−void SurfaceManager::registerSurface(MirSurfaceItem *surface)
50−{
51− connect(surface, &MirSurfaceItem::deregister, this, [this] {
52− MirSurfaceItem* surface = qobject_cast<MirSurfaceItem*>(sender());
53− disconnect(surface, 0, this, 0);
54−
55− surface->setLive(false);
44+ MirSurface* surface = new MirSurface(name, type, state, screenshot);
45+ connect(surface, &QObject::destroyed, this, [this](QObject *obj) {
46+ MirSurface* surface = qobject_cast<MirSurface*>(obj);
5647 Q_EMIT surfaceDestroyed(surface);
5748 });
49+ Q_EMIT surfaceCreated(surface);
50+ return surface;
5851}
5952
60−MirSurfaceItem *SurfaceManager::inputMethodSurface()
53+MirSurface *SurfaceManager::inputMethodSurface()
6154{
6255 if (!m_virtualKeyboard) {
6356 m_virtualKeyboard = new VirtualKeyboard;
57+ connect(m_virtualKeyboard, &QObject::destroyed, this, [this](QObject *obj) {
58+ MirSurface* surface = qobject_cast<MirSurface*>(obj);
59+ Q_EMIT surfaceDestroyed(surface);
60+ });
6461 Q_EMIT surfaceCreated(m_virtualKeyboard);
6562 }
6663 return m_virtualKeyboard;
tests/mocks/Unity/Application/SurfaceManager.h+8−11
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014-2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -19,7 +19,7 @@
1919
2020#include <QObject>
2121
22−#include "MirSurfaceItem.h"
22+#include "MirSurface.h"
2323#include "VirtualKeyboard.h"
2424
2525class SurfaceManager : public QObject
@@ -30,21 +30,18 @@ public:
3030
3131 static SurfaceManager *singleton();
3232
33− Q_INVOKABLE MirSurfaceItem *createSurface(const QString& name,
34− MirSurfaceItem::Type type,
35− MirSurfaceItem::State state,
33+ Q_INVOKABLE MirSurface* createSurface(const QString& name,
34+ Mir::Type type,
35+ Mir::State state,
3636 const QUrl& screenshot);
3737
38− // Internal mock use
39− void registerSurface(MirSurfaceItem *surface);
40−
4138 // To be used in the tests
42− Q_INVOKABLE MirSurfaceItem *inputMethodSurface();
39+ Q_INVOKABLE MirSurface* inputMethodSurface();
4340
4441Q_SIGNALS:
4542 void countChanged();
46− void surfaceCreated(MirSurfaceItem *surface);
47− void surfaceDestroyed(MirSurfaceItem *surface);
43+ void surfaceCreated(MirSurface *surface);
44+ void surfaceDestroyed(MirSurface*surface);
4845
4946private:
5047 static SurfaceManager *the_surface_manager;
tests/mocks/Unity/Application/VirtualKeyboard.cpp+5−11
@@ -22,23 +22,17 @@
2222
2323#include <QDebug>
2424
25−VirtualKeyboard::VirtualKeyboard(QQuickItem *parent)
26− : MirSurfaceItem("input-method",
27− MirSurfaceItem::InputMethod,
28− MirSurfaceItem::Minimized,
25+VirtualKeyboard::VirtualKeyboard()
26+ : MirSurface("input-method",
27+ Mir::InputMethodType,
28+ Mir::MinimizedState,
2929 QString("file://%1/Dash/graphics/phone/screenshots/vkb_portrait.png")
3030 .arg(qmlDirectory()),
3131 QString("%1/Unity/Application/VirtualKeyboard.qml")
32− .arg(mockPluginsDir()),
33− parent)
32+ .arg(mockPluginsDir()))
3433{
3534}
3635
3736VirtualKeyboard::~VirtualKeyboard()
3837{
3938}
40−
41−void VirtualKeyboard::touchEvent(QTouchEvent *event)
42−{
43− event->setAccepted(false);
44−}
tests/mocks/Unity/Application/VirtualKeyboard.h+3−11
@@ -17,26 +17,18 @@
1717#ifndef VIRTUALKEYBOARD_H
1818#define VIRTUALKEYBOARD_H
1919
20−#include "MirSurfaceItem.h"
21−#include "MirSurfaceItemModel.h"
20+#include "MirSurface.h"
2221
2322#include <QQuickItem>
24−#include <QUrl>
2523
26−class Session;
27−
28−class VirtualKeyboard : public MirSurfaceItem
24+class VirtualKeyboard : public MirSurface
2925{
3026 Q_OBJECT
3127public:
32− explicit VirtualKeyboard(QQuickItem *parent = 0);
28+ explicit VirtualKeyboard();
3329 ~VirtualKeyboard();
34−
35−protected:
36− void touchEvent(QTouchEvent * event) override;
3730};
3831
3932Q_DECLARE_METATYPE(VirtualKeyboard*)
40−Q_DECLARE_METATYPE(QList<VirtualKeyboard*>)
4133
4234#endif // VIRTUALKEYBOARD_H
tests/mocks/Unity/Application/plugin.cpp+11−8
@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2013-2014 Canonical, Ltd.
2+ * Copyright (C) 2013-2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -20,12 +20,14 @@
2020#include "ApplicationScreenshotProvider.h"
2121#include "Session.h"
2222#include "MirSurfaceItem.h"
23−#include "MirSurfaceItemModel.h"
2423#include "SurfaceManager.h"
2524#include "SessionManager.h"
2625#include "ApplicationTestInterface.h"
2726#include "UbuntuKeyboardInfo.h"
2827
28+// unity-api
29+#include <unity/shell/application/Mir.h>
30+
2931#include <qqml.h>
3032#include <QQmlEngine>
3133
@@ -67,14 +69,16 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
6769{
6870 qRegisterMetaType<Session*>("Session*");
6971 qRegisterMetaType<ApplicationInfo*>("ApplicationInfo*");
70− qRegisterMetaType<MirSurfaceItemModel*>("SessionModel*");
71− qRegisterMetaType<MirSurfaceItem*>("MirSurfaceItem*");
72− qRegisterMetaType<MirSurfaceItemModel*>("MirSurfaceItemModel*");
72+ qRegisterMetaType<SessionModel*>("SessionModel*");
73+ qRegisterMetaType<unity::shell::application::MirSurfaceInterface*>("unity::shell::application::MirSurfaceInterface*");
74+ qRegisterMetaType<Mir::Type>("Mir::Type");
75+ qRegisterMetaType<Mir::State>("Mir::State");
7376
7477 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
7578 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
7679 qmlRegisterUncreatableType<Session>(uri, 0, 1, "Session", "Session can't be instantiated from QML");
77− qmlRegisterUncreatableType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem", "MirSurfaceItem can't be instantiated from QML");
80+ qmlRegisterUncreatableType<MirSurface>(uri, 0, 1, "MirSurface", "MirSurface can't be instantiated from QML");
81+ qmlRegisterType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem");
7882
7983 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
8084
@@ -84,8 +88,7 @@ void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
8488 qmlRegisterSingletonType<ApplicationTestInterface>(uri, 0, 1, "ApplicationTest", applicationTestInterface);
8589 qmlRegisterSingletonType<UbuntuKeyboardInfo>(uri, 0, 1, "UbuntuKeyboardInfo", ubuntuKeyboardInfoSingleton);
8690
87− qRegisterMetaType<MirSurfaceItem::Type>("MirSurfaceItem::Type");
88− qRegisterMetaType<MirSurfaceItem::State>("MirSurfaceItem::State");
91+ qmlRegisterUncreatableType<Mir>(uri, 0, 1, "Mir", "Mir provides enum values, it can't be instantiated");
8992}
9093
9194void FakeUnityApplicationQmlPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
tests/qmltests/Stages/tst_ApplicationWindow.qml+39−29
@@ -45,16 +45,6 @@ Rectangle {
4545 }
4646 }
4747
48− Component {
49− id: applicationWindowComponent
50− ApplicationWindow {
51− anchors.fill: parent
52− application: fakeApplication
53− surfaceOrientationAngle: 0
54− interactive: true
55− focus: true
56− }
57− }
5848 Loader {
5949 id: applicationWindowLoader
6050 focus: true
@@ -64,7 +54,19 @@ Rectangle {
6454 left: parent.left
6555 }
6656 width: units.gu(40)
67− sourceComponent: applicationWindowComponent
57+ property bool itemDestroyed: false
58+ sourceComponent: Component {
59+ ApplicationWindow {
60+ anchors.fill: parent
61+ application: fakeApplication
62+ surfaceOrientationAngle: 0
63+ interactive: true
64+ focus: true
65+ Component.onDestruction: {
66+ applicationWindowLoader.itemDestroyed = true;
67+ }
68+ }
69+ }
6870 }
6971
7072 Rectangle {
@@ -87,13 +89,10 @@ Rectangle {
8789 id: sessionCheckbox; checked: false
8890 activeFocusOnPress: false
8991 onCheckedChanged: {
90− if (applicationWindowLoader.status !== Loader.Ready)
91− return;
92−
9392 if (checked && !fakeApplication.session) {
9493 fakeApplication.createSession();
9594 } else if (!checked && fakeApplication.session) {
96− fakeApplication.session.release();
95+ fakeApplication.destroySession();
9796 }
9897 }
9998 }
@@ -218,21 +217,29 @@ Rectangle {
218217 sessionCheckbox.checked = true;
219218 sessionControl.surfaceCheckbox.checked = true;
220219 }
221− function cleanupSession() {
222− sessionCheckbox.checked = false;
223− }
224220
225221 function cleanup() {
226222 forgetApplicationWindowChildren();
227223
224+ applicationWindowLoader.itemDestroyed = false;
225+
228226 // reload our test subject to get it in a fresh state once again
229227 applicationWindowLoader.active = false;
230228
231− appStateSelector.selectedIndex = 0;
232− cleanupSession();
229+ tryCompare(applicationWindowLoader, "status", Loader.Null);
230+ tryCompare(applicationWindowLoader, "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 ApplicationWindow 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+ // ApplicationWindow instance gets destroyed.
237+ // Another thing that happens is that we do get a new object but the old one doesn't get
238+ // deleted, so you end up with two instances in memory.
239+ tryCompare(applicationWindowLoader, "itemDestroyed", true);
233240
234− if (fakeApplication.session)
235− fakeApplication.session.release();
241+ appStateSelector.selectedIndex = 0;
242+ sessionCheckbox.checked = false;
236243
237244 applicationWindowLoader.active = true;
238245 }
@@ -372,15 +379,18 @@ Rectangle {
372379
373380 waitUntilTransitionsEnd(stateGroup);
374381
375− var fakeSurface = fakeSession.surface;
376− fakeSurface.touchPressCount = 0;
377− fakeSurface.touchReleaseCount = 0;
382+ var surfaceItem = findChild(applicationWindowLoader.item, "surfaceItem");
383+ verify(surfaceItem);
384+ verify(surfaceItem.surface === fakeSession.surface);
385+
386+ surfaceItem.touchPressCount = 0;
387+ surfaceItem.touchReleaseCount = 0;
378388
379389 tap(applicationWindowLoader.item,
380390 applicationWindowLoader.item.width / 2, applicationWindowLoader.item.height / 2);
381391
382− verify(fakeSurface.touchPressCount === 1);
383− verify(fakeSurface.touchReleaseCount === 1);
392+ verify(surfaceItem.touchPressCount === 1);
393+ verify(surfaceItem.touchReleaseCount === 1);
384394 }
385395
386396 function test_showNothingOnSuddenSurfaceLoss() {
@@ -389,9 +399,9 @@ Rectangle {
389399 tryCompare(stateGroup, "state", "surface");
390400 waitUntilTransitionsEnd(stateGroup);
391401
392− cleanupSession();
402+ sessionControl.surfaceCheckbox.checked = false;
393403
394− verify(stateGroup.state === "void");
404+ tryCompare(stateGroup, "state", "void");
395405 }
396406
397407 function test_surfaceActiveFocusFollowsAppWindowInterative() {
tests/qmltests/Stages/tst_SurfaceContainer.qml+26−32
@@ -70,12 +70,12 @@ Rectangle {
7070
7171 if (checked) {
7272 var fakeSurface = SurfaceManager.createSurface("fake-surface",
73− MirSurfaceItem.Normal,
74− MirSurfaceItem.Restored,
73+ Mir.NormalType,
74+ Mir.RestoredState,
7575 Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
7676 surfaceContainerLoader.item.surface = fakeSurface;
7777 } else {
78− ApplicationTest.removeSurface(surfaceContainerLoader.item.surface);
78+ surfaceContainerLoader.item.surface.setLive(false);
7979 }
8080 }
8181 }
@@ -121,70 +121,64 @@ Rectangle {
121121 interactiveCheckbox.checked = true;
122122 }
123123
124− /*
125− Add a first surface. Then remove it. Then add a second surface.
126− That second surface should be properly sized.
127−
128− Regression test for https://bugs.launchpad.net/ubuntu/+source/qtmir/+bug/1359819
129− */
130− function test_resetSurfaceGetsProperlySized() {
131− surfaceCheckbox.checked = true;
132− surfaceCheckbox.checked = false;
133− surfaceCheckbox.checked = true;
134− var fakeSurface = surfaceContainerLoader.item.surface;
135− compare(fakeSurface.width, surfaceContainerLoader.item.width);
136− compare(fakeSurface.height, surfaceContainerLoader.item.height);
137− }
138−
139124 function test_animateRemoval() {
140125 surfaceCheckbox.checked = true;
141126
142127 verify(surfaceContainer.surface !== null);
143128
144− ApplicationTest.removeSurface(surfaceContainer.surface);
129+ surfaceContainer.surface.setLive(false);
145130
146131 compare(surfaceContainer.state, "zombie");
147132 tryCompare(surfaceContainer, "surface", null);
148133 }
149134
150− function test_surfaceGetsNoTouchesWhenContainerNotInteractive() {
135+ function test_surfaceItemGetsNoTouchesWhenContainerNotInteractive() {
151136 surfaceCheckbox.checked = true;
152137 verify(surfaceContainer.surface !== null);
153138
154− surfaceContainer.surface.touchPressCount = 0;
155− surfaceContainer.surface.touchReleaseCount = 0;
139+ var surfaceItem = findChild(surfaceContainer, "surfaceItem");
140+ verify(surfaceItem !== null);
141+
142+ surfaceItem.touchPressCount = 0;
143+ surfaceItem.touchReleaseCount = 0;
156144
157145 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
158146
159147 // surface got touches as the surfaceContainer is interactive
160− compare(surfaceContainer.surface.touchPressCount, 1)
161− compare(surfaceContainer.surface.touchReleaseCount, 1);
148+ compare(surfaceItem.touchPressCount, 1)
149+ compare(surfaceItem.touchReleaseCount, 1);
162150
163151 interactiveCheckbox.checked = false;
164152 tap(surfaceContainer, surfaceContainer.width / 2, surfaceContainer.height / 2);
165153
166154 // surface shouldn't get the touches from the second tap as the surfaceContainer
167155 // was *not* interactive when it happened.
168− compare(surfaceContainer.surface.touchPressCount, 1)
169− compare(surfaceContainer.surface.touchReleaseCount, 1);
156+ compare(surfaceItem.touchPressCount, 1)
157+ compare(surfaceItem.touchReleaseCount, 1);
170158 }
171159
172− function test_surfaceGetsActiveFocusOnMousePress() {
160+ function test_surfaceItemGetsActiveFocusOnMousePress() {
173161 surfaceCheckbox.checked = true;
174162 verify(surfaceContainer.surface !== null);
175163
176− compare(surfaceContainer.surface.activeFocus, false);
164+ var surfaceItem = findChild(surfaceContainer, "surfaceItem");
165+ verify(surfaceItem !== null);
166+
167+ compare(surfaceItem.activeFocus, false);
177168 mouseClick(surfaceContainer);
178− compare(surfaceContainer.surface.activeFocus, true);
169+ compare(surfaceItem.activeFocus, true);
179170 }
180171
181− function test_surfaceGetsActiveFocusOnTap() {
172+ function test_surfaceItemGetsActiveFocusOnTap() {
182173 surfaceCheckbox.checked = true;
183174 verify(surfaceContainer.surface !== null);
184175
185− compare(surfaceContainer.surface.activeFocus, false);
176+ var surfaceItem = findChild(surfaceContainer, "surfaceItem");
177+ verify(surfaceItem !== null);
178+
179+ compare(surfaceItem.activeFocus, false);
186180 tap(surfaceContainer);
187− compare(surfaceContainer.surface.activeFocus, true);
181+ compare(surfaceItem.activeFocus, true);
188182 }
189183 }
190184}
tests/qmltests/tst_OrientedShell.qml+28−20
@@ -280,9 +280,9 @@ Rectangle {
280280 onCheckedChanged: {
281281 var surface = SurfaceManager.inputMethodSurface();
282282 if (checked) {
283− surface.setState(MirSurfaceItem.Restored);
283+ surface.setState(Mir.RestoredState);
284284 } else {
285− surface.setState(MirSurfaceItem.Minimized);
285+ surface.setState(Mir.MinimizedState);
286286 }
287287 }
288288 }
@@ -415,22 +415,22 @@ Rectangle {
415415 compare(dashApp.stage, ApplicationInfoInterface.MainStage);
416416
417417 tryCompareFunction(function(){return dashApp.session.surface != null;}, true);
418− verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
418+ verify(checkAppSurfaceOrientation(dashAppWindow, dashApp, root.primaryOrientationAngle));
419419
420420 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
421421 rotateTo(90);
422422
423− verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
423+ verify(checkAppSurfaceOrientation(dashAppWindow, dashApp, root.primaryOrientationAngle));
424424 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
425425
426426 rotateTo(180);
427427
428− verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
428+ verify(checkAppSurfaceOrientation(dashAppWindow, dashApp, root.primaryOrientationAngle));
429429 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
430430
431431 rotateTo(270);
432432
433− verify(checkAppSurfaceOrientation(dashApp, root.primaryOrientationAngle));
433+ verify(checkAppSurfaceOrientation(dashAppWindow, dashApp, root.primaryOrientationAngle));
434434 compare(shell.transformRotationAngle, root.primaryOrientationAngle);
435435 }
436436
@@ -1200,18 +1200,13 @@ Rectangle {
12001200 }
12011201
12021202 // expectedAngle is in orientedShell's coordinate system
1203− function checkAppSurfaceOrientation(app, expectedAngle) {
1203+ function checkAppSurfaceOrientation(item, app, expectedAngle) {
12041204 var surface = app.session.surface;
12051205 if (!surface) {
12061206 console.warn("no surface");
12071207 return false;
12081208 }
12091209
1210− if (!itemIsChildOfOrientedShell(surface)) {
1211− console.warn("surface not a child of OrientedShell");
1212− return false;
1213− }
1214−
12151210 var topMargin = 0.;
12161211 if (!app.fullscreen) {
12171212 var appsDisplayLoader = findChild(shell, "applicationsDisplayLoader");
@@ -1221,7 +1216,12 @@ Rectangle {
12211216 topMargin = appsDisplayLoader.item.maximizedAppTopMargin;
12221217 }
12231218
1224− var point = surface.mapToItem(orientedShell, 0, 0);
1219+ var surfaceItem = findSurfaceItem(item, surface);
1220+ if (!surfaceItem) {
1221+ console.warn("no surfaceItem rendering app surface");
1222+ return false;
1223+ }
1224+ var point = surfaceItem.mapToItem(orientedShell, 0, 0);
12251225
12261226 switch (expectedAngle) {
12271227 case 0:
@@ -1235,14 +1235,22 @@ Rectangle {
12351235 }
12361236 }
12371237
1238− function itemIsChildOfOrientedShell(item) {
1239− var parent = item.parent;
1240− var found = false;
1241− while (parent && !found) {
1242− found = parent === orientedShell;
1243− parent = parent.parent;
1238+ function findSurfaceItem(obj, surface) {
1239+ var childs = new Array(0);
1240+ childs.push(obj)
1241+ while (childs.length > 0) {
1242+ console.log("Checking " + childs[0].objectName);
1243+ if (childs[0].objectName === "surfaceItem"
1244+ && childs[0].surface !== undefined
1245+ && childs[0].surface === surface) {
1246+ return childs[0];
1247+ }
1248+ for (var i in childs[0].children) {
1249+ childs.push(childs[0].children[i])
1250+ }
1251+ childs.splice(0, 1);
12441252 }
1245− return found;
1253+ return null;
12461254 }
12471255 }
12481256}
tests/qmltests/tst_Shell.qml+16−16
@@ -726,19 +726,19 @@ Rectangle {
726726 var item = findChild(shell, "inputMethod");
727727 var surface = SurfaceManager.inputMethodSurface();
728728
729− surface.setState(MirSurfaceItem.Minimized);
729+ surface.setState(Mir.MinimizedState);
730730 tryCompare(item, "visible", false);
731731
732− surface.setState(MirSurfaceItem.Restored);
732+ surface.setState(Mir.RestoredState);
733733 tryCompare(item, "visible", true);
734734
735− surface.setState(MirSurfaceItem.Minimized);
735+ surface.setState(Mir.MinimizedState);
736736 tryCompare(item, "visible", false);
737737
738− surface.setState(MirSurfaceItem.Maximized);
738+ surface.setState(Mir.MaximizedState);
739739 tryCompare(item, "visible", true);
740740
741− surface.setState(MirSurfaceItem.Minimized);
741+ surface.setState(Mir.MinimizedState);
742742 tryCompare(item, "visible", false);
743743 }
744744
@@ -1112,20 +1112,20 @@ Rectangle {
11121112
11131113 waitUntilFocusedApplicationIsShowingItsSurface();
11141114
1115− var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
1116− verify(topmostSurface);
1115+ var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
1116+ verify(topmostSurfaceItem);
11171117
11181118 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
1119− topmostSurface.touchPressCount = 0;
1120− topmostSurface.touchReleaseCount = 0;
1119+ topmostSurfaceItem.touchPressCount = 0;
1120+ topmostSurfaceItem.touchReleaseCount = 0;
11211121
11221122 var tapPoint = rightEdgeDragArea.mapToItem(shell, rightEdgeDragArea.width / 2,
11231123 rightEdgeDragArea.height / 2);
11241124
11251125 tap(shell, tapPoint.x, tapPoint.y);
11261126
1127− tryCompare(topmostSurface, "touchPressCount", 1);
1128− tryCompare(topmostSurface, "touchReleaseCount", 1);
1127+ tryCompare(topmostSurfaceItem, "touchPressCount", 1);
1128+ tryCompare(topmostSurfaceItem, "touchReleaseCount", 1);
11291129 }
11301130
11311131 /*
@@ -1137,11 +1137,11 @@ Rectangle {
11371137 loadShell("phone");
11381138 swipeAwayGreeter();
11391139 var topmostSpreadDelegate = findChild(shell, "appDelegate0");
1140− var topmostSurface = findChild(topmostSpreadDelegate, "surfaceContainer").surface;
1140+ var topmostSurfaceItem = findChild(topmostSpreadDelegate, "surfaceItem");
11411141 var rightEdgeDragArea = findChild(shell, "spreadDragArea");
11421142
1143− topmostSurface.touchPressCount = 0;
1144− topmostSurface.touchReleaseCount = 0;
1143+ topmostSurfaceItem.touchPressCount = 0;
1144+ topmostSurfaceItem.touchReleaseCount = 0;
11451145
11461146 var gestureStartPoint = rightEdgeDragArea.mapToItem(shell, rightEdgeDragArea.width / 2,
11471147 rightEdgeDragArea.height / 2);
@@ -1150,8 +1150,8 @@ Rectangle {
11501150 gestureStartPoint.x /* fromX */, gestureStartPoint.y /* fromY */,
11511151 units.gu(1) /* toX */, gestureStartPoint.y /* toY */);
11521152
1153− tryCompare(topmostSurface, "touchPressCount", 0);
1154− tryCompare(topmostSurface, "touchReleaseCount", 0);
1153+ tryCompare(topmostSurfaceItem, "touchPressCount", 0);
1154+ tryCompare(topmostSurfaceItem, "touchReleaseCount", 0);
11551155 }
11561156
11571157 function waitUntilFocusedApplicationIsShowingItsSurface()