| 262 | } |
| 263 | |
| 264 | void TestProblemModel::testSeverityGrouping() |
| 265 | { |
| 266 | m_model->setGrouping(SeverityGrouping); |
| 267 | m_model->setSeverity(IProblem::Hint); |
| 268 | QCOMPARE(m_model->rowCount(), 3); |
| 269 | |
| 270 | // Check if setting problems works |
| 271 | m_model->setProblems(m_problems); |
| 272 | QCOMPARE(m_model->rowCount(), 3); |
| 273 | for (int i = 0; i < m_model->rowCount(); i++) { |
| 274 | QVERIFY(checkSeverityGroup(i, m_problems[i])); |
| 275 | } |
| 276 | |
| 277 | // Check if displaying works |
| 278 | for (int i = 0; i < m_model->rowCount(); i++) { |
| 279 | QModelIndex parent = m_model->index(i, 0); |
| 280 | QVERIFY(parent.isValid()); |
| 281 | |
| 282 | QVERIFY(checkDisplay(0, parent, m_problems[i])); |
| 283 | } |
| 284 | |
| 285 | // Check if clearing works |
| 286 | m_model->clearProblems(); |
| 287 | QCOMPARE(m_model->rowCount(), 3); |
| 288 | |
| 289 | // Check if adding problems works |
| 290 | int c = 0; |
| 291 | for (const IProblem::Ptr& p : std::as_const(m_problems)) { |
| 292 | m_model->addProblem(p); |
| 293 | QVERIFY(checkSeverityGroup(c, m_problems[c])); |
| 294 | c++; |
| 295 | } |
| 296 | |
| 297 | // Check if filtering works |
| 298 | // old-style setSeverity |
| 299 | // Error filtering |
| 300 | m_model->setSeverity(IProblem::Error); |
| 301 | QCOMPARE(m_model->rowCount(), 3); |
| 302 | checkSeverityGroup(0, m_problems[0]); |
| 303 | |
| 304 | // Warning filtering |
| 305 | m_model->setSeverity(IProblem::Warning); |
| 306 | QCOMPARE(m_model->rowCount(), 3); |
| 307 | checkSeverityGroup(0, m_problems[0]); |
| 308 | checkSeverityGroup(1, m_problems[1]); |
| 309 | |
| 310 | // Hint filtering |
| 311 | m_model->setSeverity(IProblem::Hint); |
| 312 | QCOMPARE(m_model->rowCount(), 3); |
| 313 | checkSeverityGroup(0, m_problems[0]); |
| 314 | checkSeverityGroup(1, m_problems[1]); |
| 315 | checkSeverityGroup(2, m_problems[2]); |
| 316 | |
| 317 | // Check if filtering works |
| 318 | // Error filtering |
| 319 | m_model->setSeverities(IProblem::Error); |
| 320 | QCOMPARE(m_model->rowCount(), 3); |
| 321 | checkSeverityGroup(0, m_problems[0]); |
nothing calls this directly
no test coverage detected