summaryrefslogtreecommitdiff
path: root/src/test/test_rekonqwindow.cpp
blob: b4db025665ae0ab403b37e42f019530ccb65269b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#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, addView).Times(0);
  EXPECT_CALL(window, loadDefaultUrl).Times(0);
  EXPECT_CALL(window, loadRequestedUrl).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();
}