From b5564b582089e2e75c5416785e48783bdc4a7a5e Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 24 May 2023 16:30:58 +0200 Subject: [PATCH] FileSearch: Add tests for findInFiles() taking FileContainer Change-Id: I752e8b443ac8a9c12b1fb209091727da6054a916 Reviewed-by: Eike Ziller --- tests/auto/filesearch/tst_filesearch.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/filesearch/tst_filesearch.cpp b/tests/auto/filesearch/tst_filesearch.cpp index e4ce57b670f..f1a29339f0a 100644 --- a/tests/auto/filesearch/tst_filesearch.cpp +++ b/tests/auto/filesearch/tst_filesearch.cpp @@ -37,6 +37,7 @@ SearchResultItem searchResult(const FilePath &fileName, const QString &matchingL void test_helper(const FilePath &filePath, const SearchResultItems &expectedResults, const QString &term, Utils::FindFlags flags = {}) { + { FileIterator *it = new FileListIterator({filePath}, {QTextCodec::codecForLocale()}); QFutureWatcher watcher; QSignalSpy ready(&watcher, &QFutureWatcherBase::resultsReadyAt); @@ -48,6 +49,21 @@ void test_helper(const FilePath &filePath, const SearchResultItems &expectedResu QCOMPARE(results.count(), expectedResults.count()); for (int i = 0; i < expectedResults.size(); ++i) QCOMPARE(results.at(i), expectedResults.at(i)); + } + + { + const FileListContainer container({filePath}, {QTextCodec::codecForLocale()}); + QFutureWatcher watcher; + QSignalSpy ready(&watcher, &QFutureWatcherBase::resultsReadyAt); + watcher.setFuture(Utils::findInFiles(term, container, flags, {})); + watcher.future().waitForFinished(); + QTest::qWait(100); // process events + QCOMPARE(ready.count(), 1); + SearchResultItems results = watcher.resultAt(0); + QCOMPARE(results.count(), expectedResults.count()); + for (int i = 0; i < expectedResults.size(); ++i) + QCOMPARE(results.at(i), expectedResults.at(i)); + } } void tst_FileSearch::multipleResults()