Merge lp:~unity-team/unity-api/departments into lp:unity-api

Proposed by Albert Astals Cid
Status: Merged
Approved by: Michael Zanetti
Approved revision: 145
Merged at revision: 138
Proposed branch: lp:~unity-team/unity-api/departments
Merge into: lp:unity-api
Diff against target: 626 lines (+405/-12)
11 files modified
debian/changelog (+6/-0)
include/unity/shell/scopes/DepartmentInterface.h (+135/-0)
include/unity/shell/scopes/ScopeInterface.h (+34/-7)
include/unity/shell/scopes/ScopesInterface.h (+1/-1)
test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt (+2/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp (+84/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.h (+45/-0)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp (+23/-2)
test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h (+6/-0)
test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp (+2/-0)
test/qmltest/unity/shell/scopes/tst_Scopes.qml (+67/-2)
To merge this branch: bzr merge lp:~unity-team/unity-api/departments
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Michal Hruby (community) Approve
Review via email: mp+221241@code.launchpad.net

Commit message

Add Departments interfaces

Description of the change

* Are there any related MPs required for this MP to build/function as expected?
Not required, but this should land together with
 https://code.launchpad.net/~aacid/unity8/departments/+merge/221072
and
 https://code.launchpad.net/~mhr3/unity-scopes-shell/department-support

 * Did you perform an exploratory manual test run of your code change and any related functionality?
Yes, tests work, also https://code.launchpad.net/~aacid/unity8/departments/+merge/221072 compiles and make tryDashContent works

 * Did you make sure that your branch does not contain spurious tags?
Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
It's a minor change, not needed

 * If you changed the UI, has there been a design review?
N/A

To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

421 + { tag: "Department[ScopesInterface]", type: "unity::shell::scopes::DepartmentInterface" },

ScopesInterface? Is that right? You also forgot to bzr add MockDepartment.*

Revision history for this message
Albert Astals Cid (aacid) wrote :

Fixed

Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michal Hruby (mhr3) wrote :

+1

review: Approve
Revision history for this message
Michael Zanetti (mzanetti) wrote :

61 + Q_PROPERTY(QString departmentId READ departmentId NOTIFY departmentIdChanged)
76 + Q_PROPERTY(QString parentId READ parentId NOTIFY parentIdChanged)

Just a general comment (feel free to ignore if you don't agree): A consistent API would probably go for "id" and "parentId" or "departmentId" and "parentDepartmentId".

====

91 + Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)

isn't this redundant with an empty parentId?

=====

173 + Q_PROPERTY(QString currentDepartment READ currentDepartment NOTIFY currentDepartmentChanged)

Does this refer to the departmentId or the department label?

====

Wouldn't it make sense to have isActive and hasChildren also as Department properties instead only in the model roles?

review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

> 61 + Q_PROPERTY(QString departmentId READ departmentId NOTIFY
> departmentIdChanged)
> 76 + Q_PROPERTY(QString parentId READ parentId NOTIFY parentIdChanged)
>
> Just a general comment (feel free to ignore if you don't agree): A consistent
> API would probably go for "id" and "parentId" or "departmentId" and
> "parentDepartmentId".

yeah, maybe parentDepartmentId?

>
>
> ====
>
> 91 + Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
>
> isn't this redundant with an empty parentId?

No, empty departmentId is a valid departmentId (sadly)

>
>
> =====
>
> 173 + Q_PROPERTY(QString currentDepartment READ currentDepartment NOTIFY
> currentDepartmentChanged)
>
> Does this refer to the departmentId or the department label?

departmentId, maybe rename to currentDepartmentId to make it more obvious?

>
>
> ====
>
> Wouldn't it make sense to have isActive and hasChildren also as Department
> properties instead only in the model roles?

We don't have a use case for them so i'd prefer to keep the API smaller.

Revision history for this message
Michal Hruby (mhr3) wrote :

> Just a general comment (feel free to ignore if you don't agree): A consistent
> API would probably go for "id" and "parentId" or "departmentId" and
> "parentDepartmentId".

We'd like id + parentId too, but QML doesn't like if objects have their own .id property.

lp:~unity-team/unity-api/departments updated
144. By Albert Astals Cid

Changes due to review

Revision history for this message
Albert Astals Cid (aacid) wrote :

Changes made with the aggreement of Michal

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

For the part Michal did, approve

review: Approve
Revision history for this message
Michael Zanetti (mzanetti) :
lp:~unity-team/unity-api/departments updated
145. By Albert Astals Cid

Add the two new methods to the test

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?

N/A

 * Did CI run pass? If not, please explain why.

Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-05-28 10:38:05 +0000
3+++ debian/changelog 2014-05-29 12:26:08 +0000
4@@ -1,3 +1,9 @@
5+unity-api (7.82) UNRELEASED; urgency=medium
6+
7+ * Add interfaces for scope departments.
8+
9+ -- Albert Astals Cid <albert.astals@canonical.com> Thu, 15 May 2014 17:20:44 +0200
10+
11 unity-api (7.81+14.10.20140528-0ubuntu1) utopic; urgency=low
12
13 [ Michael Zanetti ]
14
15=== added file 'include/unity/shell/scopes/DepartmentInterface.h'
16--- include/unity/shell/scopes/DepartmentInterface.h 1970-01-01 00:00:00 +0000
17+++ include/unity/shell/scopes/DepartmentInterface.h 2014-05-29 12:26:08 +0000
18@@ -0,0 +1,135 @@
19+/*
20+ * Copyright (C) 2014 Canonical, Ltd.
21+ *
22+ * This program is free software; you can redistribute it and/or modify
23+ * it under the terms of the GNU General Public License as published by
24+ * the Free Software Foundation; version 3.
25+ *
26+ * This program is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU General Public License
32+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
35+#ifndef UNITY_SHELL_SCOPES_DEPARTMENTINTERFACE_H
36+#define UNITY_SHELL_SCOPES_DEPARTMENTINTERFACE_H
37+
38+#include <unity/SymbolExport.h>
39+
40+#include <QAbstractListModel>
41+
42+namespace unity
43+{
44+namespace shell
45+{
46+namespace scopes
47+{
48+
49+/**
50+ * @brief Object representing department instance, which exposes model(s) with results.
51+ */
52+class UNITY_API DepartmentInterface : public QAbstractListModel
53+{
54+ Q_OBJECT
55+
56+ Q_ENUMS(Roles)
57+
58+ /**
59+ * @brief Id of the department.
60+ */
61+ Q_PROPERTY(QString departmentId READ departmentId NOTIFY departmentIdChanged)
62+
63+ /**
64+ * @brief Label of the department.
65+ */
66+ Q_PROPERTY(QString label READ label NOTIFY labelChanged)
67+
68+ /**
69+ * @brief Label for "All Button" of the department.
70+ */
71+ Q_PROPERTY(QString allLabel READ allLabel NOTIFY allLabelChanged)
72+
73+ /**
74+ * @brief Parent Id of the department.
75+ */
76+ Q_PROPERTY(QString parentDepartmentId READ parentDepartmentId NOTIFY parentDepartmentIdChanged)
77+
78+ /**
79+ * @brief Parent label of the department.
80+ */
81+ Q_PROPERTY(QString parentLabel READ parentLabel NOTIFY parentLabelChanged)
82+
83+ /**
84+ * @brief Is the model of the deparment completely loaded?
85+ */
86+ Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
87+
88+ /**
89+ * @brief Is this deparment the root deparment?
90+ */
91+ Q_PROPERTY(bool isRoot READ isRoot NOTIFY isRootChanged)
92+
93+ /**
94+ * @brief Number of items of the deparment.
95+ */
96+ Q_PROPERTY(int count READ count NOTIFY countChanged)
97+
98+protected:
99+ /// @cond
100+ explicit DepartmentInterface(QObject* parent = 0) : QAbstractListModel(parent) { }
101+ /// @endcond
102+
103+public:
104+ /**
105+ * @brief The roles supported by this model.
106+ */
107+ enum Roles {
108+ RoleDepartmentId,
109+ RoleLabel,
110+ RoleHasChildren,
111+ RoleIsActive
112+ };
113+
114+ // @cond
115+ virtual QString departmentId() const = 0;
116+ virtual QString label() const = 0;
117+ virtual QString allLabel() const = 0;
118+ virtual QString parentDepartmentId() const = 0;
119+ virtual QString parentLabel() const = 0;
120+ virtual bool loaded() const = 0;
121+ virtual bool isRoot() const = 0;
122+ virtual int count() const = 0;
123+ QHash<int, QByteArray> roleNames() const override
124+ {
125+ QHash<int, QByteArray> roles;
126+ roles[RoleDepartmentId] = "departmentId";
127+ roles[RoleLabel] = "label";
128+ roles[RoleHasChildren] = "hasChildren";
129+ roles[RoleIsActive] = "isActive";
130+ return roles;
131+ }
132+ // @endcond
133+
134+Q_SIGNALS:
135+ // @cond
136+ void departmentIdChanged();
137+ void labelChanged();
138+ void allLabelChanged();
139+ void parentDepartmentIdChanged();
140+ void parentLabelChanged();
141+ void loadedChanged();
142+ void isRootChanged();
143+ void countChanged();
144+ // @endcond
145+};
146+
147+}
148+}
149+}
150+
151+Q_DECLARE_METATYPE(unity::shell::scopes::DepartmentInterface*)
152+
153+#endif
154
155=== modified file 'include/unity/shell/scopes/ScopeInterface.h'
156--- include/unity/shell/scopes/ScopeInterface.h 2014-05-19 11:45:31 +0000
157+++ include/unity/shell/scopes/ScopeInterface.h 2014-05-29 12:26:08 +0000
158@@ -30,6 +30,7 @@
159
160 class CategoriesInterface;
161 class PreviewStackInterface;
162+class DepartmentInterface;
163
164 /**
165 * @brief Object representing scope instance, which exposes model(s) with results.
166@@ -109,6 +110,16 @@
167 */
168 Q_PROPERTY(bool isActive READ isActive WRITE setActive NOTIFY isActiveChanged)
169
170+ /**
171+ * @brief String specifying currently selected department
172+ */
173+ Q_PROPERTY(QString currentDepartmentId READ currentDepartmentId NOTIFY currentDepartmentIdChanged)
174+
175+ /**
176+ * @brief Boolean specifying whether current query has departments.
177+ */
178+ Q_PROPERTY(bool hasDepartments READ hasDepartments NOTIFY hasDepartmentsChanged)
179+
180 protected:
181 /// @cond
182 explicit ScopeInterface(QObject* parent = 0) : QObject(parent) { }
183@@ -130,6 +141,8 @@
184 virtual QString noResultsHint() const = 0;
185 virtual QString formFactor() const = 0;
186 virtual bool isActive() const = 0;
187+ virtual QString currentDepartmentId() const = 0;
188+ virtual bool hasDepartments() const = 0;
189
190 /* setters */
191 virtual void setSearchQuery(const QString& search_query) = 0;
192@@ -161,21 +174,35 @@
193 */
194 Q_INVOKABLE virtual void closeScope(unity::shell::scopes::ScopeInterface* scope) = 0;
195
196+ /**
197+ * @brief Get a DepartmentInterface instance for the passed departmentId.
198+ */
199+ Q_INVOKABLE virtual unity::shell::scopes::DepartmentInterface* getDepartment(QString const& departmentId) = 0;
200+
201+ /**
202+ * @brief Activate department by its id.
203+ *
204+ * This effectively runs a new query.
205+ */
206+ Q_INVOKABLE virtual void loadDepartment(QString const& departmentId) = 0;
207+
208 Q_SIGNALS:
209 // @cond
210 void idChanged();
211- void nameChanged(const QString&);
212- void iconHintChanged(const QString&);
213- void descriptionChanged(const QString&);
214- void searchHintChanged(const QString&);
215+ void nameChanged();
216+ void iconHintChanged();
217+ void descriptionChanged();
218+ void searchHintChanged();
219 void searchInProgressChanged();
220- void visibleChanged(bool);
221- void shortcutChanged(const QString&);
222+ void visibleChanged();
223+ void shortcutChanged();
224 void categoriesChanged();
225 void searchQueryChanged();
226 void noResultsHintChanged();
227 void formFactorChanged();
228- void isActiveChanged(bool);
229+ void isActiveChanged();
230+ void hasDepartmentsChanged();
231+ void currentDepartmentIdChanged();
232 // @endcond
233
234 // signals triggered by activate(..) or preview(..) requests.
235
236=== modified file 'include/unity/shell/scopes/ScopesInterface.h'
237--- include/unity/shell/scopes/ScopesInterface.h 2014-05-19 11:45:10 +0000
238+++ include/unity/shell/scopes/ScopesInterface.h 2014-05-29 12:26:08 +0000
239@@ -93,7 +93,7 @@
240
241 Q_SIGNALS:
242 // @cond
243- void loadedChanged(bool loaded);
244+ void loadedChanged();
245 // @endcond
246 };
247
248
249=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt'
250--- test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2014-05-13 13:52:12 +0000
251+++ test/qmltest/mocks/plugins/Unity/Scopes/CMakeLists.txt 2014-05-29 12:26:08 +0000
252@@ -12,6 +12,7 @@
253
254 set(ScopesMocks_SOURCES
255 Mocks/MockCategories.cpp
256+ Mocks/MockDepartment.cpp
257 Mocks/MockResultsModel.cpp
258 Mocks/MockPreviewModel.cpp
259 Mocks/MockPreviewStack.cpp
260@@ -19,6 +20,7 @@
261 Mocks/MockScope.cpp
262 Mocks/MockScopes.cpp
263 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/CategoriesInterface.h
264+ ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/DepartmentInterface.h
265 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/ResultsModelInterface.h
266 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewModelInterface.h
267 ${CMAKE_SOURCE_DIR}/include/unity/shell/scopes/PreviewWidgetModelInterface.h
268
269=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp'
270--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 1970-01-01 00:00:00 +0000
271+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.cpp 2014-05-29 12:26:08 +0000
272@@ -0,0 +1,84 @@
273+/*
274+ * Copyright (C) 2014 Canonical, Ltd.
275+ *
276+ * This program is free software; you can redistribute it and/or modify
277+ * it under the terms of the GNU General Public License as published by
278+ * the Free Software Foundation; version 3.
279+ *
280+ * This program is distributed in the hope that it will be useful,
281+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
282+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
283+ * GNU General Public License for more details.
284+ *
285+ * You should have received a copy of the GNU General Public License
286+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
287+ */
288+
289+// self
290+#include "MockDepartment.h"
291+
292+MockDepartment::MockDepartment(QObject* parent)
293+ : unity::shell::scopes::DepartmentInterface(parent)
294+{
295+}
296+
297+QString MockDepartment::departmentId() const
298+{
299+ return "root";
300+}
301+
302+QString MockDepartment::label() const
303+{
304+ return "All Departments";
305+}
306+
307+QString MockDepartment::allLabel() const
308+{
309+ return "All Departments";
310+}
311+
312+QString MockDepartment::parentDepartmentId() const
313+{
314+ return QString();
315+}
316+
317+QString MockDepartment::parentLabel() const
318+{
319+ return QString();
320+}
321+
322+bool MockDepartment::loaded() const
323+{
324+ return true;
325+}
326+
327+bool MockDepartment::isRoot() const
328+{
329+ return true;
330+}
331+
332+int MockDepartment::count() const
333+{
334+ return rowCount();
335+}
336+
337+int MockDepartment::rowCount(const QModelIndex&) const
338+{
339+ return 1;
340+}
341+
342+QVariant MockDepartment::data(const QModelIndex& /*index*/, int role) const
343+{
344+ switch (role) {
345+ case RoleDepartmentId:
346+ return "child";
347+ case RoleLabel:
348+ return "Child Clothes";
349+ case RoleHasChildren:
350+ return true;
351+ case RoleIsActive:
352+ return false;
353+ default:
354+ return QVariant();
355+ }
356+}
357
358=== added file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.h'
359--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.h 1970-01-01 00:00:00 +0000
360+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockDepartment.h 2014-05-29 12:26:08 +0000
361@@ -0,0 +1,45 @@
362+/*
363+ * Copyright (C) 2014 Canonical, Ltd.
364+ *
365+ * This program is free software; you can redistribute it and/or modify
366+ * it under the terms of the GNU General Public License as published by
367+ * the Free Software Foundation; version 3.
368+ *
369+ * This program is distributed in the hope that it will be useful,
370+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
371+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
372+ * GNU General Public License for more details.
373+ *
374+ * You should have received a copy of the GNU General Public License
375+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
376+ */
377+
378+
379+#ifndef MOCKDEPARTMENT_H
380+#define MOCKDEPARTMENT_H
381+
382+#include <unity/shell/scopes/DepartmentInterface.h>
383+
384+#include <QSharedPointer>
385+
386+class MockDepartment : public unity::shell::scopes::DepartmentInterface
387+{
388+ Q_OBJECT
389+
390+public:
391+ explicit MockDepartment(QObject* parent = 0);
392+
393+ QString departmentId() const override;
394+ QString label() const override;
395+ QString allLabel() const override;
396+ QString parentDepartmentId() const override;
397+ QString parentLabel() const override;
398+ bool loaded() const override;
399+ bool isRoot() const override;
400+ int count() const override;
401+
402+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
403+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
404+};
405+
406+#endif // MOCKDEPARTMENT_H
407
408=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp'
409--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2014-05-14 08:19:03 +0000
410+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.cpp 2014-05-29 12:26:08 +0000
411@@ -17,6 +17,7 @@
412 #include "MockScope.h"
413 #include "MockCategories.h"
414 #include "MockPreviewStack.h"
415+#include "MockDepartment.h"
416
417 MockScope::MockScope(QObject* parent) : MockScope(QString(), QString(), false, parent)
418 {
419@@ -62,6 +63,10 @@
420 return QString("");
421 }
422
423+QString MockScope::currentDepartmentId() const {
424+ return m_currentDepartmentId;
425+}
426+
427 bool MockScope::searchInProgress() const {
428 return m_searching;
429 }
430@@ -86,10 +91,14 @@
431 return m_isActive;
432 }
433
434+bool MockScope::hasDepartments() const {
435+ return m_hasDepartments;
436+}
437+
438 void MockScope::setName(const QString &str) {
439 if (str != m_name) {
440 m_name = str;
441- Q_EMIT nameChanged(m_name);
442+ Q_EMIT nameChanged();
443 }
444 }
445
446@@ -110,7 +119,7 @@
447 void MockScope::setActive(const bool active) {
448 if (active != m_isActive) {
449 m_isActive = active;
450- Q_EMIT isActiveChanged(active);
451+ Q_EMIT isActiveChanged();
452 }
453 }
454
455@@ -135,6 +144,18 @@
456 return new MockPreviewStack;
457 }
458
459+unity::shell::scopes::DepartmentInterface* MockScope::getDepartment(QString const& departmentId)
460+{
461+ Q_UNUSED(departmentId);
462+
463+ return new MockDepartment();
464+}
465+
466+void MockScope::loadDepartment(QString const& departmentId)
467+{
468+ Q_UNUSED(departmentId);
469+}
470+
471 void MockScope::cancelActivation()
472 {
473 }
474
475=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h'
476--- test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2014-05-13 13:52:12 +0000
477+++ test/qmltest/mocks/plugins/Unity/Scopes/Mocks/MockScope.h 2014-05-29 12:26:08 +0000
478@@ -41,6 +41,8 @@
479 QString noResultsHint() const override;
480 QString formFactor() const override;
481 bool isActive() const override;
482+ bool hasDepartments() const override;
483+ QString currentDepartmentId() const override;
484
485 /* setters */
486 void setName(const QString& name);
487@@ -53,6 +55,8 @@
488 Q_INVOKABLE unity::shell::scopes::PreviewStackInterface* preview(QVariant const& result) override;
489 Q_INVOKABLE void cancelActivation() override;
490 Q_INVOKABLE void closeScope(unity::shell::scopes::ScopeInterface* scope) override;
491+ Q_INVOKABLE unity::shell::scopes::DepartmentInterface* getDepartment(QString const& departmentId) override;
492+ Q_INVOKABLE void loadDepartment(QString const& departmentId) override;
493
494 protected:
495 QString m_id;
496@@ -62,9 +66,11 @@
497 QString m_searchQuery;
498 QString m_noResultsHint;
499 QString m_formFactor;
500+ QString m_currentDepartmentId;
501 bool m_visible;
502 bool m_searching;
503 bool m_isActive;
504+ bool m_hasDepartments;
505
506 QString m_previewRendererName;
507
508
509=== modified file 'test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp'
510--- test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2014-05-19 11:45:10 +0000
511+++ test/qmltest/mocks/plugins/Unity/Scopes/TestScopesPlugin.cpp 2014-05-29 12:26:08 +0000
512@@ -20,6 +20,7 @@
513 #include <QtQml/qqml.h>
514
515 #include "CategoriesInterface.h"
516+#include "DepartmentInterface.h"
517 #include "ResultsModelInterface.h"
518 #include "PreviewModelInterface.h"
519 #include "PreviewWidgetModelInterface.h"
520@@ -32,6 +33,7 @@
521 qmlRegisterType<MockScopes>(uri, 0, 2, "Scopes");
522 qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Categories object in QML. Get them from Scopes instance.");
523 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML. Get them from Scope instance.");
524+ qmlRegisterUncreatableType<unity::shell::scopes::DepartmentInterface>(uri, 0, 2, "Department", "Can't create Department object in QML. Get them from Scope instance.");
525 qmlRegisterUncreatableType<unity::shell::scopes::ResultsModelInterface>(uri, 0, 2, "ResultsModel", "Can't create new ResultsModel in QML. Get them from Categories instance.");
526 qmlRegisterUncreatableType<unity::shell::scopes::PreviewModelInterface>(uri, 0, 2, "PreviewModel", "Can't create new PreviewModel in QML. Get them from PreviewStack instance.");
527 qmlRegisterUncreatableType<unity::shell::scopes::PreviewWidgetModelInterface>(uri, 0, 2, "PreviewWidgetModel", "Can't create new PreviewWidgetModel in QML. Get them from PreviewModel instance.");
528
529=== modified file 'test/qmltest/unity/shell/scopes/tst_Scopes.qml'
530--- test/qmltest/unity/shell/scopes/tst_Scopes.qml 2014-05-19 11:45:10 +0000
531+++ test/qmltest/unity/shell/scopes/tst_Scopes.qml 2014-05-29 12:26:08 +0000
532@@ -28,6 +28,7 @@
533 }
534 property var scope: scopes.getScope(0)
535 property var preview: root.scope.preview("")
536+ property var department: root.scope.getDepartment("root")
537
538 Verifier {
539 id: scopesVerifier
540@@ -123,7 +124,9 @@
541 { tag: "Item.properties[searchQuery]", constant: "searchQuery", type: "string" },
542 { tag: "Item.properties[noResultsHint]", constant: "noResultsHint", type: "string" },
543 { tag: "Item.properties[formFactor]", constant: "formFactor", type: "string" },
544- { tag: "Item.properties[isActive]", constant: "isActive", type: "boolean" }
545+ { tag: "Item.properties[isActive]", constant: "isActive", type: "boolean" },
546+ { tag: "Item.properties[currentDepartmentId]", constant: "currentDepartmentId", type: "string" },
547+ { tag: "Item.properties[hasDepartments]", constant: "hasDepartments", type: "boolean" }
548 ];
549 }
550
551@@ -145,7 +148,9 @@
552 { tag: "Model.methods[previewRequested]", method: "previewRequested" },
553 { tag: "Model.methods[gotoScope]", method: "gotoScope" },
554 { tag: "Model.methods[openScope]", method: "openScope" },
555- { tag: "Model.methods[activateApplication]", method: "activateApplication" }
556+ { tag: "Model.methods[activateApplication]", method: "activateApplication" },
557+ { tag: "Model.methods[getDepartment]", method: "getDepartment" },
558+ { tag: "Model.methods[loadDepartment]", method: "loadDepartment" }
559 ];
560 }
561
562@@ -438,4 +443,64 @@
563 verifyData(data);
564 }
565 }
566+
567+
568+ Verifier {
569+ id: departmentVerifier
570+
571+ Repeater {
572+ id: departmentRepeater
573+ model: root.department
574+ delegate: Item {
575+ property var roles: model
576+ }
577+ }
578+
579+ function test_department_data() {
580+ return [
581+ { tag: "Department[object]", type: "object" },
582+ { tag: "Department[DepartmentInterface]", type: "unity::shell::scopes::DepartmentInterface" },
583+ ];
584+ }
585+
586+ function test_department(data) {
587+ object = departmentRepeater.model;
588+ name = "Department";
589+ verifyData(data);
590+ }
591+
592+ function test_department_roles_data() {
593+ return [
594+ { tag: "Model.roles[departmentId]", role: "departmentId", type: "string" },
595+ { tag: "Model.roles[label]", role: "label", type: "string" },
596+ { tag: "Model.roles[hasChildren]", role: "hasChildren", type: "boolean" },
597+ { tag: "Model.roles[isActive]", role: "isActive", type: "boolean" }
598+ ];
599+ }
600+
601+ function test_department_roles(data) {
602+ object = departmentRepeater.itemAt(0).roles;
603+ name = "Department";
604+ verifyData(data);
605+ }
606+
607+ function test_department_properties_data() {
608+ return [
609+ { tag: "Model.properties[departmentId]", constant: "departmentId", type: "string" },
610+ { tag: "Model.properties[label]", constant: "label", type: "string" },
611+ { tag: "Model.properties[allLabel]", constant: "allLabel", type: "string" },
612+ { tag: "Model.properties[parentDepartmentId]", constant: "parentDepartmentId", type: "string" },
613+ { tag: "Model.properties[parentLabel]", constant: "parentLabel", type: "string" },
614+ { tag: "Model.properties[loaded]", constant: "loaded", type: "boolean" },
615+ { tag: "Model.properties[isRoot]", constant: "isRoot", type: "boolean" },
616+ { tag: "Model.properties[count]", constant: "count", type: "number" }
617+ ];
618+ }
619+
620+ function test_department_properties(data) {
621+ object = departmentRepeater.model;
622+ name = "Department";
623+ verifyData(data);
624+ }
625+ }
626 }

Subscribers

People subscribed via source and target branches

to all changes: