1
/* This file is part of Zanshin Todo.
3
Copyright 2008 Kevin Ottens <ervin@kde.org>
4
Copyright 2008, 2009 Mario Bensi <nef@ipsquad.net>
6
This program is free software; you can redistribute it and/or
7
modify it under the terms of the GNU General Public License as
8
published by the Free Software Foundation; either version 2 of
9
the License or (at your option) version 3 or any later version
10
accepted by the membership of KDE e.V. (or its successor approved
11
by the membership of KDE e.V.), which shall act as a proxy
12
defined in Section 14 of version 3 of the license.
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU General Public License for more details.
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25
#include "modeltestbase.h"
27
#include <akonadi/collection.h>
28
#include <akonadi/item.h>
29
#include <akonadi/itemdeletejob.h>
30
#include <akonadi/qtest_akonadi.h>
32
#include <QtGui/QSortFilterProxyModel>
34
#include "todoflatmodel.h"
35
#include "todocategoriesmodel.h"
37
class TodoCategoriesModelTest : public ModelTestBase
43
void testInitialState();
44
void testSingleModification();
45
void testReparentModification();
46
void testSeveralReparentModification();
47
void testSingleRemoved();
48
void testMultipleRemoved();
49
void testDragAndDrop();
50
void testAddCategory_data();
51
void testAddCategory();
52
void testCategoryRename_data();
53
void testCategoryRename();
54
void testRemoveCategory_data();
55
void testRemoveCategory();
56
void testDnDCategory_data();
57
void testDnDCategory();
60
TodoFlatModel m_flatModel;
61
QSortFilterProxyModel m_flatSortedModel;
62
TodoCategoriesModel m_model;
63
QSortFilterProxyModel m_sortedModel;
66
QTEST_AKONADIMAIN(TodoCategoriesModelTest, GUI)
68
void TodoCategoriesModelTest::initTestCase()
70
ModelTestBase::initTestCase();
71
m_model.setSourceModel(&m_flatModel);
72
m_model.setCollection(m_collection);
75
m_flatSortedModel.setSourceModel(&m_flatModel);
76
m_flatSortedModel.sort(TodoFlatModel::RemoteId);
78
m_sortedModel.setSourceModel(&m_model);
79
m_sortedModel.sort(TodoFlatModel::Summary);
85
TreeNode(const QString &i, const QString &s)
86
: id(i), summary(s) { }
88
TreeNode &operator<<(const TreeNode &child)
90
const_cast<TreeNode&>(child).parent = summary;
98
QList<TreeNode> children;
102
static void dumpTree(const QList<TreeNode> &tree, int indent = 0)
105
for (int i=0; i<indent; ++i) {
109
foreach (const TreeNode &node, tree) {
110
qDebug() << prefix << "[" << node.parent << node.id << node.summary;
111
dumpTree(node.children, indent+1);
112
qDebug() << prefix << "]";
117
static void compareTrees(QAbstractItemModel *model, const QList<TreeNode> &tree,
118
const QModelIndex &root = QModelIndex())
121
foreach (const TreeNode &node, tree) {
122
QCOMPARE(model->data(model->index(row, TodoFlatModel::RemoteId, root)).toString(), node.id);
123
QCOMPARE(model->data(model->index(row, TodoFlatModel::Summary, root)).toString(), node.summary);
124
if (node.parent.isEmpty()) {
125
QVERIFY(model->data(model->index(row, TodoFlatModel::Categories, root)).toStringList().isEmpty());
127
QVERIFY(model->data(model->index(row, TodoFlatModel::Categories, root)).toStringList().contains(node.parent));
130
QCOMPARE(model->rowCount(model->index(row, 0, root)), node.children.size());
131
compareTrees(model, node.children, model->index(row, 0, root));
136
void TodoCategoriesModelTest::testInitialState()
138
QList<TreeNode> tree;
140
tree << (TreeNode(QString(), "Computer")
141
<< TreeNode(QString(), "Online")
142
<< TreeNode("fake-06", "Read magazine")
145
<< (TreeNode(QString(), "Errands")
146
<< TreeNode("fake-03", "Walk around with the dog")
149
<< (TreeNode(QString(), "Home")
150
<< TreeNode("fake-05", "Feed the dog")
153
<< (TreeNode(QString(), "Office")
154
<< TreeNode("fake-06", "Read magazine")
157
<< TreeNode(QString(), "Phone");
159
compareTrees(&m_sortedModel, tree);
162
void TodoCategoriesModelTest::testSingleModification()
164
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(5, 0)));
165
QModelIndexList indexes = m_model.indexesForItem(item, TodoFlatModel::Summary);
167
QSignalSpy spy(&m_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
169
QVERIFY(m_model.setData(indexes.first(), "Feed the cat"));
171
flushNotifications();
173
foreach (const QModelIndex &index, indexes) {
174
QCOMPARE(m_model.data(index).toString(), QString("Feed the cat"));
177
indexes = m_model.indexesForItem(item, 0);
178
QCOMPARE(spy.count(), indexes.size());
180
while (!spy.isEmpty()) {
181
QVariantList signal = spy.takeFirst();
183
QCOMPARE(signal.count(), 2);
184
QModelIndex begin = signal.at(0).value<QModelIndex>();
185
QModelIndex end = signal.at(1).value<QModelIndex>();
187
QVERIFY(begin.row()==end.row());
188
QVERIFY(begin.parent()==end.parent());
189
QCOMPARE(begin.column(), 0);
190
QCOMPARE(end.column(), (int)TodoFlatModel::LastColumn);
192
QVERIFY(indexes.contains(begin));
196
void TodoCategoriesModelTest::testReparentModification()
198
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(5, 0)));
199
QModelIndexList indexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
201
QModelIndexList oldParents;
202
QList<int> oldParentsRow;
203
foreach (const QModelIndex &index, indexes) {
204
oldParents << index.parent();
205
oldParentsRow << index.row();
208
QModelIndexList newParents;
209
QList<int> newParentsRow;
210
newParents << m_model.indexForCategory("Errands")
211
<< m_model.indexForCategory("Home");
212
foreach (const QModelIndex &newParent, newParents) {
213
newParentsRow << m_model.rowCount(newParent);
216
QSignalSpy rowsInserted(&m_model, SIGNAL(rowsInserted(QModelIndex, int, int)));
217
QSignalSpy rowsRemoved(&m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
219
// Note: It includes a category "Foo" which wasn't in the model previously,
220
// we should get an insert event for it too!
221
QVERIFY(m_model.setData(indexes.first(), "Home, Errands, Foo"));
223
flushNotifications();
225
QCOMPARE(rowsRemoved.count(), 2);
226
while (!rowsRemoved.isEmpty()) {
227
QVariantList signal = rowsRemoved.takeFirst();
228
QCOMPARE(signal.count(), 3);
230
QModelIndex parent = signal.at(0).value<QModelIndex>();
231
QVERIFY(oldParents.contains(parent));
233
int expectedRow = oldParentsRow[oldParents.indexOf(parent)];
234
QCOMPARE(signal.at(1).toInt(), expectedRow);
235
QCOMPARE(signal.at(2).toInt(), expectedRow);
238
QCOMPARE(rowsInserted.count(), 4);
240
// first insert event should be for "Foo":
242
QVariantList signal = rowsInserted.takeFirst();
243
QCOMPARE(signal.count(), 3);
245
QModelIndex parent = signal.at(0).value<QModelIndex>();
246
QVERIFY(!parent.isValid());
248
int expectedRow = m_model.rowCount()-1;
249
QCOMPARE(signal.at(1).toInt(), expectedRow);
250
QCOMPARE(signal.at(2).toInt(), expectedRow);
253
// Adjust newParents and newParentsRow to include the new "Foo" category
254
newParents << m_model.index(m_model.rowCount()-1, 0);
257
// now check the other events for the item itself
258
while (!rowsInserted.isEmpty()) {
259
QVariantList signal = rowsInserted.takeFirst();
260
QCOMPARE(signal.count(), 3);
262
QModelIndex parent = signal.at(0).value<QModelIndex>();
263
QVERIFY(newParents.contains(parent));
265
int expectedRow = newParentsRow[newParents.indexOf(parent)];
266
QCOMPARE(signal.at(1).toInt(), expectedRow);
267
QCOMPARE(signal.at(2).toInt(), expectedRow);
271
void TodoCategoriesModelTest::testSeveralReparentModification()
273
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(4, 0)));
274
QModelIndexList indexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
275
QCOMPARE(indexes.size(), 1);
276
QModelIndex index = indexes.takeFirst();
278
QModelIndex oldParent = index.parent();
279
QCOMPARE(oldParent, m_model.indexForCategory("Home"));
281
QModelIndex newParent = m_model.indexForCategory("Errands");
283
QSignalSpy rowsInserted(&m_model, SIGNAL(rowsInserted(QModelIndex, int, int)));
284
QSignalSpy rowsRemoved(&m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
287
QVERIFY(m_model.setData(index, "Errands"));
289
flushNotifications();
291
QCOMPARE(rowsRemoved.count(), 1);
292
QVariantList signal = rowsRemoved.takeFirst();
293
QCOMPARE(signal.count(), 3);
294
QCOMPARE(signal.at(0).value<QModelIndex>(), oldParent);
295
QCOMPARE(signal.at(1).toInt(), 0);
296
QCOMPARE(signal.at(2).toInt(), 0);
298
QCOMPARE(rowsInserted.count(), 1);
299
signal = rowsInserted.takeFirst();
300
QCOMPARE(signal.count(), 3);
301
QCOMPARE(signal.at(0).value<QModelIndex>(), newParent);
302
QCOMPARE(signal.at(1).toInt(), 2);
303
QCOMPARE(signal.at(2).toInt(), 2);
306
indexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
307
QCOMPARE(indexes.size(), 1);
308
index = indexes.takeFirst();
310
QVERIFY(m_model.setData(index, "Home"));
312
flushNotifications();
314
QCOMPARE(rowsRemoved.count(), 1);
315
signal = rowsRemoved.takeFirst();
316
QCOMPARE(signal.count(), 3);
317
qDebug() << signal.at(0).value<QModelIndex>() << newParent;
318
QCOMPARE(signal.at(0).value<QModelIndex>(), newParent);
319
QCOMPARE(signal.at(1).toInt(), 2);
320
QCOMPARE(signal.at(2).toInt(), 2);
322
QCOMPARE(rowsInserted.count(), 1);
323
signal = rowsInserted.takeFirst();
324
QCOMPARE(signal.count(), 3);
325
QCOMPARE(signal.at(0).value<QModelIndex>(), oldParent);
326
QCOMPARE(signal.at(1).toInt(), 1);
327
QCOMPARE(signal.at(2).toInt(), 1);
330
void TodoCategoriesModelTest::testSingleRemoved()
332
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(4, 0)));
333
QModelIndexList indexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
335
QCOMPARE(indexes.size(), 1);
336
QModelIndex index = indexes.takeFirst();
337
QModelIndex parent = index.parent();
338
int count = m_model.rowCount(parent);
340
QSignalSpy spy(&m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
342
Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob(item);
343
QVERIFY(job->exec());
345
flushNotifications();
347
QCOMPARE(m_model.rowCount(parent), count - 1);
349
QCOMPARE(spy.count(), 1);
350
QVariantList signal = spy.takeFirst();
351
QCOMPARE(signal.count(), 3);
352
QCOMPARE(signal.at(0).value<QModelIndex>(), parent);
353
QCOMPARE(signal.at(1).toInt(), 1);
354
QCOMPARE(signal.at(1).toInt(), 1);
357
void TodoCategoriesModelTest::testMultipleRemoved()
359
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(4, 0)));
360
QModelIndexList indexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
362
QCOMPARE(indexes.size(), 3);
363
QModelIndex index = indexes.takeFirst();
364
QModelIndex index2 = indexes.takeFirst();
365
QModelIndex index3 = indexes.takeFirst();
367
QModelIndex parent = index.parent();
368
QModelIndex parent2 = index2.parent();
369
QModelIndex parent3 = index3.parent();
370
int count = m_model.rowCount(parent);
372
QSignalSpy spy(&m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)));
374
Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob(item);
375
QVERIFY(job->exec());
377
flushNotifications();
379
QCOMPARE(m_model.rowCount(parent), count - 1);
381
QCOMPARE(spy.count(), 3);
382
QVariantList signal = spy.takeFirst();
383
QCOMPARE(signal.count(), 3);
384
QCOMPARE(signal.at(0).value<QModelIndex>(), parent);
385
QCOMPARE(signal.at(1).toInt(), 0);
386
QCOMPARE(signal.at(1).toInt(), 0);
388
QCOMPARE(spy.count(), 2);
389
signal = spy.takeFirst();
390
QCOMPARE(signal.count(), 3);
391
QCOMPARE(signal.at(0).value<QModelIndex>(), parent2);
392
QCOMPARE(signal.at(1).toInt(), 1);
393
QCOMPARE(signal.at(1).toInt(), 1);
395
QCOMPARE(spy.count(), 1);
396
signal = spy.takeFirst();
397
QCOMPARE(signal.count(), 3);
398
QCOMPARE(signal.at(0).value<QModelIndex>(), parent3);
399
QCOMPARE(signal.at(1).toInt(), 0);
400
QCOMPARE(signal.at(1).toInt(), 0);
403
void TodoCategoriesModelTest::testDragAndDrop()
406
Akonadi::Item item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(2, 0)));
407
QModelIndexList indexes = m_model.indexesForItem(item);
408
QModelIndexList catIndexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
410
QCOMPARE(indexes.size(), 1);
411
QModelIndex index = indexes.first();
412
QModelIndex catIndex = catIndexes.first();
413
QCOMPARE(m_model.data(catIndex).toString(), QString("Errands"));
414
QModelIndex parent = m_model.indexForCategory("Phone");
416
QMimeData *mimeData = m_model.mimeData(indexes);
417
QVERIFY(m_model.dropMimeData(mimeData, Qt::MoveAction, 0, 0, parent));
419
catIndexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
420
QCOMPARE(m_model.data(catIndexes.first()).toString(), QString("Phone"));
424
item = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(4, 0)));
425
index = m_flatModel.indexForItem(item, 0);
426
catIndex = m_flatModel.indexForItem(item, TodoFlatModel::Categories);
427
QCOMPARE(m_flatModel.data(catIndex).toString(), QString(""));
429
Akonadi::Item item2 = m_flatModel.itemForIndex(m_flatSortedModel.mapToSource(m_flatSortedModel.index(5, 0)));
430
QModelIndex index2 = m_flatModel.indexForItem(item2, 0);
431
QModelIndex catIndex2 = m_flatModel.indexForItem(item2, TodoFlatModel::Categories);
432
QCOMPARE(m_flatModel.data(catIndex2).toString(), QString(""));
439
parent = m_model.indexForCategory("Office");
441
mimeData = m_flatModel.mimeData(indexes);
442
QVERIFY(m_model.dropMimeData(mimeData, Qt::MoveAction, 0, 0, parent));
444
flushNotifications();
446
catIndexes = m_model.indexesForItem(item, TodoFlatModel::Categories);
447
QCOMPARE(m_model.data(catIndexes.first()).toString(), QString("Office"));
449
catIndexes = m_model.indexesForItem(item2, TodoFlatModel::Categories);
450
QCOMPARE(m_model.data(catIndexes.first()).toString(), QString("Office"));
453
void TodoCategoriesModelTest::testAddCategory_data()
455
QTest::addColumn<QString>("name");
456
QTest::addColumn<QString>("parentName");
457
QTest::addColumn<bool>("expected");
459
QTest::newRow("Adding root category") << "Baz" << QString() << true;
460
QTest::newRow("Adding sub-category") << "FooBar" << "Baz" << true;
461
QTest::newRow("Adding existing root category") << "Foo" << QString() << false;
462
QTest::newRow("Adding existing category, deeper") << "Foo" << "Baz" << false;
465
void TodoCategoriesModelTest::testAddCategory()
467
QFETCH(QString, name);
468
QFETCH(QString, parentName);
469
QFETCH(bool, expected);
471
QModelIndex parent = m_model.indexForCategory(parentName);
473
int row = m_model.rowCount(parent);
474
QSignalSpy spy(&m_model, SIGNAL(rowsInserted(QModelIndex, int, int)));
476
bool result = m_model.addCategory(name, parent);
477
QCOMPARE(result, expected);
479
flushNotifications();
482
QCOMPARE(spy.count(), 0);
486
QCOMPARE(spy.count(), 1);
487
QVariantList signal = spy.takeFirst();
488
QCOMPARE(signal.count(), 3);
489
QCOMPARE(signal.at(0).value<QModelIndex>(), parent);
490
QCOMPARE(signal.at(1).toInt(), row);
491
QCOMPARE(signal.at(2).toInt(), row);
493
QCOMPARE(m_model.rowCount(parent), row+1);
495
QModelIndex index = m_model.index(row, 0, parent);
496
QCOMPARE(m_model.data(index).toString(), name);
497
QCOMPARE(m_model.rowCount(index), 0);
500
void TodoCategoriesModelTest::testCategoryRename_data()
502
QTest::addColumn<QString>("oldName");
503
QTest::addColumn<QString>("newName");
504
QTest::addColumn<bool>("expected");
506
QTest::newRow("Nominal case") << "Office" << "Office renamed" << true;
507
QTest::newRow("Go back to original name") << "Office renamed" << "Office" << true;
508
QTest::newRow("Invalid name") << "Office" << " " << false;
509
QTest::newRow("Already exists") << "Office" << "Home" << false;
512
void TodoCategoriesModelTest::testCategoryRename()
514
QFETCH(QString, oldName);
515
QFETCH(QString, newName);
516
QFETCH(bool, expected);
518
QModelIndex index = m_model.indexForCategory(oldName);
520
QCOMPARE(m_model.data(index).toString(), oldName);
521
int rowCount = m_model.rowCount(index);
522
QSignalSpy spy(&m_model, SIGNAL(dataChanged(QModelIndex, QModelIndex)));
524
bool result = m_model.setData(index, newName);
525
QCOMPARE(result, expected);
526
flushNotifications();
529
QCOMPARE(spy.count(), 0);
533
QCOMPARE(m_model.data(index).toString(), newName);
534
QCOMPARE(m_model.rowCount(index), rowCount);
536
for (int row = 0; row<rowCount; row++) {
537
QModelIndex childCatIndex = index.child(row, TodoFlatModel::Categories);
538
QStringList categories = m_model.data(childCatIndex).toStringList();
540
QVERIFY(!categories.contains(oldName));
541
QVERIFY(categories.contains(newName));
544
QCOMPARE(spy.count(), rowCount+1);
546
QVariantList signal = spy.takeFirst();
547
QCOMPARE(signal.size(), 2);
548
QModelIndex begin = signal.first().value<QModelIndex>();
549
QModelIndex end = signal.last().value<QModelIndex>();
550
QCOMPARE(begin, index);
551
QCOMPARE(begin.row(), end.row());
552
QCOMPARE(begin.column(), 0);
553
QCOMPARE(end.column(), (int)TodoFlatModel::LastColumn);
555
for (int row = 0; row<rowCount; row++) {
556
signal = spy.takeFirst();
557
QCOMPARE(signal.size(), 2);
558
begin = signal.first().value<QModelIndex>();
559
end = signal.last().value<QModelIndex>();
560
QCOMPARE(begin.parent(), index);
561
QCOMPARE(begin.row(), row);
563
QCOMPARE(begin.parent(), end.parent());
564
QCOMPARE(begin.row(), end.row());
565
QCOMPARE(begin.column(), 0);
566
QCOMPARE(end.column(), (int)TodoFlatModel::LastColumn);
570
void TodoCategoriesModelTest::testRemoveCategory_data()
572
QTest::addColumn<QString>("name");
573
QTest::addColumn<bool>("expected");
575
QTest::newRow("Removing isolated category") << "Home" << true;
576
QTest::newRow("Removing non existant category") << "Plop" << false;
577
QTest::newRow("Removing category with sub-category") << "Computer" << true;
578
QTest::newRow("Removing category with actions") << "Office" << true;
581
void TodoCategoriesModelTest::testRemoveCategory()
583
QFETCH(QString, name);
584
QFETCH(bool, expected);
586
QModelIndex index = m_model.indexForCategory(name);
587
QModelIndex parent = index.parent();
588
int row = index.row();
591
QCOMPARE(m_model.data(index).toString(), name);
593
int rowCount = m_model.rowCount(index);
594
QSignalSpy spy(&m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
595
QSignalSpy flatSpy(&m_flatModel, SIGNAL(rowsRemoved(QModelIndex, int, int)));
597
bool result = m_model.removeCategory(name);
598
QCOMPARE(result, expected);
599
flushNotifications();
601
QCOMPARE(flatSpy.count(), 0);
603
QCOMPARE(spy.count(), 0);
607
QVERIFY(!m_model.indexForCategory(name).isValid());
609
QCOMPARE(spy.count(), rowCount+1);
611
for (int i=0; i<rowCount; i++) {
612
QVariantList signal = spy.takeFirst();
613
QCOMPARE(signal.size(), 3);
614
QCOMPARE(signal.at(0).value<QModelIndex>(), index);
615
QCOMPARE(signal.at(1).toInt(), 0);
616
QCOMPARE(signal.at(2).toInt(), 0);
619
QVariantList signal = spy.takeFirst();
620
QCOMPARE(signal.size(), 3);
621
QCOMPARE(signal.at(0).value<QModelIndex>(), parent);
622
QCOMPARE(signal.at(1).toInt(), row);
623
QCOMPARE(signal.at(2).toInt(), row);
627
void TodoCategoriesModelTest::testDnDCategory_data()
629
QTest::addColumn<QString>("category");
630
QTest::addColumn<QString>("oldParent");
631
QTest::addColumn<QString>("newParent");
632
QTest::addColumn<bool>("expected");
634
QTest::newRow("Moving root category to sub-category") << "Phone" << QString() << "Errands" << true;
635
QTest::newRow("Moving sub-category to root") << "Phone" << "Errands" << QString() << true;
637
void TodoCategoriesModelTest::testDnDCategory()
639
QFETCH(QString, category);
640
QFETCH(QString, oldParent);
641
QFETCH(QString, newParent);
642
QFETCH(bool, expected);
644
QModelIndex index = m_model.indexForCategory(category);
645
QModelIndex oldParentIndex = m_model.indexForCategory(oldParent);
646
QModelIndex newParentIndex = m_model.indexForCategory(newParent);
648
int oldRow = index.row();
649
int newRow = m_model.rowCount(newParentIndex);
651
QSignalSpy rowsInserted(&m_model, SIGNAL(rowsInserted(QModelIndex, int, int)));
652
QSignalSpy rowsRemoved(&m_model, SIGNAL(rowsRemoved(QModelIndex, int, int)));
654
QMimeData *mimeData = m_model.mimeData(QModelIndexList() << index);
656
bool result = m_model.dropMimeData(mimeData, Qt::MoveAction, 0, 0, newParentIndex);
657
QCOMPARE(result, expected);
659
flushNotifications();
662
QCOMPARE(rowsRemoved.count(), 0);
663
QCOMPARE(rowsInserted.count(), 0);
667
QCOMPARE(rowsRemoved.count(), 1);
668
QVariantList signal = rowsRemoved.takeFirst();
669
QCOMPARE(signal.count(), 3);
670
QCOMPARE(signal.at(0).value<QModelIndex>(), oldParentIndex);
671
QCOMPARE(signal.at(1).toInt(), oldRow);
672
QCOMPARE(signal.at(2).toInt(), oldRow);
675
QCOMPARE(rowsInserted.count(), 1);
676
signal = rowsInserted.takeFirst();
677
QCOMPARE(signal.count(), 3);
678
QCOMPARE(signal.at(0).value<QModelIndex>(), newParentIndex);
679
QCOMPARE(signal.at(1).toInt(), newRow);
680
QCOMPARE(signal.at(2).toInt(), newRow);
683
#include "todocategoriesmodeltest.moc"