From 6b0c8f7e769a141f13194cf341e888c9b49f294c Mon Sep 17 00:00:00 2001 From: aqua Date: Mon, 5 Sep 2022 16:17:50 +0300 Subject: Add RekonqWindow tests --- src/test/test_rekonqwindow.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/test_rekonqwindow.cpp (limited to 'src/test/test_rekonqwindow.cpp') 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 +#include +#include + +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(_), _)).Times(0); + EXPECT_CALL(window, loadUrl(Matcher(_), _)).Times(0); + + for (auto *action : window.findChildren(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(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(); +} -- cgit v1.2.1