@@ -17,6 +17,7 @@
17// unity-api
17// unity-api
18#include <unity/shell/launcher/LauncherModelInterface.h>
18#include <unity/shell/launcher/LauncherModelInterface.h>
19#include <unity/shell/application/ApplicationInfoInterface.h>
19#include <unity/shell/application/ApplicationInfoInterface.h>
20+#include <unity/shell/application/MirSurfaceListInterface.h>
21#include "launcheritem.h"
22#include "launcheritem.h"
22#include "launchermodel.h"
23#include "launchermodel.h"
@@ -37,11 +38,72 @@
37namespace unityapi = unity::shell::application;
38namespace unityapi = unity::shell::application;
39// This is a mock, specifically to test the LauncherModel
40// This is a mock, specifically to test the LauncherModel
41+class MockSurface: public unity::shell::application::MirSurfaceInterface
45+ MockSurface(const QString &id, QObject* parent): unityapi::MirSurfaceInterface(parent), m_id(id) {}
46+ Mir::Type type() const override { return Mir::NormalType;}
47+ QString name() const override { return QStringLiteral("mock surface"); }
48+ QString persistentId() const override { return m_id; }
49+ QPoint position() const override { return QPoint(); }
50+ QSize size() const override { return QSize(); }
51+ void resize(const QSize &size) override { Q_UNUSED(size) }
52+ void resize(int width, int height) override { Q_UNUSED(width); Q_UNUSED(height) }
53+ Mir::State state() const override { return Mir::RestoredState; }
54+ bool live() const override { return true; }
55+ bool visible() const override { return true; }
56+ Mir::OrientationAngle orientationAngle() const override { return Mir::Angle0; }
57+ void setOrientationAngle(Mir::OrientationAngle angle) override { Q_UNUSED(angle); }
58+ int minimumWidth() const override { return 0; }
59+ int minimumHeight() const override { return 0; }
60+ int maximumWidth() const override { return 0; }
61+ int maximumHeight() const override { return 0; }
62+ int widthIncrement() const override { return 0; }
63+ int heightIncrement() const override { return 0; }
64+ void setKeymap(const QString &) override {}
65+ Mir::ShellChrome shellChrome() const override { return Mir::NormalChrome; }
66+ QString keymap() const override { return QStringLiteral("de_DE"); }
67+ bool focused() const override { return true; }
68+ QRect inputBounds() const override { return QRect(); }
69+ bool confinesMousePointer() const override { return false; }
70+ QPoint requestedPosition() const override { return QPoint(); }
71+ void setRequestedPosition(const QPoint &) override {}
72+ MirSurfaceInterface* parentSurface() const override { return nullptr; }
73+ MirSurfaceListInterface* childSurfaceList() const override { return nullptr; }
74+ void close() override {}
75+ void activate() override {}
76+ void requestState(Mir::State) override {}
82+class MockSurfaceList: public unity::shell::application::MirSurfaceListInterface
86+ MockSurfaceList(QObject *parent): unityapi::MirSurfaceListInterface(parent) {}
87+ int rowCount(const QModelIndex & = QModelIndex()) const override { return m_list.count(); }
88+ QVariant data(const QModelIndex &, int) const override { return QVariant(); }
89+ Q_INVOKABLE MirSurfaceInterface* get(int index) override { return m_list.at(index); }
90+ void append(MirSurfaceInterface* surface) {
91+ beginInsertRows(QModelIndex(), m_list.count(), m_list.count());
92+ m_list.append(surface);
96+ QList<MirSurfaceInterface*> m_list;
40class MockApp: public unity::shell::application::ApplicationInfoInterface
100class MockApp: public unity::shell::application::ApplicationInfoInterface
44− MockApp(const QString &appId, QObject *parent = 0): ApplicationInfoInterface(appId, parent), m_appId(appId), m_focused(false) { }
104+ MockApp(const QString &appId, QObject *parent = 0): ApplicationInfoInterface(appId, parent), m_appId(appId), m_focused(false) {
105+ m_surfaces = new MockSurfaceList(this);
46 RequestedState requestedState() const override { return RequestedRunning; }
108 RequestedState requestedState() const override { return RequestedRunning; }
47 void setRequestedState(RequestedState) override {}
109 void setRequestedState(RequestedState) override {}
@@ -64,10 +126,10 @@ public:
64 void setExemptFromLifecycle(bool) override {}
126 void setExemptFromLifecycle(bool) override {}
65 QSize initialSurfaceSize() const override { return QSize(); }
127 QSize initialSurfaceSize() const override { return QSize(); }
66 void setInitialSurfaceSize(const QSize &) override {}
128 void setInitialSurfaceSize(const QSize &) override {}
67− MirSurfaceListInterface* surfaceList() const override { return nullptr; }
129+ MirSurfaceListInterface* surfaceList() const override { return m_surfaces; }
68 MirSurfaceListInterface* promptSurfaceList() const override { return nullptr; }
130 MirSurfaceListInterface* promptSurfaceList() const override { return nullptr; }
69− int surfaceCount() const override { return m_surfaceCount; }
131+ int surfaceCount() const override { return m_surfaces->count(); }
70− void setSurfaceCount(int count) { m_surfaceCount = count; Q_EMIT surfaceCountChanged(count); }
132+ void setSurfaces(MockSurfaceList* surfaces) { m_surfaces = surfaces; Q_EMIT surfaceCountChanged(m_surfaces->count()); }
71 void close() override {}
133 void close() override {}
73 // Methods used for mocking (not in the interface)
135 // Methods used for mocking (not in the interface)
@@ -75,7 +137,7 @@ public:
76 QString m_appId;
138 QString m_appId;
77 bool m_focused;
139 bool m_focused;
78− int m_surfaceCount = 0;
140+ MockSurfaceList *m_surfaces;
81// This is a mock, specifically to test the LauncherModel
143// This is a mock, specifically to test the LauncherModel
@@ -748,8 +810,20 @@ private Q_SLOTS:
749 QCOMPARE(launcherModel->get(0)->surfaceCount(), 0);
811 QCOMPARE(launcherModel->get(0)->surfaceCount(), 0);
750 MockApp *app = qobject_cast<MockApp*>(appManager->findApplication(appId));
812 MockApp *app = qobject_cast<MockApp*>(appManager->findApplication(appId));
751− app->setSurfaceCount(1);
813+ MockSurfaceList* surfaces = new MockSurfaceList(appManager);
814+ surfaces->append(new MockSurface("foobar", surfaces));
815+ app->setSurfaces(surfaces);
752 QCOMPARE(launcherModel->get(0)->surfaceCount(), 1);
816 QCOMPARE(launcherModel->get(0)->surfaceCount(), 1);
818+ // Make sure the new surface appears in the quicklist
819+ QuickListModel *quickList = qobject_cast<QuickListModel*>(launcherModel->get(0)->quickList());
821+ for (int i = 0; i < quickList->rowCount(); ++i) {
822+ if (quickList->get(i).actionId() == "surface_foobar") {
826+ QCOMPARE(found, true);