Merge lp:~osomon/unity-2d/listaggregatormodel-unittests into lp:unity-2d/3.0

Proposed by Olivier Tilloy
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 599
Merged at revision: 603
Proposed branch: lp:~osomon/unity-2d/listaggregatormodel-unittests
Merge into: lp:unity-2d/3.0
Diff against target: 463 lines (+398/-2)
5 files modified
.bzrignore (+3/-0)
libunity-2d-private/Unity2d/listaggregatormodel.cpp (+10/-2)
libunity-2d-private/Unity2d/listaggregatormodel.h (+3/-0)
libunity-2d-private/tests/CMakeLists.txt (+1/-0)
libunity-2d-private/tests/listaggregatormodeltest.cpp (+381/-0)
To merge this branch: bzr merge lp:~osomon/unity-2d/listaggregatormodel-unittests
Reviewer Review Type Date Requested Status
Florian Boucault (community) Approve
Review via email: mp+64422@code.launchpad.net

Commit message

[libunity-2d] Unit test the ListAggregatorModel class.

To post a comment you must log in.
Revision history for this message
Florian Boucault (fboucault) wrote :

Awesome work.

Trivial conflict remaining in .bzrignore. Please merge once resolved.

review: Approve
599. By Olivier Tilloy

Merged the latest changes from the trunk, thus resolving a minor conflict.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2011-06-15 13:10:39 +0000
3+++ .bzrignore 2011-06-15 14:43:29 +0000
4@@ -21,9 +21,11 @@
5 panel/applets/indicator-config.h
6 panel/applets/registraradaptor.*
7 panel/lib/libuqpanel.so*
8+panel/tests/Testing
9 panel/tests/homebuttonapplettest
10
11 libunity-2d-private/src/libunity-2d-private.so.*
12+libunity-2d-private/tests/Testing
13 libunity-2d-private/tests/config-test.h
14 libunity-2d-private/tests/gnomesessionclienttest.sh
15 libunity-2d-private/tests/gnomesessionclienttesthelper
16@@ -34,6 +36,7 @@
17 libunity-2d-private/tests/mouseareademo
18 libunity-2d-private/tests/paneltest
19 libunity-2d-private/tests/unity2dtrtest
20+libunity-2d-private/tests/listaggregatormodeltest
21 libunity-2d-private/Unity2d/qrc_launchermenu.cxx
22
23 po/*.gmo
24
25=== modified file 'libunity-2d-private/Unity2d/listaggregatormodel.cpp'
26--- libunity-2d-private/Unity2d/listaggregatormodel.cpp 2011-06-09 16:16:36 +0000
27+++ libunity-2d-private/Unity2d/listaggregatormodel.cpp 2011-06-15 14:43:29 +0000
28@@ -38,13 +38,21 @@
29 void
30 ListAggregatorModel::appendModel(const QVariant& model)
31 {
32+ static const char* errorMsg = "Unable to append a model that is not of type QAbstractListModel.";
33+ if (!model.isValid()) {
34+ UQ_WARNING << errorMsg << "Invalid model.";
35+ return;
36+ }
37 QObject* object = qvariant_cast<QObject*>(model);
38+ if (object == NULL) {
39+ UQ_WARNING << errorMsg << model << "is of type" << model.typeName();
40+ return;
41+ }
42 QAbstractItemModel* list = qobject_cast<QAbstractListModel*>(object);
43 if (list == NULL) {
44 list = qobject_cast<QSortFilterProxyModel*>(object);
45 if (list == NULL) {
46- UQ_WARNING << "Unable to append model that is not of type QAbstractListModel."
47- << object->objectName() << "is of type" << object->metaObject()->className();
48+ UQ_WARNING << errorMsg << object->objectName() << "is of type" << object->metaObject()->className();
49 return;
50 }
51 }
52
53=== modified file 'libunity-2d-private/Unity2d/listaggregatormodel.h'
54--- libunity-2d-private/Unity2d/listaggregatormodel.h 2011-06-09 16:16:36 +0000
55+++ libunity-2d-private/Unity2d/listaggregatormodel.h 2011-06-15 14:43:29 +0000
56@@ -41,6 +41,9 @@
57 ListAggregatorModel(QObject* parent = 0);
58 ~ListAggregatorModel();
59
60+ /* Allow test fixtures to access protected and private members. */
61+ friend class ListAggregatorModelTest;
62+
63 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
64 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const;
65 Q_INVOKABLE QVariant get(int row) const;
66
67=== modified file 'libunity-2d-private/tests/CMakeLists.txt'
68--- libunity-2d-private/tests/CMakeLists.txt 2011-06-07 16:34:46 +0000
69+++ libunity-2d-private/tests/CMakeLists.txt 2011-06-15 14:43:29 +0000
70@@ -37,6 +37,7 @@
71 paneltest
72 unity2dtrtest
73 launchermenutest
74+ listaggregatormodeltest
75 )
76
77 add_custom_target(unity2dtr_po COMMAND
78
79=== added file 'libunity-2d-private/tests/listaggregatormodeltest.cpp'
80--- libunity-2d-private/tests/listaggregatormodeltest.cpp 1970-01-01 00:00:00 +0000
81+++ libunity-2d-private/tests/listaggregatormodeltest.cpp 2011-06-15 14:43:29 +0000
82@@ -0,0 +1,381 @@
83+/*
84+ * Copyright (C) 2011 Canonical, Ltd.
85+ *
86+ * Authors:
87+ * Olivier Tilloy <olivier.tilloy@canonical.com>
88+ *
89+ * This program is free software; you can redistribute it and/or modify
90+ * it under the terms of the GNU General Public License as published by
91+ * the Free Software Foundation; version 3.
92+ *
93+ * This program is distributed in the hope that it will be useful,
94+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
95+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
96+ * GNU General Public License for more details.
97+ *
98+ * You should have received a copy of the GNU General Public License
99+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
100+ */
101+
102+// local
103+#include <listaggregatormodel.h>
104+
105+// Qt
106+#include <QTest>
107+#include <QStringListModel>
108+#include <QSignalSpy>
109+#include <QModelIndex>
110+#include <QSortFilterProxyModel>
111+#include <QAbstractListModel>
112+
113+class QMovableStringListModel : public QAbstractListModel
114+{
115+ Q_OBJECT
116+
117+public:
118+ QMovableStringListModel(const QStringList& lst, QObject* parent = 0)
119+ : QAbstractListModel(parent)
120+ , m_lst(lst)
121+ {
122+ }
123+
124+ int rowCount(const QModelIndex& parent = QModelIndex()) const
125+ {
126+ return m_lst.size();
127+ }
128+
129+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const
130+ {
131+ if (!index.isValid() || index.row() < 0 || index.row() >= m_lst.size()) {
132+ return QVariant();
133+ }
134+ return QVariant(m_lst[index.row()]);
135+ }
136+
137+ Q_INVOKABLE void move(int from, int to)
138+ {
139+ if (from < 0 || from >= m_lst.size() || to < 0 || to >= m_lst.size() || from == to) {
140+ return;
141+ }
142+ QModelIndex parent;
143+ beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0));
144+ m_lst.move(from, to);
145+ endMoveRows();
146+ }
147+
148+private:
149+ QStringList m_lst;
150+};
151+
152+class ListAggregatorModelTest : public QObject
153+{
154+ Q_OBJECT
155+
156+private Q_SLOTS:
157+
158+ void testRoleNames()
159+ {
160+ ListAggregatorModel model;
161+ const QHash<int, QByteArray> roleNames = model.roleNames();
162+ QCOMPARE(roleNames.size(), 1);
163+ QVERIFY(roleNames.contains(0));
164+ QCOMPARE(roleNames[0], QByteArray("item"));
165+ }
166+
167+ void testAppendModelWrongType()
168+ {
169+ ListAggregatorModel model;
170+ QVERIFY(model.m_models.isEmpty());
171+ QTest::ignoreMessage(QtWarningMsg, "void ListAggregatorModel::appendModel(const QVariant&): Unable to append a model that is not of type QAbstractListModel. Invalid model. ");
172+ model.appendModel(QVariant());
173+ QVERIFY(model.m_models.isEmpty());
174+ QTest::ignoreMessage(QtWarningMsg, "void ListAggregatorModel::appendModel(const QVariant&): Unable to append a model that is not of type QAbstractListModel. QVariant(bool, true) is of type bool ");
175+ model.appendModel(QVariant(true));
176+ QVERIFY(model.m_models.isEmpty());
177+ QTest::ignoreMessage(QtWarningMsg, "void ListAggregatorModel::appendModel(const QVariant&): Unable to append a model that is not of type QAbstractListModel. \"\" is of type QObject ");
178+ model.appendModel(QVariant::fromValue(new QObject));
179+ QVERIFY(model.m_models.isEmpty());
180+ }
181+
182+ void testAggregateListModel()
183+ {
184+ ListAggregatorModel model;
185+ QVERIFY(model.m_models.isEmpty());
186+ QCOMPARE(model.rowCount(), 0);
187+
188+ qRegisterMetaType<QModelIndex>("QModelIndex");
189+ QSignalSpy spyOnRowsAboutToBeInserted(&model, SIGNAL(rowsAboutToBeInserted(const QModelIndex&, int, int)));
190+ QSignalSpy spyOnRowsInserted(&model, SIGNAL(rowsInserted(const QModelIndex&, int, int)));
191+ QList<QVariant> signal;
192+
193+ QStringListModel list1(QStringList() << "aa" << "ab" << "ac");
194+ model.aggregateListModel(&list1);
195+ QCOMPARE(model.m_models.size(), 1);
196+ QCOMPARE(qobject_cast<QStringListModel*>(model.m_models[0]), &list1);
197+ QCOMPARE(model.rowCount(), 3);
198+ QCOMPARE(spyOnRowsAboutToBeInserted.count(), 1);
199+ signal = spyOnRowsAboutToBeInserted.takeFirst();
200+ QCOMPARE(signal[1].toInt(), 0);
201+ QCOMPARE(signal[2].toInt(), 2);
202+ QCOMPARE(spyOnRowsInserted.count(), 1);
203+ signal = spyOnRowsInserted.takeFirst();
204+ QCOMPARE(signal[1].toInt(), 0);
205+ QCOMPARE(signal[2].toInt(), 2);
206+
207+ QStringListModel list2(QStringList() << "ba" << "bb" << "bc" << "bd");
208+ model.aggregateListModel(&list2);
209+ QCOMPARE(model.m_models.size(), 2);
210+ QCOMPARE(qobject_cast<QStringListModel*>(model.m_models[1]), &list2);
211+ QCOMPARE(model.rowCount(), 7);
212+ QCOMPARE(spyOnRowsAboutToBeInserted.count(), 1);
213+ signal = spyOnRowsAboutToBeInserted.takeFirst();
214+ QCOMPARE(signal[1].toInt(), 3);
215+ QCOMPARE(signal[2].toInt(), 6);
216+ QCOMPARE(spyOnRowsInserted.count(), 1);
217+ signal = spyOnRowsInserted.takeFirst();
218+ QCOMPARE(signal[1].toInt(), 3);
219+ QCOMPARE(signal[2].toInt(), 6);
220+ }
221+
222+ void testRemoveListModel()
223+ {
224+ ListAggregatorModel model;
225+
226+ qRegisterMetaType<QModelIndex>("QModelIndex");
227+ QSignalSpy spyOnRowsAboutToBeRemoved(&model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)));
228+ QSignalSpy spyOnRowsRemoved(&model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)));
229+ QList<QVariant> signal;
230+
231+ QStringListModel list1(QStringList() << "aa" << "ab" << "ac");
232+ model.aggregateListModel(&list1);
233+ QStringListModel list2(QStringList() << "ba" << "bb" << "bc" << "bd");
234+ model.aggregateListModel(&list2);
235+ QStringListModel list3(QStringList() << "ca" << "cb");
236+ model.aggregateListModel(&list3);
237+
238+ model.removeListModel(&list2);
239+ QCOMPARE(model.m_models.size(), 2);
240+ QCOMPARE(qobject_cast<QStringListModel*>(model.m_models[0]), &list1);
241+ QCOMPARE(qobject_cast<QStringListModel*>(model.m_models[1]), &list3);
242+ QCOMPARE(model.rowCount(), 5);
243+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 1);
244+ signal = spyOnRowsAboutToBeRemoved.takeFirst();
245+ QCOMPARE(signal[1].toInt(), 3);
246+ QCOMPARE(signal[2].toInt(), 6);
247+ QCOMPARE(spyOnRowsRemoved.count(), 1);
248+ signal = spyOnRowsRemoved.takeFirst();
249+ QCOMPARE(signal[1].toInt(), 3);
250+ QCOMPARE(signal[2].toInt(), 6);
251+ }
252+
253+ void testData()
254+ {
255+ ListAggregatorModel model;
256+ model.aggregateListModel(new QStringListModel(QStringList() << "aa" << "ab" << "ac", &model));
257+ model.aggregateListModel(new QStringListModel(QStringList() << "ba" << "bb" << "bc" << "bd", &model));
258+ model.aggregateListModel(new QStringListModel(QStringList() << "ca" << "cb", &model));
259+ QStringList data = QStringList() << "aa" << "ab" << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb";
260+ for (int i = 0; i < model.rowCount(); ++i) {
261+ QCOMPARE(model.data(model.index(i)).toString(), data[i]);
262+ }
263+ }
264+
265+ void testGet()
266+ {
267+ ListAggregatorModel model;
268+ model.aggregateListModel(new QStringListModel(QStringList() << "aa" << "ab" << "ac", &model));
269+ model.aggregateListModel(new QStringListModel(QStringList() << "ba" << "bb" << "bc" << "bd", &model));
270+ model.aggregateListModel(new QStringListModel(QStringList() << "ca" << "cb", &model));
271+ QStringList data = QStringList() << "aa" << "ab" << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb";
272+ for (int i = 0; i < model.rowCount(); ++i) {
273+ QCOMPARE(model.get(i).toString(), data[i]);
274+ }
275+ }
276+
277+ void testComputeOffset()
278+ {
279+ ListAggregatorModel model;
280+ QStringListModel list1(QStringList() << "aa" << "ab" << "ac");
281+ model.aggregateListModel(&list1);
282+ QStringListModel list2(QStringList() << "ba" << "bb" << "bc" << "bd");
283+ model.aggregateListModel(&list2);
284+ QStringListModel list3(QStringList() << "ca" << "cb");
285+ model.aggregateListModel(&list3);
286+
287+ QCOMPARE(model.computeOffset(&list1), 0);
288+ QCOMPARE(model.computeOffset(&list2), 3);
289+ QCOMPARE(model.computeOffset(&list3), 7);
290+ }
291+
292+ void testModelAtIndex()
293+ {
294+ ListAggregatorModel model;
295+ QStringListModel list1(QStringList() << "aa" << "ab" << "ac");
296+ model.aggregateListModel(&list1);
297+ QStringListModel list2(QStringList() << "ba" << "bb" << "bc" << "bd");
298+ model.aggregateListModel(&list2);
299+ QStringListModel list3(QStringList() << "ca" << "cb");
300+ model.aggregateListModel(&list3);
301+
302+ QCOMPARE(model.modelAtIndex(0), &list1);
303+ QCOMPARE(model.modelAtIndex(1), &list1);
304+ QCOMPARE(model.modelAtIndex(2), &list1);
305+ QCOMPARE(model.modelAtIndex(3), &list2);
306+ QCOMPARE(model.modelAtIndex(4), &list2);
307+ QCOMPARE(model.modelAtIndex(5), &list2);
308+ QCOMPARE(model.modelAtIndex(6), &list2);
309+ QCOMPARE(model.modelAtIndex(7), &list3);
310+ QCOMPARE(model.modelAtIndex(8), &list3);
311+ }
312+
313+ void testRemoveRows()
314+ {
315+ ListAggregatorModel model;
316+
317+ qRegisterMetaType<QModelIndex>("QModelIndex");
318+ QSignalSpy spyOnRowsAboutToBeRemoved(&model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)));
319+ QSignalSpy spyOnRowsRemoved(&model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)));
320+ QList<QVariant> signal;
321+
322+ model.aggregateListModel(new QStringListModel(QStringList() << "aa" << "ab" << "ac", &model));
323+ model.aggregateListModel(new QStringListModel(QStringList() << "ba" << "bb" << "bc" << "bd", &model));
324+ model.aggregateListModel(new QStringListModel(QStringList() << "ca" << "cb", &model));
325+
326+ // Invalid boundaries, doesn’t remove anything.
327+ QVERIFY(!model.removeRows(-1, 2));
328+ QCOMPARE(model.rowCount(), 9);
329+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 0);
330+ QCOMPARE(spyOnRowsRemoved.count(), 0);
331+ QVERIFY(!model.removeRows(10, 2));
332+ QCOMPARE(model.rowCount(), 9);
333+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 0);
334+ QCOMPARE(spyOnRowsRemoved.count(), 0);
335+ QVERIFY(!model.removeRows(2, 0));
336+ QCOMPARE(model.rowCount(), 9);
337+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 0);
338+ QCOMPARE(spyOnRowsRemoved.count(), 0);
339+
340+ // Remove two rows from the beginning, only modifies the first model.
341+ QVERIFY(model.removeRows(0, 2));
342+ QCOMPARE(model.rowCount(), 7);
343+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 1);
344+ signal = spyOnRowsAboutToBeRemoved.takeFirst();
345+ QCOMPARE(signal[1].toInt(), 0);
346+ QCOMPARE(signal[2].toInt(), 1);
347+ QCOMPARE(spyOnRowsRemoved.count(), 1);
348+ signal = spyOnRowsRemoved.takeFirst();
349+ QCOMPARE(signal[1].toInt(), 0);
350+ QCOMPARE(signal[2].toInt(), 1);
351+ checkModelData(&model, QStringList() << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb");
352+
353+ // Request to remove three rows starting from the last index,
354+ // only one row is actually removed.
355+ QVERIFY(model.removeRows(6, 3));
356+ QCOMPARE(model.rowCount(), 6);
357+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 1);
358+ signal = spyOnRowsAboutToBeRemoved.takeFirst();
359+ QCOMPARE(signal[1].toInt(), 6);
360+ QCOMPARE(signal[2].toInt(), 6);
361+ QCOMPARE(spyOnRowsRemoved.count(), 1);
362+ signal = spyOnRowsRemoved.takeFirst();
363+ QCOMPARE(signal[1].toInt(), 6);
364+ QCOMPARE(signal[2].toInt(), 6);
365+ checkModelData(&model, QStringList() << "ac" << "ba" << "bb" << "bc" << "bd" << "ca");
366+
367+ // Remove rows that span two models.
368+ QVERIFY(model.removeRows(3, 3));
369+ QCOMPARE(model.rowCount(), 3);
370+ QCOMPARE(spyOnRowsAboutToBeRemoved.count(), 2);
371+ signal = spyOnRowsAboutToBeRemoved.takeFirst();
372+ QCOMPARE(signal[1].toInt(), 3);
373+ QCOMPARE(signal[2].toInt(), 4);
374+ signal = spyOnRowsAboutToBeRemoved.takeFirst();
375+ QCOMPARE(signal[1].toInt(), 3);
376+ QCOMPARE(signal[2].toInt(), 3);
377+ QCOMPARE(spyOnRowsRemoved.count(), 2);
378+ signal = spyOnRowsRemoved.takeFirst();
379+ QCOMPARE(signal[1].toInt(), 3);
380+ QCOMPARE(signal[2].toInt(), 4);
381+ signal = spyOnRowsRemoved.takeFirst();
382+ QCOMPARE(signal[1].toInt(), 3);
383+ QCOMPARE(signal[2].toInt(), 3);
384+ checkModelData(&model, QStringList() << "ac" << "ba" << "bb");
385+ }
386+
387+ void testMove()
388+ {
389+ ListAggregatorModel model;
390+
391+ qRegisterMetaType<QModelIndex>("QModelIndex");
392+ QSignalSpy spyOnRowsAboutToBeMoved(&model, SIGNAL(rowsAboutToBeMoved(const QModelIndex&, int, int, const QModelIndex&, int)));
393+ QSignalSpy spyOnRowsMoved(&model, SIGNAL(rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int)));
394+ QList<QVariant> signal;
395+
396+ model.aggregateListModel(new QStringListModel(QStringList() << "aa" << "ab" << "ac", &model));
397+ model.aggregateListModel(new QMovableStringListModel(QStringList() << "ba" << "bb" << "bc" << "bd", &model));
398+ QStringListModel proxiedModel(QStringList() << "ca" << "cb");
399+ QSortFilterProxyModel proxyModel;
400+ proxyModel.setSourceModel(&proxiedModel);
401+ model.aggregateListModel(&proxyModel);
402+
403+ // Moving rows from one model to another is forbidden.
404+ QTest::ignoreMessage(QtWarningMsg, "void ListAggregatorModel::move(int, int): cannot move an item from one model to another ");
405+ model.move(1, 5);
406+ QCOMPARE(spyOnRowsAboutToBeMoved.count(), 0);
407+ QCOMPARE(spyOnRowsMoved.count(), 0);
408+ checkModelData(&model, QStringList() << "aa" << "ab" << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb");
409+
410+ // Cannot move rows in a QSortFilterProxyModel.
411+ QTest::ignoreMessage(QtWarningMsg, "void ListAggregatorModel::move(int, int): cannot move the items of a QSortFilterProxyModel ");
412+ model.move(8, 7);
413+ QCOMPARE(spyOnRowsAboutToBeMoved.count(), 0);
414+ QCOMPARE(spyOnRowsMoved.count(), 0);
415+ checkModelData(&model, QStringList() << "aa" << "ab" << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb");
416+
417+ // 'move' is not defined for a QStringListModel, won’t have any effect.
418+ QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QStringListModel::move(int,int)");
419+ model.move(0, 2);
420+ QCOMPARE(spyOnRowsAboutToBeMoved.count(), 0);
421+ QCOMPARE(spyOnRowsMoved.count(), 0);
422+ checkModelData(&model, QStringList() << "aa" << "ab" << "ac" << "ba" << "bb" << "bc" << "bd" << "ca" << "cb");
423+
424+ // Actually move rows in a model that supports the operation.
425+ model.move(4, 6);
426+ QCOMPARE(spyOnRowsAboutToBeMoved.count(), 1);
427+ signal = spyOnRowsAboutToBeMoved.takeFirst();
428+ QCOMPARE(signal[1].toInt(), 4);
429+ QCOMPARE(signal[2].toInt(), 4);
430+ QCOMPARE(signal[4].toInt(), 7);
431+ QCOMPARE(spyOnRowsMoved.count(), 1);
432+ signal = spyOnRowsMoved.takeFirst();
433+ QCOMPARE(signal[1].toInt(), 4);
434+ QCOMPARE(signal[2].toInt(), 4);
435+ QCOMPARE(signal[4].toInt(), 7);
436+ checkModelData(&model, QStringList() << "aa" << "ab" << "ac" << "ba" << "bc" << "bd" << "bb" << "ca" << "cb");
437+ model.move(5, 4);
438+ QCOMPARE(spyOnRowsAboutToBeMoved.count(), 1);
439+ signal = spyOnRowsAboutToBeMoved.takeFirst();
440+ QCOMPARE(signal[1].toInt(), 5);
441+ QCOMPARE(signal[2].toInt(), 5);
442+ QCOMPARE(signal[4].toInt(), 4);
443+ QCOMPARE(spyOnRowsMoved.count(), 1);
444+ signal = spyOnRowsMoved.takeFirst();
445+ QCOMPARE(signal[1].toInt(), 5);
446+ QCOMPARE(signal[2].toInt(), 5);
447+ QCOMPARE(signal[4].toInt(), 4);
448+ checkModelData(&model, QStringList() << "aa" << "ab" << "ac" << "ba" << "bd" << "bc" << "bb" << "ca" << "cb");
449+ }
450+
451+private:
452+ void checkModelData(ListAggregatorModel* model, const QStringList& data)
453+ {
454+ for (int i = 0; i < model->rowCount(); ++i) {
455+ QCOMPARE(model->get(i).toString(), data[i]);
456+ }
457+ }
458+};
459+
460+QTEST_MAIN(ListAggregatorModelTest)
461+
462+#include "listaggregatormodeltest.moc"
463+

Subscribers

People subscribed via source and target branches