diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-05-22 12:26:58 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-06-17 10:46:21 +0000 |
commit | b213dee0134722fcdcae88efb514e0430fc72959 (patch) | |
tree | 51b62b0de0c934f30fd49a3a0056e44614f11209 /tests/unit/unittest/pchmanagerserver-test.cpp | |
parent | 912cb9278f7528709f9edf08060d997c20d3ec8c (diff) | |
download | qt-creator-b213dee0134722fcdcae88efb514e0430fc72959.tar.gz |
Clang: Improve updating
If project parts are up to date we send them directly to the indexer, so
the indexer can decide we something needs an update.
Change-Id: I7d4f32794c6b3a861cdefb3653a6dfd4e711f619
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'tests/unit/unittest/pchmanagerserver-test.cpp')
-rw-r--r-- | tests/unit/unittest/pchmanagerserver-test.cpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/tests/unit/unittest/pchmanagerserver-test.cpp b/tests/unit/unittest/pchmanagerserver-test.cpp index 502b51bc8c..47b7d987ab 100644 --- a/tests/unit/unittest/pchmanagerserver-test.cpp +++ b/tests/unit/unittest/pchmanagerserver-test.cpp @@ -48,6 +48,7 @@ using ClangBackEnd::V2::FileContainer; using ClangBackEnd::V2::FileContainers; using ClangBackEnd::ProjectPartContainer; using ClangBackEnd::ProjectPartContainers; +using UpToDataProjectParts = ClangBackEnd::ProjectPartsManagerInterface::UpToDataProjectParts; class PchManagerServer : public ::testing::Test { @@ -55,7 +56,8 @@ class PchManagerServer : public ::testing::Test { server.setClient(&mockPchManagerClient); - ON_CALL(mockProjectPartsManager, update(projectParts)).WillByDefault(Return(projectParts)); + ON_CALL(mockProjectPartsManager, update(projectParts)) + .WillByDefault(Return(UpToDataProjectParts{{}, projectParts})); ON_CALL(mockGeneratedFiles, isValid()).WillByDefault(Return(true)); } @@ -107,7 +109,8 @@ protected: Utils::LanguageVersion::C11, Utils::LanguageExtension::All}; std::vector<ProjectPartContainer> projectParts{projectPart1, projectPart2}; - std::vector<ProjectPartContainer> projectParts2{projectPart2}; + std::vector<ProjectPartContainer> projectParts1{projectPart1}; + std::vector<ProjectPartContainer> projectParts2{projectPart2}; FileContainer generatedFile{{"/path/to/", "file"}, "content", {}}; ClangBackEnd::UpdateProjectPartsMessage updateProjectPartsMessage{ Utils::clone(projectParts), {"toolChainArgument"}}; @@ -120,7 +123,7 @@ TEST_F(PchManagerServer, FilterProjectPartsAndSendThemToQueue) InSequence s; EXPECT_CALL(mockProjectPartsManager, update(updateProjectPartsMessage.projectsParts)) - .WillOnce(Return(projectParts2)); + .WillOnce(Return(UpToDataProjectParts{{}, projectParts2})); EXPECT_CALL( mockPchTaskGenerator, addProjectParts(Eq(projectParts2), ElementsAre("toolChainArgument"))); @@ -219,7 +222,7 @@ TEST_F(PchManagerServer, DontGeneratePchIfGeneratedFilesAreNotValid) InSequence s; EXPECT_CALL(mockProjectPartsManager, update(ElementsAre(projectPart1))) - .WillOnce(Return(ProjectPartContainers{projectPart1})); + .WillOnce(Return(UpToDataProjectParts{{}, ProjectPartContainers{projectPart1}})); EXPECT_CALL(mockGeneratedFiles, isValid()).WillOnce(Return(false)); EXPECT_CALL(mockPchTaskGenerator, addProjectParts(_, _)).Times(0); EXPECT_CALL(mockProjectPartsManager, updateDeferred(ElementsAre(projectPart1))); @@ -233,7 +236,7 @@ TEST_F(PchManagerServer, GeneratePchIfGeneratedFilesAreValid) InSequence s; EXPECT_CALL(mockProjectPartsManager, update(ElementsAre(projectPart1))) - .WillOnce(Return(ProjectPartContainers{projectPart1})); + .WillOnce(Return(UpToDataProjectParts{{}, ProjectPartContainers{projectPart1}})); EXPECT_CALL(mockGeneratedFiles, isValid()).WillOnce(Return(true)); EXPECT_CALL(mockPchTaskGenerator, addProjectParts(_, _)); EXPECT_CALL(mockProjectPartsManager, updateDeferred(_)).Times(0); @@ -276,4 +279,19 @@ TEST_F(PchManagerServer, AfterUpdatingGeneratedFilesAreStillInvalidSoNoPchsGener server.updateGeneratedFiles(updateGeneratedFilesMessage.clone()); } +TEST_F(PchManagerServer, SentUpToDateProjectPartIdsToClient) +{ + InSequence s; + + EXPECT_CALL(mockProjectPartsManager, update(updateProjectPartsMessage.projectsParts)) + .WillOnce(Return(UpToDataProjectParts{projectParts1, projectParts2})); + EXPECT_CALL(mockPchTaskGenerator, + addProjectParts(Eq(projectParts2), ElementsAre("toolChainArgument"))); + EXPECT_CALL(mockPchManagerClient, + precompiledHeadersUpdated( + Field(&ClangBackEnd::PrecompiledHeadersUpdatedMessage::projectPartIds, + ElementsAre(Eq(projectPart1.projectPartId))))); + + server.updateProjectParts(updateProjectPartsMessage.clone()); } +} // namespace |