on xenial help sign in
Use Interface classes from unity-api
c7548f5Albert Astals
qml/Components/PageHeader.qml+1−1
@@ -25,7 +25,7 @@ Item {
25 property bool searchEntryEnabled: false
25 property bool searchEntryEnabled: false
26 property alias searchQuery: searchField.text
26 property alias searchQuery: searchField.text
27 property ListModel searchHistory
27 property ListModel searchHistory
28− property Scope scope
28+ property var scope: null
29 property alias childItem: itemContainer.children
29 property alias childItem: itemContainer.children
30 property alias showBackButton: backButton.visible
30 property alias showBackButton: backButton.visible
31
31
qml/Dash/CardCarousel.qml+2−2
@@ -42,8 +42,8 @@ DashRenderer {
42 cacheBuffer: 1404 // 18px * 13gu * 6
42 cacheBuffer: 1404 // 18px * 13gu * 6
43 model: cardCarousel.model
43 model: cardCarousel.model
44
44
45− onClicked: cardCarousel.clicked(index, itemY)
45+ onClicked: cardCarousel.clicked(index, null)
46− onPressAndHold: cardCarousel.pressAndHold(index, itemY)
46+ onPressAndHold: cardCarousel.pressAndHold(index)
47
47
48 property real fontScale: 1 / selectedItemScaleFactor
48 property real fontScale: 1 / selectedItemScaleFactor
49 property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
49 property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
qml/Dash/CardFilterGrid.qml+2−2
@@ -64,8 +64,8 @@ DashRenderer {
64 }
64 }
65 Connections {
65 Connections {
66 target: loader.item
66 target: loader.item
67− onClicked: genericFilterGrid.clicked(index, item.y)
67+ onClicked: genericFilterGrid.clicked(index, result)
68− onPressAndHold: genericFilterGrid.pressAndHold(index, item.y)
68+ onPressAndHold: genericFilterGrid.pressAndHold(index)
69 }
69 }
70 }
70 }
71 }
71 }
qml/Dash/DashContent.qml+1−1
@@ -138,7 +138,7 @@ Item {
138
138
139 readonly property bool moving: item ? item.moving : false
139 readonly property bool moving: item ? item.moving : false
140 readonly property var categoryView: item ? item.categoryView : null
140 readonly property var categoryView: item ? item.categoryView : null
141− readonly property Scope theScope: scope
141+ readonly property var theScope: scope
142
142
143 // these are needed for autopilot tests
143 // these are needed for autopilot tests
144 readonly property string scopeId: scope.id
144 readonly property string scopeId: scope.id
qml/Dash/DashRenderer.qml+3−4
@@ -50,13 +50,12 @@ Item {
50
50
51 /// Emitted when the user clicked on an item
51 /// Emitted when the user clicked on an item
52 /// @param index is the index of the clicked item
52 /// @param index is the index of the clicked item
53− /// @param itemY is y of the clicked delegate
53+ /// @param result result model of the cliked item, used for activation
54− signal clicked(int index, real itemY)
54+ signal clicked(int index, var result)
55
55
56 /// Emitted when the user pressed and held on an item
56 /// Emitted when the user pressed and held on an item
57 /// @param index is the index of the held item
57 /// @param index is the index of the held item
58− /// @param itemY is y of the held delegate
59− signal pressAndHold(int index, real itemY)
58+ signal pressAndHold(int index)
60
59
61 function setFilter(filter, animate) {
60 function setFilter(filter, animate) {
62 }
61 }
qml/Dash/GenericScopeView.qml+2−3
@@ -25,7 +25,7 @@ import "../Components/ListItems" as ListItems
25FocusScope {
25FocusScope {
26 id: scopeView
26 id: scopeView
27
27
28− property Scope scope: null
28+ property var scope: null
29 property SortFilterProxyModel categories: categoryFilter
29 property SortFilterProxyModel categories: categoryFilter
30 property bool isCurrent: false
30 property bool isCurrent: false
31 property alias moving: categoryView.moving
31 property alias moving: categoryView.moving
@@ -187,8 +187,7 @@ FocusScope {
187 // TODO Technically it is possible that calling activate() will make the scope emit
187 // TODO Technically it is possible that calling activate() will make the scope emit
188 // previewRequested so that we show a preview but there's no scope that does that yet
188 // previewRequested so that we show a preview but there's no scope that does that yet
189 // so it's not implemented
189 // so it's not implemented
190− var item = target.model.get(index);
191− scopeView.scope.activate(item.result)
190+ scopeView.scope.activate(result)
192 } else {
191 } else {
193 previewListView.model = target.model;
192 previewListView.model = target.model;
194 previewListView.currentIndex = -1
193 previewListView.currentIndex = -1
qml/Dash/PreviewListView.qml+2−2
@@ -23,7 +23,7 @@ import "Previews" as Previews
23Item {
23Item {
24 id: root
24 id: root
25
25
26− property Scope scope: null
26+ property var scope: null
27 property var pageHeader: null
27 property var pageHeader: null
28
28
29 property alias open: previewListView.open
29 property alias open: previewListView.open
@@ -116,7 +116,7 @@ Item {
116
116
117 previewModel: {
117 previewModel: {
118 var previewStack = root.scope.preview(result);
118 var previewStack = root.scope.preview(result);
119− return previewStack.get(0);
119+ return previewStack.getPreviewModel(0);
120 }
120 }
121 }
121 }
122
122
qml/ScopeTool.qml+1−1
@@ -74,7 +74,7 @@ Rectangle {
74
74
75 model: filteredScopes
75 model: filteredScopes
76 searchHistory: SearchHistoryModel { }
76 searchHistory: SearchHistoryModel { }
77− property Scope scope: scopes.get(currentIndex)
77+ property var scope: scopes.getScope(currentIndex)
78
78
79 anchors {
79 anchors {
80 top: parent.top
80 top: parent.top
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+6−22
@@ -22,24 +22,9 @@
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)
25+ : unity::shell::scopes::CategoriesInterface(parent)
26 , m_category_count(category_count)
26 , m_category_count(category_count)
27{
27{
28− m_roles[Categories::RoleCategoryId] = "categoryId";
29− m_roles[Categories::RoleName] = "name";
30− m_roles[Categories::RoleIcon] = "icon";
31− m_roles[Categories::RoleRawRendererTemplate] = "rawRendererTemplate";
32− m_roles[Categories::RoleRenderer] = "renderer";
33− m_roles[Categories::RoleComponents] = "components";
34− m_roles[Categories::RoleProgressSource] = "progressSource";
35− m_roles[Categories::RoleResults] = "results";
36− m_roles[Categories::RoleCount] = "count";
37−}
38−
39−QHash<int, QByteArray>
40−Categories::roleNames() const
41−{
42− return m_roles;
43}
28}
44
29
45int Categories::rowCount(const QModelIndex& /*parent*/) const
30int Categories::rowCount(const QModelIndex& /*parent*/) const
@@ -65,6 +50,11 @@ void Categories::addSpecialCategory(QString const& categoryId, QString const& na
65 }
50 }
66}
51}
67
52
53+bool Categories::overrideCategoryJson(QString const& categoryId, QString const& json)
54+{
55+ qFatal("Using un-implemented Categories::overrideCategoryJson");
56+}
57+
68void Categories::countChanged()
58void Categories::countChanged()
69{
59{
70 QObject* countObject = sender();
60 QObject* countObject = sender();
@@ -126,9 +116,6 @@ Categories::data(const QModelIndex& index, int role) const
126 map["title"] = "HOLA";
116 map["title"] = "HOLA";
127 return map;
117 return map;
128 }
118 }
129− case RoleProgressSource:
130− qFatal("Using un-implemented RoleProgressSource Categories role");
131− return QVariant();
132 case RoleResults:
119 case RoleResults:
133 return QVariant();
120 return QVariant();
134 case RoleCount:
121 case RoleCount:
@@ -172,9 +159,6 @@ Categories::data(const QModelIndex& index, int role) const
172 map["subtitle"] = "HOLA";
159 map["subtitle"] = "HOLA";
173 return map;
160 return map;
174 }
161 }
175− case RoleProgressSource:
176− qFatal("Using un-implemented RoleProgressSource Categories role");
177− return QVariant();
178 case RoleResults:
162 case RoleResults:
179 return QVariant::fromValue(resultsModel);
163 return QVariant::fromValue(resultsModel);
180 case RoleCount:
164 case RoleCount:
tests/mocks/Unity/fake_categories.h+5−18
@@ -17,44 +17,31 @@
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;
48 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
35 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
49
36
50− Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject);
37+ Q_INVOKABLE void addSpecialCategory(QString const& categoryId, QString const& name, QString const& icon, QString const& rawTemplate, QObject* countObject) override;
38+ Q_INVOKABLE bool overrideCategoryJson(QString const& categoryId, QString const& json) override;
51
39
52private Q_SLOTS:
40private Q_SLOTS:
53 void countChanged();
41 void countChanged();
54
42
55private:
43private:
56 mutable QHash<int, ResultsModel*> m_resultsModels;
44 mutable QHash<int, ResultsModel*> m_resultsModels;
57− QHash<int, QByteArray> m_roles;
58 int m_category_count;
45 int m_category_count;
59
46
60 struct CategoryData {
47 struct CategoryData {
tests/mocks/Unity/fake_previewmodel.cpp+2−15
@@ -27,22 +27,14 @@
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+ : unity::shell::scopes::PreviewModelInterface(parent)
31{
32{
32 // we have one column by default
33 // we have one column by default
33 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
34 PreviewWidgetModel* columnModel = new PreviewWidgetModel(this);
34 m_previewWidgetModels.append(columnModel);
35 m_previewWidgetModels.append(columnModel);
35}
36}
36
37
37−QHash<int, QByteArray> PreviewModel::roleNames() const
38−{
39− QHash<int, QByteArray> roles;
40−
41− roles[Roles::RoleColumnModel] = "columnModel";
42−
43− return roles;
44−}
45−
46void PreviewModel::setWidgetColumnCount(int count)
38void PreviewModel::setWidgetColumnCount(int count)
47{
39{
48 if (count != 1) {
40 if (count != 1) {
@@ -65,11 +57,6 @@ bool PreviewModel::processingAction() const
65 return false;
57 return false;
66}
58}
67
59
68−void PreviewModel::setProcessingAction(bool /*processing*/)
69−{
70− qFatal("PreviewModel::setProcessingAction not implemented");
71−}
72−
73int PreviewModel::rowCount(const QModelIndex&) const
60int PreviewModel::rowCount(const QModelIndex&) const
74{
61{
75 return m_previewWidgetModels.size();
62 return m_previewWidgetModels.size();
tests/mocks/Unity/fake_previewmodel.h+7−25
@@ -18,47 +18,29 @@
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;
46 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
47
37
48− void setWidgetColumnCount(int count);
38+ void setWidgetColumnCount(int count) override;
49− int widgetColumnCount() const;
39+ int widgetColumnCount() const override;
50− bool loaded() const;
40+ bool loaded() const override;
51− bool processingAction() const;
41+ bool processingAction() const override;
52− void setProcessingAction(bool processing);
53−
54−Q_SIGNALS:
55− void widgetColumnCountChanged();
56− void loadedChanged();
57− void processingActionChanged();
58− void triggered(QString const&, QString const&, QVariantMap const&);
59
42
60private:
43private:
61− QHash<int, QByteArray> m_roles;
62 QList<PreviewWidgetModel*> m_previewWidgetModels;
44 QList<PreviewWidgetModel*> m_previewWidgetModels;
63};
45};
64
46
tests/mocks/Unity/fake_previewstack.cpp+3−11
@@ -21,7 +21,8 @@
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+ : unity::shell::scopes::PreviewStackInterface(parent)
25{
26{
26 m_previews << new PreviewModel(this);
27 m_previews << new PreviewModel(this);
27}
28}
@@ -30,15 +31,6 @@ PreviewStack::~PreviewStack()
30{
31{
31}
32}
32
33
33−QHash<int, QByteArray> PreviewStack::roleNames() const
34−{
35− QHash<int, QByteArray> roles;
36−
37− roles[Roles::RolePreviewModel] = "previewModel";
38−
39− return roles;
40−}
41−
42void PreviewStack::setWidgetColumnCount(int columnCount)
34void PreviewStack::setWidgetColumnCount(int columnCount)
43{
35{
44 if (columnCount != 1) {
36 if (columnCount != 1) {
@@ -56,7 +48,7 @@ int PreviewStack::rowCount(const QModelIndex&) const
56 return m_previews.size();
48 return m_previews.size();
57}
49}
58
50
59−PreviewModel* PreviewStack::get(int index) const
51+unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
60{
52{
61 if (index >= m_previews.size()) {
53 if (index >= m_previews.size()) {
62 return nullptr;
54 return nullptr;
tests/mocks/Unity/fake_previewstack.h+6−17
@@ -18,39 +18,28 @@
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;
45 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
37 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
46
38
47− Q_INVOKABLE PreviewModel* get(int index) const;
39+ Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
48−
49− void setWidgetColumnCount(int columnCount);
50− int widgetColumnCount() const;
51
40
52−Q_SIGNALS:
41+ void setWidgetColumnCount(int columnCount) override;
53− void widgetColumnCountChanged();
42+ int widgetColumnCount() const override;
54
43
55private:
44private:
56 QList<PreviewModel*> m_previews;
45 QList<PreviewModel*> m_previews;
tests/mocks/Unity/fake_previewwidgetmodel.cpp+2−10
@@ -35,12 +35,9 @@ struct PreviewData
35 }
35 }
36};
36};
37
37
38−PreviewWidgetModel::PreviewWidgetModel(QObject* parent) : QAbstractListModel(parent)
38+PreviewWidgetModel::PreviewWidgetModel(QObject* parent)
39+ : unity::shell::scopes::PreviewWidgetModelInterface(parent)
39{
40{
40− m_roles[Roles::RoleWidgetId] = "widgetId";
41− m_roles[Roles::RoleType] = "type";
42− m_roles[Roles::RoleProperties] = "properties";
43−
44 populateWidgets();
41 populateWidgets();
45}
42}
46
43
@@ -60,11 +57,6 @@ void PreviewWidgetModel::populateWidgets()
60
57
61}
58}
62
59
63−QHash<int, QByteArray> PreviewWidgetModel::roleNames() const
64−{
65− return m_roles;
66−}
67−
68int PreviewWidgetModel::rowCount(const QModelIndex&) const
60int PreviewWidgetModel::rowCount(const QModelIndex&) const
69{
61{
70 return m_previewWidgets.size();
62 return m_previewWidgets.size();
tests/mocks/Unity/fake_previewwidgetmodel.h+3−12
@@ -18,33 +18,24 @@
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;
44 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
36 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
45
37
46private:
38private:
47− QHash<int, QByteArray> m_roles;
48 QList<QSharedPointer<PreviewData>> m_previewWidgets;
39 QList<QSharedPointer<PreviewData>> m_previewWidgets;
49
40
50 void populateWidgets();
41 void populateWidgets();
tests/mocks/Unity/fake_resultsmodel.cpp+1−44
@@ -23,25 +23,10 @@
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)
26+ : unity::shell::scopes::ResultsModelInterface(parent)
27 , m_result_count(result_count)
27 , m_result_count(result_count)
28 , m_categoryId(categoryId)
28 , m_categoryId(categoryId)
29{
29{
30− m_roles[ResultsModel::RoleUri] = "uri";
31− m_roles[ResultsModel::RoleCategoryId] = "categoryId";
32− m_roles[ResultsModel::RoleDndUri] = "dndUri";
33− m_roles[ResultsModel::RoleResult] = "result";
34− m_roles[ResultsModel::RoleTitle] = "title";
35− m_roles[ResultsModel::RoleArt] = "art";
36− m_roles[ResultsModel::RoleSubtitle] = "subtitle";
37− m_roles[ResultsModel::RoleMascot] = "mascot";
38− 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";
45}
30}
46
31
47QString ResultsModel::categoryId() const
32QString ResultsModel::categoryId() const
@@ -54,12 +39,6 @@ void ResultsModel::setCategoryId(QString const& /*id*/)
54 qFatal("Calling un-implemented ResultsModel::setCategoryId");
39 qFatal("Calling un-implemented ResultsModel::setCategoryId");
55}
40}
56
41
57−QHash<int, QByteArray>
58−ResultsModel::roleNames() const
59−{
60− return m_roles;
61−}
62−
63int ResultsModel::rowCount(const QModelIndex& parent) const
42int ResultsModel::rowCount(const QModelIndex& parent) const
64{
43{
65 Q_UNUSED(parent);
44 Q_UNUSED(parent);
@@ -72,23 +51,6 @@ int ResultsModel::count() const
72 return rowCount();
51 return rowCount();
73}
52}
74
53
75−QVariant ResultsModel::get(int row) const
76−{
77− if (row >= m_result_count || row < 0) return QVariantMap();
78−
79− QVariantMap result;
80− QModelIndex modelIndex(index(row));
81− QHashIterator<int, QByteArray> it(roleNames());
82− while (it.hasNext()) {
83− it.next();
84− QVariant val(data(modelIndex, it.key()));
85− if (val.isNull()) continue;
86− result[it.value()] = val;
87− }
88−
89− return result;
90−}
91−
92QVariant
54QVariant
93ResultsModel::data(const QModelIndex& index, int role) const
55ResultsModel::data(const QModelIndex& index, int role) const
94{
56{
@@ -106,11 +68,6 @@ ResultsModel::data(const QModelIndex& index, int role) const
106 return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
68 return QString("Subtitle.%1.%2").arg(m_categoryId).arg(index.row());
107 case RoleMascot:
69 case RoleMascot:
108 case RoleEmblem:
70 case RoleEmblem:
109− case RoleOldPrice:
110− case RolePrice:
111− case RoleAltPrice:
112− case RoleRating:
113− case RoleAltRating:
114 case RoleSummary:
71 case RoleSummary:
115 default:
72 default:
116 return QVariant();
73 return QVariant();
tests/mocks/Unity/fake_resultsmodel.h+5−37
@@ -21,58 +21,26 @@
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;
59 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
34 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
60
35
61− Q_INVOKABLE QVariant get(int row) const;
62−
63 /* getters */
36 /* getters */
64− QString categoryId() const;
37+ QString categoryId() const override;
65− int count() const;
38+ int count() const override;
66
39
67 /* setters */
40 /* setters */
68− void setCategoryId(QString const& id);
41+ void setCategoryId(QString const& id) override;
69−
70−Q_SIGNALS:
71− void categoryIdChanged();
72− void countChanged();
73
42
74private:
43private:
75− QHash<int, QByteArray> m_roles;
76 int m_result_count;
44 int m_result_count;
77 int m_categoryId;
45 int m_categoryId;
78};
46};
tests/mocks/Unity/fake_scope.cpp+3−14
@@ -22,7 +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)
25+ : unity::shell::scopes::ScopeInterface(parent)
26 , m_id(id)
26 , m_id(id)
27 , m_name(name)
27 , m_name(name)
28 , m_visible(visible)
28 , m_visible(visible)
@@ -61,15 +61,11 @@ 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}
71
67
72−Categories* Scope::categories() const {
68+unity::shell::scopes::CategoriesInterface* Scope::categories() const {
73 return m_categories;
69 return m_categories;
74}
70}
75
71
@@ -89,13 +85,6 @@ bool Scope::isActive() const {
89 return m_isActive;
85 return m_isActive;
90}
86}
91
87
92−void Scope::setName(const QString &str) {
93− if (str != m_name) {
94− m_name = str;
95− Q_EMIT nameChanged(m_name);
96− }
97−}
98−
99void Scope::setSearchQuery(const QString &str) {
88void Scope::setSearchQuery(const QString &str) {
100 if (str != m_searchQuery) {
89 if (str != m_searchQuery) {
101 m_searchQuery = str;
90 m_searchQuery = str;
@@ -149,7 +138,7 @@ void Scope::cancelActivation()
149{
138{
150}
139}
151
140
152−void Scope::closeScope(Scope* /*scope*/)
141+void Scope::closeScope(unity::shell::scopes::ScopeInterface* /*scope*/)
153{
142{
154 qFatal("Scope::closeScope is not implemented");
143 qFatal("Scope::closeScope is not implemented");
155}
144}
tests/mocks/Unity/fake_scope.h+26−72
@@ -17,93 +17,47 @@
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+ unity::shell::scopes::CategoriesInterface* 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);
70− void setSearchQuery(const QString& search_query);
51+ void setSearchQuery(const QString& search_query) override;
71− void setNoResultsHint(const QString& hint);
52+ void setNoResultsHint(const QString& hint) override;
72− void setFormFactor(const QString& form_factor);
53+ void setFormFactor(const QString& form_factor) override;
73− void setActive(const bool);
54+ void setActive(const bool) override;
74− void setSearchInProgress(const bool inProg);
55+ Q_INVOKABLE void setSearchInProgress(const bool inProg); // This is not invokable in the Interface, here for testing benefits
75−
56+
76− Q_INVOKABLE void activate(QVariant const& result);
57+ Q_INVOKABLE void activate(QVariant const& result) override;
77− Q_INVOKABLE PreviewStack* preview(QVariant const& result);
58+ Q_INVOKABLE PreviewStack* preview(QVariant const& result) override;
78− Q_INVOKABLE void cancelActivation();
59+ Q_INVOKABLE void cancelActivation() override;
79− Q_INVOKABLE void closeScope(Scope* scope);
60+ 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
61
108protected:
62protected:
109
63
tests/mocks/Unity/fake_scopes.cpp+11−22
@@ -25,15 +25,10 @@
25#include <QTimer>
25#include <QTimer>
26
26
27Scopes::Scopes(QObject *parent)
27Scopes::Scopes(QObject *parent)
28−: QAbstractListModel(parent)
28+ : unity::shell::scopes::ScopesInterface(parent)
29−, m_loaded(false)
29+ , m_loaded(false)
30−, timer(this)
30+ , timer(this)
31{
31{
32− m_roles[Scopes::RoleScope] = "scope";
33− m_roles[Scopes::RoleId] = "id";
34− m_roles[Scopes::RoleVisible] = "visible";
35− m_roles[Scopes::RoleTitle] = "title";
36−
37 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
32 QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
38 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
33 QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
39 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
34 QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
@@ -83,11 +78,6 @@ void Scopes::load()
83 timer.start();
78 timer.start();
84}
79}
85
80
86−QHash<int, QByteArray> Scopes::roleNames() const
87−{
88− return m_roles;
89−}
90−
91int Scopes::rowCount(const QModelIndex&) const
81int Scopes::rowCount(const QModelIndex&) const
92{
82{
93 return m_scopes.count();
83 return m_scopes.count();
@@ -114,14 +104,18 @@ QVariant Scopes::data(const QModelIndex& index, int role) const
114 }
104 }
115}
105}
116
106
117−QVariant Scopes::get(int row) const
107+unity::shell::scopes::ScopeInterface* Scopes::getScope(int row) const
118{
108{
119− return data(QAbstractListModel::index(row), 0);
109+ if (row < 0 || row >= m_scopes.size()) {
110+ return nullptr;
111+ }
112+
113+ return m_scopes[row];
120}
114}
121
115
122−QVariant Scopes::get(QString const&) const
116+unity::shell::scopes::ScopeInterface* Scopes::getScope(QString const&) const
123{
117{
124− return QVariant();
118+ return nullptr;
125}
119}
126
120
127QModelIndex Scopes::parent(const QModelIndex&) const
121QModelIndex Scopes::parent(const QModelIndex&) const
@@ -134,11 +128,6 @@ bool Scopes::loaded() const
134 return m_loaded;
128 return m_loaded;
135}
129}
136
130
137−int Scopes::count() const
138−{
139− return rowCount();
140−}
141−
142void Scopes::addScope(Scope* scope)
131void Scopes::addScope(Scope* scope)
143{
132{
144 int index = rowCount();
133 int index = rowCount();
tests/mocks/Unity/fake_scopes.h+7−24
@@ -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 unity::shell::scopes::ScopeInterface* getScope(int row) const override;
51− Q_INVOKABLE QVariant get(const QString& scope_id) const;
42+ Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(const QString& scope_id) const override;
52
43
53 Q_INVOKABLE void addScope(Scope* scope);
44 Q_INVOKABLE void addScope(Scope* scope);
54
45
@@ -56,23 +47,15 @@ public:
56 Q_INVOKABLE void load();
47 Q_INVOKABLE void load();
57
48
58 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
49 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
59− QHash<int, QByteArray> roleNames() const;
60 QModelIndex parent ( const QModelIndex & index ) const;
50 QModelIndex parent ( const QModelIndex & index ) const;
61
51
62− bool loaded() const;
52+ bool loaded() const override;
63− int count() const;
64−
65−Q_SIGNALS:
66− void activateScopeRequested(const QString& scope_id);
67− void loadedChanged(bool);
68− void countChanged();
69
53
70private Q_SLOTS:
54private Q_SLOTS:
71 void updateScopes();
55 void updateScopes();
72
56
73private:
57private:
74 QList<Scope*> m_scopes;
58 QList<Scope*> m_scopes;
75− QHash<int, QByteArray> m_roles;
76 bool m_loaded;
59 bool m_loaded;
77 QTimer timer;
60 QTimer timer;
78};
61};
tests/mocks/Unity/fake_unity_plugin.cpp+3−2
@@ -40,8 +40,9 @@ void FakeUnityPlugin::registerTypes(const char *uri)
40 Q_ASSERT(uri == QLatin1String("Unity"));
40 Q_ASSERT(uri == QLatin1String("Unity"));
41
41
42 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
42 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
43− qmlRegisterType<Scope>(uri, 0, 2, "Scope");
43+ qmlRegisterType<Scope>(uri, 0, 2, "MockScope");
44+ qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
44− qmlRegisterUncreatableType<Categories>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
45+ qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
45 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
46 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
46 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
47 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
47 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
48 qmlRegisterUncreatableType<PreviewWidgetModel>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
tests/qmltests/Components/tst_PageHeaderLabel.qml+4−4
@@ -26,7 +26,7 @@ Item {
26 width: units.gu(110)
26 width: units.gu(110)
27 height: units.gu(30)
27 height: units.gu(30)
28
28
29− Scope {
29+ MockScope {
30 id: scopeMock
30 id: scopeMock
31 }
31 }
32
32
@@ -148,17 +148,17 @@ Item {
148
148
149 pageHeader.triggerSearch()
149 pageHeader.triggerSearch()
150
150
151− scopeMock.searchInProgress = false
151+ scopeMock.setSearchInProgress(false);
152 compare(searchIndicator.running, false, "Search indicator is running.")
152 compare(searchIndicator.running, false, "Search indicator is running.")
153 tryCompare(primaryImage, "visible", true)
153 tryCompare(primaryImage, "visible", true)
154
154
155− scopeMock.searchInProgress = true
155+ scopeMock.setSearchInProgress(true);
156 compare(searchIndicator.running, true, "Search indicator isn't running.")
156 compare(searchIndicator.running, true, "Search indicator isn't running.")
157 tryCompare(primaryImage, "visible", false)
157 tryCompare(primaryImage, "visible", false)
158 }
158 }
159
159
160 function cleanup() {
160 function cleanup() {
161− scopeMock.searchInProgress = false;
161+ scopeMock.setSearchInProgress(false);
162 pageHeader.resetSearch();
162 pageHeader.resetSearch();
163 }
163 }
164
164
tests/qmltests/Dash/tst_DashContent.qml+5−5
@@ -166,7 +166,7 @@ Item {
166
166
167 // test greater than scope count.
167 // test greater than scope count.
168 var currentScopeIndex = dashContent.currentIndex;
168 var currentScopeIndex = dashContent.currentIndex;
169− dashContent.setCurrentScopeAtIndex(scopesModel.count, true, false);
169+ dashContent.setCurrentScopeAtIndex(8, true, false);
170 compare(dashContent.currentIndex, currentScopeIndex, "Scope should not change if changing to greater index than count");
170 compare(dashContent.currentIndex, currentScopeIndex, "Scope should not change if changing to greater index than count");
171 }
171 }
172
172
@@ -195,7 +195,7 @@ Item {
195 dashContent.setCurrentScopeAtIndex(data.index, true, false);
195 dashContent.setCurrentScopeAtIndex(data.index, true, false);
196 tryCompareFunction(get_current_item_object_name, data.objectName)
196 tryCompareFunction(get_current_item_object_name, data.objectName)
197 var pageHeader = findChild(dashContent, "pageHeader");
197 var pageHeader = findChild(dashContent, "pageHeader");
198− compare(pageHeader.scope, scopesModel.get(data.index));
198+ compare(pageHeader.scope, scopesModel.getScope(data.index));
199 }
199 }
200
200
201 function test_is_active_data() {
201 function test_is_active_data() {
@@ -212,9 +212,9 @@ Item {
212 dashContent.setCurrentScopeAtIndex(data.select, true, false);
212 dashContent.setCurrentScopeAtIndex(data.select, true, false);
213 dashContent.visible = data.visible;
213 dashContent.visible = data.visible;
214
214
215− tryCompare(scopesModel.get(0), "isActive", data.active0);
215+ tryCompare(scopesModel.getScope(0), "isActive", data.active0);
216− tryCompare(scopesModel.get(1), "isActive", data.active1);
216+ tryCompare(scopesModel.getScope(1), "isActive", data.active1);
217− tryCompare(scopesModel.get(2), "isActive", data.active2);
217+ tryCompare(scopesModel.getScope(2), "isActive", data.active2);
218 }
218 }
219
219
220 function doFindMusicButton(parent) {
220 function doFindMusicButton(parent) {
tests/qmltests/Dash/tst_GenericScopeView.qml+10−10
@@ -39,7 +39,7 @@ Item {
39 id: scopes
39 id: scopes
40
40
41 onLoadedChanged: {
41 onLoadedChanged: {
42− genericScopeView.scope = scopes.get(2)
42+ genericScopeView.scope = scopes.getScope(2)
43 }
43 }
44 }
44 }
45
45
@@ -67,7 +67,7 @@ Item {
67 when: scopes.loaded && windowShown
67 when: scopes.loaded && windowShown
68
68
69 function init() {
69 function init() {
70− genericScopeView.scope = scopes.get(2)
70+ genericScopeView.scope = scopes.getScope(2)
71 shell.width = units.gu(120)
71 shell.width = units.gu(120)
72 genericScopeView.categoryView.positionAtBeginning();
72 genericScopeView.categoryView.positionAtBeginning();
73 tryCompare(genericScopeView.categoryView, "contentY", 0)
73 tryCompare(genericScopeView.categoryView, "contentY", 0)
@@ -96,31 +96,31 @@ Item {
96
96
97 function test_showDash() {
97 function test_showDash() {
98 previewListView.open = true;
98 previewListView.open = true;
99− scopes.get(2).showDash();
99+ scopes.getScope(2).showDash();
100 tryCompare(previewListView, "open", false);
100 tryCompare(previewListView, "open", false);
101 }
101 }
102
102
103 function test_hideDash() {
103 function test_hideDash() {
104 previewListView.open = true;
104 previewListView.open = true;
105− scopes.get(2).hideDash();
105+ scopes.getScope(2).hideDash();
106 tryCompare(previewListView, "open", false);
106 tryCompare(previewListView, "open", false);
107 }
107 }
108
108
109 function test_searchQuery() {
109 function test_searchQuery() {
110− genericScopeView.scope = scopes.get(0);
110+ genericScopeView.scope = scopes.getScope(0);
111 genericScopeView.scope.searchQuery = "test";
111 genericScopeView.scope.searchQuery = "test";
112− genericScopeView.scope = scopes.get(1);
112+ genericScopeView.scope = scopes.getScope(1);
113 genericScopeView.scope.searchQuery = "test2";
113 genericScopeView.scope.searchQuery = "test2";
114− genericScopeView.scope = scopes.get(0);
114+ genericScopeView.scope = scopes.getScope(0);
115 tryCompare(genericScopeView.scope, "searchQuery", "test");
115 tryCompare(genericScopeView.scope, "searchQuery", "test");
116− genericScopeView.scope = scopes.get(1);
116+ genericScopeView.scope = scopes.getScope(1);
117 tryCompare(genericScopeView.scope, "searchQuery", "test2");
117 tryCompare(genericScopeView.scope, "searchQuery", "test2");
118 }
118 }
119
119
120 function test_changeScope() {
120 function test_changeScope() {
121 genericScopeView.scope.searchQuery = "test"
121 genericScopeView.scope.searchQuery = "test"
122− genericScopeView.scope = scopes.get(1)
122+ genericScopeView.scope = scopes.getScope(1)
123− genericScopeView.scope = scopes.get(2)
123+ genericScopeView.scope = scopes.getScope(2)
124 tryCompare(genericScopeView.scope, "searchQuery", "test")
124 tryCompare(genericScopeView.scope, "searchQuery", "test")
125 }
125 }
126
126