summaryrefslogtreecommitdiff
path: root/src/settings
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2022-08-22 10:06:00 +0300
committeraqua <aqua@iserlohn-fortress.net>2022-08-28 09:49:20 +0300
commit05a053b65443b55787ae075fc4e99181673c2d56 (patch)
treebe240b23f5bb3f88dce4c9d55d450ebefe9d0bbe /src/settings
parentAdd Setting and MockSettings (diff)
downloadrekonq-05a053b65443b55787ae075fc4e99181673c2d56.tar.xz
Load plugins from AppLocalDataLocation by default
Diffstat (limited to 'src/settings')
-rw-r--r--src/settings/settings.cpp2
-rw-r--r--src/settings/settings.hpp8
-rw-r--r--src/settings/test/settings_mock.hpp11
-rw-r--r--src/settings/test/test_settings.cpp16
-rw-r--r--src/settings/test/test_settingsdialog.cpp7
5 files changed, 40 insertions, 4 deletions
diff --git a/src/settings/settings.cpp b/src/settings/settings.cpp
index 1ffa14cb..190bc977 100644
--- a/src/settings/settings.cpp
+++ b/src/settings/settings.cpp
@@ -26,3 +26,5 @@ void Settings::setValue(const QString &key, const QVariant &value)
}
QVariant Settings::value(const QString &key, const QVariant &defaultValue) const { return d->value(key, defaultValue); }
+
+QString Settings::filePath() const { return d->fileName(); }
diff --git a/src/settings/settings.hpp b/src/settings/settings.hpp
index c595e981..ec654f17 100644
--- a/src/settings/settings.hpp
+++ b/src/settings/settings.hpp
@@ -16,14 +16,16 @@ class Settings final : public RekonqSettings {
Q_OBJECT
public:
- explicit Settings(const QString &path, QObject *parent = nullptr);
- ~Settings() = default;
+ explicit Settings(const QString &settingsPath, QObject *parent = nullptr);
+ ~Settings() override = default;
void beginGroup(const QString &prefix) override;
void endGroup() override;
void setValue(const QString &key, const QVariant &value) override;
- QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
+ [[nodiscard]] QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const override;
+
+ [[nodiscard]] QString filePath() const override;
private:
QSettings *d;
diff --git a/src/settings/test/settings_mock.hpp b/src/settings/test/settings_mock.hpp
index ec792ff5..bc3fbc2f 100644
--- a/src/settings/test/settings_mock.hpp
+++ b/src/settings/test/settings_mock.hpp
@@ -1,3 +1,10 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#pragma once
#include <gmock/gmock.h>
@@ -8,11 +15,13 @@ class MockSettings : public RekonqSettings {
public:
explicit MockSettings() : RekonqSettings(nullptr) {}
- ~MockSettings() = default;
+ ~MockSettings() override = default;
MOCK_METHOD(void, beginGroup, (const QString &), (override));
MOCK_METHOD(void, endGroup, (), (override));
MOCK_METHOD(void, setValue, (const QString &, const QVariant &), (override));
MOCK_METHOD(QVariant, value, (const QString &, const QVariant &), (const, override));
+
+ MOCK_METHOD(QString, filePath, (), (const, override));
};
diff --git a/src/settings/test/test_settings.cpp b/src/settings/test/test_settings.cpp
index 72582bc7..2ca5ba1a 100644
--- a/src/settings/test/test_settings.cpp
+++ b/src/settings/test/test_settings.cpp
@@ -1,4 +1,13 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#include <QApplication>
+#include <QDir>
+#include <QStandardPaths>
#include <gtest/gtest.h>
#include <iostream>
@@ -23,6 +32,13 @@ TEST(settings, getFont)
EXPECT_EQ(fixed.styleHint(), QFont::Monospace) << qUtf8Printable(fixed.toString());
}
+TEST(settings, settingsPath)
+{
+ const auto path = QDir(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)).filePath("rekonqrc");
+ EXPECT_FALSE(path.isEmpty());
+ EXPECT_TRUE(path.endsWith("rekonqrc"));
+}
+
TEST(settings, Settings)
{
Settings settings(settingsFile);
diff --git a/src/settings/test/test_settingsdialog.cpp b/src/settings/test/test_settingsdialog.cpp
index b70c6dda..a50cf307 100644
--- a/src/settings/test/test_settingsdialog.cpp
+++ b/src/settings/test/test_settingsdialog.cpp
@@ -1,3 +1,10 @@
+/* ============================================================
+ * The rekonq project
+ * ============================================================
+ * SPDX-License-Identifier: GPL-3.0-only
+ * Copyright (C) 2022 aqua <aqua@iserlohn-fortress.net>
+ * ============================================================ */
+
#include "../settingsdialog.h"
#include "settings_mock.hpp"
#include <QApplication>