modeltest.cpp (krename-4.0.9) | : | modeltest.cpp (krename-4.90.90) | ||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
** If you are unsure which license is appropriate for your use, please | ** If you are unsure which license is appropriate for your use, please | |||
** review the following information: | ** review the following information: | |||
** http://www.trolltech.com/products/qt/licensing.html or contact the | ** http://www.trolltech.com/products/qt/licensing.html or contact the | |||
** sales department at sales@trolltech.com. | ** sales department at sales@trolltech.com. | |||
** | ** | |||
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |||
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |||
** | ** | |||
****************************************************************************/ | ****************************************************************************/ | |||
#include <QtGui/QtGui> | ||||
#include "modeltest.h" | #include "modeltest.h" | |||
#include <QSize> | ||||
Q_DECLARE_METATYPE(QModelIndex) | Q_DECLARE_METATYPE(QModelIndex) | |||
/*! | /*! | |||
Connect to all of the models signals. Whenever anything happens recheck eve rything. | Connect to all of the models signals. Whenever anything happens recheck eve rything. | |||
*/ | */ | |||
ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(pare nt), model(_model), fetchingMore(false) | ModelTest::ModelTest(QAbstractItemModel *_model, QObject *parent) : QObject(pare nt), model(_model), fetchingMore(false) | |||
{ | { | |||
Q_ASSERT(model); | Q_ASSERT(model); | |||
connect(model, SIGNAL(columnsAboutToBeInserted(const QModelIndex &, int, int | connect(model, &QAbstractItemModel::columnsAboutToBeInserted, | |||
)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::columnsAboutToBeRemoved, | |||
connect(model, SIGNAL(columnsAboutToBeRemoved(const QModelIndex &, int, int) | this, &ModelTest::runAllTests); | |||
), | connect(model, &QAbstractItemModel::columnsInserted, | |||
this, SLOT(runAllTests())); | this, &ModelTest::runAllTests); | |||
connect(model, SIGNAL(columnsInserted(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::columnsRemoved, | |||
this, SLOT(runAllTests())); | this, &ModelTest::runAllTests); | |||
connect(model, SIGNAL(columnsRemoved(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::dataChanged, | |||
this, SLOT(runAllTests())); | this, &ModelTest::runAllTests); | |||
connect(model, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)) | connect(model, &QAbstractItemModel::headerDataChanged, | |||
, | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::layoutAboutToBeChanged, | |||
connect(model, SIGNAL(headerDataChanged(Qt::Orientation, int, int)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::layoutChanged, | |||
connect(model, SIGNAL(layoutAboutToBeChanged ()), this, SLOT(runAllTests())) | this, &ModelTest::runAllTests); | |||
; | connect(model, &QAbstractItemModel::modelReset, | |||
connect(model, SIGNAL(layoutChanged ()), this, SLOT(runAllTests())); | this, &ModelTest::runAllTests); | |||
connect(model, SIGNAL(modelReset ()), this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::rowsAboutToBeInserted, | |||
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::rowsAboutToBeRemoved, | |||
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::rowsInserted, | |||
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | connect(model, &QAbstractItemModel::rowsRemoved, | |||
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), | this, &ModelTest::runAllTests); | |||
this, SLOT(runAllTests())); | ||||
// Special checks for inserting/removing | // Special checks for inserting/removing | |||
connect(model, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::rowsAboutToBeInserted, this, &ModelTest: | |||
this, SLOT(rowsAboutToBeInserted(const QModelIndex &, int, int))); | :rowsAboutToBeInserted); | |||
connect(model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::rowsAboutToBeRemoved, this, &ModelTest:: | |||
this, SLOT(rowsAboutToBeRemoved(const QModelIndex &, int, int))); | rowsAboutToBeRemoved); | |||
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::rowsInserted, this, &ModelTest::rowsInse | |||
this, SLOT(rowsInserted(const QModelIndex &, int, int))); | rted); | |||
connect(model, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), | connect(model, &QAbstractItemModel::rowsRemoved, this, &ModelTest::rowsRemov | |||
this, SLOT(rowsRemoved(const QModelIndex &, int, int))); | ed); | |||
runAllTests(); | runAllTests(); | |||
} | } | |||
void ModelTest::runAllTests() | void ModelTest::runAllTests() | |||
{ | { | |||
if (fetchingMore) | if (fetchingMore) { | |||
return; | return; | |||
} | ||||
nonDestructiveBasicTest(); | nonDestructiveBasicTest(); | |||
rowCount(); | rowCount(); | |||
columnCount(); | columnCount(); | |||
hasIndex(); | hasIndex(); | |||
index(); | index(); | |||
parent(); | parent(); | |||
data(); | data(); | |||
} | } | |||
/*! | /*! | |||
skipping to change at line 134 | skipping to change at line 134 | |||
Tests model's implementation of QAbstractItemModel::rowCount() and hasChildr en() | Tests model's implementation of QAbstractItemModel::rowCount() and hasChildr en() | |||
Models that are dynamically populated are not as fully tested here. | Models that are dynamically populated are not as fully tested here. | |||
*/ | */ | |||
void ModelTest::rowCount() | void ModelTest::rowCount() | |||
{ | { | |||
// check top row | // check top row | |||
QModelIndex topIndex = model->index(0, 0, QModelIndex()); | QModelIndex topIndex = model->index(0, 0, QModelIndex()); | |||
int rows = model->rowCount(topIndex); | int rows = model->rowCount(topIndex); | |||
Q_ASSERT(rows >= 0); | Q_ASSERT(rows >= 0); | |||
if (rows > 0) | if (rows > 0) { | |||
Q_ASSERT(model->hasChildren(topIndex) == true); | Q_ASSERT(model->hasChildren(topIndex) == true); | |||
} | ||||
QModelIndex secondLevelIndex = model->index(0, 0, topIndex); | QModelIndex secondLevelIndex = model->index(0, 0, topIndex); | |||
if (secondLevelIndex.isValid()) { // not the top level | if (secondLevelIndex.isValid()) { // not the top level | |||
// check a row count where parent is valid | // check a row count where parent is valid | |||
rows = model->rowCount(secondLevelIndex); | rows = model->rowCount(secondLevelIndex); | |||
Q_ASSERT(rows >= 0); | Q_ASSERT(rows >= 0); | |||
if (rows > 0) | if (rows > 0) { | |||
Q_ASSERT(model->hasChildren(secondLevelIndex) == true); | Q_ASSERT(model->hasChildren(secondLevelIndex) == true); | |||
} | ||||
} | } | |||
// The models rowCount() is tested more extensively in checkChildren(), | // The models rowCount() is tested more extensively in checkChildren(), | |||
// but this catches the big mistakes | // but this catches the big mistakes | |||
} | } | |||
/*! | /*! | |||
Tests model's implementation of QAbstractItemModel::columnCount() and hasChi ldren() | Tests model's implementation of QAbstractItemModel::columnCount() and hasChi ldren() | |||
*/ | */ | |||
void ModelTest::columnCount() | void ModelTest::columnCount() | |||
{ | { | |||
// check top row | // check top row | |||
QModelIndex topIndex = model->index(0, 0, QModelIndex()); | QModelIndex topIndex = model->index(0, 0, QModelIndex()); | |||
Q_ASSERT(model->columnCount(topIndex) >= 0); | Q_ASSERT(model->columnCount(topIndex) >= 0); | |||
// check a column count where parent is valid | // check a column count where parent is valid | |||
QModelIndex childIndex = model->index(0, 0, topIndex); | QModelIndex childIndex = model->index(0, 0, topIndex); | |||
if (childIndex.isValid()) | if (childIndex.isValid()) { | |||
Q_ASSERT(model->columnCount(childIndex) >= 0); | Q_ASSERT(model->columnCount(childIndex) >= 0); | |||
} | ||||
// columnCount() is tested more extensively in checkChildren(), | // columnCount() is tested more extensively in checkChildren(), | |||
// but this catches the big mistakes | // but this catches the big mistakes | |||
} | } | |||
/*! | /*! | |||
Tests model's implementation of QAbstractItemModel::hasIndex() | Tests model's implementation of QAbstractItemModel::hasIndex() | |||
*/ | */ | |||
void ModelTest::hasIndex() | void ModelTest::hasIndex() | |||
{ | { | |||
skipping to change at line 185 | skipping to change at line 188 | |||
Q_ASSERT(model->hasIndex(-2, 0) == false); | Q_ASSERT(model->hasIndex(-2, 0) == false); | |||
Q_ASSERT(model->hasIndex(0, -2) == false); | Q_ASSERT(model->hasIndex(0, -2) == false); | |||
int rows = model->rowCount(); | int rows = model->rowCount(); | |||
int columns = model->columnCount(); | int columns = model->columnCount(); | |||
// check out of bounds | // check out of bounds | |||
Q_ASSERT(model->hasIndex(rows, columns) == false); | Q_ASSERT(model->hasIndex(rows, columns) == false); | |||
Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false); | Q_ASSERT(model->hasIndex(rows + 1, columns + 1) == false); | |||
if (rows > 0) | if (rows > 0) { | |||
Q_ASSERT(model->hasIndex(0, 0) == true); | Q_ASSERT(model->hasIndex(0, 0) == true); | |||
} | ||||
// hasIndex() is tested more extensively in checkChildren(), | // hasIndex() is tested more extensively in checkChildren(), | |||
// but this catches the big mistakes | // but this catches the big mistakes | |||
} | } | |||
/*! | /*! | |||
Tests model's implementation of QAbstractItemModel::index() | Tests model's implementation of QAbstractItemModel::index() | |||
*/ | */ | |||
void ModelTest::index() | void ModelTest::index() | |||
{ | { | |||
// Make sure that invalid values returns an invalid index | // Make sure that invalid values returns an invalid index | |||
Q_ASSERT(model->index(-2, -2) == QModelIndex()); | Q_ASSERT(model->index(-2, -2) == QModelIndex()); | |||
Q_ASSERT(model->index(-2, 0) == QModelIndex()); | Q_ASSERT(model->index(-2, 0) == QModelIndex()); | |||
Q_ASSERT(model->index(0, -2) == QModelIndex()); | Q_ASSERT(model->index(0, -2) == QModelIndex()); | |||
int rows = model->rowCount(); | int rows = model->rowCount(); | |||
int columns = model->columnCount(); | int columns = model->columnCount(); | |||
if (rows == 0) | if (rows == 0) { | |||
return; | return; | |||
} | ||||
// Catch off by one errors | // Catch off by one errors | |||
Q_ASSERT(model->index(rows, columns) == QModelIndex()); | Q_ASSERT(model->index(rows, columns) == QModelIndex()); | |||
Q_ASSERT(model->index(0, 0).isValid() == true); | Q_ASSERT(model->index(0, 0).isValid() == true); | |||
// Make sure that the same index is *always* returned | // Make sure that the same index is *always* returned | |||
QModelIndex a = model->index(0, 0); | QModelIndex a = model->index(0, 0); | |||
QModelIndex b = model->index(0, 0); | QModelIndex b = model->index(0, 0); | |||
Q_ASSERT(a == b); | Q_ASSERT(a == b); | |||
skipping to change at line 230 | skipping to change at line 235 | |||
/*! | /*! | |||
Tests model's implementation of QAbstractItemModel::parent() | Tests model's implementation of QAbstractItemModel::parent() | |||
*/ | */ | |||
void ModelTest::parent() | void ModelTest::parent() | |||
{ | { | |||
// Make sure the model wont crash and will return an invalid QModelIndex | // Make sure the model wont crash and will return an invalid QModelIndex | |||
// when asked for the parent of an invalid index. | // when asked for the parent of an invalid index. | |||
Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); | Q_ASSERT(model->parent(QModelIndex()) == QModelIndex()); | |||
if (model->rowCount() == 0) | if (model->rowCount() == 0) { | |||
return; | return; | |||
} | ||||
// Column 0 | Column 1 | | // Column 0 | Column 1 | | |||
// QModelIndex() | | | // QModelIndex() | | | |||
// \- topIndex | topIndex1 | | // \- topIndex | topIndex1 | | |||
// \- childIndex | childIndex1 | | // \- childIndex | childIndex1 | | |||
// Common error test #1, make sure that a top level index has a parent | // Common error test #1, make sure that a top level index has a parent | |||
// that is a invalid QModelIndex. | // that is a invalid QModelIndex. | |||
QModelIndex topIndex = model->index(0, 0, QModelIndex()); | QModelIndex topIndex = model->index(0, 0, QModelIndex()); | |||
Q_ASSERT(model->parent(topIndex) == QModelIndex()); | Q_ASSERT(model->parent(topIndex) == QModelIndex()); | |||
skipping to change at line 283 | skipping to change at line 289 | |||
This function assumes that rowCount(), columnCount() and index() already wor k. | This function assumes that rowCount(), columnCount() and index() already wor k. | |||
If they have a bug it will point it out, but the above tests should have alr eady | If they have a bug it will point it out, but the above tests should have alr eady | |||
found the basic bugs because it is easier to figure out the problem in | found the basic bugs because it is easier to figure out the problem in | |||
those tests then this one. | those tests then this one. | |||
*/ | */ | |||
void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) | void ModelTest::checkChildren(const QModelIndex &parent, int currentDepth) | |||
{ | { | |||
// First just try walking back up the tree. | // First just try walking back up the tree. | |||
QModelIndex p = parent; | QModelIndex p = parent; | |||
while (p.isValid()) | while (p.isValid()) { | |||
p = p.parent(); | p = p.parent(); | |||
} | ||||
// For models that are dynamically populated | // For models that are dynamically populated | |||
if (model->canFetchMore(parent)) { | if (model->canFetchMore(parent)) { | |||
fetchingMore = true; | fetchingMore = true; | |||
model->fetchMore(parent); | model->fetchMore(parent); | |||
fetchingMore = false; | fetchingMore = false; | |||
} | } | |||
int rows = model->rowCount(parent); | int rows = model->rowCount(parent); | |||
int columns = model->columnCount(parent); | int columns = model->columnCount(parent); | |||
if (rows > 0) | if (rows > 0) { | |||
Q_ASSERT(model->hasChildren(parent)); | Q_ASSERT(model->hasChildren(parent)); | |||
} | ||||
// Some further testing against rows(), columns(), and hasChildren() | // Some further testing against rows(), columns(), and hasChildren() | |||
Q_ASSERT(rows >= 0); | Q_ASSERT(rows >= 0); | |||
Q_ASSERT(columns >= 0); | Q_ASSERT(columns >= 0); | |||
if (rows > 0) | if (rows > 0) { | |||
Q_ASSERT(model->hasChildren(parent) == true); | Q_ASSERT(model->hasChildren(parent) == true); | |||
} | ||||
//qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows | //qDebug() << "parent:" << model->data(parent).toString() << "rows:" << rows | |||
// << "columns:" << columns << "parent column:" << parent.column(); | // << "columns:" << columns << "parent column:" << parent.column(); | |||
Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false); | Q_ASSERT(model->hasIndex(rows + 1, 0, parent) == false); | |||
for (int r = 0; r < rows; ++r) { | for (int r = 0; r < rows; ++r) { | |||
if (model->canFetchMore(parent)) { | if (model->canFetchMore(parent)) { | |||
fetchingMore = true; | fetchingMore = true; | |||
model->fetchMore(parent); | model->fetchMore(parent); | |||
fetchingMore = false; | fetchingMore = false; | |||
skipping to change at line 355 | skipping to change at line 364 | |||
// And a view that you can even use to show the model. | // And a view that you can even use to show the model. | |||
//QTreeView view; | //QTreeView view; | |||
//view.setModel(model); | //view.setModel(model); | |||
//view.show(); | //view.show(); | |||
}*/ | }*/ | |||
// Check that we can get back our real parent. | // Check that we can get back our real parent. | |||
Q_ASSERT(model->parent(index) == parent); | Q_ASSERT(model->parent(index) == parent); | |||
// recursively go down the children | // recursively go down the children | |||
if (model->hasChildren(index) && currentDepth < 10 ) { | if (model->hasChildren(index) && currentDepth < 10) { | |||
//qDebug() << r << c << "has children" << model->rowCount(index) ; | //qDebug() << r << c << "has children" << model->rowCount(index) ; | |||
checkChildren(index, ++currentDepth); | checkChildren(index, ++currentDepth); | |||
}/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; }; */ | }/* else { if (currentDepth >= 10) qDebug() << "checked 10 deep"; }; */ | |||
// make sure that after testing the children that the index doesn't change. | // make sure that after testing the children that the index doesn't change. | |||
QModelIndex newerIndex = model->index(r, c, parent); | QModelIndex newerIndex = model->index(r, c, parent); | |||
Q_ASSERT(index == newerIndex); | Q_ASSERT(index == newerIndex); | |||
} | } | |||
} | } | |||
} | } | |||
/*! | /*! | |||
Tests model's implementation of QAbstractItemModel::data() | Tests model's implementation of QAbstractItemModel::data() | |||
*/ | */ | |||
void ModelTest::data() | void ModelTest::data() | |||
{ | { | |||
// Invalid index should return an invalid qvariant | // Invalid index should return an invalid qvariant | |||
Q_ASSERT(!model->data(QModelIndex()).isValid()); | Q_ASSERT(!model->data(QModelIndex()).isValid()); | |||
if (model->rowCount() == 0) | if (model->rowCount() == 0) { | |||
return; | return; | |||
} | ||||
// A valid index should have a valid QVariant data | // A valid index should have a valid QVariant data | |||
Q_ASSERT(model->index(0, 0).isValid()); | Q_ASSERT(model->index(0, 0).isValid()); | |||
// shouldn't be able to set data on an invalid index | // shouldn't be able to set data on an invalid index | |||
Q_ASSERT(model->setData(QModelIndex(), "foo", Qt::DisplayRole) == false); | Q_ASSERT(model->setData(QModelIndex(), "foo", Qt::DisplayRole) == false); | |||
// General Purpose roles that should return a QString | // General Purpose roles that should return a QString | |||
QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); | QVariant variant = model->data(model->index(0, 0), Qt::ToolTipRole); | |||
if (variant.isValid()) { | if (variant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QString>(variant)); | Q_ASSERT(variant.canConvert<QString>()); | |||
} | } | |||
variant = model->data(model->index(0, 0), Qt::StatusTipRole); | variant = model->data(model->index(0, 0), Qt::StatusTipRole); | |||
if (variant.isValid()) { | if (variant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QString>(variant)); | Q_ASSERT(variant.canConvert<QString>()); | |||
} | } | |||
variant = model->data(model->index(0, 0), Qt::WhatsThisRole); | variant = model->data(model->index(0, 0), Qt::WhatsThisRole); | |||
if (variant.isValid()) { | if (variant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QString>(variant)); | Q_ASSERT(variant.canConvert<QString>()); | |||
} | } | |||
// General Purpose roles that should return a QSize | // General Purpose roles that should return a QSize | |||
variant = model->data(model->index(0, 0), Qt::SizeHintRole); | variant = model->data(model->index(0, 0), Qt::SizeHintRole); | |||
if (variant.isValid()) { | if (variant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QSize>(variant)); | Q_ASSERT(variant.canConvert<QSize>()); | |||
} | } | |||
// General Purpose roles that should return a QFont | // General Purpose roles that should return a QFont | |||
QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole); | QVariant fontVariant = model->data(model->index(0, 0), Qt::FontRole); | |||
if (fontVariant.isValid()) { | if (fontVariant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QFont>(fontVariant)); | Q_ASSERT(variant.canConvert<QFont>()); | |||
} | } | |||
// Check that the alignment is one we know about | // Check that the alignment is one we know about | |||
QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlig nmentRole); | QVariant textAlignmentVariant = model->data(model->index(0, 0), Qt::TextAlig nmentRole); | |||
if (textAlignmentVariant.isValid()) { | if (textAlignmentVariant.isValid()) { | |||
int alignment = textAlignmentVariant.toInt(); | int alignment = textAlignmentVariant.toInt(); | |||
Q_ASSERT(alignment == Qt::AlignLeft || | Q_ASSERT(alignment == Qt::AlignLeft || | |||
alignment == Qt::AlignRight || | alignment == Qt::AlignRight || | |||
alignment == Qt::AlignHCenter || | alignment == Qt::AlignHCenter || | |||
alignment == Qt::AlignJustify); | alignment == Qt::AlignJustify); | |||
} | } | |||
// General Purpose roles that should return a QColor | // General Purpose roles that should return a QColor | |||
QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorR ole); | QVariant colorVariant = model->data(model->index(0, 0), Qt::BackgroundColorR ole); | |||
if (colorVariant.isValid()) { | if (colorVariant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QColor>(colorVariant)); | Q_ASSERT(variant.canConvert<QColor>()); | |||
} | } | |||
colorVariant = model->data(model->index(0, 0), Qt::TextColorRole); | colorVariant = model->data(model->index(0, 0), Qt::TextColorRole); | |||
if (colorVariant.isValid()) { | if (colorVariant.isValid()) { | |||
Q_ASSERT(qVariantCanConvert<QColor>(colorVariant)); | Q_ASSERT(variant.canConvert<QColor>()); | |||
} | } | |||
// Check that the "check state" is one we know about. | // Check that the "check state" is one we know about. | |||
QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateR ole); | QVariant checkStateVariant = model->data(model->index(0, 0), Qt::CheckStateR ole); | |||
if (checkStateVariant.isValid()) { | if (checkStateVariant.isValid()) { | |||
int state = checkStateVariant.toInt(); | int state = checkStateVariant.toInt(); | |||
Q_ASSERT(state == Qt::Unchecked || | Q_ASSERT(state == Qt::Unchecked || | |||
state == Qt::PartiallyChecked || | state == Qt::PartiallyChecked || | |||
state == Qt::Checked); | state == Qt::Checked); | |||
} | } | |||
skipping to change at line 462 | skipping to change at line 472 | |||
c.last = model->data(model->index(start - 1, 0, parent)); | c.last = model->data(model->index(start - 1, 0, parent)); | |||
c.next = model->data(model->index(start, 0, parent)); | c.next = model->data(model->index(start, 0, parent)); | |||
insert.push(c); | insert.push(c); | |||
} | } | |||
/*! | /*! | |||
Confirm that what was said was going to happen actually did | Confirm that what was said was going to happen actually did | |||
\sa rowsAboutToBeInserted() | \sa rowsAboutToBeInserted() | |||
*/ | */ | |||
void ModelTest::rowsInserted(const QModelIndex & parent, int start, int end) | void ModelTest::rowsInserted(const QModelIndex &parent, int start, int end) | |||
{ | { | |||
Changing c = insert.pop(); | Changing c = insert.pop(); | |||
Q_ASSERT(c.parent == parent); | Q_ASSERT(c.parent == parent); | |||
Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent)); | Q_ASSERT(c.oldSize + (end - start + 1) == model->rowCount(parent)); | |||
Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); | Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); | |||
/* | /* | |||
if (c.next != model->data(model->index(end + 1, 0, c.parent))) { | if (c.next != model->data(model->index(end + 1, 0, c.parent))) { | |||
qDebug() << start << end; | qDebug() << start << end; | |||
for (int i=0; i < model->rowCount(); ++i) | for (int i=0; i < model->rowCount(); ++i) | |||
qDebug() << model->index(i, 0).data().toString(); | qDebug() << model->index(i, 0).data().toString(); | |||
skipping to change at line 499 | skipping to change at line 509 | |||
c.last = model->data(model->index(start - 1, 0, parent)); | c.last = model->data(model->index(start - 1, 0, parent)); | |||
c.next = model->data(model->index(end + 1, 0, parent)); | c.next = model->data(model->index(end + 1, 0, parent)); | |||
remove.push(c); | remove.push(c); | |||
} | } | |||
/*! | /*! | |||
Confirm that what was said was going to happen actually did | Confirm that what was said was going to happen actually did | |||
\sa rowsAboutToBeRemoved() | \sa rowsAboutToBeRemoved() | |||
*/ | */ | |||
void ModelTest::rowsRemoved(const QModelIndex & parent, int start, int end) | void ModelTest::rowsRemoved(const QModelIndex &parent, int start, int end) | |||
{ | { | |||
Changing c = remove.pop(); | Changing c = remove.pop(); | |||
Q_ASSERT(c.parent == parent); | Q_ASSERT(c.parent == parent); | |||
Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent)); | Q_ASSERT(c.oldSize - (end - start + 1) == model->rowCount(parent)); | |||
Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); | Q_ASSERT(c.last == model->data(model->index(start - 1, 0, c.parent))); | |||
Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent))); | Q_ASSERT(c.next == model->data(model->index(start, 0, c.parent))); | |||
} | } | |||
End of changes. 36 change blocks. | ||||
58 lines changed or deleted | 68 lines changed or added |