From ed5f795869b2f63b8f7e164239e4afcf9f13bb77 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 20:51:18 +0200 Subject: 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. --- tests/test_querycompleter.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'tests') 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 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 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" -- cgit v1.2.3