summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-09-05 16:17:50 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-09-05 23:07:42 +0300
commit6b0c8f7e769a141f13194cf341e888c9b49f294c (patch)
tree308895235933e1246759ffb540269a349d0ef151 /src/test
parentUrlBar: add completer (diff)
downloadrekonq-6b0c8f7e769a141f13194cf341e888c9b49f294c.tar.xz
Add RekonqWindow tests
Diffstat (limited to 'src/test')
-rw-r--r--src/test/rekonqwindow_mock.hpp17
l---------src/test/settings_mock.hpp1
-rw-r--r--src/test/test_rekonqwindow.cpp38
3 files changed, 56 insertions, 0 deletions
diff --git a/src/test/rekonqwindow_mock.hpp b/src/test/rekonqwindow_mock.hpp
new file mode 100644
index 00000000..403237d4
--- /dev/null
+++ b/src/test/rekonqwindow_mock.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "../rekonqwindow.hpp"
+#include <gmock/gmock.h>
+
+class FakeWindow : public RekonqWindow {
+ Q_OBJECT
+
+public:
+ explicit FakeWindow(QWidget *parent = nullptr) : RekonqWindow(parent) {}
+ ~FakeWindow() override = default;
+
+ MOCK_METHOD(RekonqView *, currentView, (), (override));
+ MOCK_METHOD(int, addView, (RekonqView *), (override));
+ MOCK_METHOD(void, loadUrl, (rekonq::DefaultUrl, rekonq::OpenType), (override));
+ MOCK_METHOD(void, loadUrl, (const QUrl &, rekonq::OpenType), (override));
+};
diff --git a/src/test/settings_mock.hpp b/src/test/settings_mock.hpp
new file mode 120000
index 00000000..369a0abe
--- /dev/null
+++ b/src/test/settings_mock.hpp
@@ -0,0 +1 @@
+../settings/test/settings_mock.hpp \ No newline at end of file
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();
+}