Changeset View
Changeset View
Standalone View
Standalone View
kdevplatform/shell/tests/test_problemmodel.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 43 | { | |||
---|---|---|---|---|---|
44 | Q_OBJECT | 44 | Q_OBJECT | ||
45 | private Q_SLOTS: | 45 | private Q_SLOTS: | ||
46 | void initTestCase(); | 46 | void initTestCase(); | ||
47 | void cleanupTestCase(); | 47 | void cleanupTestCase(); | ||
48 | 48 | | |||
49 | void testNoGrouping(); | 49 | void testNoGrouping(); | ||
50 | void testPathGrouping(); | 50 | void testPathGrouping(); | ||
51 | void testSeverityGrouping(); | 51 | void testSeverityGrouping(); | ||
52 | void testPlaceholderText(); | ||||
52 | 53 | | |||
53 | private: | 54 | private: | ||
54 | void generateProblems(); | 55 | void generateProblems(); | ||
55 | bool checkIsSame(int row, const QModelIndex &parent, const IProblem::Ptr &problem); | 56 | bool checkIsSame(int row, const QModelIndex &parent, const IProblem::Ptr &problem); | ||
56 | bool checkDiagnostics(int row, const QModelIndex &parent); | 57 | bool checkDiagnostics(int row, const QModelIndex &parent); | ||
57 | bool checkDisplay(int row, const QModelIndex &parent, const IProblem::Ptr &problem); | 58 | bool checkDisplay(int row, const QModelIndex &parent, const IProblem::Ptr &problem); | ||
58 | bool checkLabel(int row, const QModelIndex &parent, const QString &label); | 59 | bool checkLabel(int row, const QModelIndex &parent, const QString &label); | ||
59 | bool checkPathGroup(int row, const IProblem::Ptr &problem); | 60 | bool checkPathGroup(int row, const IProblem::Ptr &problem); | ||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Line(s) | 356 | { | |||
357 | QVERIFY(parent.isValid()); | 358 | QVERIFY(parent.isValid()); | ||
358 | 359 | | |||
359 | checkDiagnostics(0, parent); | 360 | checkDiagnostics(0, parent); | ||
360 | } | 361 | } | ||
361 | 362 | | |||
362 | m_model->clearProblems(); | 363 | m_model->clearProblems(); | ||
363 | } | 364 | } | ||
364 | 365 | | |||
366 | void TestProblemModel::testPlaceholderText() | ||||
367 | { | ||||
368 | const QString text1 = QStringLiteral("testPlaceholderText1"); | ||||
369 | const QString text2 = QStringLiteral("testPlaceholderText2"); | ||||
370 | const QString empty; | ||||
371 | | ||||
372 | m_model->setGrouping(NoGrouping); | ||||
373 | | ||||
374 | // Test model with empty placeholder text | ||||
375 | | ||||
376 | QCOMPARE(m_model->rowCount(), 0); | ||||
377 | m_model->setPlaceholderText(empty); | ||||
378 | QCOMPARE(m_model->rowCount(), 0); | ||||
379 | m_model->setProblems(m_problems); | ||||
380 | QCOMPARE(m_model->rowCount(), 3); | ||||
381 | m_model->clearProblems(); | ||||
382 | QCOMPARE(m_model->rowCount(), 0); | ||||
383 | | ||||
384 | // Test empty model with non-empty placeholder text | ||||
385 | | ||||
386 | m_model->setPlaceholderText(text1); | ||||
387 | QCOMPARE(m_model->rowCount(), 1); | ||||
388 | QVERIFY(checkLabel(0, QModelIndex(), text1)); | ||||
389 | | ||||
390 | m_model->setPlaceholderText(text2); | ||||
391 | QCOMPARE(m_model->rowCount(), 1); | ||||
392 | QVERIFY(checkLabel(0, QModelIndex(), text2)); | ||||
393 | | ||||
394 | // Test non-empty model with non-empty placeholder text | ||||
395 | | ||||
396 | m_model->setProblems(m_problems); | ||||
397 | QCOMPARE(m_model->rowCount(), 3); | ||||
398 | | ||||
399 | m_model->clearProblems(); | ||||
400 | QCOMPARE(m_model->rowCount(), 1); | ||||
401 | QVERIFY(checkLabel(0, QModelIndex(), text2)); | ||||
402 | | ||||
403 | m_model->addProblem(m_problems[0]); | ||||
404 | QCOMPARE(m_model->rowCount(), 1); | ||||
405 | QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); | ||||
406 | | ||||
407 | m_model->addProblem(m_problems[1]); | ||||
408 | QCOMPARE(m_model->rowCount(), 2); | ||||
409 | QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); | ||||
410 | | ||||
411 | m_model->setPlaceholderText(text1); | ||||
412 | QCOMPARE(m_model->rowCount(), 2); | ||||
413 | QVERIFY(checkIsSame(0, QModelIndex(), m_problems[0])); | ||||
414 | QVERIFY(checkIsSame(1, QModelIndex(), m_problems[1])); | ||||
415 | | ||||
416 | m_model->setProblems({}); | ||||
417 | QCOMPARE(m_model->rowCount(), 1); | ||||
418 | QVERIFY(checkLabel(0, QModelIndex(), text1)); | ||||
419 | } | ||||
420 | | ||||
365 | // Generate 3 problems, all with different paths, different severity | 421 | // Generate 3 problems, all with different paths, different severity | ||
366 | // Also generates a problem with diagnostics | 422 | // Also generates a problem with diagnostics | ||
367 | void TestProblemModel::generateProblems() | 423 | void TestProblemModel::generateProblems() | ||
368 | { | 424 | { | ||
369 | IProblem::Ptr p1(new DetectedProblem()); | 425 | IProblem::Ptr p1(new DetectedProblem()); | ||
370 | IProblem::Ptr p2(new DetectedProblem()); | 426 | IProblem::Ptr p2(new DetectedProblem()); | ||
371 | IProblem::Ptr p3(new DetectedProblem()); | 427 | IProblem::Ptr p3(new DetectedProblem()); | ||
372 | 428 | | |||
▲ Show 20 Lines • Show All 143 Lines • Show Last 20 Lines |