MCPcopy Create free account
hub / github.com/KDE/kdevelop / testItemSanity

Method testItemSanity

kdevplatform/project/tests/test_projectmodel.cpp:264–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

262}
263
264void TestProjectModel::testItemSanity()
265{
266#ifdef Q_OS_WIN
267 QString child3Path = QStringLiteral("file:///c:/bcd");
268 QString child4Path = QStringLiteral("file:///c:/abcd");
269#else
270 QString child3Path = QStringLiteral("file:///bcd");
271 QString child4Path = QStringLiteral("file:///abcd");
272#endif
273 QString newtestPath = QDir::rootPath() + QStringLiteral("newtest");
274 auto* parent = new ProjectBaseItem(nullptr, QStringLiteral("test"));
275 auto* child = new ProjectBaseItem( nullptr, QStringLiteral("test"), parent );
276 auto* child2 = new ProjectBaseItem(nullptr, QStringLiteral("ztest"), parent);
277 auto* child3 = new ProjectFileItem(nullptr, Path(QUrl(child3Path)), parent);
278 auto* child4 = new ProjectFileItem(nullptr, Path(QUrl(child4Path)), parent);
279
280 // Just some basic santiy checks on the API
281 QCOMPARE( parent->child( 0 ), child );
282 QCOMPARE( parent->row(), -1 );
283 QVERIFY( !parent->child( -1 ) );
284 QVERIFY( !parent->file() );
285 QVERIFY( !parent->folder() );
286 QVERIFY( !parent->project() );
287 QVERIFY( !parent->child( parent->rowCount() ) );
288 QCOMPARE( parent->iconName(), QString() );
289 QCOMPARE( parent->index(), QModelIndex() );
290
291 QCOMPARE( child->type(), (int)ProjectBaseItem::BaseItem );
292
293 QCOMPARE( child->lessThan( child2 ), true );
294 QCOMPARE( child3->lessThan( child4 ), false );
295
296 // Check that model is properly emitting data-changes
297 model->appendRow( parent );
298 QCOMPARE( parent->index(), model->index(0, 0, QModelIndex()) );
299 QSignalSpy s( model, SIGNAL(dataChanged(QModelIndex,QModelIndex)) );
300 parent->setPath( Path(newtestPath) );
301 QCOMPARE( s.count(), 1 );
302 QCOMPARE( model->data( parent->index() ).toString(), QStringLiteral("newtest") );
303
304 parent->removeRow( child->row() );
305}
306
307void TestProjectModel::testTakeRow()
308{

Callers

nothing calls this directly

Calls 15

folderMethod · 0.80
appendRowMethod · 0.80
removeRowMethod · 0.80
PathClass · 0.50
QUrlClass · 0.50
QStringClass · 0.50
QModelIndexClass · 0.50
childMethod · 0.45
rowMethod · 0.45
fileMethod · 0.45
projectMethod · 0.45
rowCountMethod · 0.45

Tested by

no test coverage detected