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

Method testCreateFileSystemItems

kdevplatform/project/tests/test_projectmodel.cpp:59–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59void TestProjectModel::testCreateFileSystemItems()
60{
61 QFETCH( int, itemType );
62 QFETCH( Path, itemPath );
63 QFETCH( Path, expectedItemPath );
64 QFETCH( QString, expectedItemText );
65 QFETCH( QStringList, expectedRelativeItemPath );
66 QFETCH( int, expectedItemRow );
67
68 ProjectBaseItem* newitem = nullptr;
69 switch( itemType ) {
70 case ProjectBaseItem::Folder:
71 newitem = new ProjectFolderItem( nullptr, itemPath );
72 break;
73 case ProjectBaseItem::BuildFolder:
74 newitem = new ProjectBuildFolderItem( nullptr, itemPath );
75 break;
76 case ProjectBaseItem::File:
77 newitem = new ProjectFileItem( nullptr, itemPath );
78 break;
79 }
80 int origRowCount = model->rowCount();
81 model->appendRow( newitem );
82 QCOMPARE( model->rowCount(), origRowCount+1 );
83 QCOMPARE( newitem->row(), expectedItemRow );
84 QModelIndex idx = model->index( expectedItemRow, 0, QModelIndex() );
85 QVERIFY( model->itemFromIndex( idx ) );
86 QCOMPARE( model->itemFromIndex( idx ), newitem );
87 QCOMPARE( newitem->text(), expectedItemText );
88 QCOMPARE( newitem->path(), expectedItemPath );
89 if( itemType == ProjectBaseItem::File ) {
90 QCOMPARE( dynamic_cast<ProjectFileItem*>( newitem )->fileName(), expectedItemText );
91 }
92 if( itemType == ProjectBaseItem::Folder || itemType == ProjectBaseItem::BuildFolder ) {
93 QCOMPARE( dynamic_cast<ProjectFolderItem*>( newitem )->folderName(), expectedItemText );
94 }
95 QCOMPARE( newitem->type(), itemType );
96 QCOMPARE( model->data( idx ).toString(), expectedItemText );
97 QCOMPARE( model->indexFromItem( newitem ), idx );
98 QCOMPARE( model->pathFromIndex( idx ), expectedRelativeItemPath );
99 QCOMPARE( model->pathToIndex( expectedRelativeItemPath ), idx );
100}
101
102void TestProjectModel::testCreateFileSystemItems_data()
103{

Callers

nothing calls this directly

Calls 15

appendRowMethod · 0.80
folderNameMethod · 0.80
indexFromItemMethod · 0.80
pathToIndexMethod · 0.80
QModelIndexClass · 0.50
rowCountMethod · 0.45
rowMethod · 0.45
indexMethod · 0.45
itemFromIndexMethod · 0.45
textMethod · 0.45
pathMethod · 0.45
fileNameMethod · 0.45

Tested by

no test coverage detected