summaryrefslogtreecommitdiff
path: root/src/settings/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings/test')
-rw-r--r--src/settings/test/rekonqrc36
-rw-r--r--src/settings/test/test_settings.cpp40
-rw-r--r--src/settings/test/test_settings.qrc5
3 files changed, 68 insertions, 13 deletions
diff --git a/src/settings/test/rekonqrc b/src/settings/test/rekonqrc
new file mode 100644
index 00000000..97329a6d
--- /dev/null
+++ b/src/settings/test/rekonqrc
@@ -0,0 +1,36 @@
+[General]
+FirstRun=true
+lang=TODO: change type to StringList
+homepage=http://www.kde.org/
+newtab=http://www.kde.org/
+searchUrl=https://duckduckgo.com/?q=%1
+pluginPath=TODO: change type to Path
+
+[Network]
+downloadPath=TODO: change type to Path
+downloadPathAsk=true
+userAgent=TODO
+
+[Appearance]
+defaultFontSize=16
+minFontSize=7
+defaultEncoding=ISO 8859-1
+defaultZoom=10
+
+[Shortcuts]
+actionShowSidebar=Ctrl+B
+actionShowSearchBar=Ctrl+F
+actionSettings=Ctrl+S
+actionQuit=Ctrl+Q
+actionNewTab=Ctrl+T
+actionCloseTab=Ctrl+W
+actionSwitchTabLeft=Ctrl+Left
+actionSwitchTabRight=Ctrl+Right
+actionFocusAddressBar=F6
+actionBack=Alt+Left
+actionForward=Alt+Right
+actionRefresh=F5
+actionReload=Ctrl+F5
+actionOpen=Ctrl+O
+actionBookmark=Ctrl+D
+
diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp
index fdb976f6..babbcdb6 100644
--- a/src/settings/test/test_settings.cpp
+++ b/src/settings/test/test_settings.cpp
@@ -6,8 +6,10 @@
* ============================================================ */
#include <QApplication>
+#include <QDialogButtonBox>
#include <QDir>
#include <QLineEdit>
+#include <QPushButton>
#include <QStandardPaths>
#include <gtest/gtest.h>
@@ -22,8 +24,6 @@ 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);
@@ -53,12 +53,16 @@ TEST(settings, settingsPath)
TEST(settings, Settings)
{
- Settings settings(settingsFile);
+ Settings settings(":rekonqrc");
+ EXPECT_THAT(settings.filePath(), QStringEq(":rekonqrc"));
const auto FirstRun = settings.value("FirstRun");
EXPECT_TRUE(FirstRun.isValid());
EXPECT_TRUE(FirstRun.toBool());
+ settings.setValue("FirstRun", false);
+ EXPECT_FALSE(settings.value("FirstRun").toBool());
+
settings.beginGroup("Network");
const auto downloadPathAsk = settings.value("downloadPathAsk");
EXPECT_TRUE(downloadPathAsk.isValid());
@@ -75,24 +79,34 @@ TEST(settings, SettingsDialog)
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);
+ EXPECT_CALL(mockSettings, beginGroup).Times(3 * 4);
+ EXPECT_CALL(mockSettings, endGroup).Times(3 * 4);
// 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, value).Times(35 * 2).WillRepeatedly(ReturnArg<1>());
+ EXPECT_CALL(mockSettings, setValue(_, _)).Times(33 + 34);
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();
+ // change setting
+ {
+ 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();
+ }
+
+ // reset setting
+ {
+ SettingsDialog dlg(&mockSettings);
+ auto *resetBtn = dlg.findChild<QDialogButtonBox *>()->button(QDialogButtonBox::RestoreDefaults);
+ EXPECT_FALSE(resetBtn == nullptr);
+ resetBtn->click();
+ }
}
int main(int argc, char **argv)
{
::testing::InitGoogleTest(&argc, argv);
- if (argc > 1) settingsFile = argv[argc - 1];
// handling fonts requires a QGuiApplication
// The proper platform name needs to be added to the argument list before the QGuiApplication constructor is called
diff --git a/src/settings/test/test_settings.qrc b/src/settings/test/test_settings.qrc
new file mode 100644
index 00000000..deaf088f
--- /dev/null
+++ b/src/settings/test/test_settings.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+ <qresource>
+ <file>rekonqrc</file>
+ </qresource>
+</RCC>