| 57 | } |
| 58 | |
| 59 | void 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 | |
| 102 | void TestProjectModel::testCreateFileSystemItems_data() |
| 103 | { |
nothing calls this directly
no test coverage detected