| 661 | } |
| 662 | |
| 663 | void TestBreakpointModel::testDocumentReload() |
| 664 | { |
| 665 | const auto [url, doc, b1, b2] = setupEditAndCheckPrimaryDocumentAndBreakpoints(); |
| 666 | RETURN_IF_TEST_FAILED(); |
| 667 | |
| 668 | // Set some extra breakpoint data that should be preserved even after a reload. |
| 669 | b1->setIgnoreHits(1); |
| 670 | b1->setCondition("i == 0"); |
| 671 | b1->setHitCount(1); |
| 672 | b2->setIgnoreHits(2); |
| 673 | b2->setCondition("*i > 0"); |
| 674 | b2->setHitCount(2); |
| 675 | |
| 676 | QVERIFY(doc->save()); |
| 677 | QCOMPARE(doc->state(), IDocument::Clean); |
| 678 | |
| 679 | // Wait needed for BreakpointModel::save() to complete. |
| 680 | QTest::qWait(1); |
| 681 | |
| 682 | applyReloadModeAndReload(url, doc, b1); |
| 683 | RETURN_IF_TEST_FAILED(); |
| 684 | |
| 685 | verifyTwoModelBreakpoints(b1, b2); |
| 686 | RETURN_IF_TEST_FAILED(); |
| 687 | |
| 688 | // Verify the breakpoints' locations and marks. |
| 689 | const auto marks = documentMarks(doc); |
| 690 | QCOMPARE(marks.size(), 2); |
| 691 | VERIFY_BREAKPOINT(b1, 23, BreakpointModel::DisabledBreakpointMark, marks, ); |
| 692 | VERIFY_BREAKPOINT(b2, 24, BreakpointModel::ReachedBreakpointMark, marks, ); |
| 693 | |
| 694 | // Verify that reloading does not affect unrelated breakpoint data. |
| 695 | QCOMPARE(b1->enabled(), false); |
| 696 | QCOMPARE(b1->ignoreHits(), 1); |
| 697 | QCOMPARE(b1->condition(), "i == 0"); |
| 698 | QCOMPARE(b1->hitCount(), 1); |
| 699 | QCOMPARE(b2->enabled(), true); |
| 700 | QCOMPARE(b2->ignoreHits(), 2); |
| 701 | QCOMPARE(b2->condition(), "*i > 0"); |
| 702 | QCOMPARE(b2->hitCount(), 2); |
| 703 | |
| 704 | const auto savedBreakpoints = readBreakpointsFromConfig(); |
| 705 | QCOMPARE(savedBreakpoints.size(), 2); |
| 706 | QCOMPARE(savedBreakpoints.at(0)->line(), 23); |
| 707 | QCOMPARE(savedBreakpoints.at(0)->enabled(), false); |
| 708 | QCOMPARE(savedBreakpoints.at(0)->ignoreHits(), 1); |
| 709 | QCOMPARE(savedBreakpoints.at(0)->condition(), "i == 0"); |
| 710 | QCOMPARE(savedBreakpoints.at(1)->line(), 24); |
| 711 | QCOMPARE(savedBreakpoints.at(1)->enabled(), true); |
| 712 | QCOMPARE(savedBreakpoints.at(1)->ignoreHits(), 2); |
| 713 | QCOMPARE(savedBreakpoints.at(1)->condition(), "*i > 0"); |
| 714 | } |
| 715 | |
| 716 | void TestBreakpointModel::testModifiedDocumentReload_data() |
| 717 | { |
nothing calls this directly
no test coverage detected