File indexing completed on 2025-03-16 04:30:27
0001 0002 #include "k3btestutils.h" 0003 0004 #include <QModelIndex> 0005 #include <QTest> 0006 0007 Q_DECLARE_METATYPE( QModelIndex ) 0008 0009 namespace TestUtils 0010 { 0011 0012 InsertRemoveModelSpy::InsertRemoveModelSpy( QObject* object, const char* beginSignal, const char* doneSignal ) 0013 : 0014 beginSpy( object, beginSignal ), 0015 doneSpy( object, doneSignal ) 0016 { 0017 qRegisterMetaType<QModelIndex>(); 0018 } 0019 0020 void InsertRemoveModelSpy::check( QModelIndex const& index, int first, int last ) 0021 { 0022 QVariantList args; 0023 0024 QCOMPARE( beginSpy.size(), 1 ); 0025 args = beginSpy.takeFirst(); 0026 QCOMPARE( args.at( 0 ).typeName(), "QModelIndex" ); 0027 QCOMPARE( args.at( 0 ).value<QModelIndex>(), index ); 0028 QCOMPARE( args.at( 1 ).type(), QVariant::Int ); 0029 QCOMPARE( args.at( 1 ).toInt(), first ); 0030 QCOMPARE( args.at( 2 ).type(), QVariant::Int ); 0031 QCOMPARE( args.at( 2 ).toInt(), last ); 0032 0033 QCOMPARE( doneSpy.size(), 1 ); 0034 args = doneSpy.takeFirst(); 0035 QCOMPARE( args.at( 0 ).typeName(), "QModelIndex" ); 0036 QCOMPARE( args.at( 0 ).value<QModelIndex>(), index ); 0037 QCOMPARE( args.at( 1 ).type(), QVariant::Int ); 0038 QCOMPARE( args.at( 1 ).toInt(), first ); 0039 QCOMPARE( args.at( 2 ).type(), QVariant::Int ); 0040 QCOMPARE( args.at( 2 ).toInt(), last ); 0041 } 0042 0043 } // namespace TestUtils