| 262 | } |
| 263 | |
| 264 | void 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 | |
| 307 | void TestProjectModel::testTakeRow() |
| 308 | { |
nothing calls this directly
no test coverage detected