| 352 | } |
| 353 | |
| 354 | void TestProblemModel::testPlaceholderText() |
| 355 | { |
| 356 | const QString text1 = QStringLiteral("testPlaceholderText1"); |
| 357 | const QString text2 = QStringLiteral("testPlaceholderText2"); |
| 358 | const QString empty; |
| 359 | |
| 360 | m_model->setGrouping(NoGrouping); |
| 361 | |
| 362 | // Test model with empty placeholder text |
| 363 | |
| 364 | QCOMPARE(m_model->rowCount(), 0); |
| 365 | m_model->setPlaceholderText(empty); |
| 366 | QCOMPARE(m_model->rowCount(), 0); |
| 367 | m_model->setProblems(m_problems); |
| 368 | QCOMPARE(m_model->rowCount(), 3); |
| 369 | m_model->clearProblems(); |
| 370 | QCOMPARE(m_model->rowCount(), 0); |
| 371 | |
| 372 | // Test empty model with non-empty placeholder text |
| 373 | |
| 374 | m_model->setPlaceholderText(text1); |
| 375 | QCOMPARE(m_model->rowCount(), 1); |
| 376 | QVERIFY(checkLabel(0, QModelIndex(), text1)); |
| 377 | |
| 378 | m_model->setPlaceholderText(text2); |
| 379 | QCOMPARE(m_model->rowCount(), 1); |
| 380 | QVERIFY(checkLabel(0, QModelIndex(), text2)); |
| 381 | |
| 382 | // Test non-empty model with non-empty placeholder text |
| 383 | |
| 384 | m_model->setProblems(m_problems); |
| 385 | QCOMPARE(m_model->rowCount(), 3); |
| 386 | |
| 387 | m_model->clearProblems(); |
| 388 | QCOMPARE(m_model->rowCount(), 1); |
| 389 | QVERIFY(checkLabel(0, QModelIndex(), text2)); |
| 390 | |
| 391 | m_model->addProblem(m_problems[0]); |
| 392 | QCOMPARE(m_model->rowCount(), 1); |
| 393 | QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); |
| 394 | |
| 395 | m_model->addProblem(m_problems[1]); |
| 396 | QCOMPARE(m_model->rowCount(), 2); |
| 397 | QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); |
| 398 | |
| 399 | m_model->setPlaceholderText(text1); |
| 400 | QCOMPARE(m_model->rowCount(), 2); |
| 401 | QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); |
| 402 | QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); |
| 403 | |
| 404 | m_model->setProblems({}); |
| 405 | QCOMPARE(m_model->rowCount(), 1); |
| 406 | QVERIFY(checkLabel(0, QModelIndex(), text1)); |
| 407 | } |
| 408 | |
| 409 | // Needed because util/Path.cpp asserts e.g. C: on Windows |
| 410 | QString TestProblemModel::prependPathRoot(QString const& currentPath) const |
nothing calls this directly
no test coverage detected