on xenial help sign in
Use headers from unity-api
86529e6Albert Astals
tests/mocks/Unity/CMakeLists.txt+8
@@ -6,6 +6,7 @@ add_subdirectory(Notifications)
6pkg_search_module(DEE dee-1.0 REQUIRED)
6pkg_search_module(DEE dee-1.0 REQUIRED)
7pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
7pkg_search_module(GOBJECT gobject-2.0 REQUIRED)
8pkg_search_module(DEEQT libdee-qt5 REQUIRED)
8pkg_search_module(DEEQT libdee-qt5 REQUIRED)
9+pkg_check_modules(SCOPES_API REQUIRED unity-shell-scopes=1)
9
10
10include_directories(
11include_directories(
11 ${CMAKE_CURRENT_BINARY_DIR}
12 ${CMAKE_CURRENT_BINARY_DIR}
@@ -27,6 +28,13 @@ set(UnityQML_SOURCES
27 fake_previewstack.cpp
28 fake_previewstack.cpp
28 fake_previewwidgetmodel.cpp
29 fake_previewwidgetmodel.cpp
29 fake_unity_plugin.cpp
30 fake_unity_plugin.cpp
31+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/CategoriesInterface.h
32+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewModelInterface.h
33+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewStackInterface.h
34+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/PreviewWidgetModelInterface.h
35+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ResultsModelInterface.h
36+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopeInterface.h
37+ ${SCOPES_API_INCLUDEDIR}/unity/shell/scopes/ScopesInterface.h
30)
38)
31
39
32add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
40add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
tests/mocks/Unity/fake_categories.cpp+8−2
@@ -22,9 +22,10 @@
22#include "fake_resultsmodel.h"
22#include "fake_resultsmodel.h"
23
23
24Categories::Categories(int category_count, QObject* parent)
24Categories::Categories(int category_count, QObject* parent)
25− : QAbstractListModel(parent)
26− , m_category_count(category_count)
25+ : m_category_count(category_count)
27{
26{
27+ setParent(parent);
28+
28 m_roles[Categories::RoleCategoryId] = "categoryId";
29 m_roles[Categories::RoleCategoryId] = "categoryId";
29 m_roles[Categories::RoleName] = "name";
30 m_roles[Categories::RoleName] = "name";
30 m_roles[Categories::RoleIcon] = "icon";
31 m_roles[Categories::RoleIcon] = "icon";
@@ -65,6 +66,11 @@ void Categories::addSpecialCategory(QString const& categoryId, QString const& na
65 }
66 }
66}
67}
67
68
69+bool Categories::overrideCategoryJson(QString const& categoryId, QString const& json)
70+{
71+ qFatal("Using un-implemented Categories::overrideCategoryJson");
72+}
73+
68void Categories::countChanged()
74void Categories::countChanged()
69{
75{
70 QObject* countObject = sender();
76 QObject* countObject = sender();
tests/mocks/Unity/fake_categories.h+5−16
@@ -17,37 +17,26 @@
17#ifndef FAKE_CATEGORIES_H
17#ifndef FAKE_CATEGORIES_H
18#define FAKE_CATEGORIES_H
18#define FAKE_CATEGORIES_H
19
19
20+#include <unity/shell/scopes/CategoriesInterface.h>
21+
20// Qt
22// Qt
21−#include <QAbstractListModel>
22#include <QList>
23#include <QList>
23
24
24class ResultsModel;
25class ResultsModel;
25
26
26−class Categories : public QAbstractListModel
27+class Categories : public unity::shell::scopes::CategoriesInterface
27{
28{
28 Q_OBJECT
29 Q_OBJECT
29
30
30− Q_ENUMS(Roles)
31−
32public:
31public:
33 Categories(int category_count, QObject* parent = 0);
32 Categories(int category_count, QObject* parent = 0);
34− enum Roles {
35− RoleCategoryId,
36− RoleName,
37− RoleIcon,
38− RoleRawRendererTemplate,
39− RoleRenderer,
40− RoleComponents,
41− RoleProgressSource, // maybe
42− RoleResults,
43− RoleCount
44− };
45
33
46 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
34 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
47 QHash<int, QByteArray> roleNames() const override;
35 QHash<int, QByteArray> roleNames() const override;
48 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
49
37
50− Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject);
38+ Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject) override;
39+ Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
51
40
52private Q_SLOTS:
41private Q_SLOTS:
53 void countChanged();
42 void countChanged();
tests/mocks/Unity/fake_previewmodel.cpp+3−1
@@ -27,8 +27,10 @@
27// Qt
27// Qt
28#include <QDebug>
28#include <QDebug>
29
29
30−PreviewModel::PreviewModel(QObject* parent) : QAbstractListModel(parent)
30+PreviewModel::PreviewModel(QObject* parent)
31{
31{
32+ setParent(parent);
33+
32 // we have one column by default
34 // we have one column by default
33 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
35 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
34 m_previewWidgetModels.append(columnModel);
36 m_previewWidgetModels.append(columnModel);
tests/mocks/Unity/fake_previewmodel.h+7−22
@@ -18,45 +18,30 @@
18#ifndef FAKE_PREVIEWMODEL_H
18#ifndef FAKE_PREVIEWMODEL_H
19#define FAKE_PREVIEWMODEL_H
19#define FAKE_PREVIEWMODEL_H
20
20
21−#include <QAbstractListModel>
21+#include <unity/shell/scopes/PreviewModelInterface.h>
22+
22#include <QSharedPointer>
23#include <QSharedPointer>
23#include <QVariantMap>
24#include <QVariantMap>
24
25
25class PreviewWidgetModel;
26class PreviewWidgetModel;
26
27
27−class PreviewModel : public QAbstractListModel
28+class PreviewModel : public unity::shell::scopes::PreviewModelInterface
28{
29{
29 Q_OBJECT
30 Q_OBJECT
30
31
31− Q_ENUMS(Roles)
32−
33− Q_PROPERTY(int widgetColumnCount READ widgetColumnCount WRITE setWidgetColumnCount NOTIFY widgetColumnCountChanged)
34− Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
35− Q_PROPERTY(bool processingAction READ processingAction NOTIFY processingActionChanged)
36−
37public:
32public:
38 explicit PreviewModel(QObject* parent = 0);
33 explicit PreviewModel(QObject* parent = 0);
39
34
40− enum Roles {
41− RoleColumnModel
42− };
43−
44 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
45 QHash<int, QByteArray> roleNames() const override;
36 QHash<int, QByteArray> roleNames() const override;
46 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
37 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
47
38
48− void setWidgetColumnCount(int count);
39+ void setWidgetColumnCount(int count) override;
49− int widgetColumnCount() const;
40+ int widgetColumnCount() const override;
50− bool loaded() const;
41+ bool loaded() const override;
51− bool processingAction() const;
42+ bool processingAction() const override;
52 void setProcessingAction(bool processing);
43 void setProcessingAction(bool processing);
53
44
54−Q_SIGNALS:
55− void widgetColumnCountChanged();
56− void loadedChanged();
57− void processingActionChanged();
58− void triggered(QString const&, QString const&, QVariantMap const&);
59−
60private:
45private:
61 QHash<int, QByteArray> m_roles;
46 QHash<int, QByteArray> m_roles;
62 QList<PreviewWidgetModel*> m_previewWidgetModels;
47 QList<PreviewWidgetModel*> m_previewWidgetModels;
tests/mocks/Unity/fake_previewstack.cpp+4−2
@@ -21,8 +21,10 @@
21#include "fake_previewmodel.h"
21#include "fake_previewmodel.h"
22#include "fake_scope.h"
22#include "fake_scope.h"
23
23
24−PreviewStack::PreviewStack(QObject* parent) : QAbstractListModel(parent)
24+PreviewStack::PreviewStack(QObject* parent)
25{
25{
26+ setParent(parent);
27+
26 m_previews << new PreviewModel(this);
28 m_previews << new PreviewModel(this);
27}
29}
28
30
@@ -56,7 +58,7 @@ int PreviewStack::rowCount(const QModelIndex&) const
56 return m_previews.size();
58 return m_previews.size();
57}
59}
58
60
59−PreviewModel* PreviewStack::get(int index) const
61+unity::shell::scopes::PreviewModelInterface* PreviewStack::get(int index) const
60{
62{
61 if (index >= m_previews.size()) {
63 if (index >= m_previews.size()) {
62 return nullptr;
64 return nullptr;
tests/mocks/Unity/fake_previewstack.h+6−16
@@ -18,39 +18,29 @@
18#ifndef FAKE_PREVIEWSTACK_H
18#ifndef FAKE_PREVIEWSTACK_H
19#define FAKE_PREVIEWSTACK_H
19#define FAKE_PREVIEWSTACK_H
20
20
21−#include <QAbstractListModel>
21+#include <unity/shell/scopes/PreviewStackInterface.h>
22+
22#include <QSharedPointer>
23#include <QSharedPointer>
23#include <QVariantMap>
24#include <QVariantMap>
24
25
25class PreviewModel;
26class PreviewModel;
26
27
27−class PreviewStack : public QAbstractListModel
28+class PreviewStack : public unity::shell::scopes::PreviewStackInterface
28{
29{
29 Q_OBJECT
30 Q_OBJECT
30
31
31− Q_ENUMS(Roles)
32−
33− Q_PROPERTY(int widgetColumnCount READ widgetColumnCount WRITE setWidgetColumnCount NOTIFY widgetColumnCountChanged)
34−
35public:
32public:
36 explicit PreviewStack(QObject* parent = 0);
33 explicit PreviewStack(QObject* parent = 0);
37 virtual ~PreviewStack();
34 virtual ~PreviewStack();
38
35
39− enum Roles {
40− RolePreviewModel
41− };
42−
43 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
36 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
44 QHash<int, QByteArray> roleNames() const override;
37 QHash<int, QByteArray> roleNames() const override;
45 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
38 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
46
39
47− Q_INVOKABLE PreviewModel* get(int index) const;
40+ Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* get(int index) const override;
48−
49− void setWidgetColumnCount(int columnCount);
50− int widgetColumnCount() const;
51
41
52−Q_SIGNALS:
42+ void setWidgetColumnCount(int columnCount) override;
53− void widgetColumnCountChanged();
43+ int widgetColumnCount() const override;
54
44
55private:
45private:
56 QList<PreviewModel*> m_previews;
46 QList<PreviewModel*> m_previews;
tests/mocks/Unity/fake_previewwidgetmodel.cpp+3−1
@@ -35,8 +35,10 @@ struct PreviewData
35 }
35 }
36};
36};
37
37
38−PreviewWidgetModel::PreviewWidgetModel(QObject* parent) : QAbstractListModel(parent)
38+PreviewWidgetModel::PreviewWidgetModel(QObject* parent)
39{
39{
40+ setParent(parent);
41+
40 m_roles[Roles::RoleWidgetId] = "widgetId";
42 m_roles[Roles::RoleWidgetId] = "widgetId";
41 m_roles[Roles::RoleType] = "type";
43 m_roles[Roles::RoleType] = "type";
42 m_roles[Roles::RoleProperties] = "properties";
44 m_roles[Roles::RoleProperties] = "properties";
tests/mocks/Unity/fake_previewwidgetmodel.h+3−10
@@ -18,27 +18,20 @@
18#ifndef FAKE_PREVIEWWIDGETMODEL_H
18#ifndef FAKE_PREVIEWWIDGETMODEL_H
19#define FAKE_PREVIEWWIDGETMODEL_H
19#define FAKE_PREVIEWWIDGETMODEL_H
20
20
21−#include <QAbstractListModel>
21+#include <unity/shell/scopes/PreviewWidgetModelInterface.h>
22+
22#include <QSharedPointer>
23#include <QSharedPointer>
23#include <QVariantMap>
24#include <QVariantMap>
24
25
25class PreviewData;
26class PreviewData;
26
27
27−class PreviewWidgetModel : public QAbstractListModel
28+class PreviewWidgetModel : public unity::shell::scopes::PreviewWidgetModelInterface
28{
29{
29 Q_OBJECT
30 Q_OBJECT
30
31
31− Q_ENUMS(Roles)
32−
33public:
32public:
34 explicit PreviewWidgetModel(QObject* parent = 0);
33 explicit PreviewWidgetModel(QObject* parent = 0);
35
34
36− enum Roles {
37− RoleWidgetId,
38− RoleType,
39− RoleProperties
40− };
41−
42 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
43 QHash<int, QByteArray> roleNames() const override;
36 QHash<int, QByteArray> roleNames() const override;
44 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
37 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
tests/mocks/Unity/fake_resultsmodel.cpp+3−12
@@ -23,10 +23,11 @@
23#include <paths.h>
23#include <paths.h>
24
24
25ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
25ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
26− : QAbstractListModel(parent)
27− , m_result_count(result_count)
26+ : m_result_count(result_count)
28 , m_categoryId(categoryId)
27 , m_categoryId(categoryId)
29{
28{
29+ setParent(parent);
30+
30 m_roles[ResultsModel::RoleUri] = "uri";
31 m_roles[ResultsModel::RoleUri] = "uri";
31 m_roles[ResultsModel::RoleCategoryId] = "categoryId";
32 m_roles[ResultsModel::RoleCategoryId] = "categoryId";
32 m_roles[ResultsModel::RoleDndUri] = "dndUri";
33 m_roles[ResultsModel::RoleDndUri] = "dndUri";
@@ -36,11 +37,6 @@ ResultsModel::ResultsModel(int result_count, int categoryId, QObject* parent)
36 m_roles[ResultsModel::RoleSubtitle] = "subtitle";
37 m_roles[ResultsModel::RoleSubtitle] = "subtitle";
37 m_roles[ResultsModel::RoleMascot] = "mascot";
38 m_roles[ResultsModel::RoleMascot] = "mascot";
38 m_roles[ResultsModel::RoleEmblem] = "emblem";
39 m_roles[ResultsModel::RoleEmblem] = "emblem";
39− m_roles[ResultsModel::RoleOldPrice] = "oldPrice";
40− m_roles[ResultsModel::RolePrice] = "price";
41− m_roles[ResultsModel::RoleAltPrice] = "altPrice";
42− m_roles[ResultsModel::RoleRating] = "rating";
43− m_roles[ResultsModel::RoleAltRating] = "altRating";
44 m_roles[ResultsModel::RoleSummary] = "summary";
40 m_roles[ResultsModel::RoleSummary] = "summary";
45}
41}
46
42
@@ -105,11 +101,6 @@ ResultsModel::data(const QModelIndex& index, int role) const
105 case RoleSubtitle:
101 case RoleSubtitle:
106 case RoleMascot:
102 case RoleMascot:
107 case RoleEmblem:
103 case RoleEmblem:
108− case RoleOldPrice:
109− case RolePrice:
110− case RoleAltPrice:
111− case RoleRating:
112− case RoleAltRating:
113 case RoleSummary:
104 case RoleSummary:
114 default:
105 default:
115 return QVariant();
106 return QVariant();
tests/mocks/Unity/fake_resultsmodel.h+6−34
@@ -21,55 +21,27 @@
21#ifndef FAKE_RESULTS_MODEL_H
21#ifndef FAKE_RESULTS_MODEL_H
22#define FAKE_RESULTS_MODEL_H
22#define FAKE_RESULTS_MODEL_H
23
23
24−#include <QAbstractListModel>
24+#include <unity/shell/scopes/ResultsModelInterface.h>
25
25
26−class ResultsModel : public QAbstractListModel
26+class ResultsModel : public unity::shell::scopes::ResultsModelInterface
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29
29
30− Q_ENUMS(Roles)
31−
32− Q_PROPERTY(QString categoryId READ categoryId WRITE setCategoryId NOTIFY categoryIdChanged)
33− Q_PROPERTY(int count READ count NOTIFY countChanged)
34−
35public:
30public:
36 explicit ResultsModel(int result_count, int categoryId, QObject* parent = 0);
31 explicit ResultsModel(int result_count, int categoryId, QObject* parent = 0);
37
32
38− enum Roles {
39− RoleUri,
40− RoleCategoryId,
41− RoleDndUri,
42− RoleResult,
43− // card components
44− RoleTitle,
45− RoleArt,
46− RoleSubtitle,
47− RoleMascot,
48− RoleEmblem,
49− RoleOldPrice,
50− RolePrice,
51− RoleAltPrice,
52− RoleRating,
53− RoleAltRating,
54− RoleSummary
55− };
56−
57 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
33 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
58 QHash<int, QByteArray> roleNames() const override;
34 QHash<int, QByteArray> roleNames() const override;
59 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
60
36
61− Q_INVOKABLE QVariant get(int row) const;
37+ Q_INVOKABLE QVariant get(int row) const override;
62
38
63 /* getters */
39 /* getters */
64− QString categoryId() const;
40+ QString categoryId() const override;
65− int count() const;
41+ int count() const override;
66
42
67 /* setters */
43 /* setters */
68− void setCategoryId(QString const& id);
44+ void setCategoryId(QString const& id) override;
69−
70−Q_SIGNALS:
71− void categoryIdChanged();
72− void countChanged();
73
45
74private:
46private:
75 QHash<int, QByteArray> m_roles;
47 QHash<int, QByteArray> m_roles;
tests/mocks/Unity/fake_scope.cpp+3−7
@@ -22,8 +22,7 @@ Scope::Scope(QObject* parent) : Scope(QString(), QString(), false, parent)
22}
22}
23
23
24Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
24Scope::Scope(QString const& id, QString const& name, bool visible, QObject* parent)
25− : QObject(parent)
26− , m_id(id)
25+ : m_id(id)
27 , m_name(name)
26 , m_name(name)
28 , m_visible(visible)
27 , m_visible(visible)
29 , m_searching(false)
28 , m_searching(false)
@@ -31,6 +30,7 @@ Scope::Scope(QString const& id, QString const& name, bool visible, QObject* pare
31 , m_previewRendererName("preview-generic")
30 , m_previewRendererName("preview-generic")
32 , m_categories(new Categories(20, this))
31 , m_categories(new Categories(20, this))
33{
32{
33+ setParent(parent);
34}
34}
35
35
36QString Scope::id() const {
36QString Scope::id() const {
@@ -61,10 +61,6 @@ QString Scope::shortcut() const {
61 return QString("");
61 return QString("");
62}
62}
63
63
64−bool Scope::connected() const {
65− return true;
66−}
67−
68bool Scope::searchInProgress() const {
64bool Scope::searchInProgress() const {
69 return m_searching;
65 return m_searching;
70}
66}
@@ -149,7 +145,7 @@ void Scope::cancelActivation()
149{
145{
150}
146}
151
147
152−void Scope::closeScope(Scope* /*scope*/)
148+void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
153{
149{
154 qFatal("Scope::closeScope is not implemented");
150 qFatal("Scope::closeScope is not implemented");
155}
151}
tests/mocks/Unity/fake_scope.h+24−69
@@ -17,93 +17,48 @@
17#ifndef FAKE_SCOPE_H
17#ifndef FAKE_SCOPE_H
18#define FAKE_SCOPE_H
18#define FAKE_SCOPE_H
19
19
20+#include <unity/shell/scopes/ScopeInterface.h>
21+
20#include "fake_categories.h"
22#include "fake_categories.h"
21#include "fake_previewstack.h"
23#include "fake_previewstack.h"
22
24
23−#include <QObject>
24#include <QTimer>
25#include <QTimer>
25
26
26−class Preview;
27+class Scope : public unity::shell::scopes::ScopeInterface
27−
28−class Scope : public QObject
29{
28{
30 Q_OBJECT
29 Q_OBJECT
31
30
32− Q_PROPERTY(QString id READ id NOTIFY idChanged)
33− Q_PROPERTY(QString name READ name NOTIFY nameChanged)
34− Q_PROPERTY(QString iconHint READ iconHint NOTIFY iconHintChanged)
35− Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
36− Q_PROPERTY(QString searchHint READ searchHint NOTIFY searchHintChanged)
37− Q_PROPERTY(bool searchInProgress READ searchInProgress WRITE setSearchInProgress NOTIFY searchInProgressChanged)
38− Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
39− Q_PROPERTY(QString shortcut READ shortcut NOTIFY shortcutChanged)
40− Q_PROPERTY(Categories* categories READ categories NOTIFY categoriesChanged)
41− //Q_PROPERTY(Filters* filters READ filters NOTIFY filtersChanged)
42−
43− Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
44− Q_PROPERTY(QString noResultsHint READ noResultsHint WRITE setNoResultsHint NOTIFY noResultsHintChanged)
45− Q_PROPERTY(QString formFactor READ formFactor WRITE setFormFactor NOTIFY formFactorChanged)
46− Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
47−
48public:
31public:
49 Scope(QObject* parent = 0);
32 Scope(QObject* parent = 0);
50 Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
33 Scope(QString const& id, QString const& name, bool visible, QObject* parent = 0);
51
34
52 /* getters */
35 /* getters */
53− QString id() const;
36+ QString id() const override;
54− QString name() const;
37+ QString name() const override;
55− QString iconHint() const;
38+ QString iconHint() const override;
56− QString description() const;
39+ QString description() const override;
57− QString searchHint() const;
40+ QString searchHint() const override;
58− bool visible() const;
41+ bool visible() const override;
59− QString shortcut() const;
42+ QString shortcut() const override;
60− bool connected() const;
61− bool searchInProgress() const;
43+ bool searchInProgress() const override;
62− Categories* categories() const;
44+ Categories* categories() const override;
63− QString searchQuery() const;
45+ QString searchQuery() const override;
64− QString noResultsHint() const;
46+ QString noResultsHint() const override;
65− QString formFactor() const;
47+ QString formFactor() const override;
66− bool isActive() const;
48+ bool isActive() const override;
67
49
68 /* setters */
50 /* setters */
69 void setName(const QString& name);
51 void setName(const QString& name);
70− void setSearchQuery(const QString& search_query);
52+ void setSearchQuery(const QString& search_query) override;
71− void setNoResultsHint(const QString& hint);
53+ void setNoResultsHint(const QString& hint) override;
72− void setFormFactor(const QString& form_factor);
54+ void setFormFactor(const QString& form_factor) override;
73− void setActive(const bool);
55+ void setActive(const bool) override;
74 void setSearchInProgress(const bool inProg);
56 void setSearchInProgress(const bool inProg);
75
57
76− Q_INVOKABLE void activate(QVariant const& result);
58+ Q_INVOKABLE void activate(QVariant const& result) override;
77− Q_INVOKABLE PreviewStack* preview(QVariant const& result);
59+ Q_INVOKABLE PreviewStack* preview(QVariant const& result) override;
78− Q_INVOKABLE void cancelActivation();
60+ Q_INVOKABLE void cancelActivation() override;
79− Q_INVOKABLE void closeScope(Scope* scope);
61+ Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
80−
81−Q_SIGNALS:
82− void idChanged();
83− void nameChanged(const QString&);
84− void iconHintChanged(const QString&);
85− void descriptionChanged(const QString&);
86− void searchHintChanged(const QString&);
87− void searchInProgressChanged();
88− void visibleChanged(bool);
89− void shortcutChanged(const QString&);
90− void categoriesChanged();
91− //void filtersChanged();
92− void searchQueryChanged();
93− void noResultsHintChanged();
94− void formFactorChanged();
95− void isActiveChanged(bool);
96−
97− // signals triggered by activate(..) or preview(..) requests.
98− void showDash();
99− void hideDash();
100− void gotoUri(const QString &uri);
101− void activated();
102− void previewRequested(QVariant const& result);
103− void gotoScope(QString const& scopeId);
104− void openScope(Scope* scope);
105−
106− void activateApplication(const QString &desktop);
107
62
108protected:
63protected:
109
64
tests/mocks/Unity/fake_scopes.cpp+3−3
@@ -24,11 +24,11 @@
24// Qt
24// Qt
25#include <QTimer>
25#include <QTimer>
26
26
27−Scopes::Scopes(QObject *parent)
27+Scopes::Scopes(QObject *parent) : m_loaded(false)
28−: QAbstractListModel(parent)
29−, m_loaded(false)
30, timer(this)
28, timer(this)
31{
29{
30+ setParent(parent);
31+
32 m_roles[Scopes::RoleScope] = "scope";
32 m_roles[Scopes::RoleScope] = "scope";
33 m_roles[Scopes::RoleId] = "id";
33 m_roles[Scopes::RoleId] = "id";
34 m_roles[Scopes::RoleVisible] = "visible";
34 m_roles[Scopes::RoleVisible] = "visible";
tests/mocks/Unity/fake_scopes.h+7−17
@@ -19,36 +19,27 @@
19#ifndef FAKE_SCOPES_H
19#ifndef FAKE_SCOPES_H
20#define FAKE_SCOPES_H
20#define FAKE_SCOPES_H
21
21
22+#include <unity/shell/scopes/ScopesInterface.h>
23+
22// Local
24// Local
23#include "fake_scope.h"
25#include "fake_scope.h"
24
26
25// Qt
27// Qt
26−#include <QAbstractListModel>
27#include <QList>
28#include <QList>
28#include <QTimer>
29#include <QTimer>
29
30
30−class Scopes : public QAbstractListModel
31+class Scopes : public unity::shell::scopes::ScopesInterface
31{
32{
32 Q_OBJECT
33 Q_OBJECT
33− Q_ENUMS(Roles)
34− Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
35− Q_PROPERTY(int count READ count NOTIFY countChanged)
36
34
37public:
35public:
38 explicit Scopes(QObject *parent = 0);
36 explicit Scopes(QObject *parent = 0);
39 ~Scopes();
37 ~Scopes();
40
38
41− enum Roles {
42− RoleScope,
43− RoleId,
44− RoleVisible,
45− RoleTitle
46− };
47−
48− Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
39+ Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
49
40
50− Q_INVOKABLE QVariant get(int row) const;
41+ Q_INVOKABLE QVariant get(int row) const override;
51− Q_INVOKABLE QVariant get(const QString& scope_id) const;
42+ Q_INVOKABLE QVariant get(const QString& scope_id) const override;
52
43
53 Q_INVOKABLE void addScope(Scope* scope);
44 Q_INVOKABLE void addScope(Scope* scope);
54
45
@@ -59,12 +50,11 @@ public:
59 QHash<int, QByteArray> roleNames() const;
50 QHash<int, QByteArray> roleNames() const;
60 QModelIndex parent ( const QModelIndex & index ) const;
51 QModelIndex parent ( const QModelIndex & index ) const;
61
52
62− bool loaded() const;
53+ bool loaded() const override;
63 int count() const;
54 int count() const;
64
55
65Q_SIGNALS:
56Q_SIGNALS:
66 void activateScopeRequested(const QString& scope_id);
57 void activateScopeRequested(const QString& scope_id);
67− void loadedChanged(bool);
68 void countChanged();
58 void countChanged();
69
59
70private Q_SLOTS:
60private Q_SLOTS: