From f44641bec7af750ae4ef2bd681b14a0dffa2233b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Mon, 24 Apr 2023 17:36:02 +0200 Subject: [PATCH] Core: Add a test for LocatorFileCache This test corresponds to the old test for BaseFileFilter. Change-Id: If1e775f0f8490943ff41fb6a7ccc4069914fe1f2 Reviewed-by: Marcus Tillmanns Reviewed-by: Qt CI Bot --- .../coreplugin/locator/locator_test.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/plugins/coreplugin/locator/locator_test.cpp b/src/plugins/coreplugin/locator/locator_test.cpp index a261d15586b..806e5274446 100644 --- a/src/plugins/coreplugin/locator/locator_test.cpp +++ b/src/plugins/coreplugin/locator/locator_test.cpp @@ -16,6 +16,7 @@ #include using namespace Core::Tests; +using namespace Utils; namespace { @@ -24,7 +25,7 @@ QTC_DECLARE_MYTESTDATADIR("../../../tests/locators/") class MyBaseFileFilter : public Core::BaseFileFilter { public: - MyBaseFileFilter(const Utils::FilePaths &theFiles) + MyBaseFileFilter(const FilePaths &theFiles) { setFileIterator(new BaseFileFilter::ListIterator(theFiles)); } @@ -51,7 +52,8 @@ void Core::Internal::CorePlugin::test_basefilefilter() QFETCH(QStringList, testFiles); QFETCH(QList, referenceDataList); - MyBaseFileFilter filter(Utils::FileUtils::toFilePathList(testFiles)); + const FilePaths filePaths = FileUtils::toFilePathList(testFiles); + MyBaseFileFilter filter(filePaths); BasicLocatorFilterTest test(&filter); for (const ReferenceData &reference : std::as_const(referenceDataList)) { @@ -61,12 +63,22 @@ void Core::Internal::CorePlugin::test_basefilefilter() // ResultData::printFilterEntries(results); QCOMPARE(results, reference.results); } + + LocatorFileCache cache; + cache.setFilePaths(filePaths); + const LocatorMatcherTasks tasks = {cache.matcher()}; + for (const ReferenceData &reference : std::as_const(referenceDataList)) { + const LocatorFilterEntries filterEntries = LocatorMatcher::runBlocking( + tasks, reference.searchText); + const ResultDataList results = ResultData::fromFilterEntryList(filterEntries); + QCOMPARE(results, reference.results); + } } void Core::Internal::CorePlugin::test_basefilefilter_data() { auto shortNativePath = [](const QString &file) { - return Utils::FilePath::fromString(file).shortNativePath(); + return FilePath::fromString(file).shortNativePath(); }; QTest::addColumn("testFiles");