summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSzabolcs David <davidsz@inf.u-szeged.hu>2015-11-06 05:33:47 -0800
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2015-11-12 10:46:55 +0000
commit6677ddec16488f21c5f730f4a4005c66d11d81e1 (patch)
tree048c51f6dfa789d6c06b04b1c9603b89596d608d /tests
parentc61fa3df0fc3373de79a633da8f9b42d41523b55 (diff)
Fix resetting attributes in top level WebEngineSettings
Store default values in separate containers and remove related FIXMEs from WebEngineSettings. Add API test case in order to demonstrate the bug. Change-Id: If9d98265cab0f41b543fe690d534879b65f2b577 Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/qwebenginesettings/qwebenginesettings.pro2
-rw-r--r--tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp63
-rw-r--r--tests/auto/widgets/widgets.pro1
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginesettings/qwebenginesettings.pro b/tests/auto/widgets/qwebenginesettings/qwebenginesettings.pro
new file mode 100644
index 000000000..70786e70f
--- /dev/null
+++ b/tests/auto/widgets/qwebenginesettings/qwebenginesettings.pro
@@ -0,0 +1,2 @@
+include(../tests.pri)
+QT *= core-private gui-private
diff --git a/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
new file mode 100644
index 000000000..0f6a6062e
--- /dev/null
+++ b/tests/auto/widgets/qwebenginesettings/tst_qwebenginesettings.cpp
@@ -0,0 +1,63 @@
+/*
+ Copyright (C) 2015 The Qt Company Ltd.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <QtTest/QtTest>
+
+#include <qwebengineprofile.h>
+#include <qwebenginesettings.h>
+
+class tst_QWebEngineSettings: public QObject {
+ Q_OBJECT
+
+private Q_SLOTS:
+ void resetAttributes();
+};
+
+void tst_QWebEngineSettings::resetAttributes()
+{
+ QWebEngineProfile profile;
+ QWebEngineSettings *settings = profile.settings();
+
+ // Attribute
+ bool defaultValue = settings->testAttribute(QWebEngineSettings::FullScreenSupportEnabled);
+ settings->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, !defaultValue);
+ QCOMPARE(!defaultValue, settings->testAttribute(QWebEngineSettings::FullScreenSupportEnabled));
+ settings->resetAttribute(QWebEngineSettings::FullScreenSupportEnabled);
+ QCOMPARE(defaultValue, settings->testAttribute(QWebEngineSettings::FullScreenSupportEnabled));
+
+ // Font family
+ QString defaultFamily = settings->fontFamily(QWebEngineSettings::StandardFont);
+ QString newFontFamily("PugDog");
+ settings->setFontFamily(QWebEngineSettings::StandardFont, newFontFamily);
+ QCOMPARE(newFontFamily, settings->fontFamily(QWebEngineSettings::StandardFont));
+ settings->resetFontFamily(QWebEngineSettings::StandardFont);
+ QCOMPARE(defaultFamily, settings->fontFamily(QWebEngineSettings::StandardFont));
+
+ // Font size
+ int defaultSize = settings->fontSize(QWebEngineSettings::MinimumFontSize);
+ int newSize = defaultSize + 10;
+ settings->setFontSize(QWebEngineSettings::MinimumFontSize, newSize);
+ QCOMPARE(newSize, settings->fontSize(QWebEngineSettings::MinimumFontSize));
+ settings->resetFontSize(QWebEngineSettings::MinimumFontSize);
+ QCOMPARE(defaultSize, settings->fontSize(QWebEngineSettings::MinimumFontSize));
+}
+
+QTEST_MAIN(tst_QWebEngineSettings)
+
+#include "tst_qwebenginesettings.moc"
diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro
index 20aeea78b..986d5bbee 100644
--- a/tests/auto/widgets/widgets.pro
+++ b/tests/auto/widgets/widgets.pro
@@ -8,6 +8,7 @@ SUBDIRS += \
qwebengineinspector \
qwebengineprofile \
qwebenginescript \
+ qwebenginesettings \
qwebengineview
qtHaveModule(positioning) {