| 362 | } |
| 363 | |
| 364 | void TestBreakpointModel::init() |
| 365 | { |
| 366 | Core::self()->documentControllerInternal()->initialize(); |
| 367 | |
| 368 | // Restore the primary test file under empty temporary working dir. |
| 369 | m_tempDir = std::make_unique<QTemporaryDir>(); |
| 370 | QVERIFY(QFile::copy(TEST_FILES_DIR "/primary_test.cpp", m_tempDir->filePath(primaryTestFileName))); |
| 371 | |
| 372 | // pre-conditions |
| 373 | QVERIFY(documentController()); |
| 374 | QVERIFY(breakpointModel()); |
| 375 | QVERIFY(documentController()->openDocuments().empty()); |
| 376 | |
| 377 | // init() must put breakpointModel() and breakpointConfig() |
| 378 | // into state where "breakpointModel()->load()" can work: |
| 379 | // - breakpointConfig() has single breakpoint. |
| 380 | // - No breakpoints are registered/exist in the model. |
| 381 | |
| 382 | // Remove all breakpoints, overwrites breakpointConfig(). |
| 383 | // This must be done *before* writing the hard-coded config below. |
| 384 | auto* const model = breakpointModel(); |
| 385 | model->removeRows(0, model->rowCount()); |
| 386 | |
| 387 | // Setup hard-coded breakpoint model config with single breakpoint. |
| 388 | // Tests can use this by doing "breakpointModel()->load()" before modifying the BreakpointModel. |
| 389 | KConfigGroup config = breakpointConfig(); |
| 390 | config.writeEntry("number", 1); |
| 391 | // (ab)use Breakpoint to write the config data for it. |
| 392 | Breakpoint entry(nullptr, Breakpoint::CodeBreakpoint); |
| 393 | // set source line location at "foo(5);" |
| 394 | const auto url = testFileUrl(primaryTestFileName); |
| 395 | RETURN_IF_TEST_FAILED(); |
| 396 | entry.setLocation(url, 21); |
| 397 | { |
| 398 | KConfigGroup group = config.group(QString::number(0)); |
| 399 | entry.save(group); |
| 400 | } |
| 401 | |
| 402 | QCOMPARE(breakpointModel()->rowCount(), 0); |
| 403 | } |
| 404 | |
| 405 | void TestBreakpointModel::cleanup() |
| 406 | { |
no test coverage detected