| 74 | } |
| 75 | |
| 76 | void testFindNextAndWrap() |
| 77 | { |
| 78 | QTemporaryFile file; |
| 79 | const bool wrote = writeTempHelp(file); |
| 80 | report("temp help document created", wrote); |
| 81 | if (!wrote) |
| 82 | return; |
| 83 | |
| 84 | HelpDialog dialog("Search Test", file.fileName()); |
| 85 | HelpWidgets widgets = findWidgets(dialog); |
| 86 | if (!requireWidgets(widgets)) |
| 87 | return; |
| 88 | |
| 89 | widgets.edit->setText("target"); |
| 90 | report("find button enables with query", widgets.button->isEnabled()); |
| 91 | |
| 92 | widgets.button->click(); |
| 93 | const QTextCursor firstCursor = widgets.browser->textCursor(); |
| 94 | const int firstStart = firstCursor.selectionStart(); |
| 95 | report("first find selects match", selectedTextEquals(widgets.browser, "target")); |
| 96 | |
| 97 | widgets.button->click(); |
| 98 | const QTextCursor secondCursor = widgets.browser->textCursor(); |
| 99 | const int secondStart = secondCursor.selectionStart(); |
| 100 | report("find next advances", selectedTextEquals(widgets.browser, "target") && secondStart > firstStart, |
| 101 | "first=" + std::to_string(firstStart) + " second=" + std::to_string(secondStart)); |
| 102 | |
| 103 | widgets.button->click(); |
| 104 | const QTextCursor wrapCursor = widgets.browser->textCursor(); |
| 105 | report("find next wraps to first match", |
| 106 | selectedTextEquals(widgets.browser, "target") && wrapCursor.selectionStart() == firstStart); |
| 107 | report("wrap status is shown", widgets.status->text() == "Wrapped to top", |
| 108 | widgets.status->text().toStdString()); |
| 109 | } |
| 110 | |
| 111 | void testNoMatchClearsSelectionAndRecovers() |
| 112 | { |
no test coverage detected