diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-08-24 16:38:49 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-08-28 09:49:20 +0300 |
commit | c5ed279da0e74adb79c6c2a3e485cb9668b1c130 (patch) | |
tree | 4271dcd3530bec7df25b01190317bee56533df94 /src/settings/test | |
parent | Load plugins from AppLocalDataLocation by default (diff) | |
download | rekonq-c5ed279da0e74adb79c6c2a3e485cb9668b1c130.tar.xz |
SettingsDialog: save settings when changed
- connect Restore Defaults button
Diffstat (limited to 'src/settings/test')
-rw-r--r-- | src/settings/test/test_settings.cpp | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp index 2ca5ba1a..fdb976f6 100644 --- a/src/settings/test/test_settings.cpp +++ b/src/settings/test/test_settings.cpp @@ -7,22 +7,34 @@ #include <QApplication> #include <QDir> +#include <QLineEdit> #include <QStandardPaths> #include <gtest/gtest.h> -#include <iostream> - // Software under Test #include "../helpers.hpp" #include "../settings.hpp" #include "../settingsdialog.h" #include "settings_mock.hpp" +using ::testing::_; using ::testing::AtLeast; +using ::testing::ContainerEq; using ::testing::ReturnArg; const char *settingsFile = nullptr; +MATCHER_P(QStringEq, a, "") +{ + *result_listener << "where the arg is " << qUtf8Printable(arg); + return arg.compare(a) == 0; +} +MATCHER_P(QVariantEq, a, "") +{ + *result_listener << "where the arg is " << qUtf8Printable(arg.toString()); + return arg.toString().compare(a) == 0; +} + TEST(settings, getFont) { const auto serif = getFont(QFont::Serif); @@ -60,12 +72,21 @@ TEST(settings, Settings) TEST(settings, SettingsDialog) { - MockSettings settings; - EXPECT_CALL(settings, beginGroup).Times(4); - EXPECT_CALL(settings, endGroup).Times(4); - EXPECT_CALL(settings, value).Times(AtLeast(4)).WillRepeatedly(ReturnArg<1>()); - - SettingsDialog dlg(&settings); + MockSettings mockSettings; + // There are 4 groups in total, but General should not be calling beginGroup/endGroup + // beginGroup/endGroup are called twice: during the ctor and when accepted + EXPECT_CALL(mockSettings, beginGroup).Times(3 * 2); + EXPECT_CALL(mockSettings, endGroup).Times(3 * 2); + // There are 35 settings in total, one of which is hidden and won't be set by the dialog + EXPECT_CALL(mockSettings, value).Times(35).WillRepeatedly(ReturnArg<1>()); + EXPECT_CALL(mockSettings, setValue(_, _)).Times(33); + EXPECT_CALL(mockSettings, setValue(QStringEq("homepage"), QVariantEq("about:blank"))); + + SettingsDialog dlg(&mockSettings); + auto *homepage = dlg.findChild<QLineEdit *>("homepage"); + EXPECT_TRUE(homepage->text() == QLatin1String("http://www.kde.org/")) << qUtf8Printable(homepage->text()); + homepage->setText("about:blank"); + dlg.accept(); } int main(int argc, char **argv) |