diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-06-04 15:53:27 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-06-17 10:50:00 +0000 |
commit | 300feced2079b291ef107d0015bcf1f88e9e0eaf (patch) | |
tree | 394b59a5316c3708c2386b01b30dee01aa61081d /tests | |
parent | ee27ae2ef78692b29d26c466c519f4318526a7a4 (diff) |
ClangRefactoring: Activate updating for indexing
Change-Id: I6fb818edfab8ef7d9cfab0520276acedf0597fd3
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/builddependenciesstorage-test.cpp | 11 | ||||
-rw-r--r-- | tests/unit/unittest/mockbuilddependenciesstorage.h | 2 | ||||
-rw-r--r-- | tests/unit/unittest/symbolindexer-test.cpp | 15 |
3 files changed, 27 insertions, 1 deletions
diff --git a/tests/unit/unittest/builddependenciesstorage-test.cpp b/tests/unit/unittest/builddependenciesstorage-test.cpp index aa82370485..052ed452f0 100644 --- a/tests/unit/unittest/builddependenciesstorage-test.cpp +++ b/tests/unit/unittest/builddependenciesstorage-test.cpp @@ -70,6 +70,7 @@ protected: MockSqliteWriteStatement &updatePchCreationTimeStampStatement = storage.updatePchCreationTimeStampStatement; MockSqliteWriteStatement &deleteAllProjectPartsFilesWithProjectPartNameStatement = storage.deleteAllProjectPartsFilesWithProjectPartNameStatement; + MockSqliteReadStatement &fetchProjectPartsFilesStatement = storage.fetchProjectPartsFilesStatement; }; TEST_F(BuildDependenciesStorage, ConvertStringsToJson) @@ -232,5 +233,13 @@ TEST_F(BuildDependenciesStorage, FetchUsedMacros) ASSERT_THAT(usedMacros, result); } -} +TEST_F(BuildDependenciesStorage, FetchSources) +{ + ClangBackEnd::FilePathIds result{3, 5, 7}; + EXPECT_CALL(fetchProjectPartsFilesStatement, valuesReturnFilePathIds(_, 22)).WillOnce(Return(result)); + auto sources = storage.fetchSources(22); + + ASSERT_THAT(sources, result); +} +} // namespace diff --git a/tests/unit/unittest/mockbuilddependenciesstorage.h b/tests/unit/unittest/mockbuilddependenciesstorage.h index 46c201de55..a4d34e481d 100644 --- a/tests/unit/unittest/mockbuilddependenciesstorage.h +++ b/tests/unit/unittest/mockbuilddependenciesstorage.h @@ -51,5 +51,7 @@ public: ClangBackEnd::ProjectPartId(Utils::SmallStringView projectPartName)); MOCK_METHOD2(updatePchCreationTimeStamp, void(long long pchCreationTimeStamp, ClangBackEnd::ProjectPartId projectPartId)); + MOCK_CONST_METHOD1(fetchSources, + ClangBackEnd::FilePathIds(ClangBackEnd::ProjectPartId projectPartId)); }; diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp index a03f2be507..2db11dc5fb 100644 --- a/tests/unit/unittest/symbolindexer-test.cpp +++ b/tests/unit/unittest/symbolindexer-test.cpp @@ -922,6 +922,21 @@ TEST_F(SymbolIndexer, DependentSourceAreUpToDate) indexer.updateProjectParts({projectPart1}); } +TEST_F(SymbolIndexer, SourcesAreWatched) +{ + using ClangBackEnd::IdPaths; + InSequence s; + FilePathIds sourcePathIds{4, 6, 8}; + + EXPECT_CALL(mockBuildDependenciesStorage, fetchSources(projectPart1.projectPartId)) + .WillOnce(Return(sourcePathIds)); + EXPECT_CALL(mockPathWatcher, + updateIdPaths(ElementsAre(AllOf(Field(&IdPaths::id, projectPart1.projectPartId), + Field(&IdPaths::filePathIds, sourcePathIds))))); + + indexer.updateProjectParts({projectPart1}); +} + TEST_F(SymbolIndexer, CallSetNotifier) { EXPECT_CALL(mockPathWatcher, setNotifier(_)); |