Merge lp:~unity-team/unity/phablet.fake-unity-plugin into lp:unity/phablet

Proposed by Nick Dedekind
Status: Merged
Approved by: Albert Astals Cid
Approved revision: no longer in the source branch.
Merged at revision: 615
Proposed branch: lp:~unity-team/unity/phablet.fake-unity-plugin
Merge into: lp:unity/phablet
Diff against target: 502 lines (+455/-0)
9 files modified
tests/qmltests/plugins/CMakeLists.txt (+1/-0)
tests/qmltests/plugins/Unity/CMakeLists.txt (+35/-0)
tests/qmltests/plugins/Unity/fake_lens.cpp (+65/-0)
tests/qmltests/plugins/Unity/fake_lens.h (+56/-0)
tests/qmltests/plugins/Unity/fake_lenses.cpp (+150/-0)
tests/qmltests/plugins/Unity/fake_lenses.h (+80/-0)
tests/qmltests/plugins/Unity/fake_unity_plugin.cpp (+32/-0)
tests/qmltests/plugins/Unity/fake_unity_plugin.h (+34/-0)
tests/qmltests/plugins/Unity/qmldir (+2/-0)
To merge this branch: bzr merge lp:~unity-team/unity/phablet.fake-unity-plugin
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Albert Astals Cid (community) Approve
Andrea Cimitan (community) Approve
Review via email: mp+158865@code.launchpad.net

Commit message

Fake Unity plugin for dash tests.

Description of the change

Fake Unity plugin for dash tests.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andrea Cimitan (cimi) wrote :

Tested this on my branches, works well

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

Silly, why did you fail in the Digia thing if that already was merged?

Revision history for this message
Andrea Cimitan (cimi) wrote :

ready to top approve? any review from c++ guys?

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

Nick: Should we give the Lens a parent to not have the problem we had in your other MR about the PanelContent?

review: Needs Information
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

> Nick: Should we give the Lens a parent to not have the problem we had in your
> other MR about the PanelContent?

We should indeed.

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

Works for me, let's see what CI says

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

Needs remerging

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

Retriggered CI

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 :

Ok, let's merge!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/qmltests/plugins/CMakeLists.txt'
2--- tests/qmltests/plugins/CMakeLists.txt 2013-04-19 09:48:47 +0000
3+++ tests/qmltests/plugins/CMakeLists.txt 2013-04-21 14:41:25 +0000
4@@ -1,2 +1,3 @@
5 add_subdirectory(HudClient)
6 add_subdirectory(Ubuntu)
7+add_subdirectory(Unity)
8
9=== added directory 'tests/qmltests/plugins/Unity'
10=== added file 'tests/qmltests/plugins/Unity/CMakeLists.txt'
11--- tests/qmltests/plugins/Unity/CMakeLists.txt 1970-01-01 00:00:00 +0000
12+++ tests/qmltests/plugins/Unity/CMakeLists.txt 2013-04-21 14:41:25 +0000
13@@ -0,0 +1,35 @@
14+set(CMAKE_AUTOMOC ON)
15+
16+include(FindPkgConfig)
17+find_package(Qt5Core REQUIRED)
18+find_package(Qt5Quick REQUIRED)
19+
20+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wextra -std=c++11")
21+set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
22+
23+include_directories(
24+ ${CMAKE_CURRENT_BINARY_DIR}
25+ ${Qt5Core_INCLUDE_DIRS}
26+ ${Qt5Quick_INCLUDE_DIRS}
27+)
28+
29+add_definitions(-DQT_NO_KEYWORDS)
30+
31+set(UnityQML_SOURCES
32+ fake_lens.cpp
33+ fake_lenses.cpp
34+ fake_unity_plugin.cpp
35+)
36+
37+add_library(FakeUnityQml MODULE ${UnityQML_SOURCES})
38+target_link_libraries(FakeUnityQml
39+ ${Qt5Core_LIBRARIES}
40+ ${Qt5Quick_LIBRARIES}
41+)
42+
43+qt5_use_modules(FakeUnityQml Qml)
44+
45+# copy qmldir file into build directory for shadow builds
46+file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
47+ DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
48+ )
49
50=== added file 'tests/qmltests/plugins/Unity/fake_lens.cpp'
51--- tests/qmltests/plugins/Unity/fake_lens.cpp 1970-01-01 00:00:00 +0000
52+++ tests/qmltests/plugins/Unity/fake_lens.cpp 2013-04-21 14:41:25 +0000
53@@ -0,0 +1,65 @@
54+/*
55+ * Copyright (C) 2013 Canonical, Ltd.
56+ *
57+ * This program is free software; you can redistribute it and/or modify
58+ * it under the terms of the GNU General Public License as published by
59+ * the Free Software Foundation; version 3.
60+ *
61+ * This program is distributed in the hope that it will be useful,
62+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
63+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+ * GNU General Public License for more details.
65+ *
66+ * You should have received a copy of the GNU General Public License
67+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
68+ */
69+
70+// Self
71+#include "fake_lens.h"
72+
73+// TODO: Implement remaining pieces
74+
75+Lens::Lens(QObject* parent)
76+: QObject(parent),
77+ m_visible(false)
78+{}
79+
80+Lens::Lens(QString const& id,
81+ QString const& name,
82+ bool visible,
83+ QObject* parent)
84+: QObject(parent),
85+ m_id(id),
86+ m_name(name),
87+ m_visible(visible)
88+{}
89+
90+QString Lens::id() const {
91+ return m_id;
92+}
93+
94+QString Lens::name() const {
95+ return m_name;
96+}
97+
98+QString Lens::searchQuery() const {
99+ return m_searchQuery;
100+}
101+
102+void Lens::setName(const QString &str) {
103+ if (str != m_name) {
104+ m_name = str;
105+ Q_EMIT nameChanged(m_name);
106+ }
107+}
108+
109+void Lens::setSearchQuery(const QString &str) {
110+ if (str != m_searchQuery) {
111+ m_searchQuery = str;
112+ Q_EMIT searchQueryChanged(m_searchQuery);
113+ }
114+}
115+
116+bool Lens::visible() const {
117+ return m_visible;
118+}
119
120=== added file 'tests/qmltests/plugins/Unity/fake_lens.h'
121--- tests/qmltests/plugins/Unity/fake_lens.h 1970-01-01 00:00:00 +0000
122+++ tests/qmltests/plugins/Unity/fake_lens.h 2013-04-21 14:41:25 +0000
123@@ -0,0 +1,56 @@
124+/*
125+ * Copyright (C) 2013 Canonical, Ltd.
126+ *
127+ * This program is free software; you can redistribute it and/or modify
128+ * it under the terms of the GNU General Public License as published by
129+ * the Free Software Foundation; version 3.
130+ *
131+ * This program is distributed in the hope that it will be useful,
132+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
133+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
134+ * GNU General Public License for more details.
135+ *
136+ * You should have received a copy of the GNU General Public License
137+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
138+ */
139+
140+#ifndef FAKE_LENS_H
141+#define FAKE_LENS_H
142+
143+// Qt
144+#include <QObject>
145+
146+class Lens : public QObject
147+{
148+ Q_OBJECT
149+ Q_PROPERTY(QString id READ id NOTIFY idChanged)
150+ Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
151+ Q_PROPERTY(QString searchQuery READ searchQuery WRITE setSearchQuery NOTIFY searchQueryChanged)
152+ Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
153+
154+public:
155+ Lens(QObject* parent = 0);
156+ Lens(QString const& id, QString const& name, bool visible, QObject* parent = 0);
157+
158+ QString id() const;
159+ QString name() const;
160+ QString searchQuery() const;
161+ bool visible() const;
162+
163+ void setName(const QString &str);
164+ void setSearchQuery(const QString &str);
165+
166+Q_SIGNALS:
167+ void idChanged(QString);
168+ void nameChanged(QString);
169+ void searchQueryChanged(QString);
170+ void visibleChanged(bool);
171+
172+private:
173+ QString m_id;
174+ QString m_name;
175+ QString m_searchQuery;
176+ bool m_visible;
177+};
178+
179+#endif // FAKE_LENS_H
180
181=== added file 'tests/qmltests/plugins/Unity/fake_lenses.cpp'
182--- tests/qmltests/plugins/Unity/fake_lenses.cpp 1970-01-01 00:00:00 +0000
183+++ tests/qmltests/plugins/Unity/fake_lenses.cpp 2013-04-21 14:41:25 +0000
184@@ -0,0 +1,150 @@
185+/*
186+ * Copyright (C) 2013 Canonical, Ltd.
187+ *
188+ * This program is free software; you can redistribute it and/or modify
189+ * it under the terms of the GNU General Public License as published by
190+ * the Free Software Foundation; version 3.
191+ *
192+ * This program is distributed in the hope that it will be useful,
193+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
194+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
195+ * GNU General Public License for more details.
196+ *
197+ * You should have received a copy of the GNU General Public License
198+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
199+ *
200+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
201+ */
202+
203+// Self
204+#include "fake_lenses.h"
205+
206+// TODO: Implement remaining pieces, like Categories (i.e. LensView now gives warnings)
207+
208+// Qt
209+#include <QTimer>
210+
211+Lenses::Lenses(QObject *parent)
212+: QAbstractListModel(parent)
213+, m_loaded(false)
214+, timer(this)
215+{
216+ m_roles[Lenses::RoleLens] = "lens";
217+ m_roles[Lenses::RoleId] = "id";
218+ m_roles[Lenses::RoleVisible] = "visible";
219+
220+ QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
221+ QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
222+ QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
223+
224+ timer.setSingleShot(true);
225+ timer.setInterval(100);
226+ QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateLenses()));
227+ load();
228+}
229+
230+Lenses::~Lenses()
231+{
232+ qDeleteAll(m_lenses);
233+ m_lenses.clear();
234+}
235+
236+void Lenses::updateLenses()
237+{
238+ clear();
239+ addLens(new Lens("MockLens1", "People", true, this));
240+ addLens(new Lens("MockLens2", "Music", true, this));
241+ addLens(new Lens("MockLens3", "Home", false, this));
242+ addLens(new Lens("MockLens4", "Apps", true, this));
243+ addLens(new Lens("MockLens5", "Video", true, this));
244+
245+ if (!m_loaded) {
246+ m_loaded = true;
247+ Q_EMIT loadedChanged(m_loaded);
248+ }
249+}
250+
251+void Lenses::clear()
252+{
253+ timer.stop();
254+ if (m_lenses.size() > 0) {
255+ beginRemoveRows(QModelIndex(), 0, m_lenses.count()-1);
256+ qDeleteAll(m_lenses);
257+ m_lenses.clear();
258+ endRemoveRows();
259+ }
260+
261+ if (m_loaded) {
262+ m_loaded = false;
263+ Q_EMIT loadedChanged(m_loaded);
264+ }
265+}
266+
267+void Lenses::load()
268+{
269+ timer.start();
270+}
271+
272+QHash<int, QByteArray> Lenses::roleNames() const
273+{
274+ return m_roles;
275+}
276+
277+int Lenses::rowCount(const QModelIndex&) const
278+{
279+ return m_lenses.count();
280+}
281+
282+QVariant Lenses::data(const QModelIndex& index, int role) const
283+{
284+ Q_UNUSED(role)
285+
286+ if (!index.isValid() || index.row() >= m_lenses.size()) {
287+ return QVariant();
288+ }
289+
290+ Lens* lens = m_lenses.at(index.row());
291+
292+ if (role == Lenses::RoleLens) {
293+ return QVariant::fromValue(lens);
294+ } else if (role == Lenses::RoleId) {
295+ return QVariant::fromValue(lens->id());
296+ } else if (role == Lenses::RoleVisible) {
297+ return QVariant::fromValue(lens->visible());
298+ } else {
299+ return QVariant();
300+ }
301+}
302+
303+QVariant Lenses::get(int row) const
304+{
305+ return data(QAbstractListModel::index(row), 0);
306+}
307+
308+QVariant Lenses::get(QString const&) const
309+{
310+ return QVariant();
311+}
312+
313+QModelIndex Lenses::parent(const QModelIndex&) const
314+{
315+ return QModelIndex();
316+}
317+
318+bool Lenses::loaded() const
319+{
320+ return m_loaded;
321+}
322+
323+int Lenses::count() const
324+{
325+ return rowCount();
326+}
327+
328+void Lenses::addLens(Lens* lens)
329+{
330+ int index = rowCount();
331+ beginInsertRows(QModelIndex(), index, index);
332+ m_lenses.append(lens);
333+ endInsertRows();
334+}
335
336=== added file 'tests/qmltests/plugins/Unity/fake_lenses.h'
337--- tests/qmltests/plugins/Unity/fake_lenses.h 1970-01-01 00:00:00 +0000
338+++ tests/qmltests/plugins/Unity/fake_lenses.h 2013-04-21 14:41:25 +0000
339@@ -0,0 +1,80 @@
340+/*
341+ * Copyright (C) 2013 Canonical, Ltd.
342+ *
343+ * This program is free software; you can redistribute it and/or modify
344+ * it under the terms of the GNU General Public License as published by
345+ * the Free Software Foundation; version 3.
346+ *
347+ * This program is distributed in the hope that it will be useful,
348+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
349+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
350+ * GNU General Public License for more details.
351+ *
352+ * You should have received a copy of the GNU General Public License
353+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
354+ *
355+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
356+ */
357+
358+#ifndef FAKE_LENSES_H
359+#define FAKE_LENSES_H
360+
361+// Local
362+#include "fake_lens.h"
363+
364+// Qt
365+#include <QAbstractListModel>
366+#include <QList>
367+#include <QTimer>
368+
369+class Lenses : public QAbstractListModel
370+{
371+ Q_OBJECT
372+ Q_ENUMS(Roles)
373+ Q_PROPERTY(bool loaded READ loaded NOTIFY loadedChanged)
374+ Q_PROPERTY(int count READ count NOTIFY countChanged)
375+
376+public:
377+ explicit Lenses(QObject *parent = 0);
378+ ~Lenses();
379+
380+ enum Roles {
381+ RoleLens,
382+ RoleId,
383+ RoleVisible
384+ };
385+
386+ Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
387+
388+ Q_INVOKABLE QVariant get(int row) const;
389+ Q_INVOKABLE QVariant get(const QString& lens_id) const;
390+
391+ Q_INVOKABLE void addLens(Lens* lens);
392+
393+ Q_INVOKABLE void clear();
394+ Q_INVOKABLE void load();
395+
396+
397+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
398+ QHash<int, QByteArray> roleNames() const;
399+ QModelIndex parent ( const QModelIndex & index ) const;
400+
401+ bool loaded() const;
402+ int count() const;
403+
404+Q_SIGNALS:
405+ void activateLensRequested(const QString& lens_id);
406+ void loadedChanged(bool);
407+ void countChanged();
408+
409+private Q_SLOTS:
410+ void updateLenses();
411+
412+private:
413+ QList<Lens*> m_lenses;
414+ QHash<int, QByteArray> m_roles;
415+ bool m_loaded;
416+ QTimer timer;
417+};
418+
419+#endif // LENSES_H
420
421=== added file 'tests/qmltests/plugins/Unity/fake_unity_plugin.cpp'
422--- tests/qmltests/plugins/Unity/fake_unity_plugin.cpp 1970-01-01 00:00:00 +0000
423+++ tests/qmltests/plugins/Unity/fake_unity_plugin.cpp 2013-04-21 14:41:25 +0000
424@@ -0,0 +1,32 @@
425+/*
426+ * Copyright (C) 2013 Canonical, Ltd.
427+ *
428+ * This program is free software; you can redistribute it and/or modify
429+ * it under the terms of the GNU General Public License as published by
430+ * the Free Software Foundation; version 3.
431+ *
432+ * This program is distributed in the hope that it will be useful,
433+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
434+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
435+ * GNU General Public License for more details.
436+ *
437+ * You should have received a copy of the GNU General Public License
438+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
439+ *
440+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
441+ */
442+
443+// Self
444+#include "fake_unity_plugin.h"
445+#include "fake_lenses.h"
446+
447+// Qt
448+#include <QtQml>
449+
450+void FakeUnityPlugin::registerTypes(const char *uri)
451+{
452+ Q_ASSERT(uri == QLatin1String("Unity"));
453+
454+ qmlRegisterType<Lenses>(uri, 0, 1, "Lenses");
455+ qmlRegisterType<Lens>(uri, 0, 1, "Lens");
456+}
457
458=== added file 'tests/qmltests/plugins/Unity/fake_unity_plugin.h'
459--- tests/qmltests/plugins/Unity/fake_unity_plugin.h 1970-01-01 00:00:00 +0000
460+++ tests/qmltests/plugins/Unity/fake_unity_plugin.h 2013-04-21 14:41:25 +0000
461@@ -0,0 +1,34 @@
462+/*
463+ * Copyright (C) 2013 Canonical, Ltd.
464+ *
465+ * This program is free software; you can redistribute it and/or modify
466+ * it under the terms of the GNU General Public License as published by
467+ * the Free Software Foundation; version 3.
468+ *
469+ * This program is distributed in the hope that it will be useful,
470+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
471+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
472+ * GNU General Public License for more details.
473+ *
474+ * You should have received a copy of the GNU General Public License
475+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
476+ *
477+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
478+ */
479+
480+#ifndef FAKE_UNITY_PLUGIN_H
481+#define FAKE_UNITY_PLUGIN_H
482+
483+// Qt
484+#include <QtQml/QQmlExtensionPlugin>
485+
486+class FakeUnityPlugin : public QQmlExtensionPlugin
487+{
488+ Q_OBJECT
489+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
490+
491+public:
492+ void registerTypes(const char *uri);
493+};
494+
495+#endif
496
497=== added file 'tests/qmltests/plugins/Unity/qmldir'
498--- tests/qmltests/plugins/Unity/qmldir 1970-01-01 00:00:00 +0000
499+++ tests/qmltests/plugins/Unity/qmldir 2013-04-21 14:41:25 +0000
500@@ -0,0 +1,2 @@
501+module Unity
502+plugin FakeUnityQml

Subscribers

People subscribed via source and target branches