krop's commit fixes my problem in a better way, reverting
[kdepim.git] / akonadi_next / modeltest.cpp
blob686a535d8ce5d2c08d877726bc1a0ceb9d6fa4a0
1 /****************************************************************************
2 **
3 ** Copyright (C) 2007 Trolltech ASA. All rights reserved.
4 **
5 ** This file is part of the Qt Concurrent project on Trolltech Labs.
6 **
7 ** This file may be used under the terms of the GNU General Public
8 ** License version 2.0 as published by the Free Software Foundation
9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 ** this file. Please review the following information to ensure GNU
11 ** General Public Licensing requirements will be met:
12 ** http://www.trolltech.com/products/qt/opensource.html
14 ** If you are unsure which license is appropriate for your use, please
15 ** review the following information:
16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 ** sales department at sales@trolltech.com.
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 ****************************************************************************/
24 #include <QtGui/QtGui>
26 #include "modeltest.h"
28 Q_DECLARE_METATYPE ( QModelIndex )
30 /*!
31 Connect to all of the models signals. Whenever anything happens recheck everything.
33 ModelTest::ModelTest ( QAbstractItemModel *_model, QObject *parent ) : QObject ( parent ), model ( _model ), fetchingMore ( false )
35 Q_ASSERT ( model );
37 connect ( model, SIGNAL ( columnsAboutToBeInserted ( const QModelIndex &, int, int ) ),
38 this, SLOT ( runAllTests() ) );
39 connect ( model, SIGNAL ( columnsAboutToBeRemoved ( const QModelIndex &, int, int ) ),
40 this, SLOT ( runAllTests() ) );
41 connect ( model, SIGNAL ( columnsInserted ( const QModelIndex &, int, int ) ),
42 this, SLOT ( runAllTests() ) );
43 connect ( model, SIGNAL ( columnsRemoved ( const QModelIndex &, int, int ) ),
44 this, SLOT ( runAllTests() ) );
45 connect ( model, SIGNAL ( dataChanged ( const QModelIndex &, const QModelIndex & ) ),
46 this, SLOT ( runAllTests() ) );
47 connect ( model, SIGNAL ( headerDataChanged ( Qt::Orientation, int, int ) ),
48 this, SLOT ( runAllTests() ) );
49 connect ( model, SIGNAL ( layoutAboutToBeChanged () ), this, SLOT ( runAllTests() ) );
50 connect ( model, SIGNAL ( layoutChanged () ), this, SLOT ( runAllTests() ) );
51 connect ( model, SIGNAL ( modelReset () ), this, SLOT ( runAllTests() ) );
52 connect ( model, SIGNAL ( rowsAboutToBeInserted ( const QModelIndex &, int, int ) ),
53 this, SLOT ( runAllTests() ) );
54 connect ( model, SIGNAL ( rowsAboutToBeRemoved ( const QModelIndex &, int, int ) ),
55 this, SLOT ( runAllTests() ) );
56 connect ( model, SIGNAL ( rowsInserted ( const QModelIndex &, int, int ) ),
57 this, SLOT ( runAllTests() ) );
58 connect ( model, SIGNAL ( rowsRemoved ( const QModelIndex &, int, int ) ),
59 this, SLOT ( runAllTests() ) );
61 // Special checks for inserting/removing
62 connect ( model, SIGNAL ( layoutAboutToBeChanged() ),
63 this, SLOT ( layoutAboutToBeChanged() ) );
64 connect ( model, SIGNAL ( layoutChanged() ),
65 this, SLOT ( layoutChanged() ) );
67 connect ( model, SIGNAL ( rowsAboutToBeInserted ( const QModelIndex &, int, int ) ),
68 this, SLOT ( rowsAboutToBeInserted ( const QModelIndex &, int, int ) ) );
69 connect ( model, SIGNAL ( rowsAboutToBeRemoved ( const QModelIndex &, int, int ) ),
70 this, SLOT ( rowsAboutToBeRemoved ( const QModelIndex &, int, int ) ) );
71 connect ( model, SIGNAL ( rowsInserted ( const QModelIndex &, int, int ) ),
72 this, SLOT ( rowsInserted ( const QModelIndex &, int, int ) ) );
73 connect ( model, SIGNAL ( rowsRemoved ( const QModelIndex &, int, int ) ),
74 this, SLOT ( rowsRemoved ( const QModelIndex &, int, int ) ) );
76 connect ( model, SIGNAL ( rowsAboutToBeMoved ( const QModelIndex &, int, int, const QModelIndex &, int ) ),
77 this, SLOT ( rowsAboutToBeMoved ( const QModelIndex &, int, int, const QModelIndex &, int ) ) );
78 connect ( model, SIGNAL ( rowsMoved ( const QModelIndex &, int, int, const QModelIndex &, int ) ),
79 this, SLOT ( rowsMoved ( const QModelIndex &, int, int, const QModelIndex &, int ) ) );
81 runAllTests();
84 void ModelTest::runAllTests()
87 // qDebug() << "rats";
88 if ( fetchingMore )
89 return;
90 nonDestructiveBasicTest();
91 rowCount();
92 columnCount();
93 hasIndex();
94 index();
95 parent();
96 data();
99 /*!
100 nonDestructiveBasicTest tries to call a number of the basic functions (not all)
101 to make sure the model doesn't outright segfault, testing the functions that makes sense.
103 void ModelTest::nonDestructiveBasicTest()
105 Q_ASSERT ( model->buddy ( QModelIndex() ) == QModelIndex() );
106 model->canFetchMore ( QModelIndex() );
107 Q_ASSERT ( model->columnCount ( QModelIndex() ) >= 0 );
108 Q_ASSERT ( model->data ( QModelIndex() ) == QVariant() );
109 fetchingMore = true;
110 model->fetchMore ( QModelIndex() );
111 fetchingMore = false;
112 Qt::ItemFlags flags = model->flags ( QModelIndex() );
113 Q_ASSERT ( flags == Qt::ItemIsDropEnabled || flags == 0 );
114 model->hasChildren ( QModelIndex() );
115 model->hasIndex ( 0, 0 );
116 model->headerData ( 0, Qt::Horizontal );
117 model->index ( 0, 0 );
118 model->itemData ( QModelIndex() );
119 QVariant cache;
120 model->match ( QModelIndex(), -1, cache );
121 model->mimeTypes();
122 Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
123 Q_ASSERT ( model->rowCount() >= 0 );
124 QVariant variant;
125 model->setData ( QModelIndex(), variant, -1 );
126 model->setHeaderData ( -1, Qt::Horizontal, QVariant() );
127 model->setHeaderData ( 999999, Qt::Horizontal, QVariant() );
128 QMap<int, QVariant> roles;
129 model->sibling ( 0, 0, QModelIndex() );
130 model->span ( QModelIndex() );
131 model->supportedDropActions();
135 Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren()
137 Models that are dynamically populated are not as fully tested here.
139 void ModelTest::rowCount()
141 // qDebug() << "rc";
142 // check top row
143 QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
144 int rows = model->rowCount ( topIndex );
145 Q_ASSERT ( rows >= 0 );
146 if ( rows > 0 )
147 Q_ASSERT ( model->hasChildren ( topIndex ) == true );
149 QModelIndex secondLevelIndex = model->index ( 0, 0, topIndex );
150 if ( secondLevelIndex.isValid() ) { // not the top level
151 // check a row count where parent is valid
152 rows = model->rowCount ( secondLevelIndex );
153 Q_ASSERT ( rows >= 0 );
154 if ( rows > 0 )
155 Q_ASSERT ( model->hasChildren ( secondLevelIndex ) == true );
158 // The models rowCount() is tested more extensively in checkChildren(),
159 // but this catches the big mistakes
163 Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren()
165 void ModelTest::columnCount()
167 // check top row
168 QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
169 Q_ASSERT ( model->columnCount ( topIndex ) >= 0 );
171 // check a column count where parent is valid
172 QModelIndex childIndex = model->index ( 0, 0, topIndex );
173 if ( childIndex.isValid() )
174 Q_ASSERT ( model->columnCount ( childIndex ) >= 0 );
176 // columnCount() is tested more extensively in checkChildren(),
177 // but this catches the big mistakes
181 Tests model's implementation of QAbstractItemModel::hasIndex()
183 void ModelTest::hasIndex()
185 // qDebug() << "hi";
186 // Make sure that invalid values returns an invalid index
187 Q_ASSERT ( model->hasIndex ( -2, -2 ) == false );
188 Q_ASSERT ( model->hasIndex ( -2, 0 ) == false );
189 Q_ASSERT ( model->hasIndex ( 0, -2 ) == false );
191 int rows = model->rowCount();
192 int columns = model->columnCount();
194 // check out of bounds
195 Q_ASSERT ( model->hasIndex ( rows, columns ) == false );
196 Q_ASSERT ( model->hasIndex ( rows + 1, columns + 1 ) == false );
198 if ( rows > 0 )
199 Q_ASSERT ( model->hasIndex ( 0, 0 ) == true );
201 // hasIndex() is tested more extensively in checkChildren(),
202 // but this catches the big mistakes
206 Tests model's implementation of QAbstractItemModel::index()
208 void ModelTest::index()
210 // qDebug() << "i";
211 // Make sure that invalid values returns an invalid index
212 Q_ASSERT ( model->index ( -2, -2 ) == QModelIndex() );
213 Q_ASSERT ( model->index ( -2, 0 ) == QModelIndex() );
214 Q_ASSERT ( model->index ( 0, -2 ) == QModelIndex() );
216 int rows = model->rowCount();
217 int columns = model->columnCount();
219 if ( rows == 0 )
220 return;
222 // Catch off by one errors
223 Q_ASSERT ( model->index ( rows, columns ) == QModelIndex() );
224 Q_ASSERT ( model->index ( 0, 0 ).isValid() == true );
226 // Make sure that the same index is *always* returned
227 QModelIndex a = model->index ( 0, 0 );
228 QModelIndex b = model->index ( 0, 0 );
229 Q_ASSERT ( a == b );
231 // index() is tested more extensively in checkChildren(),
232 // but this catches the big mistakes
236 Tests model's implementation of QAbstractItemModel::parent()
238 void ModelTest::parent()
240 // qDebug() << "p";
241 // Make sure the model wont crash and will return an invalid QModelIndex
242 // when asked for the parent of an invalid index.
243 Q_ASSERT ( model->parent ( QModelIndex() ) == QModelIndex() );
245 if ( model->rowCount() == 0 )
246 return;
248 // Column 0 | Column 1 |
249 // QModelIndex() | |
250 // \- topIndex | topIndex1 |
251 // \- childIndex | childIndex1 |
253 // Common error test #1, make sure that a top level index has a parent
254 // that is a invalid QModelIndex.
255 QModelIndex topIndex = model->index ( 0, 0, QModelIndex() );
256 Q_ASSERT ( model->parent ( topIndex ) == QModelIndex() );
258 // Common error test #2, make sure that a second level index has a parent
259 // that is the first level index.
260 if ( model->rowCount ( topIndex ) > 0 ) {
261 QModelIndex childIndex = model->index ( 0, 0, topIndex );
262 Q_ASSERT ( model->parent ( childIndex ) == topIndex );
265 // Common error test #3, the second column should NOT have the same children
266 // as the first column in a row.
267 // Usually the second column shouldn't have children.
268 QModelIndex topIndex1 = model->index ( 0, 1, QModelIndex() );
269 if ( model->rowCount ( topIndex1 ) > 0 ) {
270 QModelIndex childIndex = model->index ( 0, 0, topIndex );
271 QModelIndex childIndex1 = model->index ( 0, 0, topIndex1 );
272 Q_ASSERT ( childIndex != childIndex1 );
275 // Full test, walk n levels deep through the model making sure that all
276 // parent's children correctly specify their parent.
277 checkChildren ( QModelIndex() );
281 Called from the parent() test.
283 A model that returns an index of parent X should also return X when asking
284 for the parent of the index.
286 This recursive function does pretty extensive testing on the whole model in an
287 effort to catch edge cases.
289 This function assumes that rowCount(), columnCount() and index() already work.
290 If they have a bug it will point it out, but the above tests should have already
291 found the basic bugs because it is easier to figure out the problem in
292 those tests then this one.
294 void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth )
296 // First just try walking back up the tree.
297 QModelIndex p = parent;
298 while ( p.isValid() )
299 p = p.parent();
301 // For models that are dynamically populated
302 if ( model->canFetchMore ( parent ) ) {
303 fetchingMore = true;
304 model->fetchMore ( parent );
305 fetchingMore = false;
308 int rows = model->rowCount ( parent );
309 int columns = model->columnCount ( parent );
311 if ( rows > 0 )
312 Q_ASSERT ( model->hasChildren ( parent ) );
314 // Some further testing against rows(), columns(), and hasChildren()
315 Q_ASSERT ( rows >= 0 );
316 Q_ASSERT ( columns >= 0 );
317 if ( rows > 0 )
318 Q_ASSERT ( model->hasChildren ( parent ) == true );
320 //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows
321 // << "columns:" << columns << "parent column:" << parent.column();
323 Q_ASSERT ( model->hasIndex ( rows, 0, parent ) == false );
324 Q_ASSERT ( model->index(rows, 0, parent).isValid() == false );
325 for ( int r = 0; r < rows; ++r ) {
326 if ( model->canFetchMore ( parent ) ) {
327 fetchingMore = true;
328 model->fetchMore ( parent );
329 fetchingMore = false;
331 Q_ASSERT ( model->hasIndex ( r, columns, parent ) == false );
332 Q_ASSERT ( model->index(r, columns, parent).isValid() == false );
333 for ( int c = 0; c < columns; ++c ) {
334 Q_ASSERT ( model->hasIndex ( r, c, parent ) == true );
335 QModelIndex index = model->index ( r, c, parent );
336 // rowCount() and columnCount() said that it existed...
337 Q_ASSERT ( index.isValid() == true );
339 // index() should always return the same index when called twice in a row
340 QModelIndex modifiedIndex = model->index ( r, c, parent );
341 Q_ASSERT ( index == modifiedIndex );
343 // Make sure we get the same index if we request it twice in a row
344 QModelIndex a = model->index ( r, c, parent );
345 QModelIndex b = model->index ( r, c, parent );
346 Q_ASSERT ( a == b );
348 // Some basic checking on the index that is returned
349 Q_ASSERT ( index.model() == model );
350 Q_ASSERT ( index.row() == r );
351 Q_ASSERT ( index.column() == c );
352 // While you can technically return a QVariant usually this is a sign
353 // of an bug in data() Disable if this really is ok in your model.
354 // qDebug() << index << index.data() << index.parent();
355 Q_ASSERT ( model->data ( index, Qt::DisplayRole ).isValid() == true );
357 // If the next test fails here is some somewhat useful debug you play with.
359 if (model->parent(index) != parent) {
360 qDebug() << r << c << currentDepth << model->data(index).toString()
361 << model->data(parent).toString();
362 qDebug() << index << parent << model->parent(index);
363 // And a view that you can even use to show the model.
364 //QTreeView view;
365 //view.setModel(model);
366 //view.show();
369 // Check that we can get back our real parent.
370 Q_ASSERT ( model->parent ( index ) == parent );
372 // recursively go down the children
373 if ( model->hasChildren ( index ) && currentDepth < 10 ) {
374 //qDebug() << r << c << "has children" << model->rowCount(index);
375 checkChildren ( index, ++currentDepth );
376 }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; };*/
378 // make sure that after testing the children that the index doesn't change.
379 QModelIndex newerIndex = model->index ( r, c, parent );
380 Q_ASSERT ( index == newerIndex );
386 Tests model's implementation of QAbstractItemModel::data()
388 void ModelTest::data()
390 // Invalid index should return an invalid qvariant
391 Q_ASSERT ( !model->data ( QModelIndex() ).isValid() );
393 if ( model->rowCount() == 0 )
394 return;
396 // A valid index should have a valid QVariant data
397 Q_ASSERT ( model->index ( 0, 0 ).isValid() );
399 // shouldn't be able to set data on an invalid index
400 Q_ASSERT ( model->setData ( QModelIndex(), QLatin1String ( "foo" ), Qt::DisplayRole ) == false );
402 // General Purpose roles that should return a QString
403 QVariant variant = model->data ( model->index ( 0, 0 ), Qt::ToolTipRole );
404 if ( variant.isValid() ) {
405 Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
407 variant = model->data ( model->index ( 0, 0 ), Qt::StatusTipRole );
408 if ( variant.isValid() ) {
409 Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
411 variant = model->data ( model->index ( 0, 0 ), Qt::WhatsThisRole );
412 if ( variant.isValid() ) {
413 Q_ASSERT ( qVariantCanConvert<QString> ( variant ) );
416 // General Purpose roles that should return a QSize
417 variant = model->data ( model->index ( 0, 0 ), Qt::SizeHintRole );
418 if ( variant.isValid() ) {
419 Q_ASSERT ( qVariantCanConvert<QSize> ( variant ) );
422 // General Purpose roles that should return a QFont
423 QVariant fontVariant = model->data ( model->index ( 0, 0 ), Qt::FontRole );
424 if ( fontVariant.isValid() ) {
425 Q_ASSERT ( qVariantCanConvert<QFont> ( fontVariant ) );
428 // Check that the alignment is one we know about
429 QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole );
430 if ( textAlignmentVariant.isValid() ) {
431 int alignment = textAlignmentVariant.toInt();
432 Q_ASSERT ( alignment == ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) );
435 // General Purpose roles that should return a QColor
436 QVariant colorVariant = model->data ( model->index ( 0, 0 ), Qt::BackgroundColorRole );
437 if ( colorVariant.isValid() ) {
438 Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
441 colorVariant = model->data ( model->index ( 0, 0 ), Qt::TextColorRole );
442 if ( colorVariant.isValid() ) {
443 Q_ASSERT ( qVariantCanConvert<QColor> ( colorVariant ) );
446 // Check that the "check state" is one we know about.
447 QVariant checkStateVariant = model->data ( model->index ( 0, 0 ), Qt::CheckStateRole );
448 if ( checkStateVariant.isValid() ) {
449 int state = checkStateVariant.toInt();
450 Q_ASSERT ( state == Qt::Unchecked ||
451 state == Qt::PartiallyChecked ||
452 state == Qt::Checked );
457 Store what is about to be inserted to make sure it actually happens
459 \sa rowsInserted()
461 void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, int end )
463 // Q_UNUSED(end);
464 qDebug() << "rowsAboutToBeInserted" << "start=" << start << "end=" << end << "parent=" << model->data ( parent ).value<QString>()
465 << "current count of parent=" << model->rowCount ( parent ); // << "display of last=" << model->data( model->index(start-1, 0, parent) );
466 // qDebug() << model->index(start-1, 0, parent) << model->data( model->index(start-1, 0, parent) );
467 Changing c;
468 c.parent = parent;
469 c.oldSize = model->rowCount ( parent );
470 c.last = model->data ( model->index ( start - 1, 0, parent ) );
471 c.next = model->data ( model->index ( start, 0, parent ) );
472 insert.push ( c );
476 Confirm that what was said was going to happen actually did
478 \sa rowsAboutToBeInserted()
480 void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end )
482 Changing c = insert.pop();
483 Q_ASSERT ( c.parent == parent );
484 qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize
485 << "parent=" << model->data ( parent ).value<QString>() << "current rowcount=" << model->rowCount ( parent );
487 for (int ii=start; ii <= end; ii++)
489 qDebug() << "itemWasInserted:" << model->data ( model->index ( ii, 0, parent ));
493 Q_ASSERT ( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) );
494 Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
496 if (c.next != model->data(model->index(end + 1, 0, c.parent))) {
497 qDebug() << start << end;
498 for (int i=0; i < model->rowCount(); ++i)
499 qDebug() << model->index(i, 0).data().toString();
500 qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent));
503 Q_ASSERT ( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) );
506 void ModelTest::layoutAboutToBeChanged()
508 for ( int i = 0; i < qBound ( 0, model->rowCount(), 100 ); ++i )
509 changing.append ( QPersistentModelIndex ( model->index ( i, 0 ) ) );
512 void ModelTest::layoutChanged()
514 for ( int i = 0; i < changing.count(); ++i ) {
515 QPersistentModelIndex p = changing[i];
516 Q_ASSERT ( p == model->index ( p.row(), p.column(), p.parent() ) );
518 changing.clear();
521 void ModelTest::rowsAboutToBeMoved(const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow )
523 qDebug() << "rowsAboutToBeMoved" << srcParent << start << end << destParent << destinationRow;
524 Changing cs;
525 cs.parent = srcParent;
526 cs.oldSize = model->rowCount ( srcParent );
527 cs.last = model->data ( model->index ( start - 1, 0, srcParent ) );
528 cs.next = model->data ( model->index ( end + 1, 0, srcParent ) );
529 remove.push ( cs );
530 Changing cd;
531 cd.parent = destParent;
532 cd.oldSize = model->rowCount ( destParent );
533 cd.last = model->data ( model->index ( destinationRow - 1, 0, destParent ) );
534 cd.next = model->data ( model->index ( destinationRow, 0, destParent ) );
535 insert.push ( cd );
538 void ModelTest::rowsMoved(const QModelIndex &srcParent, int start, int end, const QModelIndex &destParent, int destinationRow )
540 qDebug() << "rowsMoved" << srcParent << start << end << destParent << destinationRow;
542 Changing cd = insert.pop();
543 Q_ASSERT ( cd.parent == destParent );
544 if (srcParent == destParent)
546 Q_ASSERT ( cd.oldSize == model->rowCount ( destParent ) );
548 // TODO: Find out what I can assert here about last and next.
549 // Q_ASSERT ( cd.last == model->data ( model->index ( destinationRow - 1, 0, cd.parent ) ) );
550 // Q_ASSERT ( cd.next == model->data ( model->index ( destinationRow + (end - start + 1), 0, cd.parent ) ) );
554 else
556 Q_ASSERT ( cd.oldSize + ( end - start + 1 ) == model->rowCount ( destParent ) );
558 Q_ASSERT ( cd.last == model->data ( model->index ( destinationRow - 1, 0, cd.parent ) ) );
559 Q_ASSERT ( cd.next == model->data ( model->index ( destinationRow + (end - start + 1), 0, cd.parent ) ) );
561 Changing cs = remove.pop();
563 Q_ASSERT ( cs.parent == srcParent );
564 if (srcParent == destParent)
566 Q_ASSERT ( cs.oldSize == model->rowCount ( srcParent ) );
568 else
570 Q_ASSERT ( cs.oldSize - ( end - start + 1 ) == model->rowCount ( srcParent ) );
572 Q_ASSERT ( cs.last == model->data ( model->index ( start - 1, 0, srcParent ) ) );
573 qDebug() << cs.next << model->data ( model->index ( start, 0, srcParent ) );
574 Q_ASSERT ( cs.next == model->data ( model->index ( start, 0, srcParent ) ) );
580 Store what is about to be inserted to make sure it actually happens
582 \sa rowsRemoved()
584 void ModelTest::rowsAboutToBeRemoved ( const QModelIndex &parent, int start, int end )
586 qDebug() << "ratbr" << parent << start << end;
587 Changing c;
588 c.parent = parent;
589 c.oldSize = model->rowCount ( parent );
590 c.last = model->data ( model->index ( start - 1, 0, parent ) );
591 c.next = model->data ( model->index ( end + 1, 0, parent ) );
592 remove.push ( c );
596 Confirm that what was said was going to happen actually did
598 \sa rowsAboutToBeRemoved()
600 void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end )
602 qDebug() << "rr" << parent << start << end;
603 Changing c = remove.pop();
604 Q_ASSERT ( c.parent == parent );
605 Q_ASSERT ( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) );
606 Q_ASSERT ( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) );
607 Q_ASSERT ( c.next == model->data ( model->index ( start, 0, c.parent ) ) );