summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 20:53:49 +0200
committerDanilo M. <danix@danix.xyz>2026-08-04 12:54:17 +0200
commit45e5887f5b33e5f30d3c16187bb5d6e707983804 (patch)
tree806b2a7bb0b8f914caa3db7b0eeb4eadae84bb96 /tests
parenteb56cf5bb04771244f7bb90eadef165ccc5b9a94 (diff)
downloadqtmaildir-45e5887f5b33e5f30d3c16187bb5d6e707983804.tar.gz
qtmaildir-45e5887f5b33e5f30d3c16187bb5d6e707983804.zip
feat(config): add completion_on_focus and extra_mimetypes
Mimetypes are the one completion list with no enumerator, so the user can extend it. Entries append to the built-ins and a malformed one is skipped with a problem recorded rather than dropping the whole list. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_config.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/test_config.cpp b/tests/test_config.cpp
index 24f6afb..451eb43 100644
--- a/tests/test_config.cpp
+++ b/tests/test_config.cpp
@@ -39,6 +39,11 @@ private slots:
void unknownStartupQueryFallsBackAndReports();
void generalSectionKeysAreActuallyRead();
void messageZoomDefaultsAndValidates();
+ void completionOnFocusDefaultsToFalse();
+ void completionOnFocusIsActuallyRead();
+ void extraMimetypesAppendToBuiltins();
+ void extraMimetypeDescriptionMayContainComma();
+ void malformedExtraMimetypeIsSkipped();
};
static QString writeIni(const QTemporaryDir &dir, const QString &body)
@@ -345,5 +350,74 @@ void TestConfig::messageZoomDefaultsAndValidates()
}
}
+void TestConfig::completionOnFocusDefaultsToFalse()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n")));
+ QCOMPARE(config.completionOnFocus(), false);
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::completionOnFocusIsActuallyRead()
+{
+ // The default is false, so a test that only checks the default would pass
+ // just as happily against a "general/completion_on_focus" lookup that
+ // matches nothing. Round-tripping a true proves the key is really read.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral("[general]\n"
+ "completion_on_focus=true\n")));
+ QCOMPARE(config.completionOnFocus(), true);
+}
+
+void TestConfig::extraMimetypesAppendToBuiltins()
+{
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[completion]\n"
+ "extra_mimetypes = application/epub+zip|EPUB book, message/rfc822\n")));
+
+ const QList<CompletionEntry> extra = config.extraMimetypes();
+ QCOMPARE(extra.size(), 2);
+ QCOMPARE(extra.at(0).value, QStringLiteral("application/epub+zip"));
+ QCOMPARE(extra.at(0).description, QStringLiteral("EPUB book"));
+ QCOMPARE(extra.at(1).value, QStringLiteral("message/rfc822"));
+ QVERIFY(extra.at(1).description.isEmpty());
+ QVERIFY(config.problems().isEmpty());
+}
+
+void TestConfig::extraMimetypeDescriptionMayContainComma()
+{
+ // '|' separates value from description precisely so a description can
+ // contain a comma without QSettings tearing the entry in two.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[completion]\n"
+ "extra_mimetypes = \"application/epub+zip|EPUB, an ebook format\"\n")));
+
+ const QList<CompletionEntry> extra = config.extraMimetypes();
+ QCOMPARE(extra.size(), 1);
+ QCOMPARE(extra.at(0).value, QStringLiteral("application/epub+zip"));
+ QCOMPARE(extra.at(0).description, QStringLiteral("EPUB, an ebook format"));
+}
+
+void TestConfig::malformedExtraMimetypeIsSkipped()
+{
+ // One bad entry must not cost the user the rest of the list.
+ QTemporaryDir dir;
+ Config config;
+ config.load(writeIni(dir, QStringLiteral(
+ "[completion]\n"
+ "extra_mimetypes = |no value here, message/rfc822\n")));
+
+ const QList<CompletionEntry> extra = config.extraMimetypes();
+ QCOMPARE(extra.size(), 1);
+ QCOMPARE(extra.at(0).value, QStringLiteral("message/rfc822"));
+ QVERIFY(!config.problems().isEmpty());
+}
+
QTEST_MAIN(TestConfig)
#include "test_config.moc"