Merge lp:~nick-dedekind/unity8/mirCompositor-appMocks into lp:~unity-team/unity8/mirCompositor

Proposed by Nick Dedekind
Status: Merged
Merged at revision: 1067
Proposed branch: lp:~nick-dedekind/unity8/mirCompositor-appMocks
Merge into: lp:~unity-team/unity8/mirCompositor
Diff against target: 692 lines (+299/-48)
10 files modified
tests/mocks/Unity/Application/ApplicationInfo.cpp (+60/-22)
tests/mocks/Unity/Application/ApplicationInfo.h (+21/-8)
tests/mocks/Unity/Application/ApplicationManager.cpp (+31/-18)
tests/mocks/Unity/Application/ApplicationManager.h (+6/-0)
tests/mocks/Unity/Application/CMakeLists.txt (+2/-0)
tests/mocks/Unity/Application/MirSurfaceItem.cpp (+40/-0)
tests/mocks/Unity/Application/MirSurfaceItem.h (+84/-0)
tests/mocks/Unity/Application/SurfaceManager.cpp (+16/-0)
tests/mocks/Unity/Application/SurfaceManager.h (+26/-0)
tests/mocks/Unity/Application/plugin.cpp (+13/-0)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/mirCompositor-appMocks
Reviewer Review Type Date Requested Status
Daniel d'Andrada (community) Approve
Review via email: mp+227317@code.launchpad.net

Commit message

Fixed up AppManager mock for qtmir surfaces.

Description of the change

Fixed up AppManager mock for qtmir surfaces.

To post a comment you must log in.
1060. By Nick Dedekind

removed qdebug

1061. By Nick Dedekind

whitespace

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Would be nice to update the copyright year of the files you changed, like tests/mocks/Unity/Application/ApplicationInfo.h

