* Tests with BreakpointModel and IDocumentController. * * Check BreakpointModel behaviour of Editing, Saving, * Discarding, Reloading, Renaming documents * with source line breakpoints set in them. */
| 27 | * with source line breakpoints set in them. |
| 28 | */ |
| 29 | class TestBreakpointModel : public QObject |
| 30 | { |
| 31 | Q_OBJECT |
| 32 | public: |
| 33 | explicit TestBreakpointModel(QObject* parent = nullptr); |
| 34 | |
| 35 | enum class ReloadMode { Clean, Dirty, DirtyBreakpointLine }; |
| 36 | Q_ENUM(ReloadMode) |
| 37 | |
| 38 | enum class CloseDocumentUserChoice { Cancel, Discard, Save }; |
| 39 | Q_ENUM(CloseDocumentUserChoice) |
| 40 | |
| 41 | private Q_SLOTS: |
| 42 | void initTestCase(); |
| 43 | void init(); |
| 44 | void cleanup(); |
| 45 | void cleanupTestCase(); |
| 46 | |
| 47 | void testDocumentSave(); |
| 48 | void testDocumentEditAndSave(); |
| 49 | void testDocumentEditAndDiscard(); |
| 50 | void testSetLocation(); |
| 51 | void testUpdateMarkType(); |
| 52 | void testRemoveDocumentFile(); |
| 53 | void testDocumentClear(); |
| 54 | void testDocumentSetText(); |
| 55 | void testDocumentReload_data(); |
| 56 | void testDocumentReload(); |
| 57 | void testModifiedDocumentReload_data(); |
| 58 | void testModifiedDocumentReload(); |
| 59 | |
| 60 | private: |
| 61 | using DocumentMarks = QHash<int, KDevelop::BreakpointModel::MarkType>; |
| 62 | static DocumentMarks documentMarks(const KDevelop::IDocument* doc); |
| 63 | static void printLines(int from, int count, const KDevelop::IDocument* doc); |
| 64 | static void verifyBreakpoint(KDevelop::Breakpoint* breakpoint, int expectedLine, uint expectedMarkType, |
| 65 | const DocumentMarks& marks); |
| 66 | static void verifyUntrackedBreakpoint(KDevelop::Breakpoint* breakpoint, int expectedLine); |
| 67 | |
| 68 | static void verifyTwoModelBreakpoints(KDevelop::Breakpoint* b1, KDevelop::Breakpoint* b2); |
| 69 | static ReloadMode applyReloadModeAndReload(const QUrl& url, KDevelop::IDocument* doc, KDevelop::Breakpoint* b1); |
| 70 | |
| 71 | QUrl testFileUrl(const QString& fileName) const; |
| 72 | |
| 73 | using DocumentAndBreakpoint = std::tuple<QUrl, KDevelop::IDocument*, KDevelop::Breakpoint*>; |
| 74 | DocumentAndBreakpoint setupPrimaryDocumentAndBreakpoint(); |
| 75 | |
| 76 | using DocumentAndTwoBreakpoints = |
| 77 | std::tuple<QUrl, KDevelop::IDocument*, KDevelop::Breakpoint*, KDevelop::Breakpoint*>; |
| 78 | DocumentAndTwoBreakpoints setupEditAndCheckPrimaryDocumentAndBreakpoints(); |
| 79 | DocumentAndTwoBreakpoints setupEditCheckAndSavePrimaryDocumentAndBreakpoints(); |
| 80 | |
| 81 | std::unique_ptr<QTemporaryDir> m_tempDir; ///< Test working directory |
| 82 | }; |
| 83 | |
| 84 | #endif // KDEVPLATFORM_TEST_BREAKPOINTMODEL_H |
nothing calls this directly
no test coverage detected