MCPcopy Create free account
hub / github.com/KDE/kdevelop / init

Method init

kdevplatform/debugger/tests/test_breakpointmodel.cpp:364–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364void 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
405void TestBreakpointModel::cleanup()
406{

Callers 1

VariableToolTipMethod · 0.45

Calls 13

documentControllerFunction · 0.85
breakpointModelFunction · 0.85
breakpointConfigFunction · 0.85
emptyMethod · 0.80
openDocumentsMethod · 0.80
writeEntryMethod · 0.80
initializeMethod · 0.45
filePathMethod · 0.45
removeRowsMethod · 0.45
rowCountMethod · 0.45
setLocationMethod · 0.45

Tested by

no test coverage detected