diff options
| author | Danilo M. <danix@danix.xyz> | 2026-08-03 20:51:18 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-08-04 12:54:14 +0200 |
| commit | ed5f795869b2f63b8f7e164239e4afcf9f13bb77 (patch) | |
| tree | b18130e7915884d11da876ff68ba161589c3a3cf /tests | |
| parent | 8e65d8f5eba78acc9558e26f9b728521f323b1a6 (diff) | |
| download | qtmaildir-ed5f795869b2f63b8f7e164239e4afcf9f13bb77.tar.gz qtmaildir-ed5f795869b2f63b8f7e164239e4afcf9f13bb77.zip | |
feat(completion): add the prefix, date and mimetype vocabularies
Keywords are syntax and stay untranslated; the descriptions beside them are
prose and go through tr().
The tables are free functions with no QObject to inherit tr() from, so the
file declares a VocabularyStrings context with Q_DECLARE_TR_FUNCTIONS rather
than borrowing QObject::tr, which would file every string under the QObject
context.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_querycompleter.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/test_querycompleter.cpp b/tests/test_querycompleter.cpp index aead30d..fb14adf 100644 --- a/tests/test_querycompleter.cpp +++ b/tests/test_querycompleter.cpp @@ -39,6 +39,8 @@ private slots: void rangeLowerBoundCompletes(); void bareValueAllowsRelativeEntries(); void rangeSuppressesRelativeEntries(); + void prefixVocabularyCoversNotmuchKeywords(); + void dateVocabularySeparatesRelativeEntries(); }; void TestQueryCompleter::emptyTextCompletesPrefix() @@ -167,5 +169,38 @@ void TestQueryCompleter::rangeSuppressesRelativeEntries() QVERIFY(!ctx.allowRangeEntries); } +void TestQueryCompleter::prefixVocabularyCoversNotmuchKeywords() +{ + const QList<CompletionEntry> entries = prefixVocabulary(); + + QStringList values; + for (const CompletionEntry &entry : entries) + values.append(entry.value); + + QVERIFY(values.contains(QStringLiteral("tag:"))); + QVERIFY(values.contains(QStringLiteral("date:"))); + QVERIFY(values.contains(QStringLiteral("and"))); + + // Every entry carries a description; a blank column teaches nothing. + for (const CompletionEntry &entry : entries) + QVERIFY(!entry.description.isEmpty()); +} + +void TestQueryCompleter::dateVocabularySeparatesRelativeEntries() +{ + const QList<CompletionEntry> entries = dateVocabulary(); + + bool sawSymbolic = false; + bool sawRelative = false; + for (const CompletionEntry &entry : entries) { + if (entry.value == QStringLiteral("today")) + sawSymbolic = true; + if (entry.value.contains(QStringLiteral(".."))) + sawRelative = true; + } + QVERIFY(sawSymbolic); + QVERIFY(sawRelative); +} + QTEST_MAIN(TestQueryCompleter) #include "test_querycompleter.moc" |
