diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-09-09 10:08:01 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-09-14 08:50:47 +0300 |
commit | b10895dd611057bf09c8142d9ebb55263db4faf0 (patch) | |
tree | c3577fb00fe4212f90e1fd283d7fb8bda975a775 /src/test | |
parent | Add clazy cmake preset (diff) | |
download | rekonq-b10895dd611057bf09c8142d9ebb55263db4faf0.tar.xz |
Rework SearchEngineRKNQ-11-main-window
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_searchengine.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/test/test_searchengine.cpp b/src/test/test_searchengine.cpp new file mode 100644 index 00000000..6efe6cdc --- /dev/null +++ b/src/test/test_searchengine.cpp @@ -0,0 +1,43 @@ +/* ============================================================ + * The rekonq project + * ============================================================ + * SPDX-License-Identifier: GPL-3.0-only + * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net> + * ============================================================ */ + +#include "../searchengine.hpp" +#include "settings_mock.hpp" +#include <rekonq.hpp> + +using ::testing::_; // NOLINT(bugprone-reserved-identifier) +using ::testing::Matcher; +using ::testing::Return; + +MATCHER_P(QStringEq, a, "") +{ + *result_listener << "where the arg is " << qUtf8Printable(arg); + return arg.compare(a) == 0; +} + +TEST(SearchEngine, reload) +{ + MockSettings settings; + EXPECT_CALL(settings, beginGroup(QStringEq("SearchEngines"))).Times(1); + EXPECT_CALL(settings, beginGroup(QStringEq("SearchEngines.ddg"))).Times(1); + EXPECT_CALL(settings, endGroup).Times(2); + EXPECT_CALL(settings, value(QStringEq("engines"))).Times(1).WillOnce(Return(QVariant{"ddg"})); + EXPECT_CALL(settings, value(QStringEq("default"))).Times(1).WillOnce(Return(QVariant{"ddg"})); + EXPECT_CALL(settings, value(QStringEq("name"))).Times(1).WillOnce(Return(QVariant{"DuckDuckGo"})); + EXPECT_CALL(settings, value(QStringEq("url"))).Times(1).WillOnce(Return(QVariant{"https://dd.go/&q=%1"})); + EXPECT_CALL(settings, value(QString("enabled"))).Times(1).WillOnce(Return(QVariant{true})); + + SearchEngine::reload(&settings); + const auto engines = SearchEngine::engines(); + EXPECT_EQ(engines.count(), 1); + + const auto *e = SearchEngine::defaultEngine(); + ASSERT_NE(e, nullptr); + EXPECT_THAT(e->name(), QStringEq("DuckDuckGo")); + EXPECT_THAT(e->query("cats"), QStringEq("https://dd.go/&q=cats")); + EXPECT_TRUE(e->isEnabled()); +} |