Merge lp:~mzanetti/unity-api/appdrawermodelinterface into lp:unity-api

Proposed by Michael Zanetti
Status: Superseded
Proposed branch: lp:~mzanetti/unity-api/appdrawermodelinterface
Merge into: lp:unity-api
Diff against target: 617 lines (+307/-20)
14 files modified
debian/changelog (+17/-0)
include/unity/shell/launcher/AppDrawerModelInterface.h (+71/-0)
include/unity/shell/launcher/CMakeLists.txt (+1/-1)
include/unity/shell/launcher/LauncherItemInterface.h (+10/-6)
include/unity/shell/launcher/QuickListModelInterface.h (+4/-1)
test/gtest/unity/util/IniParser/IniParser_test.cpp (+16/-8)
test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt (+2/-0)
test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.cpp (+89/-0)
test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.h (+38/-0)
test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.cpp (+14/-0)
test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.h (+6/-0)
test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockQuickListModel.cpp (+2/-0)
test/qmltest/mocks/plugins/Unity/Launcher/TestLauncherPlugin.cpp (+4/-0)
test/qmltest/unity/shell/launcher/tst_Launcher.qml (+33/-4)
To merge this branch: bzr merge lp:~mzanetti/unity-api/appdrawermodelinterface
Reviewer Review Type Date Requested Status
Lukáš Tinkl (community) Approve
Unity8 CI Bot continuous-integration Needs Fixing
Ubuntu Unity PS integration team Pending
Review via email: mp+310057@code.launchpad.net

This proposal has been superseded by a proposal from 2016-11-30.

Commit message

Add AppDrawerModelInterface

Description of the change

Requires: lp:~mzanetti/unity8/appdrawer

See silo 2150 for working builds.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:261
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/111/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/3382/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/3410
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/3261/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/3261/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/3261/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/3261/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/3261/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/3261/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/3261/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3261
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/3261/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/3261/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/111/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

LGTM, works fine with the u8 appdrawer branch

CI failing because of lp:1642673, passing locally

review: Approve
262. By Michael Zanetti

merge in 22022 as prereq

263. By Michael Zanetti

bump versions again after merging