Revision history for this message
Daniel d'Andrada (dandrader) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'tests/mocks/Unity/Application/ApplicationInfo.cpp'
--- tests/mocks/Unity/Application/ApplicationInfo.cpp 2014-03-20 10:02:52 +0000
+++ tests/mocks/Unity/Application/ApplicationInfo.cpp 2014-07-18 16:28:08 +0000
@@ -15,6 +15,8 @@
15 */15 */
1616
17#include "ApplicationInfo.h"17#include "ApplicationInfo.h"
18#include "MirSurfaceItem.h"
19#include "SurfaceManager.h"
1820
19#include <QGuiApplication>21#include <QGuiApplication>
20#include <QQuickItem>22#include <QQuickItem>
@@ -24,29 +26,39 @@
2426
25ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)27ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
26 : ApplicationInfoInterface(appId, parent)28 : ApplicationInfoInterface(appId, parent)
27 ,m_appId(appId)29 , m_appId(appId)
28 ,m_stage(MainStage)30 , m_stage(MainStage)
29 ,m_state(Starting)31 , m_state(Starting)
30 ,m_focused(false)32 , m_focused(false)
31 ,m_fullscreen(false)33 , m_fullscreen(false)
32 ,m_windowItem(0)34 , m_windowItem(0)
33 ,m_windowComponent(0)35 , m_windowComponent(0)
34 ,m_parentItem(0)36 , m_parentItem(0)
37 , m_surface(0)
35{38{
36 QTimer::singleShot(300, this, SLOT(setRunning()));39 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
37}40}
3841
39ApplicationInfo::ApplicationInfo(QObject *parent)42ApplicationInfo::ApplicationInfo(QObject *parent)
40 : ApplicationInfoInterface(QString(), parent)43 : ApplicationInfoInterface(QString(), parent)
41 ,m_stage(MainStage)44 , m_stage(MainStage)
42 ,m_state(Starting)45 , m_state(Starting)
43 ,m_focused(false)46 , m_focused(false)
44 ,m_fullscreen(false)47 , m_fullscreen(false)
45 ,m_windowItem(0)48 , m_windowItem(0)
46 ,m_windowComponent(0)49 , m_windowComponent(0)
47 ,m_parentItem(0)50 , m_parentItem(0)
48{51 , m_surface(0)
49 QTimer::singleShot(300, this, SLOT(setRunning()));52{
53 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
54}
55
56ApplicationInfo::~ApplicationInfo()
57{
58 if (m_surface) {
59 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
60 m_surface->deleteLater();
61 }
50}62}
5163
52void ApplicationInfo::onWindowComponentStatusChanged(QQmlComponent::Status status)64void ApplicationInfo::onWindowComponentStatusChanged(QQmlComponent::Status status)
@@ -55,10 +67,36 @@
55 doCreateWindowItem();67 doCreateWindowItem();
56}68}
5769
58void ApplicationInfo::setRunning()70void ApplicationInfo::onStateChanged(State state)
59{71{
60 m_state = Running;72 if (state == ApplicationInfo::Running) {
61 Q_EMIT stateChanged();73 QTimer::singleShot(1000, this, SLOT(createSurface()));
74 } else if (state == ApplicationInfo::Stopped) {
75 destroySurface();
76 }
77}
78
79void ApplicationInfo::createSurface()
80{
81 if (m_surface || state() == ApplicationInfo::Stopped) return;
82
83 m_surface = new MirSurfaceItem(name(),
84 MirSurfaceItem::Normal,
85 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
86 screenshot());
87 Q_EMIT surfaceChanged(m_surface);
88 Q_EMIT SurfaceManager::singleton()->surfaceCreated(m_surface);
89}
90
91void ApplicationInfo::destroySurface()
92{
93 if (!m_surface) return;
94 MirSurfaceItem* oldSurface = m_surface;
95 m_surface = nullptr;
96
97 Q_EMIT surfaceChanged(nullptr);
98 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(oldSurface);
99 oldSurface->deleteLater();
62}100}
63101
64void ApplicationInfo::createWindowComponent()102void ApplicationInfo::createWindowComponent()
65103
=== modified file 'tests/mocks/Unity/Application/ApplicationInfo.h'
--- tests/mocks/Unity/Application/ApplicationInfo.h 2014-03-20 10:02:52 +0000
+++ tests/mocks/Unity/Application/ApplicationInfo.h 2014-07-18 16:28:08 +0000
@@ -21,6 +21,7 @@
21#include <QQmlComponent>21#include <QQmlComponent>
2222
23class QQuickItem;23class QQuickItem;
24class MirSurfaceItem;
2425
25// unity-api26// unity-api
26#include <unity/shell/application/ApplicationInfoInterface.h>27#include <unity/shell/application/ApplicationInfoInterface.h>
@@ -36,6 +37,7 @@
3637
37 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)38 Q_PROPERTY(bool fullscreen READ fullscreen WRITE setFullscreen NOTIFY fullscreenChanged)
38 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)39 Q_PROPERTY(Stage stage READ stage WRITE setStage NOTIFY stageChanged)
40 Q_PROPERTY(MirSurfaceItem* surface READ surface NOTIFY surfaceChanged)
3941
40 // Only exists in this fake implementation42 // Only exists in this fake implementation
4143
@@ -45,9 +47,10 @@
45 // QML component used to represent the application window47 // QML component used to represent the application window
46 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)48 Q_PROPERTY(QString windowQml READ windowQml WRITE setWindowQml NOTIFY windowQmlChanged)
4749
48 public:50public:
49 ApplicationInfo(QObject *parent = NULL);51 ApplicationInfo(QObject *parent = NULL);
50 ApplicationInfo(const QString &appId, QObject *parent = NULL);52 ApplicationInfo(const QString &appId, QObject *parent = NULL);
53 ~ApplicationInfo();
5154
52 #define IMPLEMENT_PROPERTY(name, Name, type) \55 #define IMPLEMENT_PROPERTY(name, Name, type) \
53 public: \56 public: \
@@ -56,11 +59,11 @@
56 { \59 { \
57 if (m_##name != value) { \60 if (m_##name != value) { \
58 m_##name = value; \61 m_##name = value; \
59 Q_EMIT name##Changed(); \62 Q_EMIT name##Changed(value); \
60 } \63 } \
61 } \64 } \
62 Q_SIGNALS: \65 Q_SIGNALS: \
63 void name##Changed(); \66 void name##Changed(const type&); \
64 private: \67 private: \
65 type m_##name;68 type m_##name;
6669
@@ -78,21 +81,31 @@
7881
79 #undef IMPLEMENT_PROPERTY82 #undef IMPLEMENT_PROPERTY
8083
81 public:84public:
85 MirSurfaceItem* surface() const { return m_surface; }
86
87Q_SIGNALS:
88 void surfaceChanged(MirSurfaceItem*);
89
90public:
82 void showWindow(QQuickItem *parent);91 void showWindow(QQuickItem *parent);
83 void hideWindow();92 void hideWindow();
8493
85 private Q_SLOTS:94private Q_SLOTS:
86 void onWindowComponentStatusChanged(QQmlComponent::Status status);95 void onWindowComponentStatusChanged(QQmlComponent::Status status);
87 void setRunning();96 void onStateChanged(State state);
8897
89 private:98 void createSurface();
99 void destroySurface();
100
101private:
90 void createWindowItem();102 void createWindowItem();
91 void doCreateWindowItem();103 void doCreateWindowItem();
92 void createWindowComponent();104 void createWindowComponent();
93 QQuickItem *m_windowItem;105 QQuickItem *m_windowItem;
94 QQmlComponent *m_windowComponent;106 QQmlComponent *m_windowComponent;
95 QQuickItem *m_parentItem;107 QQuickItem *m_parentItem;
108 MirSurfaceItem* m_surface;
96};109};
97110
98Q_DECLARE_METATYPE(ApplicationInfo*)111Q_DECLARE_METATYPE(ApplicationInfo*)
99112
=== modified file 'tests/mocks/Unity/Application/ApplicationManager.cpp'
--- tests/mocks/Unity/Application/ApplicationManager.cpp 2014-07-10 09:27:19 +0000
+++ tests/mocks/Unity/Application/ApplicationManager.cpp 2014-07-18 16:28:08 +0000
@@ -16,6 +16,7 @@
1616
17#include "ApplicationManager.h"17#include "ApplicationManager.h"
18#include "ApplicationInfo.h"18#include "ApplicationInfo.h"
19#include "MirSurfaceItem.h"
1920
20#include <paths.h>21#include <paths.h>
2122
@@ -36,6 +37,9 @@
36 , m_sideStage(0)37 , m_sideStage(0)
37 , m_rightMargin(0)38 , m_rightMargin(0)
38{39{
40 m_roleNames.insert(RoleSurface, "surface");
41 m_roleNames.insert(RoleFullscreen, "fullscreen");
42
39 buildListOfAvailableApplications();43 buildListOfAvailableApplications();
40}44}
4145
@@ -69,6 +73,10 @@
69 return app->focused();73 return app->focused();
70 case RoleScreenshot:74 case RoleScreenshot:
71 return app->screenshot();75 return app->screenshot();
76 case RoleSurface:
77 return QVariant::fromValue(app->surface());
78 case RoleFullscreen:
79 return app->fullscreen();
72 default:80 default:
73 return QVariant();81 return QVariant();
74 }82 }
@@ -89,6 +97,17 @@
89 return nullptr;97 return nullptr;
90}98}
9199
100QModelIndex ApplicationManager::findIndex(ApplicationInfo* application)
101{
102 for (int i = 0; i < m_runningApplications.size(); ++i) {
103 if (m_runningApplications.at(i) == application) {
104 return index(i);
105 }
106 }
107
108 return QModelIndex();
109}
110
92void ApplicationManager::add(ApplicationInfo *application) {111void ApplicationManager::add(ApplicationInfo *application) {
93 if (!application) {112 if (!application) {
94 return;113 return;
@@ -100,6 +119,12 @@
100 Q_EMIT applicationAdded(application->appId());119 Q_EMIT applicationAdded(application->appId());
101 Q_EMIT countChanged();120 Q_EMIT countChanged();
102 Q_EMIT focusRequested(application->appId());121 Q_EMIT focusRequested(application->appId());
122
123 connect(application, &ApplicationInfo::surfaceChanged, this, [application, this]() {
124 QModelIndex appIndex = findIndex(application);
125 if (!appIndex.isValid()) return;
126 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << ApplicationManager::RoleSurface);
127 });
103}128}
104129
105void ApplicationManager::remove(ApplicationInfo *application) {130void ApplicationManager::remove(ApplicationInfo *application) {
@@ -111,6 +136,7 @@
111 Q_EMIT applicationRemoved(application->appId());136 Q_EMIT applicationRemoved(application->appId());
112 Q_EMIT countChanged();137 Q_EMIT countChanged();
113 }138 }
139 disconnect(application, &ApplicationInfo::surfaceChanged, this, 0);
114}140}
115141
116void ApplicationManager::move(int from, int to) {142void ApplicationManager::move(int from, int to) {
@@ -180,6 +206,7 @@
180 application->setStage(ApplicationInfo::MainStage);206 application->setStage(ApplicationInfo::MainStage);
181 }207 }
182 add(application);208 add(application);
209 application->setState(ApplicationInfo::Running);
183210
184 return application;211 return application;
185}212}
@@ -193,6 +220,7 @@
193 if (application->appId() == focusedApplicationId()) {220 if (application->appId() == focusedApplicationId()) {
194 unfocusCurrentApplication();221 unfocusCurrentApplication();
195 }222 }
223 application->setState(ApplicationInfo::Stopped);
196 remove(application);224 remove(application);
197 return true;225 return true;
198}226}
@@ -213,7 +241,6 @@
213 return false;241 return false;
214 }242 }
215243
216 application->setScreenshot(QString("image://application/%1/%2").arg(appId).arg(QDateTime::currentMSecsSinceEpoch()));
217 QModelIndex appIndex = index(idx);244 QModelIndex appIndex = index(idx);
218 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);245 Q_EMIT dataChanged(appIndex, appIndex, QVector<int>() << RoleScreenshot);
219 return true;246 return true;
@@ -352,6 +379,9 @@
352 "}").arg(qmlDirectory())379 "}").arg(qmlDirectory())
353 .arg(application->icon().toString());380 .arg(application->icon().toString());
354 application->setImageQml(imageQml);381 application->setImageQml(imageQml);
382
383 application->setScreenshot(QString("file://%1/Dash/graphics/phone/screenshots/%2@12.png").arg(qmlDirectory())
384 .arg(application->icon().toString()));
355}385}
356386
357void ApplicationManager::buildListOfAvailableApplications()387void ApplicationManager::buildListOfAvailableApplications()
@@ -363,7 +393,6 @@
363 application->setName("Dialer");393 application->setName("Dialer");
364 application->setIcon(QUrl("dialer"));394 application->setIcon(QUrl("dialer"));
365 application->setStage(ApplicationInfo::SideStage);395 application->setStage(ApplicationInfo::SideStage);
366 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
367 generateQmlStrings(application);396 generateQmlStrings(application);
368 m_availableApplications.append(application);397 m_availableApplications.append(application);
369398
@@ -372,7 +401,6 @@
372 application->setName("Camera");401 application->setName("Camera");
373 application->setIcon(QUrl("camera"));402 application->setIcon(QUrl("camera"));
374 application->setFullscreen(true);403 application->setFullscreen(true);
375 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
376 generateQmlStrings(application);404 generateQmlStrings(application);
377 m_availableApplications.append(application);405 m_availableApplications.append(application);
378406
@@ -380,7 +408,6 @@
380 application->setAppId("gallery-app");408 application->setAppId("gallery-app");
381 application->setName("Gallery");409 application->setName("Gallery");
382 application->setIcon(QUrl("gallery"));410 application->setIcon(QUrl("gallery"));
383 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
384 generateQmlStrings(application);411 generateQmlStrings(application);
385 m_availableApplications.append(application);412 m_availableApplications.append(application);
386413
@@ -389,7 +416,6 @@
389 application->setName("Facebook");416 application->setName("Facebook");
390 application->setIcon(QUrl("facebook"));417 application->setIcon(QUrl("facebook"));
391 application->setStage(ApplicationInfo::SideStage);418 application->setStage(ApplicationInfo::SideStage);
392 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
393 generateQmlStrings(application);419 generateQmlStrings(application);
394 m_availableApplications.append(application);420 m_availableApplications.append(application);
395421
@@ -398,7 +424,6 @@
398 application->setFullscreen(true);424 application->setFullscreen(true);
399 application->setName("Browser");425 application->setName("Browser");
400 application->setIcon(QUrl("browser"));426 application->setIcon(QUrl("browser"));
401 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
402 generateQmlStrings(application);427 generateQmlStrings(application);
403 m_availableApplications.append(application);428 m_availableApplications.append(application);
404429
@@ -407,7 +432,6 @@
407 application->setName("Twitter");432 application->setName("Twitter");
408 application->setIcon(QUrl("twitter"));433 application->setIcon(QUrl("twitter"));
409 application->setStage(ApplicationInfo::SideStage);434 application->setStage(ApplicationInfo::SideStage);
410 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
411 generateQmlStrings(application);435 generateQmlStrings(application);
412 m_availableApplications.append(application);436 m_availableApplications.append(application);
413437
@@ -415,7 +439,6 @@
415 application->setAppId("gmail-webapp");439 application->setAppId("gmail-webapp");
416 application->setName("GMail");440 application->setName("GMail");
417 application->setIcon(QUrl("gmail"));441 application->setIcon(QUrl("gmail"));
418 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
419 m_availableApplications.append(application);442 m_availableApplications.append(application);
420443
421 application = new ApplicationInfo(this);444 application = new ApplicationInfo(this);
@@ -423,7 +446,6 @@
423 application->setName("Weather");446 application->setName("Weather");
424 application->setIcon(QUrl("weather"));447 application->setIcon(QUrl("weather"));
425 application->setStage(ApplicationInfo::SideStage);448 application->setStage(ApplicationInfo::SideStage);
426 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
427 generateQmlStrings(application);449 generateQmlStrings(application);
428 m_availableApplications.append(application);450 m_availableApplications.append(application);
429451
@@ -432,7 +454,6 @@
432 application->setName("Notepad");454 application->setName("Notepad");
433 application->setIcon(QUrl("notepad"));455 application->setIcon(QUrl("notepad"));
434 application->setStage(ApplicationInfo::SideStage);456 application->setStage(ApplicationInfo::SideStage);
435 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
436 m_availableApplications.append(application);457 m_availableApplications.append(application);
437458
438 application = new ApplicationInfo(this);459 application = new ApplicationInfo(this);
@@ -440,7 +461,6 @@
440 application->setName("Calendar");461 application->setName("Calendar");
441 application->setIcon(QUrl("calendar"));462 application->setIcon(QUrl("calendar"));
442 application->setStage(ApplicationInfo::SideStage);463 application->setStage(ApplicationInfo::SideStage);
443 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
444 m_availableApplications.append(application);464 m_availableApplications.append(application);
445465
446 application = new ApplicationInfo(this);466 application = new ApplicationInfo(this);
@@ -448,21 +468,18 @@
448 application->setName("Media Player");468 application->setName("Media Player");
449 application->setIcon(QUrl("mediaplayer-app"));469 application->setIcon(QUrl("mediaplayer-app"));
450 application->setFullscreen(true);470 application->setFullscreen(true);
451 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
452 m_availableApplications.append(application);471 m_availableApplications.append(application);
453472
454 application = new ApplicationInfo(this);473 application = new ApplicationInfo(this);
455 application->setAppId("evernote");474 application->setAppId("evernote");
456 application->setName("Evernote");475 application->setName("Evernote");
457 application->setIcon(QUrl("evernote"));476 application->setIcon(QUrl("evernote"));
458 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
459 m_availableApplications.append(application);477 m_availableApplications.append(application);
460478
461 application = new ApplicationInfo(this);479 application = new ApplicationInfo(this);
462 application->setAppId("map");480 application->setAppId("map");
463 application->setName("Map");481 application->setName("Map");
464 application->setIcon(QUrl("map"));482 application->setIcon(QUrl("map"));
465 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
466 generateQmlStrings(application);483 generateQmlStrings(application);
467 m_availableApplications.append(application);484 m_availableApplications.append(application);
468485
@@ -470,28 +487,24 @@
470 application->setAppId("pinterest");487 application->setAppId("pinterest");
471 application->setName("Pinterest");488 application->setName("Pinterest");
472 application->setIcon(QUrl("pinterest"));489 application->setIcon(QUrl("pinterest"));
473 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
474 m_availableApplications.append(application);490 m_availableApplications.append(application);
475491
476 application = new ApplicationInfo(this);492 application = new ApplicationInfo(this);
477 application->setAppId("soundcloud");493 application->setAppId("soundcloud");
478 application->setName("SoundCloud");494 application->setName("SoundCloud");
479 application->setIcon(QUrl("soundcloud"));495 application->setIcon(QUrl("soundcloud"));
480 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
481 m_availableApplications.append(application);496 m_availableApplications.append(application);
482497
483 application = new ApplicationInfo(this);498 application = new ApplicationInfo(this);
484 application->setAppId("wikipedia");499 application->setAppId("wikipedia");
485 application->setName("Wikipedia");500 application->setName("Wikipedia");
486 application->setIcon(QUrl("wikipedia"));501 application->setIcon(QUrl("wikipedia"));
487 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
488 m_availableApplications.append(application);502 m_availableApplications.append(application);
489503
490 application = new ApplicationInfo(this);504 application = new ApplicationInfo(this);
491 application->setAppId("youtube");505 application->setAppId("youtube");
492 application->setName("YouTube");506 application->setName("YouTube");
493 application->setIcon(QUrl("youtube"));507 application->setIcon(QUrl("youtube"));
494 application->setScreenshot(QString("image://application/%1/%2").arg(application->appId()).arg(QDateTime::currentMSecsSinceEpoch()));
495 m_availableApplications.append(application);508 m_availableApplications.append(application);
496}509}
497510
498511
=== modified file 'tests/mocks/Unity/Application/ApplicationManager.h'
--- tests/mocks/Unity/Application/ApplicationManager.h 2014-03-11 11:14:10 +0000
+++ tests/mocks/Unity/Application/ApplicationManager.h 2014-07-18 16:28:08 +0000
@@ -53,6 +53,10 @@
53 ApplicationManager(QObject *parent = NULL);53 ApplicationManager(QObject *parent = NULL);
54 virtual ~ApplicationManager();54 virtual ~ApplicationManager();
5555
56 enum MoreRoles {
57 RoleSurface = RoleScreenshot+1,
58 RoleFullscreen,
59 };
56 enum Role {60 enum Role {
57 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,61 Dash, Default, Indicators, Notifications, Greeter, Launcher, OnScreenKeyboard,
58 ShutdownDialog62 ShutdownDialog
@@ -108,6 +112,8 @@
108 int rightMargin() const;112 int rightMargin() const;
109 void setRightMargin(int rightMargin);113 void setRightMargin(int rightMargin);
110114
115 QModelIndex findIndex(ApplicationInfo* application);
116
111 Q_SIGNALS:117 Q_SIGNALS:
112 void keyboardHeightChanged();118 void keyboardHeightChanged();
113 void keyboardVisibleChanged();119 void keyboardVisibleChanged();
114120
=== modified file 'tests/mocks/Unity/Application/CMakeLists.txt'
--- tests/mocks/Unity/Application/CMakeLists.txt 2014-06-26 08:26:58 +0000
+++ tests/mocks/Unity/Application/CMakeLists.txt 2014-07-18 16:28:08 +0000
@@ -6,6 +6,8 @@
6 ApplicationImage.cpp6 ApplicationImage.cpp
7 ApplicationManager.cpp7 ApplicationManager.cpp
8 ApplicationScreenshotProvider.cpp8 ApplicationScreenshotProvider.cpp
9 MirSurfaceItem.cpp
10 SurfaceManager.cpp
9 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h11 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationInfoInterface.h
10 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h12 ${APPLICATION_API_INCLUDEDIR}/unity/shell/application/ApplicationManagerInterface.h
11)13)
1214
=== added file 'tests/mocks/Unity/Application/MirSurfaceItem.cpp'
--- tests/mocks/Unity/Application/MirSurfaceItem.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Application/MirSurfaceItem.cpp 2014-07-18 16:28:08 +0000
@@ -0,0 +1,40 @@
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 "MirSurfaceItem.h"
18
19#include <QPainter>
20
21MirSurfaceItem::MirSurfaceItem(const QString& name,
22 MirSurfaceItem::Type type,
23 MirSurfaceItem::State state,
24 const QUrl& screenshot,
25 QQuickItem *parent)
26 : QQuickPaintedItem(parent)
27 , m_name(name)
28 , m_type(type)
29 , m_state(state)
30 , m_img(screenshot.isLocalFile() ? screenshot.toLocalFile() : screenshot.toString())
31{
32 setFillColor(Qt::white);
33}
34
35void MirSurfaceItem::paint(QPainter * painter)
36{
37 if (!m_img.isNull()) {
38 painter->drawImage(contentsBoundingRect(), m_img, QRect(QPoint(0,0), m_img.size()));
39 }
40}
041
=== added file 'tests/mocks/Unity/Application/MirSurfaceItem.h'
--- tests/mocks/Unity/Application/MirSurfaceItem.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Application/MirSurfaceItem.h 2014-07-18 16:28:08 +0000
@@ -0,0 +1,84 @@
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 MIRSURFACEITEM_H
18#define MIRSURFACEITEM_H
19
20#include <QQuickPaintedItem>
21#include <QImage>
22
23class MirSurfaceItem : public QQuickPaintedItem
24{
25 Q_OBJECT
26 Q_ENUMS(Type)
27 Q_ENUMS(State)
28
29 Q_PROPERTY(Type type READ type NOTIFY typeChanged)
30 Q_PROPERTY(State state READ state NOTIFY stateChanged)
31 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
32
33public:
34 enum Type {
35 Normal,
36 Utility,
37 Dialog,
38 Overlay,
39 Freestyle,
40 Popover,
41 InputMethod,
42 };
43
44 enum State {
45 Unknown,
46 Restored,
47 Minimized,
48 Maximized,
49 VertMaximized,
50 /* SemiMaximized, */
51 Fullscreen,
52 };
53
54 explicit MirSurfaceItem(const QString& name,
55 Type type,
56 State state,
57 const QUrl& screenshot,
58 QQuickItem *parent = 0);
59
60 //getters
61 Type type() const { return m_type; }
62 State state() const { return m_state; }
63 QString name() const { return m_name; }
64
65 Q_INVOKABLE void release() {}
66
67 void paint(QPainter * painter) override;
68
69Q_SIGNALS:
70 void typeChanged(Type);
71 void stateChanged(State);
72 void nameChanged(QString);
73
74private:
75
76 const QString m_name;
77 const Type m_type;
78 const State m_state;
79 const QImage m_img;
80};
81
82Q_DECLARE_METATYPE(MirSurfaceItem*)
83
84#endif // MIRSURFACEITEM_H
085
=== added file 'tests/mocks/Unity/Application/SurfaceManager.cpp'
--- tests/mocks/Unity/Application/SurfaceManager.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Application/SurfaceManager.cpp 2014-07-18 16:28:08 +0000
@@ -0,0 +1,16 @@
1#include "SurfaceManager.h"
2
3SurfaceManager *SurfaceManager::the_surface_manager = nullptr;
4
5SurfaceManager *SurfaceManager::singleton()
6{
7 if (!the_surface_manager) {
8 the_surface_manager = new SurfaceManager();
9 }
10 return the_surface_manager;
11}
12
13SurfaceManager::SurfaceManager(QObject *parent) :
14 QObject(parent)
15{
16}
017
=== added file 'tests/mocks/Unity/Application/SurfaceManager.h'
--- tests/mocks/Unity/Application/SurfaceManager.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Application/SurfaceManager.h 2014-07-18 16:28:08 +0000
@@ -0,0 +1,26 @@
1#ifndef SURFACEMANAGER_H
2#define SURFACEMANAGER_H
3
4#include <QObject>
5
6class MirSurfaceItem;
7
8class SurfaceManager : public QObject
9{
10 Q_OBJECT
11public:
12 explicit SurfaceManager(QObject *parent = 0);
13
14 static SurfaceManager *singleton();
15
16Q_SIGNALS:
17 void countChanged();
18 void surfaceCreated(MirSurfaceItem *surface);
19 void surfaceDestroyed(MirSurfaceItem *surface);
20
21private:
22 static SurfaceManager *the_surface_manager;
23
24};
25
26#endif // SURFACEMANAGER_H
027
=== modified file 'tests/mocks/Unity/Application/plugin.cpp'
--- tests/mocks/Unity/Application/plugin.cpp 2014-01-20 11:34:59 +0000
+++ tests/mocks/Unity/Application/plugin.cpp 2014-07-18 16:28:08 +0000
@@ -19,6 +19,8 @@
19#include "ApplicationImage.h"19#include "ApplicationImage.h"
20#include "ApplicationManager.h"20#include "ApplicationManager.h"
21#include "ApplicationScreenshotProvider.h"21#include "ApplicationScreenshotProvider.h"
22#include "MirSurfaceItem.h"
23#include "SurfaceManager.h"
2224
23#include <qqml.h>25#include <qqml.h>
24#include <QQmlEngine>26#include <QQmlEngine>
@@ -34,14 +36,25 @@
34 return s_appManager;36 return s_appManager;
35}37}
3638
39static QObject* surfaceManagerSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
40 Q_UNUSED(engine);
41 Q_UNUSED(scriptEngine);
42 return SurfaceManager::singleton();
43}
44
37void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)45void FakeUnityApplicationQmlPlugin::registerTypes(const char *uri)
38{46{
47 qRegisterMetaType<MirSurfaceItem*>("MirSurfaceItem*");
48
39 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");49 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Abstract interface. Cannot be created in QML");
40 qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);50 qmlRegisterSingletonType<ApplicationManager>(uri, 0, 1, "ApplicationManager", applicationManagerSingleton);
51 qmlRegisterSingletonType<SurfaceManager>(uri, 0, 1, "SurfaceManager", surfaceManagerSingleton);
4152
42 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");53 qmlRegisterUncreatableType<unity::shell::application::ApplicationInfoInterface>(uri, 0, 1, "ApplicationInfoInterface", "Abstract interface. Cannot be created in QML");
43 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");54 qmlRegisterType<ApplicationInfo>(uri, 0, 1, "ApplicationInfo");
4455
56 qmlRegisterUncreatableType<MirSurfaceItem>(uri, 0, 1, "MirSurfaceItem", "MirSurfaceItem can't be instantiated from QML");
57
45 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");58 qmlRegisterType<ApplicationImage>(uri, 0, 1, "ApplicationImage");
46}59}
4760

Subscribers

People subscribed via source and target branches

to all changes: