Merge lp:~nick-dedekind/unity8/indicator-tests-qt5.2.1 into lp:unity8

Proposed by Nick Dedekind
Status: Merged
Approved by: Michał Sawicz
Approved revision: 750
Merged at revision: 751
Proposed branch: lp:~nick-dedekind/unity8/indicator-tests-qt5.2.1
Merge into: lp:unity8
Diff against target: 334 lines (+203/-31)
8 files modified
qml/Panel/IndicatorItem.qml (+13/-21)
tests/mocks/Unity/Indicators/CMakeLists.txt (+1/-0)
tests/mocks/Unity/Indicators/IndicatorsModel.qml (+4/-6)
tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp (+116/-0)
tests/mocks/Unity/Indicators/fakeindicatorsmodel.h (+59/-0)
tests/mocks/Unity/Indicators/fakeplugin.cpp (+6/-0)
tests/qmltests/Panel/tst_IndicatorRow.qml (+3/-3)
tests/qmltests/Panel/tst_MenuContent.qml (+1/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity8/indicator-tests-qt5.2.1
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+209048@code.launchpad.net

Commit message

Remocked IndicatorModel to fix qt5.2.1 changes.

Description of the change

Remocked IndicatorModel to fix qt5.2.1 changes.

 * Are there any related MPs required for this MP to build/function as expected? Please list.
No

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

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
N/A

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

To post a comment you must log in.
749. By Nick Dedekind

removed unnecessary includes

750. By Nick Dedekind

comments to plugin cpp

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:750
http://jenkins.qa.ubuntu.com/job/unity8-ci/2420/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/3622
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/3233/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1290
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/941
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/945
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/945/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/941
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/3187
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3626
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/3626/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3235
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/3235/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/5612/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/4421

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2420/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes, this helps!

 * Did CI run pass? If not, please explain why.
Unrelated known failures due to uitk py3 transition not there yet and a Qt crash.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Panel/IndicatorItem.qml'
2--- qml/Panel/IndicatorItem.qml 2014-01-13 17:40:09 +0000
3+++ qml/Panel/IndicatorItem.qml 2014-03-03 12:00:54 +0000
4@@ -19,37 +19,29 @@
5 import Unity.Indicators 0.1 as Indicators
6 import "../Components"
7
8-Item {
9- id: indicatorItem
10+Loader {
11+ id: root
12
13- property alias widgetSource: loader.source
14+ property alias widgetSource: root.source
15 property bool dimmed: false
16 property var indicatorProperties: undefined
17- property bool indicatorVisible: loader.item ? loader.item.enabled : false
18+ property bool indicatorVisible: item ? item.enabled : false
19 property string identifier
20
21 opacity: dimmed ? 0.4 : 1
22 Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
23
24- width: loader.item ? loader.item.width : 0
25-
26- Loader {
27- id: loader
28-
29- onLoaded: {
30- item.height = Qt.binding(function() { return indicatorItem.height; });
31-
32- for(var pName in indicatorProperties) {
33- if (item.hasOwnProperty(pName)) {
34- item[pName] = indicatorProperties[pName];
35- }
36+ onLoaded: {
37+ for(var pName in indicatorProperties) {
38+ if (item.hasOwnProperty(pName)) {
39+ item[pName] = indicatorProperties[pName];
40 }
41 }
42+ }
43
44- Binding {
45- target: loader.item
46- property: "objectName"
47- value: identifier + "-widget"
48- }
49+ Binding {
50+ target: item
51+ property: "objectName"
52+ value: identifier + "-widget"
53 }
54 }
55
56=== modified file 'tests/mocks/Unity/Indicators/CMakeLists.txt'
57--- tests/mocks/Unity/Indicators/CMakeLists.txt 2013-12-12 16:32:20 +0000
58+++ tests/mocks/Unity/Indicators/CMakeLists.txt 2014-03-03 12:00:54 +0000
59@@ -16,6 +16,7 @@
60 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
61 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
62 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
63+ fakeindicatorsmodel.cpp
64 )
65
66 set(IndicatorsFakeQml_RESOURCES
67
68=== modified file 'tests/mocks/Unity/Indicators/IndicatorsModel.qml'
69--- tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-01-14 16:44:35 +0000
70+++ tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-03-03 12:00:54 +0000
71@@ -17,12 +17,10 @@
72 import QtQuick 2.0
73 import Unity.Indicators 0.1 as Indicators
74
75-ListModel {
76-
77- property var indicatorData : undefined
78-
79- function load() {
80- clear();
81+Indicators.FakeIndicatorsModel {
82+
83+ function load(profile) {
84+ unload();
85
86 append({ "identifier": "indicator-fake1",
87 "position": 0,
88
89=== added file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp'
90--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 1970-01-01 00:00:00 +0000
91+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 2014-03-03 12:00:54 +0000
92@@ -0,0 +1,116 @@
93+/*
94+ * Copyright 2014 Canonical Ltd.
95+ *
96+ * This program is free software; you can redistribute it and/or modify
97+ * it under the terms of the GNU Lesser General Public License as published by
98+ * the Free Software Foundation; version 3.
99+ *
100+ * This program is distributed in the hope that it will be useful,
101+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
102+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
103+ * GNU Lesser General Public License for more details.
104+ *
105+ * You should have received a copy of the GNU Lesser General Public License
106+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
107+ *
108+ * Authors:
109+ * Nick Dedekind <nick.dedekind@canonical.com>
110+ */
111+
112+#include "fakeindicatorsmodel.h"
113+#include "indicators.h"
114+
115+FakeIndicatorsModel::FakeIndicatorsModel(QObject *parent)
116+ : QAbstractListModel(parent)
117+{
118+ QObject::connect(this, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
119+ QObject::connect(this, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SIGNAL(countChanged()));
120+ QObject::connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged()));
121+}
122+
123+/*! \internal */
124+FakeIndicatorsModel::~FakeIndicatorsModel()
125+{
126+ unload();
127+}
128+
129+int FakeIndicatorsModel::count() const
130+{
131+ return rowCount();
132+}
133+
134+void FakeIndicatorsModel::load(const QString&)
135+{
136+}
137+
138+void FakeIndicatorsModel::unload()
139+{
140+ beginResetModel();
141+
142+ qDeleteAll(m_indicators);
143+ m_indicators.clear();
144+
145+ endResetModel();
146+}
147+
148+
149+void FakeIndicatorsModel::append(const QVariantMap& row)
150+{
151+ Indicator* new_row = new QHash<int, QVariant>();
152+ for (auto iter = row.begin(); iter != row.end(); ++iter )
153+ {
154+ int key = roleNames().key(iter.key().toUtf8(), -1);
155+ if (key != -1) {
156+ new_row->insert(key, iter.value());
157+ }
158+ }
159+
160+ beginInsertRows(QModelIndex(), m_indicators.count(), m_indicators.count());
161+
162+ m_indicators.append(new_row);
163+
164+ endInsertRows();
165+}
166+
167+QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const
168+{
169+ static QHash<int, QByteArray> roles;
170+ if (roles.isEmpty())
171+ {
172+ roles[IndicatorsModelRole::Identifier] = "identifier";
173+ roles[IndicatorsModelRole::Position] = "position";
174+ roles[IndicatorsModelRole::WidgetSource] = "widgetSource";
175+ roles[IndicatorsModelRole::PageSource] = "pageSource";
176+ roles[IndicatorsModelRole::IndicatorProperties] = "indicatorProperties";
177+ }
178+ return roles;
179+}
180+
181+int FakeIndicatorsModel::columnCount(const QModelIndex &) const
182+{
183+ return 1;
184+}
185+
186+Q_INVOKABLE QVariant FakeIndicatorsModel::data(int row, int role) const
187+{
188+ return data(index(row, 0), role);
189+}
190+
191+QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const
192+{
193+ if (!index.isValid() || index.row() >= m_indicators.size())
194+ return QVariant();
195+
196+ Indicator* indicator = m_indicators[index.row()];
197+ return indicator->value(role, QVariant());
198+}
199+
200+QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const
201+{
202+ return QModelIndex();
203+}
204+
205+int FakeIndicatorsModel::rowCount(const QModelIndex&) const
206+{
207+ return m_indicators.count();
208+}
209
210=== added file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.h'
211--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 1970-01-01 00:00:00 +0000
212+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 2014-03-03 12:00:54 +0000
213@@ -0,0 +1,59 @@
214+/*
215+ * Copyright 2014 Canonical Ltd.
216+ *
217+ * This program is free software; you can redistribute it and/or modify
218+ * it under the terms of the GNU Lesser General Public License as published by
219+ * the Free Software Foundation; version 3.
220+ *
221+ * This program is distributed in the hope that it will be useful,
222+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
223+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
224+ * GNU Lesser General Public License for more details.
225+ *
226+ * You should have received a copy of the GNU Lesser General Public License
227+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
228+ *
229+ * Authors:
230+ * Nick Dedekind <nick.dedekind@canonical.com>
231+ */
232+
233+#ifndef FAKE_INDICATORSMODEL_H
234+#define FAKE_INDICATORSMODEL_H
235+
236+#include <QAbstractListModel>
237+
238+class FakeIndicatorsModel : public QAbstractListModel
239+{
240+ Q_OBJECT
241+ Q_ENUMS(Roles)
242+ Q_PROPERTY(int count READ count NOTIFY countChanged)
243+public:
244+
245+ FakeIndicatorsModel(QObject *parent=0);
246+ ~FakeIndicatorsModel();
247+
248+ Q_INVOKABLE void load(const QString& profile);
249+ Q_INVOKABLE void unload();
250+
251+ Q_INVOKABLE void append(const QVariantMap& row);
252+
253+ Q_INVOKABLE QVariant data(int row, int role) const;
254+
255+ /* QAbstractItemModel */
256+ QHash<int, QByteArray> roleNames() const;
257+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
258+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
259+ QModelIndex parent (const QModelIndex &index) const;
260+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
261+
262+Q_SIGNALS:
263+ void countChanged();
264+
265+private:
266+ int count() const;
267+
268+ typedef QHash<int, QVariant> Indicator;
269+ QList<Indicator*> m_indicators;
270+};
271+
272+#endif // FAKE_INDICATORSMODEL_H
273
274=== modified file 'tests/mocks/Unity/Indicators/fakeplugin.cpp'
275--- tests/mocks/Unity/Indicators/fakeplugin.cpp 2013-12-12 16:32:20 +0000
276+++ tests/mocks/Unity/Indicators/fakeplugin.cpp 2014-03-03 12:00:54 +0000
277@@ -23,6 +23,7 @@
278 #include "fakeplugin.h"
279
280 // local
281+#include "fakeindicatorsmodel.h"
282 #include "indicators.h"
283 #include "menucontentactivator.h"
284 #include "unitymenumodelstack.h"
285@@ -32,10 +33,15 @@
286 {
287 Q_INIT_RESOURCE(indicators_fake);
288
289+ // internal
290+ qmlRegisterType<FakeIndicatorsModel>(uri, 0, 1, "FakeIndicatorsModel");
291+
292+ // external
293 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
294 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
295 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
296
297+ // external uncreatables
298 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
299 qmlRegisterUncreatableType<ActionState>(uri, 0, 1, "ActionState", "Can't create ActionState class");
300 qmlRegisterUncreatableType<NetworkActionState>(uri, 0, 1, "NetworkActionState", "Can't create NetworkActionState class");
301
302=== modified file 'tests/qmltests/Panel/tst_IndicatorRow.qml'
303--- tests/qmltests/Panel/tst_IndicatorRow.qml 2014-01-30 14:58:20 +0000
304+++ tests/qmltests/Panel/tst_IndicatorRow.qml 2014-03-03 12:00:54 +0000
305@@ -70,13 +70,13 @@
306 function test_set_current_item() {
307 init_test();
308 indicatorRow.setCurrentItemIndex(0);
309- compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake1", "Incorrect item at position 0");
310+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake1", "Incorrect item at position 0");
311
312 indicatorRow.setCurrentItemIndex(1);
313- compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake2", "Incorrect item at position 1");
314+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake2", "Incorrect item at position 1");
315
316 indicatorRow.setCurrentItemIndex(2);
317- compare(indicatorRow.indicatorsModel.get(indicatorRow.currentItemIndex).identifier, "indicator-fake3", "Incorrect item at position 2");
318+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake3", "Incorrect item at position 2");
319 }
320
321 function test_highlight_data() {
322
323=== modified file 'tests/qmltests/Panel/tst_MenuContent.qml'
324--- tests/qmltests/Panel/tst_MenuContent.qml 2014-01-30 14:58:20 +0000
325+++ tests/qmltests/Panel/tst_MenuContent.qml 2014-03-03 12:00:54 +0000
326@@ -133,7 +133,7 @@
327 var menuIndex = i%menuCount;
328
329 activate_content(menuIndex);
330- testTabObjectName = indicatorsModel.get(menuIndex).identifier;
331+ testTabObjectName = indicatorsModel.data(menuIndex, Indicators.IndicatorsModelRole.Identifier);
332 compare(tabs.selectedTabIndex, menuIndex, "Current tab index does not match selected tab index");
333 tryCompareFunction(selected_tab_equals_test_tab, true);
334 }

Subscribers

People subscribed via source and target branches