Unmerged revisions

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 2016-09-09 14:39:28 +0000
3+++ debian/changelog 2016-11-30 10:44:09 +0000
4@@ -1,3 +1,20 @@
5+unity-api (7.121) UNRELEASED; urgency=medium
6+
7+ * Add AppDrawerModelInterface
8+
9+ -- Michael Zanetti <michael.zanetti@canonical.com> Thu, 10 Nov 2016 19:14:25 +0100
10+
11+unity-api (7.120+17.04.20161123-0ubuntu1) zesty; urgency=medium
12+
13+ [ Andrea Azzarone ]
14+ * Add hasSeparator role to quicklistModel.
15+
16+ [ Marcus Tomlinson ]
17+ * Don't rely on glib error message strings in IniParser_test (LP:
18+ #1642673)
19+
20+ -- Andrea Cimitan <andrea.cimitan@canonical.com> Wed, 23 Nov 2016 12:11:04 +0000
21+
22 unity-api (7.119+16.10.20160909-0ubuntu1) yakkety; urgency=medium
23
24 [ Daniel d'Andrada ]
25
26=== added file 'include/unity/shell/launcher/AppDrawerModelInterface.h'
27--- include/unity/shell/launcher/AppDrawerModelInterface.h 1970-01-01 00:00:00 +0000
28+++ include/unity/shell/launcher/AppDrawerModelInterface.h 2016-11-30 10:44:09 +0000
29@@ -0,0 +1,71 @@
30+/*
31+ * Copyright 2016 Canonical Ltd.
32+ *
33+ * This program is free software; you can redistribute it and/or modify
34+ * it under the terms of the GNU Lesser General Public License as published by
35+ * the Free Software Foundation; version 3.
36+ *
37+ * This program is distributed in the hope that it will be useful,
38+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
39+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40+ * GNU Lesser General Public License for more details.
41+ *
42+ * You should have received a copy of the GNU Lesser General Public License
43+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
44+ */
45+
46+#pragma once
47+
48+#include <unity/SymbolExport.h>
49+
50+#include <QAbstractListModel>
51+
52+namespace unity {
53+namespace shell {
54+namespace launcher {
55+
56+/**
57+ * @brief A list of app drawer items to be displayed
58+ *
59+ * This model exposes all the items that should be shown in the app drawer.
60+ */
61+class UNITY_API AppDrawerModelInterface: public QAbstractListModel
62+{
63+ Q_OBJECT
64+ Q_ENUMS(Roles)
65+public:
66+ /**
67+ * @brief The Roles supported by the model
68+ *
69+ * See LauncherItemInterface properties for details.
70+ */
71+ enum Roles {
72+ RoleAppId,
73+ RoleName,
74+ RoleIcon,
75+ RoleKeywords,
76+ RoleUsage
77+ };
78+
79+ /// @cond
80+ AppDrawerModelInterface(QObject* parent = nullptr): QAbstractListModel(parent) {}
81+ /// @endcond
82+
83+ virtual ~AppDrawerModelInterface() {}
84+
85+ /// @cond
86+ QHash<int, QByteArray> roleNames() const override {
87+ QHash<int, QByteArray> roles;
88+ roles.insert(RoleAppId, "appId");
89+ roles.insert(RoleName, "name");
90+ roles.insert(RoleIcon, "icon");
91+ roles.insert(RoleKeywords, "keywords");
92+ roles.insert(RoleUsage, "usage");
93+ return roles;
94+ }
95+ /// @endcond
96+};
97+
98+}
99+}
100+}
101
102=== modified file 'include/unity/shell/launcher/CMakeLists.txt'
103--- include/unity/shell/launcher/CMakeLists.txt 2016-05-18 13:43:40 +0000
104+++ include/unity/shell/launcher/CMakeLists.txt 2016-11-30 10:44:09 +0000
105@@ -7,7 +7,7 @@
106
107 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
108
109-set(VERSION 9)
110+set(VERSION 11)
111 set(PKGCONFIG_NAME "unity-shell-launcher")
112 set(PKGCONFIG_DESCRIPTION "Unity shell Launcher APIs")
113 set(PKGCONFIG_REQUIRES "Qt5Core")
114
115=== modified file 'include/unity/shell/launcher/LauncherItemInterface.h'
116--- include/unity/shell/launcher/LauncherItemInterface.h 2016-05-11 10:48:13 +0000
117+++ include/unity/shell/launcher/LauncherItemInterface.h 2016-11-30 10:44:09 +0000
118@@ -1,5 +1,5 @@
119 /*
120- * Copyright 2013 Canonical Ltd.
121+ * Copyright 2013-2106 Canonical Ltd.
122 *
123 * This program is free software; you can redistribute it and/or modify
124 * it under the terms of the GNU Lesser General Public License as published by
125@@ -12,9 +12,6 @@
126 *
127 * You should have received a copy of the GNU Lesser General Public License
128 * along with this program. If not, see <http://www.gnu.org/licenses/>.
129- *
130- * Authors:
131- * Michael Zanetti <michael.zanetti@canonical.com>
132 */
133
134 #ifndef UNITY_SHELL_LAUNCHER_LAUNCHERITEM_H
135@@ -52,12 +49,17 @@
136 /**
137 * @brief The user visible name of the item.
138 */
139- Q_PROPERTY(QString name READ name CONSTANT)
140+ Q_PROPERTY(QString name READ name NOTIFY nameChanged)
141
142 /**
143 * @brief The full path to the icon to be shown for the item.
144 */
145- Q_PROPERTY(QString icon READ icon CONSTANT)
146+ Q_PROPERTY(QString icon READ icon NOTIFY iconChanged)
147+
148+ /**
149+ * @brief The keywords for this item.
150+ */
151+ Q_PROPERTY(QStringList keywords READ keywords NOTIFY keywordsChanged)
152
153 /**
154 * @brief A flag whether the item is pinned or not
155@@ -137,6 +139,7 @@
156 virtual QString appId() const = 0;
157 virtual QString name() const = 0;
158 virtual QString icon() const = 0;
159+ virtual QStringList keywords() const = 0;
160 virtual bool pinned() const = 0;
161 virtual bool running() const = 0;
162 virtual bool recent() const = 0;
163@@ -151,6 +154,7 @@
164 Q_SIGNALS:
165 void nameChanged(const QString &name);
166 void iconChanged(const QString &icon);
167+ void keywordsChanged(const QStringList &keywords);
168 void pinnedChanged(bool pinned);
169 void runningChanged(bool running);
170 void recentChanged(bool running);
171
172=== modified file 'include/unity/shell/launcher/QuickListModelInterface.h'
173--- include/unity/shell/launcher/QuickListModelInterface.h 2013-08-19 13:29:21 +0000
174+++ include/unity/shell/launcher/QuickListModelInterface.h 2016-11-30 10:44:09 +0000
175@@ -38,6 +38,7 @@
176 * - RoleLabel (label): The text entry in the QuickList menu (QString).
177 * - RoleIcon (icon): The icon to be shown for this entry (QString).
178 * - RoleClickable (clickable): Determines if the entry can be triggered or is just a static text (boolean)
179+ * - RoleHasSeparator (hasSeparator): Determines if the entry has a separator (boolean)
180 */
181 class UNITY_API QuickListModelInterface: public QAbstractListModel
182 {
183@@ -49,6 +50,7 @@
184 m_roleNames.insert(RoleLabel, "label");
185 m_roleNames.insert(RoleIcon, "icon");
186 m_roleNames.insert(RoleClickable, "clickable");
187+ m_roleNames.insert(RoleHasSeparator, "hasSeparator");
188 }
189 /// @endcond
190 public:
191@@ -60,7 +62,8 @@
192 enum Roles {
193 RoleLabel,
194 RoleIcon,
195- RoleClickable
196+ RoleClickable,
197+ RoleHasSeparator
198 };
199
200 /// @cond
201
202=== modified file 'test/gtest/unity/util/IniParser/IniParser_test.cpp'
203--- test/gtest/unity/util/IniParser/IniParser_test.cpp 2016-03-29 10:08:45 +0000
204+++ test/gtest/unity/util/IniParser/IniParser_test.cpp 2016-11-30 10:44:09 +0000
205@@ -148,7 +148,8 @@
206 }
207 catch (const LogicException& e)
208 {
209- EXPECT_NE(string::npos, string(e.what()).find("Key file does not have group 'foo'"));
210+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get string value"));
211+ EXPECT_NE(string::npos, string(e.what()).find("group: foo"));
212 }
213 try
214 {
215@@ -156,7 +157,8 @@
216 }
217 catch (const LogicException& e)
218 {
219- EXPECT_NE(string::npos, string(e.what()).find("Key file does not have group 'foo'"));
220+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get localized string value"));
221+ EXPECT_NE(string::npos, string(e.what()).find("group: foo"));
222 }
223 try
224 {
225@@ -164,7 +166,8 @@
226 }
227 catch (const LogicException& e)
228 {
229- EXPECT_NE(string::npos, string(e.what()).find("Key file does not have group 'foo'"));
230+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get integer value"));
231+ EXPECT_NE(string::npos, string(e.what()).find("group: foo"));
232 }
233 try
234 {
235@@ -172,7 +175,8 @@
236 }
237 catch (const LogicException& e)
238 {
239- EXPECT_NE(string::npos, string(e.what()).find("Key file contains key 'doublevalue' in group 'first' which has a value that cannot be interpreted."));
240+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get integer value"));
241+ EXPECT_NE(string::npos, string(e.what()).find("group: first"));
242 }
243 try
244 {
245@@ -180,7 +184,8 @@
246 }
247 catch (const LogicException& e)
248 {
249- EXPECT_NE(string::npos, string(e.what()).find("Key file does not have group 'foo'"));
250+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get boolean value"));
251+ EXPECT_NE(string::npos, string(e.what()).find("group: foo"));
252 }
253 try
254 {
255@@ -188,7 +193,8 @@
256 }
257 catch (const LogicException& e)
258 {
259- EXPECT_NE(string::npos, string(e.what()).find("Value 'foo' cannot be interpreted as a number."));
260+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get integer array"));
261+ EXPECT_NE(string::npos, string(e.what()).find("group: first"));
262 }
263 try
264 {
265@@ -196,7 +202,8 @@
266 }
267 catch (const LogicException& e)
268 {
269- EXPECT_NE(string::npos, string(e.what()).find("Value '4.5' cannot be interpreted as a number."));
270+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get integer array"));
271+ EXPECT_NE(string::npos, string(e.what()).find("group: second"));
272 }
273 try
274 {
275@@ -204,7 +211,8 @@
276 }
277 catch (const LogicException& e)
278 {
279- EXPECT_NE(string::npos, string(e.what()).find("Value 'foo' cannot be interpreted as a boolean."));
280+ EXPECT_NE(string::npos, string(e.what()).find("unity::LogicException: Could not get boolean array"));
281+ EXPECT_NE(string::npos, string(e.what()).find("group: first"));
282 }
283 }
284
285
286=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt'
287--- test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2014-09-03 22:59:26 +0000
288+++ test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2016-11-30 10:44:09 +0000
289@@ -16,11 +16,13 @@
290 ${CMAKE_SOURCE_DIR}/include/unity/shell/launcher/LauncherModelInterface.h
291 ${CMAKE_SOURCE_DIR}/include/unity/shell/launcher/LauncherItemInterface.h
292 ${CMAKE_SOURCE_DIR}/include/unity/shell/launcher/QuickListModelInterface.h
293+ ${CMAKE_SOURCE_DIR}/include/unity/shell/launcher/AppDrawerModelInterface.h
294 ${CMAKE_SOURCE_DIR}/include/unity/shell/application/ApplicationManagerInterface.h
295 ${CMAKE_SOURCE_DIR}/include/unity/shell/application/ApplicationInfoInterface.h
296 Mocks/MockLauncherModel.cpp
297 Mocks/MockLauncherItem.cpp
298 Mocks/MockQuickListModel.cpp
299+ Mocks/MockAppDrawerModel.cpp
300 ${CMAKE_CURRENT_SOURCE_DIR}/../Application/Mocks/MockApplicationManager.cpp
301 ${CMAKE_CURRENT_SOURCE_DIR}/../Application/Mocks/MockApplicationInfo.cpp
302 )
303
304=== added file 'test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.cpp'
305--- test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.cpp 1970-01-01 00:00:00 +0000
306+++ test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.cpp 2016-11-30 10:44:09 +0000
307@@ -0,0 +1,89 @@
308+/*
309+ * Copyright 2016 Canonical Ltd.
310+ *
311+ * This program is free software; you can redistribute it and/or modify
312+ * it under the terms of the GNU Lesser General Public License as published by
313+ * the Free Software Foundation; version 3.
314+ *
315+ * This program is distributed in the hope that it will be useful,
316+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
317+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
318+ * GNU Lesser General Public License for more details.
319+ *
320+ * You should have received a copy of the GNU Lesser General Public License
321+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
322+ */
323+
324+#include <Mocks/MockAppDrawerModel.h>
325+#include <Mocks/MockLauncherItem.h>
326+
327+using namespace unity::shell::launcher;
328+
329+MockAppDrawerModel::MockAppDrawerModel(QObject* parent): AppDrawerModelInterface(parent)
330+{
331+ MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
332+ item->setKeywords({"keyword1", "keyword2"});
333+ m_list.append(item);
334+ item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
335+ item->setKeywords({"keyword1", "keyword2"});
336+ m_list.append(item);
337+ item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
338+ item->setKeywords({"keyword1", "keyword2"});
339+ m_list.append(item);
340+ item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
341+ item->setKeywords({"keyword1", "keyword2"});
342+ m_list.append(item);
343+ item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser", this);
344+ item->setKeywords({"keyword1", "keyword2"});
345+ m_list.append(item);
346+ item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
347+ item->setKeywords({"keyword1", "keyword2"});
348+ m_list.append(item);
349+ item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
350+ item->setKeywords({"keyword1", "keyword2"});
351+ m_list.append(item);
352+ item = new MockLauncherItem("ubuntu-weather-app", "/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather", this);
353+ item->setKeywords({"keyword1", "keyword2"});
354+ m_list.append(item);
355+ item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
356+ item->setKeywords({"keyword1", "keyword2"});
357+ m_list.append(item);
358+ item = new MockLauncherItem("ubuntu-calendar-app", "/usr/share/applications/ubuntu-calendar-app.desktop","Calendar", "calendar", this);
359+ item->setKeywords({"keyword1", "keyword2"});
360+ m_list.append(item);
361+}
362+
363+MockAppDrawerModel::~MockAppDrawerModel()
364+{
365+ while (!m_list.empty())
366+ {
367+ m_list.takeFirst()->deleteLater();
368+ }
369+}
370+
371+// cppcheck-suppress unusedFunction
372+int MockAppDrawerModel::rowCount(const QModelIndex& parent) const
373+{
374+ Q_UNUSED(parent)
375+ return m_list.count();
376+}
377+
378+QVariant MockAppDrawerModel::data(const QModelIndex& index, int role) const
379+{
380+ LauncherItemInterface *item = m_list.at(index.row());
381+ switch(role)
382+ {
383+ case RoleAppId:
384+ return item->appId();
385+ case RoleName:
386+ return item->name();
387+ case RoleIcon:
388+ return item->icon();
389+ case RoleKeywords:
390+ return item->keywords();
391+ case RoleUsage:
392+ return 1;
393+ }
394+
395+ return QVariant();
396+}
397
398=== added file 'test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.h'
399--- test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.h 1970-01-01 00:00:00 +0000
400+++ test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockAppDrawerModel.h 2016-11-30 10:44:09 +0000
401@@ -0,0 +1,38 @@
402+/*
403+ * Copyright 2016 Canonical Ltd.
404+ *
405+ * This program is free software; you can redistribute it and/or modify
406+ * it under the terms of the GNU Lesser General Public License as published by
407+ * the Free Software Foundation; version 3.
408+ *
409+ * This program is distributed in the hope that it will be useful,
410+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
411+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
412+ * GNU Lesser General Public License for more details.
413+ *
414+ * You should have received a copy of the GNU Lesser General Public License
415+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
416+ */
417+
418+#pragma once
419+
420+#include <AppDrawerModelInterface.h>
421+
422+class MockLauncherItem;
423+
424+using namespace unity::shell::launcher;
425+
426+class UNITY_API MockAppDrawerModel: public AppDrawerModelInterface
427+{
428+ Q_OBJECT
429+
430+public:
431+ MockAppDrawerModel(QObject* parent = 0);
432+ ~MockAppDrawerModel();
433+
434+ int rowCount(const QModelIndex& parent) const override;
435+ QVariant data(const QModelIndex& index, int role) const override;
436+
437+private:
438+ QList<MockLauncherItem*> m_list;
439+};
440
441=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.cpp'
442--- test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.cpp 2016-05-18 13:43:40 +0000
443+++ test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.cpp 2016-11-30 10:44:09 +0000
444@@ -61,6 +61,20 @@
445 return m_icon;
446 }
447
448+QStringList MockLauncherItem::keywords() const
449+{
450+ return m_keywords;
451+}
452+
453+void MockLauncherItem::setKeywords(const QStringList &keywords)
454+{
455+ if (m_keywords != keywords)
456+ {
457+ m_keywords = keywords;
458+ Q_EMIT keywordsChanged(m_keywords);
459+ }
460+}
461+
462 bool MockLauncherItem::pinned() const
463 {
464 return m_pinned;
465
466=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.h'
467--- test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.h 2016-05-18 13:43:40 +0000
468+++ test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockLauncherItem.h 2016-11-30 10:44:09 +0000
469@@ -22,6 +22,8 @@
470
471 #include <LauncherItemInterface.h>
472
473+#include <QStringList>
474+
475 using namespace unity::shell::launcher;
476
477 class UNITY_API MockLauncherItem: public LauncherItemInterface
478@@ -35,6 +37,9 @@
479 QString name() const;
480 QString icon() const;
481
482+ QStringList keywords() const;
483+ void setKeywords(const QStringList &keywords);
484+
485 bool pinned() const;
486 void setPinned(bool pinned);
487
488@@ -67,6 +72,7 @@
489 QString m_desktopFile;
490 QString m_name;
491 QString m_icon;
492+ QStringList m_keywords;
493 bool m_pinned;
494 bool m_running;
495 bool m_recent;
496
497=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockQuickListModel.cpp'
498--- test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockQuickListModel.cpp 2013-08-19 13:29:21 +0000
499+++ test/qmltest/mocks/plugins/Unity/Launcher/Mocks/MockQuickListModel.cpp 2016-11-30 10:44:09 +0000
500@@ -37,6 +37,8 @@
501 return QLatin1String("copy.png");
502 case RoleClickable:
503 return true;
504+ case RoleHasSeparator:
505+ return true;
506 }
507 return QVariant();
508 }
509
510=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/TestLauncherPlugin.cpp'
511--- test/qmltest/mocks/plugins/Unity/Launcher/TestLauncherPlugin.cpp 2013-09-11 15:28:22 +0000
512+++ test/qmltest/mocks/plugins/Unity/Launcher/TestLauncherPlugin.cpp 2016-11-30 10:44:09 +0000
513@@ -21,9 +21,11 @@
514 #include <Mocks/MockLauncherModel.h>
515 #include <Mocks/MockLauncherItem.h>
516 #include <Mocks/MockQuickListModel.h>
517+#include <Mocks/MockAppDrawerModel.h>
518
519 #include <LauncherModelInterface.h>
520 #include <LauncherItemInterface.h>
521+#include <AppDrawerModelInterface.h>
522
523 #include <QtQml/qqml.h>
524
525@@ -42,10 +44,12 @@
526 qmlRegisterUncreatableType<LauncherModelInterface>(uri, 0, 1, "LauncherModelInterface", "Interface for the LauncherModel");
527 qmlRegisterUncreatableType<LauncherItemInterface>(uri, 0, 1, "LauncherItemInterface", "Interface for the LauncherItem");
528 qmlRegisterUncreatableType<QuickListModelInterface>(uri, 0, 1, "QuickListModelInterface", "Interface for the QuickListModel");
529+ qmlRegisterUncreatableType<AppDrawerModelInterface>(uri, 0, 1, "AppDrawerModelInterface", "Interface for the AppDrawerModel");
530
531 qmlRegisterSingletonType<MockLauncherModel>(uri, 0, 1, "LauncherModel", modelProvider);
532 qmlRegisterUncreatableType<MockLauncherItem>(uri, 0, 1, "LauncherItem", "Can't create LauncherItems in QML. Get them from the LauncherModel");
533 qmlRegisterUncreatableType<MockQuickListModel>(uri, 0, 1, "QuickListModel", "Can't create QuickListModels in QML. Get them from the LauncherItems");
534+ qmlRegisterType<MockAppDrawerModel>(uri, 0, 1, "AppDrawerModel");
535
536 // Need to register the appmanager here ourselves as there won't be a real AppManager plugin in this test
537 qmlRegisterUncreatableType<unity::shell::application::ApplicationManagerInterface>(uri, 0, 1, "ApplicationManagerInterface", "Interface for the ApplicationManager");
538
539=== modified file 'test/qmltest/unity/shell/launcher/tst_Launcher.qml'
540--- test/qmltest/unity/shell/launcher/tst_Launcher.qml 2016-05-18 13:43:40 +0000
541+++ test/qmltest/unity/shell/launcher/tst_Launcher.qml 2016-11-30 10:44:09 +0000
542@@ -1,5 +1,5 @@
543 /*
544- * Copyright 2013 Canonical Ltd.
545+ * Copyright 2013-2016 Canonical Ltd.
546 *
547 * This program is free software; you can redistribute it and/or modify
548 * it under the terms of the GNU Lesser General Public License as published by
549@@ -12,9 +12,6 @@
550 *
551 * You should have received a copy of the GNU Lesser General Public License
552 * along with this program. If not, see <http://www.gnu.org/licenses/>.
553- *
554- * Authors:
555- * Michael Zanetti <michael.zanetti@canonical.com>
556 */
557
558 import QtQuick 2.0
559@@ -67,6 +64,15 @@
560 }
561 }
562
563+
564+ Repeater {
565+ id: appDrawerRepeater
566+ model: AppDrawerModel {}
567+ delegate: Item {
568+ property var roles: model
569+ }
570+ }
571+
572 function initTestCase() {
573 if (repeater.count < 5) {
574 print("This Test Suite requires at least 5 items in the model.")
575@@ -138,6 +144,7 @@
576 { tag: "Item.properties[appId]", constant: "appId", type: "string" },
577 { tag: "Item.properties[name]", constant: "name", type: "string" },
578 { tag: "Item.properties[icon]", constant: "icon", type: "string" },
579+ { tag: "Item.properties[keywords]", constant: "keywords", type: "object" },
580 { tag: "Item.properties[pinned]", property: "pinned", type: "boolean" },
581 { tag: "Item.properties[recent]", property: "recent", type: "boolean" },
582 { tag: "Item.properties[running]", property: "running", type: "boolean" },
583@@ -168,6 +175,7 @@
584 { tag: "Model.roles[label]", role: "label", type: "string" },
585 { tag: "Model.roles[icon]", role: "icon", type: "string" },
586 { tag: "Model.roles[clickable]", role: "clickable", type: "boolean" },
587+ { tag: "Model.roles[hasSeparator]", role: "hasSeparator", type: "boolean" }
588 ];
589 }
590
591@@ -181,5 +189,26 @@
592
593 verifyData(data);
594 }
595+
596+ function test_appdrawer_model_roles_data() {
597+ return [
598+ { tag: "Model.roles[appId]", role: "appId", type: "string" },
599+ { tag: "Model.roles[name]", role: "name", type: "string" },
600+ { tag: "Model.roles[icon]", role: "icon", type: "string" },
601+ { tag: "Model.roles[keywords]", role: "keywords", type: "object" },
602+ { tag: "Model.roles[usage]", role: "usage", type: "number" },
603+ ];
604+ }
605+
606+ function test_appdrawer_model_roles(data) {
607+ name = "AppDrawerModel"
608+ try {
609+ object = appDrawerRepeater.itemAt(0).roles;
610+ } catch(err) {
611+ object = undefined;
612+ }
613+
614+ verifyData(data);
615+ }
616 }
617 }

Subscribers

People subscribed via source and target branches

to all changes: