diff options
Diffstat (limited to 'src/test/test_rekonqwindow.cpp')
-rw-r--r-- | src/test/test_rekonqwindow.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/test/test_rekonqwindow.cpp b/src/test/test_rekonqwindow.cpp new file mode 100644 index 00000000..9e90cd94 --- /dev/null +++ b/src/test/test_rekonqwindow.cpp @@ -0,0 +1,38 @@ +#include "rekonqwindow_mock.hpp" +#include "settings_mock.hpp" +#include <QApplication> +#include <QRegularExpression> +#include <gtest/gtest.h> + +using ::testing::_; // NOLINT(bugprone-reserved-identifier) +using ::testing::Matcher; +using ::testing::ReturnArg; + +TEST(RekonqWindow, mock_shortcuts) +{ + FakeWindow window; + EXPECT_CALL(window, currentView).Times(0); + EXPECT_CALL(window, addView).Times(0); + EXPECT_CALL(window, loadUrl(Matcher<rekonq::DefaultUrl>(_), _)).Times(0); + EXPECT_CALL(window, loadUrl(Matcher<const QUrl &>(_), _)).Times(0); + + for (auto *action : window.findChildren<QAction *>(QRegularExpression("^action.*"))) { + EXPECT_TRUE(action->shortcut().isEmpty()) << qUtf8Printable(action->objectName()); + } + + MockSettings settings; + EXPECT_CALL(settings, value).WillRepeatedly(ReturnArg<0>()); + + window.setupShortcuts(&settings); + for (auto *action : window.findChildren<QAction *>(QRegularExpression("^action.*"))) { + EXPECT_FALSE(action->shortcut().isEmpty()) << qUtf8Printable(action->objectName()); + } +} + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + QApplication app(argc, argv); + + return RUN_ALL_TESTS(); +} |