1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include "k3btestutils.h"
#include <QModelIndex>
#include <QTest>
Q_DECLARE_METATYPE( QModelIndex )
namespace TestUtils
{
InsertRemoveModelSpy::InsertRemoveModelSpy( QObject* object, const char* beginSignal, const char* doneSignal )
:
beginSpy( object, beginSignal ),
doneSpy( object, doneSignal )
{
qRegisterMetaType<QModelIndex>();
}
void InsertRemoveModelSpy::check( QModelIndex const& index, int first, int last )
{
QVariantList args;
QCOMPARE( beginSpy.size(), 1 );
args = beginSpy.takeFirst();
QCOMPARE( args.at( 0 ).typeName(), "QModelIndex" );
QCOMPARE( args.at( 0 ).value<QModelIndex>(), index );
QCOMPARE( args.at( 1 ).type(), QVariant::Int );
QCOMPARE( args.at( 1 ).toInt(), first );
QCOMPARE( args.at( 2 ).type(), QVariant::Int );
QCOMPARE( args.at( 2 ).toInt(), last );
QCOMPARE( doneSpy.size(), 1 );
args = doneSpy.takeFirst();
QCOMPARE( args.at( 0 ).typeName(), "QModelIndex" );
QCOMPARE( args.at( 0 ).value<QModelIndex>(), index );
QCOMPARE( args.at( 1 ).type(), QVariant::Int );
QCOMPARE( args.at( 1 ).toInt(), first );
QCOMPARE( args.at( 2 ).type(), QVariant::Int );
QCOMPARE( args.at( 2 ).toInt(), last );
}
} // namespace TestUtils
|