on xenial help sign in
merge manualsurface/session creation into applicationinfo
84b65c5Nick Dedekind
tests/mocks/Unity/Application/ApplicationInfo.cpp+11−8
@@ -34,7 +34,7 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
34 , m_focused(false)
34 , m_focused(false)
35 , m_fullscreen(false)
35 , m_fullscreen(false)
36 , m_session(0)
36 , m_session(0)
37− , m_manualSessionCreation(false)
37+ , m_manualSurfaceCreation(false)
38{
38{
39}
39}
40
40
@@ -45,7 +45,7 @@ ApplicationInfo::ApplicationInfo(QObject *parent)
45 , m_focused(false)
45 , m_focused(false)
46 , m_fullscreen(false)
46 , m_fullscreen(false)
47 , m_session(0)
47 , m_session(0)
48− , m_manualSessionCreation(false)
48+ , m_manualSurfaceCreation(false)
49{
49{
50}
50}
51
51
@@ -79,6 +79,10 @@ void ApplicationInfo::setSession(Session* session)
79 if (m_session) {
79 if (m_session) {
80 m_session->setApplication(this);
80 m_session->setApplication(this);
81 m_session->setParent(this);
81 m_session->setParent(this);
82+
83+ if (!m_manualSurfaceCreation) {
84+ QTimer::singleShot(500, m_session, SLOT(createSurface()));
85+ }
82 }
86 }
83
87
84 Q_EMIT sessionChanged(m_session);
88 Q_EMIT sessionChanged(m_session);
@@ -137,8 +141,7 @@ void ApplicationInfo::setState(State value)
137 m_state = value;
141 m_state = value;
138 Q_EMIT stateChanged(value);
142 Q_EMIT stateChanged(value);
139
143
140− if (!m_manualSessionCreation && m_state == ApplicationInfo::Running) {
144+ if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
141−
142 QTimer::singleShot(500, this, SLOT(createSession()));
145 QTimer::singleShot(500, this, SLOT(createSession()));
143 }
146 }
144 }
147 }
@@ -160,10 +163,10 @@ void ApplicationInfo::setFullscreen(bool value)
160 }
163 }
161}
164}
162
165
163−void ApplicationInfo::setManualSessionCreation(bool value)
166+void ApplicationInfo::setManualSurfaceCreation(bool value)
164{
167{
165− if (value != m_manualSessionCreation) {
168+ if (value != m_manualSurfaceCreation) {
166− m_manualSessionCreation = value;
169+ m_manualSurfaceCreation = value;
167− Q_EMIT manualSessionCreationChanged(value);
170+ Q_EMIT manualSurfaceCreationChanged(value);
168 }
171 }
169}
172}
tests/mocks/Unity/Application/ApplicationInfo.h+5−5
@@ -39,7 +39,7 @@ class ApplicationInfo : public ApplicationInfoInterface {
39 // Only exists in this fake implementation
39 // Only exists in this fake implementation
40
40
41 // whether the test code will explicitly control the creation of the application surface
41 // whether the test code will explicitly control the creation of the application surface
42− Q_PROPERTY(bool manualSessionCreation READ manualSessionCreation WRITE setManualSessionCreation NOTIFY manualSessionCreationChanged)
42+ Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
43
43
44public:
44public:
45 ApplicationInfo(QObject *parent = nullptr);
45 ApplicationInfo(QObject *parent = nullptr);
@@ -73,8 +73,8 @@ public:
73 void setFullscreen(bool value);
73 void setFullscreen(bool value);
74 bool fullscreen() const { return m_fullscreen; }
74 bool fullscreen() const { return m_fullscreen; }
75
75
76− bool manualSessionCreation() const { return m_manualSessionCreation; }
76+ bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
77− void setManualSessionCreation(bool value);
77+ void setManualSurfaceCreation(bool value);
78
78
79public:
79public:
80 void setSession(Session* session);
80 void setSession(Session* session);
@@ -83,7 +83,7 @@ public:
83Q_SIGNALS:
83Q_SIGNALS:
84 void sessionChanged(Session*);
84 void sessionChanged(Session*);
85 void fullscreenChanged(bool value);
85 void fullscreenChanged(bool value);
86− void manualSessionCreationChanged(bool value);
86+ void manualSurfaceCreationChanged(bool value);
87
87
88public Q_SLOTS:
88public Q_SLOTS:
89 Q_INVOKABLE void createSession();
89 Q_INVOKABLE void createSession();
@@ -102,7 +102,7 @@ private:
102 bool m_fullscreen;
102 bool m_fullscreen;
103 Session* m_session;
103 Session* m_session;
104
104
105− bool m_manualSessionCreation;
105+ bool m_manualSurfaceCreation;
106};
106};
107
107
108Q_DECLARE_METATYPE(ApplicationInfo*)
108Q_DECLARE_METATYPE(ApplicationInfo*)
tests/mocks/Unity/Application/Session.cpp−24
@@ -32,7 +32,6 @@ Session::Session(const QString &name,
32 , m_surface(nullptr)
32 , m_surface(nullptr)
33 , m_parentSession(nullptr)
33 , m_parentSession(nullptr)
34 , m_children(new SessionModel(this))
34 , m_children(new SessionModel(this))
35− , m_manualSurfaceCreation(false)
36{
35{
37 qDebug() << "Session::Session() " << this->name();
36 qDebug() << "Session::Session() " << this->name();
38
37
@@ -78,22 +77,7 @@ void Session::setApplication(ApplicationInfo* application)
78 if (m_application == application)
77 if (m_application == application)
79 return;
78 return;
80
79
81− if (m_application) {
82− disconnect(m_application, 0, this, 0);
83− }
84−
85 m_application = application;
80 m_application = application;
86−
87− if (m_application) {
88− connect(m_application, &ApplicationInfo::stateChanged, this, [this](ApplicationInfo::State state) {
89− if (!m_manualSurfaceCreation && state == ApplicationInfo::Running) {
90− QTimer::singleShot(500, this, SLOT(createSurface()));
91− }
92− });
93− if (!m_manualSurfaceCreation && m_application->state() == ApplicationInfo::Running) {
94− QTimer::singleShot(500, this, SLOT(createSurface()));
95− }
96− }
97}
81}
98
82
99void Session::setSurface(MirSurfaceItem* surface)
83void Session::setSurface(MirSurfaceItem* surface)
@@ -173,11 +157,3 @@ SessionModel* Session::childSessions() const
173{
157{
174 return m_children;
158 return m_children;
175}
159}
176−
177−void Session::setManualSurfaceCreation(bool value)
178−{
179− if (value != m_manualSurfaceCreation) {
180− m_manualSurfaceCreation = value;
181− Q_EMIT manualSurfaceCreationChanged(value);
182− }
183−}
tests/mocks/Unity/Application/Session.h−11
@@ -31,11 +31,6 @@ class Session : public QObject
31 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
31 Q_PROPERTY(Session* parentSession READ parentSession NOTIFY parentSessionChanged DESIGNABLE false)
32 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
32 Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
33
33
34− // Only exists in this fake implementation
35−
36− // whether the test code will explicitly control the creation of the application surface
37− Q_PROPERTY(bool manualSurfaceCreation READ manualSurfaceCreation WRITE setManualSurfaceCreation NOTIFY manualSurfaceCreationChanged)
38−
39public:
34public:
40 explicit Session(const QString &name,
35 explicit Session(const QString &name,
41 const QUrl& screenshot,
36 const QUrl& screenshot,
@@ -58,15 +53,11 @@ public:
58 void insertChildSession(uint index, Session* session);
53 void insertChildSession(uint index, Session* session);
59 void removeChildSession(Session* session);
54 void removeChildSession(Session* session);
60
55
61− bool manualSurfaceCreation() const { return m_manualSurfaceCreation; }
62− void setManualSurfaceCreation(bool value);
63−
64Q_SIGNALS:
56Q_SIGNALS:
65 void surfaceChanged(MirSurfaceItem*);
57 void surfaceChanged(MirSurfaceItem*);
66 void parentSessionChanged(Session*);
58 void parentSessionChanged(Session*);
67 void removed();
59 void removed();
68 void aboutToBeDestroyed();
60 void aboutToBeDestroyed();
69− void manualSurfaceCreationChanged(bool value);
70
61
71public Q_SLOTS:
62public Q_SLOTS:
72 Q_INVOKABLE void createSurface();
63 Q_INVOKABLE void createSurface();
@@ -81,8 +72,6 @@ private:
81 MirSurfaceItem* m_surface;
72 MirSurfaceItem* m_surface;
82 Session* m_parentSession;
73 Session* m_parentSession;
83 SessionModel* m_children;
74 SessionModel* m_children;
84−
85− bool m_manualSurfaceCreation;
86};
75};
87
76
88Q_DECLARE_METATYPE(Session*)
77Q_DECLARE_METATYPE(Session*)
tests/qmltests/Stages/tst_ApplicationWindow.qml+1−2
@@ -31,7 +31,7 @@ Rectangle {
31
31
32 Component.onCompleted: {
32 Component.onCompleted: {
33 root.fakeApplication = ApplicationManager.add("gallery-app");
33 root.fakeApplication = ApplicationManager.add("gallery-app");
34− root.fakeApplication.manualSessionCreation = true;
34+ root.fakeApplication.manualSurfaceCreation = true;
35 root.fakeApplication.setState(ApplicationInfoInterface.Starting);
35 root.fakeApplication.setState(ApplicationInfoInterface.Starting);
36 }
36 }
37 property QtObject fakeApplication: null
37 property QtObject fakeApplication: null
@@ -84,7 +84,6 @@ Rectangle {
84
84
85 if (checked && !fakeApplication.session) {
85 if (checked && !fakeApplication.session) {
86 fakeApplication.createSession();
86 fakeApplication.createSession();
87− fakeSession.manualSurfaceCreation = true;
88 fakeSession.createSurface();
87 fakeSession.createSurface();
89 } else if (!checked && fakeApplication.session) {
88 } else if (!checked && fakeApplication.session) {
90 fakeApplication.session.release();
89 fakeApplication.session.release();
tests/qmltests/Stages/tst_SessionContainer.qml−1
@@ -73,7 +73,6 @@ Rectangle {
73
73
74 if (checked) {
74 if (checked) {
75 var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
75 var fakeSession = SessionManager.createSession("music-player", Qt.resolvedUrl("../Dash/artwork/music-player-design.png"));
76− fakeSession.manualSurfaceCreation = true;
77 fakeSession.createSurface();
76 fakeSession.createSurface();
78 sessionContainerLoader.item.session = fakeSession;
77 sessionContainerLoader.item.session = fakeSession;
79 } else {
78 } else {