summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJüri Valdmann <juri.valdmann@qt.io>2019-07-09 09:42:39 +0200
committerJüri Valdmann <juri.valdmann@qt.io>2019-07-15 17:04:39 +0200
commit1f699db3d71a0afcb961466bcc6b1a8ed6f72468 (patch)
tree4825360ad986123d730b38501b245db91a33c206 /tests/auto
parent2227f9086f856223c90e7cca0637853d45b848f2 (diff)
Ignore persisted spellchecking preferences
Ignore on-disk values of spellCheckEnabled and spellCheckLanguages prefs to preserve backwards compatibility. Fixes deterministic failure in second run of tst_spellchecking because the first run disabled spellchecking. Put all settings-related tests in tst_spellchecking into one test and pretend to check that settings are not persisted. Since settings are currently read and written on independent task sequences without guaranteed ordering, the test would succeed even if settings were persisted. Specifically, in code like this profile = new QWebEngineProfile("MyProf"); // 1 delete profile; // 2 profile = new QWebEngineProfile("MyProf"); // 3 the write from line 2 will usually happen after the read from line 3. Once persistence becomes a public feature we probably should add some way to guarantee the proper ordering of reads and writes. Change-Id: Icb2290417049848dbe68b7f991bbe2d52756f295 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/spellchecking/tst_spellchecking.cpp83
1 files changed, 48 insertions, 35 deletions
diff --git a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
index b6582083d..a9123ec15 100644
--- a/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
+++ b/tests/auto/widgets/spellchecking/tst_spellchecking.cpp
@@ -72,10 +72,7 @@ class tst_Spellchecking : public QObject
private Q_SLOTS:
void init();
void cleanup();
- void initTestCase();
- void spellCheckLanguage();
- void spellCheckLanguages();
- void spellCheckEnabled();
+ void settings();
void spellcheck();
void spellcheck_data();
@@ -84,19 +81,8 @@ private:
WebView *m_view;
};
-void tst_Spellchecking::initTestCase()
-{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- QVERIFY(profile);
- QVERIFY(!profile->isSpellCheckEnabled());
- QVERIFY(profile->spellCheckLanguages().isEmpty());
-}
-
void tst_Spellchecking::init()
{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- profile->setSpellCheckEnabled(false);
- profile->setSpellCheckLanguages(QStringList());
m_view = new WebView();
}
@@ -106,7 +92,6 @@ void tst_Spellchecking::load()
m_view->show();
QSignalSpy spyFinished(m_view->page(), &QWebEnginePage::loadFinished);
QVERIFY(spyFinished.wait());
-
}
void tst_Spellchecking::cleanup()
@@ -114,29 +99,57 @@ void tst_Spellchecking::cleanup()
delete m_view;
}
-void tst_Spellchecking::spellCheckLanguage()
+void tst_Spellchecking::settings()
{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- QVERIFY(profile);
- profile->setSpellCheckLanguages({"en-US"});
- QVERIFY(profile->spellCheckLanguages() == QStringList({"en-US"}));
-}
+ // Default profile has spellchecking disabled
-void tst_Spellchecking::spellCheckLanguages()
-{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- QVERIFY(profile);
- profile->setSpellCheckLanguages({"en-US","de-DE"});
- QVERIFY(profile->spellCheckLanguages() == QStringList({"en-US","de-DE"}));
-}
+ QVERIFY(!QWebEngineProfile::defaultProfile()->isSpellCheckEnabled());
+ QVERIFY(QWebEngineProfile::defaultProfile()->spellCheckLanguages().isEmpty());
+ // New named profiles have spellchecking disabled
-void tst_Spellchecking::spellCheckEnabled()
-{
- QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
- QVERIFY(profile);
- profile->setSpellCheckEnabled(true);
- QVERIFY(profile->isSpellCheckEnabled());
+ auto profile1 = std::make_unique<QWebEngineProfile>(QStringLiteral("Profile1"));
+ QVERIFY(!profile1->isSpellCheckEnabled());
+ QVERIFY(profile1->spellCheckLanguages().isEmpty());
+
+ auto profile2 = std::make_unique<QWebEngineProfile>(QStringLiteral("Profile2"));
+ QVERIFY(!profile2->isSpellCheckEnabled());
+ QVERIFY(profile2->spellCheckLanguages().isEmpty());
+
+ // New otr profiles have spellchecking disabled
+
+ auto profile3 = std::make_unique<QWebEngineProfile>();
+ QVERIFY(!profile2->isSpellCheckEnabled());
+ QVERIFY(profile2->spellCheckLanguages().isEmpty());
+
+ // Settings can be changed
+
+ profile1->setSpellCheckEnabled(true);
+ QVERIFY(profile1->isSpellCheckEnabled());
+
+ profile1->setSpellCheckLanguages({"en-US"});
+ QVERIFY(profile1->spellCheckLanguages() == QStringList({"en-US"}));
+
+ profile1->setSpellCheckLanguages({"en-US","de-DE"});
+ QVERIFY(profile1->spellCheckLanguages() == QStringList({"en-US","de-DE"}));
+
+ // Settings are per profile
+
+ QVERIFY(!profile2->isSpellCheckEnabled());
+ QVERIFY(profile2->spellCheckLanguages().isEmpty());
+
+ QVERIFY(!profile3->isSpellCheckEnabled());
+ QVERIFY(profile3->spellCheckLanguages().isEmpty());
+
+ // Settings are not persisted
+
+ // TODO(juvaldma): Write from dtor currently usually happens *after* the
+ // read from the ctor, so this test would pass even if settings were
+ // persisted. It would start to fail on the second run though.
+ profile1.reset();
+ profile1 = std::make_unique<QWebEngineProfile>(QStringLiteral("Profile1"));
+ QVERIFY(!profile1->isSpellCheckEnabled());
+ QVERIFY(profile1->spellCheckLanguages().isEmpty());
}
void tst_Spellchecking::spellcheck()