diff options
Diffstat (limited to 'tests')
20 files changed, 434 insertions, 431 deletions
diff --git a/tests/unit/echoserver/echoclangcodemodelserver.cpp b/tests/unit/echoserver/echoclangcodemodelserver.cpp index 38d2d39544..70612953ac 100644 --- a/tests/unit/echoserver/echoclangcodemodelserver.cpp +++ b/tests/unit/echoserver/echoclangcodemodelserver.cpp @@ -43,47 +43,47 @@ void EchoClangCodeModelServer::end() QCoreApplication::quit(); } -void EchoClangCodeModelServer::registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) +void EchoClangCodeModelServer::documentsOpened(const DocumentsOpenedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) +void EchoClangCodeModelServer::documentsChanged(const DocumentsChangedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) +void EchoClangCodeModelServer::documentsClosed(const DocumentsClosedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) +void EchoClangCodeModelServer::projectPartsUpdated(const ProjectPartsUpdatedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) +void EchoClangCodeModelServer::projectPartsRemoved(const ProjectPartsRemovedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) +void EchoClangCodeModelServer::unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) +void EchoClangCodeModelServer::unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::completeCode(const CompleteCodeMessage &message) +void EchoClangCodeModelServer::requestCompletions(const RequestCompletionsMessage &message) { echoMessage(message); } -void EchoClangCodeModelServer::requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message) +void EchoClangCodeModelServer::requestAnnotations(const RequestAnnotationsMessage &message) { echoMessage(message); } @@ -103,7 +103,7 @@ void EchoClangCodeModelServer::requestToolTip(const RequestToolTipMessage &messa echoMessage(message); } -void EchoClangCodeModelServer::updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) +void EchoClangCodeModelServer::documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) { echoMessage(message); } diff --git a/tests/unit/echoserver/echoclangcodemodelserver.h b/tests/unit/echoserver/echoclangcodemodelserver.h index d3452d2d32..261b690dee 100644 --- a/tests/unit/echoserver/echoclangcodemodelserver.h +++ b/tests/unit/echoserver/echoclangcodemodelserver.h @@ -36,19 +36,23 @@ class EchoClangCodeModelServer : public ClangCodeModelServerInterface, public: void dispatch(const MessageEnvelop &message) override; void end() override; - void registerTranslationUnitsForEditor(const RegisterTranslationUnitForEditorMessage &message) override; - void updateTranslationUnitsForEditor(const UpdateTranslationUnitsForEditorMessage &message) override; - void unregisterTranslationUnitsForEditor(const UnregisterTranslationUnitsForEditorMessage &message) override; - void registerProjectPartsForEditor(const RegisterProjectPartsForEditorMessage &message) override; - void unregisterProjectPartsForEditor(const UnregisterProjectPartsForEditorMessage &message) override; - void registerUnsavedFilesForEditor(const RegisterUnsavedFilesForEditorMessage &message) override; - void unregisterUnsavedFilesForEditor(const UnregisterUnsavedFilesForEditorMessage &message) override; - void completeCode(const CompleteCodeMessage &message) override; - void requestDocumentAnnotations(const RequestDocumentAnnotationsMessage &message) override; + + void documentsOpened(const DocumentsOpenedMessage &message) override; + void documentsChanged(const DocumentsChangedMessage &message) override; + void documentsClosed(const DocumentsClosedMessage &message) override; + void documentVisibilityChanged(const DocumentVisibilityChangedMessage &message) override; + + void projectPartsUpdated(const ProjectPartsUpdatedMessage &message) override; + void projectPartsRemoved(const ProjectPartsRemovedMessage &message) override; + + void unsavedFilesUpdated(const UnsavedFilesUpdatedMessage &message) override; + void unsavedFilesRemoved(const UnsavedFilesRemovedMessage &message) override; + + void requestCompletions(const RequestCompletionsMessage &message) override; + void requestAnnotations(const RequestAnnotationsMessage &message) override; void requestReferences(const RequestReferencesMessage &message) override; void requestFollowSymbol(const RequestFollowSymbolMessage &message) override; void requestToolTip(const RequestToolTipMessage &message) override; - void updateVisibleTranslationUnits(const UpdateVisibleTranslationUnitsMessage &message) override; private: void echoMessage(const MessageEnvelop &message); diff --git a/tests/unit/unittest/clangcodemodelserver-test.cpp b/tests/unit/unittest/clangcodemodelserver-test.cpp index 7f88681f32..ea4238975e 100644 --- a/tests/unit/unittest/clangcodemodelserver-test.cpp +++ b/tests/unit/unittest/clangcodemodelserver-test.cpp @@ -114,46 +114,48 @@ protected: protected: bool waitUntilAllJobsFinished(int timeOutInMs = 10000); - void registerProjectPart(); - void registerProjectPart(const Utf8String &projectPartId); - void changeProjectPartArguments(); - - void registerProjectAndFile(const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages = AnnotationJobsMultiplier); - void registerProjectAndFileAndWaitForFinished(const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages = AnnotationJobsMultiplier); - void registerProjectAndFilesAndWaitForFinished(int expectedDocumentAnnotationsChangedMessages = 2 * AnnotationJobsMultiplier); - void registerFile(const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages = AnnotationJobsMultiplier); - void registerFile(const Utf8String &filePath, const Utf8String &projectPartId, - int expectedDocumentAnnotationsChangedMessages = AnnotationJobsMultiplier); - void registerFiles(int expectedDocumentAnnotationsChangedMessages); - void registerFileWithUnsavedContent(const Utf8String &filePath, const Utf8String &content); + void updateProjectPart(); + void updateProjectPart(const Utf8String &projectPartId); + void updateProjectPartWithArguments(); + + void updateProjectAndOpenDocument(const Utf8String &filePath, + int expectedAnnotationsMessages = AnnotationJobsMultiplier); + void updateProjectAndOpenDocumentAndWaitForFinished( + const Utf8String &filePath, int expectedAnnotationsMessages = AnnotationJobsMultiplier); + void updateProjectAndOpenDocumentsAndWaitForFinished( + int expectedAnnotationsdMessages = 2 * AnnotationJobsMultiplier); + + void openDocument(const Utf8String &filePath, + int expectedAnnotationsMessages = AnnotationJobsMultiplier); + void openDocument(const Utf8String &filePath, + const Utf8String &projectPartId, + int expectedAnnotationsMessages = AnnotationJobsMultiplier); + void openDocuments(int expectedAnnotationsMessages); + void openDocumentWithUnsavedContent(const Utf8String &filePath, const Utf8String &content); + void closeDocument(const Utf8String &filePath); void updateUnsavedContent(const Utf8String &filePath, const Utf8String &fileContent, quint32 revisionNumber); - - void unregisterFile(const Utf8String &filePath); - void removeUnsavedFile(const Utf8String &filePath); void updateVisibilty(const Utf8String ¤tEditor, const Utf8String &additionalVisibleEditor); - void requestDocumentAnnotations(const Utf8String &filePath); + void requestAnnotations(const Utf8String &filePath); void requestReferences(quint32 documentRevision = 0); void requestFollowSymbol(quint32 documentRevision = 0); - - void completeCode(const Utf8String &filePath, uint line = 1, uint column = 1, - const Utf8String &projectPartId = Utf8String()); - void completeCodeInFileA(); - void completeCodeInFileB(); + void requestCompletions(const Utf8String &filePath, + uint line = 1, + uint column = 1, + const Utf8String &projectPartId = Utf8String()); + void requestCompletionsInFileA(); + void requestCompletionsInFileB(); bool isSupportiveTranslationUnitInitialized(const Utf8String &filePath); DocumentProcessor documentProcessorForFile(const Utf8String &filePath); - void expectDocumentAnnotationsChanged(int count); + void expectAnnotations(int count); void expectCompletion(const CodeCompletion &completion); void expectCompletionFromFileA(); void expectCompletionFromFileBEnabledByMacro(); @@ -162,7 +164,7 @@ protected: void expectNoCompletionWithUnsavedMethod(); void expectReferences(); void expectFollowSymbol(); - void expectDocumentAnnotationsChangedForFileBWithSpecificHighlightingMark(); + void expectAnnotationsForFileBWithSpecificHighlightingMark(); static const Utf8String unsavedContent(const QString &unsavedFilePath); @@ -192,23 +194,23 @@ using ClangCodeModelServerSlowTest = ClangCodeModelServer; TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletion) { - registerProjectAndFile(filePathA); + updateProjectAndOpenDocument(filePathA); expectCompletionFromFileA(); - completeCodeInFileA(); + requestCompletionsInFileA(); } -TEST_F(ClangCodeModelServerSlowTest, RequestDocumentAnnotations) +TEST_F(ClangCodeModelServerSlowTest, RequestAnnotations) { - registerProjectAndFileAndWaitForFinished(filePathB); + updateProjectAndOpenDocumentAndWaitForFinished(filePathB); - expectDocumentAnnotationsChangedForFileBWithSpecificHighlightingMark(); - requestDocumentAnnotations(filePathB); + expectAnnotationsForFileBWithSpecificHighlightingMark(); + requestAnnotations(filePathB); } TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision) { - registerProjectAndFileAndWaitForFinished(filePathC); + updateProjectAndOpenDocumentAndWaitForFinished(filePathC); expectReferences(); requestReferences(); @@ -216,7 +218,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesForCurrentDocumentRevision TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage) { - registerProjectAndFileAndWaitForFinished(filePathC); + updateProjectAndOpenDocumentAndWaitForFinished(filePathC); requestReferences(/*documentRevision=*/ 99); @@ -229,7 +231,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestReferencesTakesRevisionFromMessage) TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevision) { - registerProjectAndFileAndWaitForFinished(filePathC); + updateProjectAndOpenDocumentAndWaitForFinished(filePathC); expectFollowSymbol(); requestFollowSymbol(); @@ -237,7 +239,7 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolForCurrentDocumentRevisi TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage) { - registerProjectAndFileAndWaitForFinished(filePathC); + updateProjectAndOpenDocumentAndWaitForFinished(filePathC); requestFollowSymbol(/*documentRevision=*/ 99); @@ -248,90 +250,90 @@ TEST_F(ClangCodeModelServerSlowTest, RequestFollowSymbolTakesRevisionFromMessage queue.clear(); // Avoid blocking } -TEST_F(ClangCodeModelServerSlowTest, NoInitialDocumentAnnotationsForClosedDocument) +TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForClosedDocument) { - const int expectedDocumentAnnotationsChangedCount = 0; - registerProjectAndFile(filePathA, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = 0; + updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount); - unregisterFile(filePathA); + closeDocument(filePathA); } -TEST_F(ClangCodeModelServerSlowTest, NoDocumentAnnotationsForClosedDocument) +TEST_F(ClangCodeModelServerSlowTest, NoAnnotationsForClosedDocument) { - const int expectedDocumentAnnotationsChangedCount = AnnotationJobsMultiplier; // Only for registration. - registerProjectAndFileAndWaitForFinished(filePathA, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration. + updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount); updateUnsavedContent(filePathA, Utf8String(), 1); - unregisterFile(filePathA); + closeDocument(filePathA); } -TEST_F(ClangCodeModelServerSlowTest, NoInitialDocumentAnnotationsForOutdatedDocumentRevision) +TEST_F(ClangCodeModelServerSlowTest, NoInitialAnnotationsForOutdatedDocumentRevision) { - const int expectedDocumentAnnotationsChangedCount = AnnotationJobsMultiplier; // Only for registration. - registerProjectAndFile(filePathA, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration. + updateProjectAndOpenDocument(filePathA, expectedAnnotationsCount); updateUnsavedContent(filePathA, Utf8String(), 1); } TEST_F(ClangCodeModelServerSlowTest, NoCompletionsForClosedDocument) { - const int expectedDocumentAnnotationsChangedCount = AnnotationJobsMultiplier; // Only for registration. - registerProjectAndFileAndWaitForFinished(filePathA, expectedDocumentAnnotationsChangedCount); - completeCodeInFileA(); + const int expectedAnnotationsCount = AnnotationJobsMultiplier; // Only for registration. + updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount); + requestCompletionsInFileA(); - unregisterFile(filePathA); + closeDocument(filePathA); } TEST_F(ClangCodeModelServerSlowTest, CodeCompletionDependingOnProject) { - const int expectedDocumentAnnotationsChangedCount = 2 * AnnotationJobsMultiplier; // For registration and due to project change. - registerProjectAndFileAndWaitForFinished(filePathB, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and due to project change. + updateProjectAndOpenDocumentAndWaitForFinished(filePathB, expectedAnnotationsCount); expectCompletionFromFileBEnabledByMacro(); - changeProjectPartArguments(); - completeCodeInFileB(); + updateProjectPartWithArguments(); + requestCompletionsInFileB(); } TEST_F(ClangCodeModelServerSlowTest, GetCodeCompletionForUnsavedFile) { - registerProjectPart(); - expectDocumentAnnotationsChanged(AnnotationJobsMultiplier); - registerFileWithUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1)); + updateProjectPart(); + expectAnnotations(AnnotationJobsMultiplier); + openDocumentWithUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1)); expectCompletionFromFileAUnsavedMethodVersion1(); - completeCodeInFileA(); + requestCompletionsInFileA(); } TEST_F(ClangCodeModelServerSlowTest, GetNoCodeCompletionAfterRemovingUnsavedFile) { - const int expectedDocumentAnnotationsChangedCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal. - registerProjectAndFileAndWaitForFinished(filePathA, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal. + updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount); removeUnsavedFile(filePathA); expectNoCompletionWithUnsavedMethod(); - completeCodeInFileA(); + requestCompletionsInFileA(); } TEST_F(ClangCodeModelServerSlowTest, GetNewCodeCompletionAfterUpdatingUnsavedFile) { - const int expectedDocumentAnnotationsChangedCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal. - registerProjectAndFileAndWaitForFinished(filePathA, expectedDocumentAnnotationsChangedCount); + const int expectedAnnotationsCount = 2 * AnnotationJobsMultiplier; // For registration and update/removal. + updateProjectAndOpenDocumentAndWaitForFinished(filePathA, expectedAnnotationsCount); updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1); expectCompletionFromFileAUnsavedMethodVersion2(); - completeCodeInFileA(); + requestCompletionsInFileA(); } TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterCreationIsNotDirty) { - registerProjectAndFile(filePathA, AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier); ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 0U, false, false)); } TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor) { - registerProjectAndFilesAndWaitForFinished(); + updateProjectAndOpenDocumentsAndWaitForFinished(); auto functionDocument = documents.document(filePathA, projectPartId); auto variableDocument = documents.document(filePathB, projectPartId); @@ -344,21 +346,21 @@ TEST_F(ClangCodeModelServerSlowTest, SetCurrentAndVisibleEditor) TEST_F(ClangCodeModelServerSlowTest, StartCompletionJobFirstOnEditThatTriggersCompletion) { - registerProjectAndFile(filePathA, 2 * AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier); ASSERT_TRUE(waitUntilAllJobsFinished()); expectCompletionFromFileA(); updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1); - completeCodeInFileA(); + requestCompletionsInFileA(); const QList<Jobs::RunningJob> jobs = clangServer.runningJobsForTestsOnly(); ASSERT_THAT(jobs.size(), Eq(1)); - ASSERT_THAT(jobs.first().jobRequest.type, Eq(JobRequest::Type::CompleteCode)); + ASSERT_THAT(jobs.first().jobRequest.type, Eq(JobRequest::Type::RequestCompletions)); } TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfterRegister) { - registerProjectAndFile(filePathA, AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, AnnotationJobsMultiplier); ASSERT_TRUE(waitUntilAllJobsFinished()); ASSERT_FALSE(isSupportiveTranslationUnitInitialized(filePathA)); @@ -366,7 +368,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitNotInitializedAfte TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstEdit) { - registerProjectAndFile(filePathA, 2 * AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, 2 * AnnotationJobsMultiplier); ASSERT_TRUE(waitUntilAllJobsFinished()); updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1); @@ -377,7 +379,7 @@ TEST_F(ClangCodeModelServerSlowTest, SupportiveTranslationUnitIsSetupAfterFirstE TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs) { - registerProjectAndFile(filePathA, 3 * AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, 3 * AnnotationJobsMultiplier); ASSERT_TRUE(waitUntilAllJobsFinished()); updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion2), 1); ASSERT_TRUE(waitUntilAllJobsFinished()); @@ -391,7 +393,7 @@ TEST_F(ClangCodeModelServerSlowTest, DoNotRunDuplicateJobs) TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit) { - registerProjectAndFile(filePathA, 4 * AnnotationJobsMultiplier); + updateProjectAndOpenDocument(filePathA, 4 * AnnotationJobsMultiplier); ASSERT_TRUE(waitUntilAllJobsFinished()); for (unsigned revision = 1; revision <= 3; ++revision) { @@ -402,7 +404,7 @@ TEST_F(ClangCodeModelServerSlowTest, OpenDocumentAndEdit) TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore) { - registerProjectAndFilesAndWaitForFinished(); + updateProjectAndOpenDocumentsAndWaitForFinished(); auto functionDocument = documents.document(filePathA, projectPartId); auto variableDocument = documents.document(filePathB, projectPartId); updateVisibilty(filePathB, filePathA); @@ -417,7 +419,7 @@ TEST_F(ClangCodeModelServerSlowTest, IsNotCurrentCurrentAndVisibleEditorAnymore) TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterUpdateNeedsReparse) { - registerProjectAndFileAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier); + updateProjectAndOpenDocumentAndWaitForFinished(filePathA, 2 * AnnotationJobsMultiplier); updateUnsavedContent(filePathA, unsavedContent(filePathAUnsavedVersion1), 1U); ASSERT_THAT(clangServer, HasDirtyDocument(filePathA, projectPartId, 1U, true, true)); @@ -425,32 +427,32 @@ TEST_F(ClangCodeModelServerSlowTest, TranslationUnitAfterUpdateNeedsReparse) TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartChange) { - registerProjectAndFileAndWaitForFinished(filePathC, 2 * AnnotationJobsMultiplier); + updateProjectAndOpenDocumentAndWaitForFinished(filePathC, 2 * AnnotationJobsMultiplier); updateVisibilty(filePathB, filePathB); // Disable processing jobs requestReferences(); expectReferences(); - changeProjectPartArguments(); // Here we do not want to loose the RequestReferences job + updateProjectPartWithArguments(); // Here we do not want to loose the RequestReferences job updateVisibilty(filePathC, filePathC); // Enable processing jobs } TEST_F(ClangCodeModelServerSlowTest, TakeOverJobsOnProjectPartIdChange) { - registerProjectPart(projectPartId); - registerProjectPart(projectPartId2); - registerFile(filePathC, projectPartId, 0); + updateProjectPart(projectPartId); + updateProjectPart(projectPartId2); + openDocument(filePathC, projectPartId, 0); requestReferences(); expectReferences(); - registerFile(filePathC, projectPartId2); // Here we do not want to loose the RequestReferences job + openDocument(filePathC, projectPartId2); // Here we do not want to loose the RequestReferences job } void ClangCodeModelServer::SetUp() { clangServer.setClient(&mockClangCodeModelClient); - clangServer.setUpdateDocumentAnnotationsTimeOutInMsForTestsOnly(0); + clangServer.setUpdateAnnotationsTimeOutInMsForTestsOnly(0); clangServer.setUpdateVisibleButNotCurrentDocumentsTimeOutInMsForTestsOnly(0); } @@ -470,83 +472,81 @@ bool ClangCodeModelServer::waitUntilAllJobsFinished(int timeOutInMs) return ProcessEventUtilities::processEventsUntilTrue(noJobsRunningAnymore, timeOutInMs); } -void ClangCodeModelServer::registerProjectAndFilesAndWaitForFinished( - int expectedDocumentAnnotationsChangedMessages) +void ClangCodeModelServer::updateProjectAndOpenDocumentsAndWaitForFinished(int expectedAnnotationsdMessages) { - registerProjectPart(); - registerFiles(expectedDocumentAnnotationsChangedMessages); + updateProjectPart(); + openDocuments(expectedAnnotationsdMessages); ASSERT_TRUE(waitUntilAllJobsFinished()); } -void ClangCodeModelServer::registerFile(const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages) +void ClangCodeModelServer::openDocument(const Utf8String &filePath, + int expectedAnnotationsMessages) { - registerFile(filePath, projectPartId, expectedDocumentAnnotationsChangedMessages); + openDocument(filePath, projectPartId, expectedAnnotationsMessages); } -void ClangCodeModelServer::registerFile(const Utf8String &filePath, +void ClangCodeModelServer::openDocument(const Utf8String &filePath, const Utf8String &projectPartId, - int expectedDocumentAnnotationsChangedMessages) + int expectedAnnotationsMessages) { const FileContainer fileContainer(filePath, projectPartId); - const RegisterTranslationUnitForEditorMessage message({fileContainer}, filePath, {filePath}); + const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath}); - expectDocumentAnnotationsChanged(expectedDocumentAnnotationsChangedMessages); + expectAnnotations(expectedAnnotationsMessages); - clangServer.registerTranslationUnitsForEditor(message); + clangServer.documentsOpened(message); } -void ClangCodeModelServer::registerFiles(int expectedDocumentAnnotationsChangedMessages) +void ClangCodeModelServer::openDocuments(int expectedAnnotationsMessages) { const FileContainer fileContainerA(filePathA, projectPartId); const FileContainer fileContainerB(filePathB, projectPartId); - const RegisterTranslationUnitForEditorMessage message({fileContainerA, - fileContainerB}, - filePathA, - {filePathA, filePathB}); + const DocumentsOpenedMessage message({fileContainerA, fileContainerB}, + filePathA, + {filePathA, filePathB}); - expectDocumentAnnotationsChanged(expectedDocumentAnnotationsChangedMessages); + expectAnnotations(expectedAnnotationsMessages); - clangServer.registerTranslationUnitsForEditor(message); + clangServer.documentsOpened(message); } -void ClangCodeModelServer::expectDocumentAnnotationsChanged(int count) +void ClangCodeModelServer::expectAnnotations(int count) { - EXPECT_CALL(mockClangCodeModelClient, documentAnnotationsChanged(_)).Times(count); + EXPECT_CALL(mockClangCodeModelClient, annotations(_)).Times(count); } -void ClangCodeModelServer::registerFileWithUnsavedContent(const Utf8String &filePath, - const Utf8String &unsavedContent) +void ClangCodeModelServer::openDocumentWithUnsavedContent(const Utf8String &filePath, + const Utf8String &unsavedContent) { const FileContainer fileContainer(filePath, projectPartId, unsavedContent, true); - const RegisterTranslationUnitForEditorMessage message({fileContainer}, filePath, {filePath}); + const DocumentsOpenedMessage message({fileContainer}, filePath, {filePath}); - clangServer.registerTranslationUnitsForEditor(message); + clangServer.documentsOpened(message); } -void ClangCodeModelServer::completeCode(const Utf8String &filePath, - uint line, - uint column, - const Utf8String &projectPartId) +void ClangCodeModelServer::requestCompletions(const Utf8String &filePath, + uint line, + uint column, + const Utf8String &projectPartId) { Utf8String theProjectPartId = projectPartId; if (theProjectPartId.isEmpty()) theProjectPartId = this->projectPartId; - const CompleteCodeMessage message(filePath, line, column, theProjectPartId); + const RequestCompletionsMessage message(filePath, line, column, theProjectPartId); - clangServer.completeCode(message); + clangServer.requestCompletions(message); } -void ClangCodeModelServer::completeCodeInFileA() +void ClangCodeModelServer::requestCompletionsInFileA() { - completeCode(filePathA, 20, 1); + requestCompletions(filePathA, 20, 1); } -void ClangCodeModelServer::completeCodeInFileB() +void ClangCodeModelServer::requestCompletionsInFileB() { - completeCode(filePathB, 35, 1); + requestCompletions(filePathB, 35, 1); } bool ClangCodeModelServer::isSupportiveTranslationUnitInitialized(const Utf8String &filePath) @@ -570,7 +570,7 @@ DocumentProcessor ClangCodeModelServer::documentProcessorForFile(const Utf8Strin void ClangCodeModelServer::expectCompletion(const CodeCompletion &completion) { EXPECT_CALL(mockClangCodeModelClient, - codeCompleted(Field(&CodeCompletedMessage::codeCompletions, + completions(Field(&CompletionsMessage::codeCompletions, Contains(completion)))) .Times(1); } @@ -609,7 +609,7 @@ void ClangCodeModelServer::expectNoCompletionWithUnsavedMethod() CodeCompletion::FunctionCompletionKind); EXPECT_CALL(mockClangCodeModelClient, - codeCompleted(Field(&CodeCompletedMessage::codeCompletions, + completions(Field(&CompletionsMessage::codeCompletions, Not(Contains(completion))))) .Times(1); } @@ -649,11 +649,11 @@ void ClangCodeModelServer::expectCompletionFromFileA() expectCompletion(completion); } -void ClangCodeModelServer::requestDocumentAnnotations(const Utf8String &filePath) +void ClangCodeModelServer::requestAnnotations(const Utf8String &filePath) { - const RequestDocumentAnnotationsMessage message({filePath, projectPartId}); + const RequestAnnotationsMessage message({filePath, projectPartId}); - clangServer.requestDocumentAnnotations(message); + clangServer.requestAnnotations(message); } void ClangCodeModelServer::requestReferences(quint32 documentRevision) @@ -674,7 +674,7 @@ void ClangCodeModelServer::requestFollowSymbol(quint32 documentRevision) clangServer.requestFollowSymbol(message); } -void ClangCodeModelServer::expectDocumentAnnotationsChangedForFileBWithSpecificHighlightingMark() +void ClangCodeModelServer::expectAnnotationsForFileBWithSpecificHighlightingMark() { HighlightingTypes types; types.mainHighlightingType = ClangBackEnd::HighlightingType::Function; @@ -682,80 +682,79 @@ void ClangCodeModelServer::expectDocumentAnnotationsChangedForFileBWithSpecificH types.mixinHighlightingTypes.push_back(ClangBackEnd::HighlightingType::FunctionDefinition); const TokenInfoContainer tokenInfo(1, 6, 8, types); EXPECT_CALL(mockClangCodeModelClient, - documentAnnotationsChanged( - Field(&DocumentAnnotationsChangedMessage::tokenInfos, + annotations( + Field(&AnnotationsMessage::tokenInfos, PartlyContains(tokenInfo)))).Times(AnnotationJobsMultiplier); } void ClangCodeModelServer::updateUnsavedContent(const Utf8String &filePath, - const Utf8String &fileContent, - quint32 revisionNumber) + const Utf8String &fileContent, + quint32 revisionNumber) { const FileContainer fileContainer(filePath, projectPartId, fileContent, true, revisionNumber); - const UpdateTranslationUnitsForEditorMessage message({fileContainer}); + const DocumentsChangedMessage message({fileContainer}); - clangServer.updateTranslationUnitsForEditor(message); + clangServer.documentsChanged(message); } void ClangCodeModelServer::removeUnsavedFile(const Utf8String &filePath) { const FileContainer fileContainer(filePath, projectPartId, Utf8StringVector(), 74); - const UpdateTranslationUnitsForEditorMessage message({fileContainer}); + const DocumentsChangedMessage message({fileContainer}); - clangServer.updateTranslationUnitsForEditor(message); + clangServer.documentsChanged(message); } -void ClangCodeModelServer::unregisterFile(const Utf8String &filePath) +void ClangCodeModelServer::closeDocument(const Utf8String &filePath) { const QVector<FileContainer> fileContainers = {FileContainer(filePath, projectPartId)}; - const UnregisterTranslationUnitsForEditorMessage message(fileContainers); + const DocumentsClosedMessage message(fileContainers); - clangServer.unregisterTranslationUnitsForEditor(message); + clangServer.documentsClosed(message); } -void ClangCodeModelServer::registerProjectPart() +void ClangCodeModelServer::updateProjectPart() { - registerProjectPart(projectPartId); + updateProjectPart(projectPartId); } -void ClangCodeModelServer::registerProjectPart(const Utf8String &projectPartId) +void ClangCodeModelServer::updateProjectPart(const Utf8String &projectPartId) { - RegisterProjectPartsForEditorMessage message({ProjectPartContainer(projectPartId)}); + ProjectPartsUpdatedMessage message({ProjectPartContainer(projectPartId)}); - clangServer.registerProjectPartsForEditor(message); + clangServer.projectPartsUpdated(message); } -void ClangCodeModelServer::registerProjectAndFile(const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages) +void ClangCodeModelServer::updateProjectAndOpenDocument(const Utf8String &filePath, + int expectedAnnotationsMessages) { - registerProjectPart(); - registerFile(filePath, expectedDocumentAnnotationsChangedMessages); + updateProjectPart(); + openDocument(filePath, expectedAnnotationsMessages); } -void ClangCodeModelServer::registerProjectAndFileAndWaitForFinished( - const Utf8String &filePath, - int expectedDocumentAnnotationsChangedMessages) +void ClangCodeModelServer::updateProjectAndOpenDocumentAndWaitForFinished( + const Utf8String &filePath, int expectedAnnotationsMessages) { - registerProjectAndFile(filePath, expectedDocumentAnnotationsChangedMessages); + updateProjectAndOpenDocument(filePath, expectedAnnotationsMessages); ASSERT_TRUE(waitUntilAllJobsFinished()); } -void ClangCodeModelServer::changeProjectPartArguments() +void ClangCodeModelServer::updateProjectPartWithArguments() { const ProjectPartContainer projectPartContainer(projectPartId, {Utf8StringLiteral("-DArgumentDefinition")}); - const RegisterProjectPartsForEditorMessage message({projectPartContainer}); + const ProjectPartsUpdatedMessage message({projectPartContainer}); - clangServer.registerProjectPartsForEditor(message); + clangServer.projectPartsUpdated(message); } void ClangCodeModelServer::updateVisibilty(const Utf8String ¤tEditor, - const Utf8String &additionalVisibleEditor) + const Utf8String &additionalVisibleEditor) { - const UpdateVisibleTranslationUnitsMessage message(currentEditor, - {currentEditor, additionalVisibleEditor}); + const DocumentVisibilityChangedMessage message(currentEditor, + {currentEditor, additionalVisibleEditor}); - clangServer.updateVisibleTranslationUnits(message); + clangServer.documentVisibilityChanged(message); } const Utf8String ClangCodeModelServer::unsavedContent(const QString &unsavedFilePath) diff --git a/tests/unit/unittest/clangcompletecodejob-test.cpp b/tests/unit/unittest/clangcompletecodejob-test.cpp index fd7113a2eb..2b23dfc09d 100644 --- a/tests/unit/unittest/clangcompletecodejob-test.cpp +++ b/tests/unit/unittest/clangcompletecodejob-test.cpp @@ -38,7 +38,7 @@ namespace { class CompleteCodeJob : public ClangAsyncJobTest { protected: - void SetUp() override { BaseSetUp(JobRequest::Type::CompleteCode, job); } + void SetUp() override { BaseSetUp(JobRequest::Type::RequestCompletions, job); } protected: ClangBackEnd::CompleteCodeJob job; @@ -65,7 +65,7 @@ TEST_F(CompleteCodeJob, SendAnnotations) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, codeCompleted(_)).Times(1); + EXPECT_CALL(mockIpcClient, completions(_)).Times(1); job.runAsync(); @@ -79,8 +79,8 @@ TEST_F(CompleteCodeJob, ForwardTicketNumber) job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); EXPECT_CALL(mockIpcClient, - codeCompleted(Field(&CodeCompletedMessage::ticketNumber, - Eq(jobRequest.ticketNumber)))) + completions(Field(&CompletionsMessage::ticketNumber, + Eq(jobRequest.ticketNumber)))) .Times(1); job.runAsync(); @@ -92,7 +92,7 @@ TEST_F(CompleteCodeJob, DontSendCompletionsIfDocumentWasClosed) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, codeCompleted(_)).Times(0); + EXPECT_CALL(mockIpcClient, completions(_)).Times(0); job.runAsync(); documents.remove({FileContainer{filePath, projectPartId}}); diff --git a/tests/unit/unittest/clangdocumentprocessor-test.cpp b/tests/unit/unittest/clangdocumentprocessor-test.cpp index d18803eb4b..d441688c75 100644 --- a/tests/unit/unittest/clangdocumentprocessor-test.cpp +++ b/tests/unit/unittest/clangdocumentprocessor-test.cpp @@ -72,7 +72,7 @@ TEST_F(DocumentProcessor, ProcessEmpty) TEST_F(DocumentProcessorSlowTest, ProcessSingleJob) { const JobRequest jobRequest - = documentProcessor->createJobRequest(JobRequest::Type::UpdateDocumentAnnotations); + = documentProcessor->createJobRequest(JobRequest::Type::UpdateAnnotations); documentProcessor->addJob(jobRequest); const JobRequests jobsStarted = documentProcessor->process(); diff --git a/tests/unit/unittest/clangdocumentprocessors-test.cpp b/tests/unit/unittest/clangdocumentprocessors-test.cpp index 0e16ab1f4e..8142d9d408 100644 --- a/tests/unit/unittest/clangdocumentprocessors-test.cpp +++ b/tests/unit/unittest/clangdocumentprocessors-test.cpp @@ -157,7 +157,7 @@ TEST_F(DocumentProcessors, ProcessEmpty) TEST_F(DocumentProcessorsSlowTest, ProcessSingle) { DocumentProcessor documentProcessor = documentProcessors.create(document); - documentProcessor.addJob(JobRequest::Type::UpdateDocumentAnnotations); + documentProcessor.addJob(JobRequest::Type::UpdateAnnotations); const JobRequests jobsStarted = documentProcessors.process(); diff --git a/tests/unit/unittest/clangjobqueue-test.cpp b/tests/unit/unittest/clangjobqueue-test.cpp index de0161c713..b5758dc25b 100644 --- a/tests/unit/unittest/clangjobqueue-test.cpp +++ b/tests/unit/unittest/clangjobqueue-test.cpp @@ -90,7 +90,7 @@ protected: TEST_F(JobQueue, AddJob) { const JobRequest jobRequest = createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations); + JobRequest::Type::UpdateAnnotations); jobQueue.add(jobRequest); @@ -100,7 +100,7 @@ TEST_F(JobQueue, AddJob) TEST_F(JobQueue, DoNotAddDuplicate) { const JobRequest request = createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations); + JobRequest::Type::UpdateAnnotations); jobQueue.add(request); const bool added = jobQueue.add(request); @@ -115,7 +115,7 @@ TEST_F(JobQueue, DoNotAddDuplicateForWhichAJobIsAlreadyRunning) }); const bool added = jobQueue.add(createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations)); + JobRequest::Type::UpdateAnnotations)); ASSERT_FALSE(added); } @@ -127,7 +127,7 @@ TEST_F(JobQueue, DoNotAddForNotExistingDocument) }); const bool added = jobQueue.add(createJobRequest(Utf8StringLiteral("notExistingDocument.cpp"), - JobRequest::Type::UpdateDocumentAnnotations)); + JobRequest::Type::UpdateAnnotations)); ASSERT_FALSE(added); } @@ -136,7 +136,7 @@ TEST_F(JobQueue, DoNotAddForNotIntactDocument) { document.setHasParseOrReparseFailed(true); const bool added = jobQueue.add(createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations)); + JobRequest::Type::UpdateAnnotations)); ASSERT_FALSE(added); } @@ -150,7 +150,7 @@ TEST_F(JobQueue, CancelDuringAddForNotIntactDocument) }); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); ASSERT_TRUE(canceled); } @@ -164,7 +164,7 @@ TEST_F(JobQueue, ProcessEmpty) TEST_F(JobQueue, ProcessSingleJob) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -174,7 +174,7 @@ TEST_F(JobQueue, ProcessSingleJob) TEST_F(JobQueue, ProcessUntilEmpty) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); jobQueue.add(createJobRequest(filePath1, JobRequest::Type::ParseSupportiveTranslationUnit)); JobRequests jobsToRun; @@ -191,7 +191,7 @@ TEST_F(JobQueue, ProcessUntilEmpty) TEST_F(JobQueue, RemoveRequestsForClosedDocuments) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); removeDocument(); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -202,7 +202,7 @@ TEST_F(JobQueue, RemoveRequestsForClosedDocuments) TEST_F(JobQueue, RemoveRequestsForClosedProject) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); removeProject(); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -213,7 +213,7 @@ TEST_F(JobQueue, RemoveRequestsForClosedProject) TEST_F(JobQueue, RemoveRequestsForOudatedUnsavedFiles) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); updateUnsavedFiles(); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -224,7 +224,7 @@ TEST_F(JobQueue, RemoveRequestsForOudatedUnsavedFiles) TEST_F(JobQueue, RemoveRequestsForChangedDocumentRevision) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); updateDocumentRevision(); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -235,7 +235,7 @@ TEST_F(JobQueue, RemoveRequestsForChangedDocumentRevision) TEST_F(JobQueue, RemoveRequestsForOudatedProject) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); updateProject(); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -247,7 +247,7 @@ TEST_F(JobQueue, RemoveRequestsForOudatedProject) TEST_F(JobQueue, RemoveRequestsForNotIntactDocuments) { const Utf8String filePath = createTranslationUnitForDeletedFile(); - jobQueue.add(createJobRequest(filePath, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath, JobRequest::Type::UpdateAnnotations)); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -257,7 +257,7 @@ TEST_F(JobQueue, RemoveRequestsForNotIntactDocuments) TEST_F(JobQueue, CancelRequestsForNotIntactDocuments) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); document.setHasParseOrReparseFailed(true); bool canceled = false; jobQueue.setCancelJobRequest([&canceled](const JobRequest &) { @@ -272,8 +272,8 @@ TEST_F(JobQueue, CancelRequestsForNotIntactDocuments) TEST_F(JobQueue, PrioritizeCurrentDocumentOverNotCurrent) { resetVisibilityAndCurrentEditor(); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); + jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateAnnotations)); documents.setUsedByCurrentEditor(filePath2); jobQueue.prioritizeRequests(); @@ -284,8 +284,8 @@ TEST_F(JobQueue, PrioritizeCurrentDocumentOverNotCurrent) TEST_F(JobQueue, PrioritizeVisibleDocumentsOverNotVisible) { resetVisibilityAndCurrentEditor(); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); + jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateAnnotations)); documents.setVisibleInEditors({filePath2}); jobQueue.prioritizeRequests(); @@ -296,8 +296,8 @@ TEST_F(JobQueue, PrioritizeVisibleDocumentsOverNotVisible) TEST_F(JobQueue, PrioritizeCurrentDocumentOverVisible) { resetVisibilityAndCurrentEditor(); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); + jobQueue.add(createJobRequest(filePath2, JobRequest::Type::UpdateAnnotations)); documents.setVisibleInEditors({filePath1, filePath2}); documents.setUsedByCurrentEditor(filePath2); @@ -308,7 +308,7 @@ TEST_F(JobQueue, PrioritizeCurrentDocumentOverVisible) TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); documents.setVisibleInEditors({}); documents.setUsedByCurrentEditor(Utf8StringLiteral("aNonExistingFilePath")); @@ -319,8 +319,8 @@ TEST_F(JobQueue, RunNothingForNotCurrentOrVisibleDocument) TEST_F(JobQueue, RunOnlyOneJobPerTranslationUnitIfMultipleAreInQueue) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestAnnotations)); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -335,10 +335,10 @@ TEST_F(JobQueue, RunJobsForDistinctTranslationUnits) const TranslationUnit alternativeTu = document.translationUnits().createAndAppend(); document.translationUnits().updateParseTimePoint(alternativeTu.id(), Clock::now()); jobQueue.add(createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations, + JobRequest::Type::UpdateAnnotations, PreferredTranslationUnit::RecentlyParsed)); jobQueue.add(createJobRequest(filePath1, - JobRequest::Type::UpdateDocumentAnnotations, + JobRequest::Type::UpdateAnnotations, PreferredTranslationUnit::PreviouslyParsed)); const JobRequests jobsToRun = jobQueue.processQueue(); @@ -348,7 +348,7 @@ TEST_F(JobQueue, RunJobsForDistinctTranslationUnits) } TEST_F(JobQueue, DoNotRunJobForTranslationUnittThatIsBeingProcessed) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); JobRequests jobsToRun = jobQueue.processQueue(); jobQueue.setIsJobRunningForTranslationUnitHandler([](const Utf8String &) { return true; @@ -359,9 +359,9 @@ TEST_F(JobQueue, DoNotRunJobForTranslationUnittThatIsBeingProcessed) ASSERT_THAT(jobsToRun.size(), Eq(0)); } -TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByUnsavedFileChange) +TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByUnsavedFileChange) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); updateUnsavedFiles(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -369,9 +369,9 @@ TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByUnsavedFileChange) ASSERT_THAT(jobsToStart.size(), Eq(0)); } -TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByProjectRemoval) +TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByProjectRemoval) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); removeProject(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -379,9 +379,9 @@ TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByProjectRemoval) ASSERT_THAT(jobsToStart.size(), Eq(0)); } -TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByProjectChange) +TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByProjectChange) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); updateProject(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -389,9 +389,9 @@ TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByProjectChange) ASSERT_THAT(jobsToStart.size(), Eq(0)); } -TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByDocumentClose) +TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByDocumentClose) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); removeDocument(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -399,9 +399,9 @@ TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByDocumentClose) ASSERT_THAT(jobsToStart.size(), Eq(0)); } -TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByNotIntactDocument) +TEST_F(JobQueue, RequestUpdateAnnotationsOutdatableByNotIntactDocument) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::UpdateAnnotations)); document.setHasParseOrReparseFailed(true); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -411,7 +411,7 @@ TEST_F(JobQueue, RequestUpdateDocumentAnnotationsOutdatableByNotIntactDocument) TEST_F(JobQueue, RequestCompleteCodeOutdatableByDocumentClose) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CompleteCode)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestCompletions)); removeDocument(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -422,7 +422,7 @@ TEST_F(JobQueue, RequestCompleteCodeOutdatableByDocumentClose) TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByUnsavedFilesChange) { pretendParsedTranslationUnit(); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CompleteCode)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestCompletions)); updateUnsavedFiles(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -433,7 +433,7 @@ TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByUnsavedFilesChange) TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByDocumentRevisionChange) { pretendParsedTranslationUnit(); - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::CompleteCode)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestCompletions)); updateDocumentRevision(); const JobRequests jobsToStart = jobQueue.processQueue(); @@ -443,7 +443,7 @@ TEST_F(JobQueue, RequestCompleteCodeNotOutdatableByDocumentRevisionChange) TEST_F(JobQueue, RequestCompleteCodeOutdatableByDocumentRevisionChange) { - jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestDocumentAnnotations)); + jobQueue.add(createJobRequest(filePath1, JobRequest::Type::RequestAnnotations)); updateDocumentRevision(); const JobRequests jobsToStart = jobQueue.processQueue(); diff --git a/tests/unit/unittest/clangjobs-test.cpp b/tests/unit/unittest/clangjobs-test.cpp index cf3507d108..3288b216d4 100644 --- a/tests/unit/unittest/clangjobs-test.cpp +++ b/tests/unit/unittest/clangjobs-test.cpp @@ -83,7 +83,7 @@ TEST_F(Jobs, ProcessEmptyQueue) TEST_F(JobsSlowTest, ProcessQueueWithSingleJob) { - jobs.add(document, JobRequest::Type::UpdateDocumentAnnotations); + jobs.add(document, JobRequest::Type::UpdateAnnotations); const JobRequests jobsStarted = jobs.process(); @@ -93,9 +93,9 @@ TEST_F(JobsSlowTest, ProcessQueueWithSingleJob) TEST_F(JobsSlowTest, ProcessQueueUntilEmpty) { - jobs.add(document, JobRequest::Type::UpdateDocumentAnnotations); - jobs.add(document, JobRequest::Type::UpdateDocumentAnnotations); - jobs.add(document, JobRequest::Type::UpdateDocumentAnnotations); + jobs.add(document, JobRequest::Type::UpdateAnnotations); + jobs.add(document, JobRequest::Type::UpdateAnnotations); + jobs.add(document, JobRequest::Type::UpdateAnnotations); jobs.process(); @@ -104,7 +104,7 @@ TEST_F(JobsSlowTest, ProcessQueueUntilEmpty) TEST_F(JobsSlowTest, IsJobRunning) { - jobs.add(document, JobRequest::Type::UpdateDocumentAnnotations); + jobs.add(document, JobRequest::Type::UpdateAnnotations); jobs.process(); const bool isJobRunning = jobs.isJobRunningForTranslationUnit(document.translationUnit().id()); diff --git a/tests/unit/unittest/clangrequestdocumentannotationsjob-test.cpp b/tests/unit/unittest/clangrequestannotationsjob-test.cpp index 5e2d77fee4..76740d041a 100644 --- a/tests/unit/unittest/clangrequestdocumentannotationsjob-test.cpp +++ b/tests/unit/unittest/clangrequestannotationsjob-test.cpp @@ -25,7 +25,7 @@ #include "clangasyncjob-base.h" -#include <clangrequestdocumentannotationsjob.h> +#include <clangrequestannotationsjob.h> using namespace ClangBackEnd; @@ -33,23 +33,23 @@ using testing::_; namespace { -class RequestDocumentAnnotationsJob : public ClangAsyncJobTest +class RequestAnnotationsJob : public ClangAsyncJobTest { protected: - void SetUp() override { BaseSetUp(JobRequest::Type::RequestDocumentAnnotations, job); } + void SetUp() override { BaseSetUp(JobRequest::Type::RequestAnnotations, job); } protected: - ClangBackEnd::RequestDocumentAnnotationsJob job; + ClangBackEnd::RequestAnnotationsJob job; }; -TEST_F(RequestDocumentAnnotationsJob, PrepareAsyncRun) +TEST_F(RequestAnnotationsJob, PrepareAsyncRun) { job.setContext(jobContext); ASSERT_TRUE(job.prepareAsyncRun()); } -TEST_F(RequestDocumentAnnotationsJob, RunAsync) +TEST_F(RequestAnnotationsJob, RunAsync) { job.setContext(jobContext); job.prepareAsyncRun(); @@ -59,22 +59,22 @@ TEST_F(RequestDocumentAnnotationsJob, RunAsync) ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(RequestDocumentAnnotationsJob, SendAnnotations) +TEST_F(RequestAnnotationsJob, SendAnnotations) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(1); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(1); job.runAsync(); ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(RequestDocumentAnnotationsJob, DontSendAnnotationsIfDocumentWasClosed) +TEST_F(RequestAnnotationsJob, DontSendAnnotationsIfDocumentWasClosed) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(0); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(0); job.runAsync(); documents.remove({FileContainer{filePath, projectPartId}}); diff --git a/tests/unit/unittest/clangresumedocumentjob-test.cpp b/tests/unit/unittest/clangresumedocumentjob-test.cpp index 11a9e49072..9582b0c0d1 100644 --- a/tests/unit/unittest/clangresumedocumentjob-test.cpp +++ b/tests/unit/unittest/clangresumedocumentjob-test.cpp @@ -83,7 +83,7 @@ TEST_F(ResumeDocumentJob, SendsAnnotationsAfterResume) suspendDocument(); job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(1); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(1); job.runAsync(); ASSERT_TRUE(waitUntilJobFinished(job)); diff --git a/tests/unit/unittest/clangupdatedocumentannotationsjob-test.cpp b/tests/unit/unittest/clangupdateannotationsjob-test.cpp index 1378cce878..8c6ee421fd 100644 --- a/tests/unit/unittest/clangupdatedocumentannotationsjob-test.cpp +++ b/tests/unit/unittest/clangupdateannotationsjob-test.cpp @@ -25,7 +25,7 @@ #include "clangasyncjob-base.h" -#include <clangupdatedocumentannotationsjob.h> +#include <clangupdateannotationsjob.h> using namespace ClangBackEnd; @@ -34,25 +34,25 @@ using testing::_; namespace { -class UpdateDocumentAnnotationsJob : public ClangAsyncJobTest +class UpdateAnnotationsJob : public ClangAsyncJobTest { protected: - void SetUp() override { BaseSetUp(JobRequest::Type::UpdateDocumentAnnotations, job); } + void SetUp() override { BaseSetUp(JobRequest::Type::UpdateAnnotations, job); } protected: - ClangBackEnd::UpdateDocumentAnnotationsJob job; + ClangBackEnd::UpdateAnnotationsJob job; }; -using UpdateDocumentAnnotationsJobSlowTest = UpdateDocumentAnnotationsJob; +using UpdateAnnotationsJobSlowTest = UpdateAnnotationsJob; -TEST_F(UpdateDocumentAnnotationsJob, PrepareAsyncRun) +TEST_F(UpdateAnnotationsJob, PrepareAsyncRun) { job.setContext(jobContext); ASSERT_TRUE(job.prepareAsyncRun()); } -TEST_F(UpdateDocumentAnnotationsJobSlowTest, RunAsync) +TEST_F(UpdateAnnotationsJobSlowTest, RunAsync) { job.setContext(jobContext); job.prepareAsyncRun(); @@ -62,22 +62,22 @@ TEST_F(UpdateDocumentAnnotationsJobSlowTest, RunAsync) ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(UpdateDocumentAnnotationsJobSlowTest, SendAnnotations) +TEST_F(UpdateAnnotationsJobSlowTest, SendAnnotations) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(1); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(1); job.runAsync(); ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(UpdateDocumentAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentWasClosed) +TEST_F(UpdateAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentWasClosed) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(0); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(0); job.runAsync(); documents.remove({FileContainer{filePath, projectPartId}}); @@ -85,11 +85,11 @@ TEST_F(UpdateDocumentAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentWasClo ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(UpdateDocumentAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentRevisionChanged) +TEST_F(UpdateAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentRevisionChanged) { job.setContext(jobContextWithMockClient); job.prepareAsyncRun(); - EXPECT_CALL(mockIpcClient, documentAnnotationsChanged(_)).Times(0); + EXPECT_CALL(mockIpcClient, annotations(_)).Times(0); job.runAsync(); documents.update({FileContainer(filePath, projectPartId, Utf8String(), true, 99)}); @@ -97,7 +97,7 @@ TEST_F(UpdateDocumentAnnotationsJobSlowTest, DontSendAnnotationsIfDocumentRevisi ASSERT_TRUE(waitUntilJobFinished(job)); } -TEST_F(UpdateDocumentAnnotationsJobSlowTest, UpdatesTranslationUnit) +TEST_F(UpdateAnnotationsJobSlowTest, UpdatesTranslationUnit) { const TimePoint timePointBefore = document.lastProjectPartChangeTimePoint(); const QSet<Utf8String> dependendOnFilesBefore = document.dependedFilePaths(); diff --git a/tests/unit/unittest/clientserverinprocess-test.cpp b/tests/unit/unittest/clientserverinprocess-test.cpp index 1b0743c558..68dd598e59 100644 --- a/tests/unit/unittest/clientserverinprocess-test.cpp +++ b/tests/unit/unittest/clientserverinprocess-test.cpp @@ -95,137 +95,136 @@ TEST_F(ClientServerInProcess, SendAliveMessage) scheduleClientMessages(); } -TEST_F(ClientServerInProcess, SendRegisterTranslationUnitForEditorMessage) +TEST_F(ClientServerInProcess, SendDocumentsOpenedMessage) { - ClangBackEnd::RegisterTranslationUnitForEditorMessage message({fileContainer}, - filePath, - {filePath}); + ClangBackEnd::DocumentsOpenedMessage message({fileContainer}, filePath, {filePath}); - EXPECT_CALL(mockClangCodeModelServer, registerTranslationUnitsForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, documentsOpened(message)) .Times(1); - serverProxy.registerTranslationUnitsForEditor(message); + serverProxy.documentsOpened(message); scheduleServerMessages(); } TEST_F(ClientServerInProcess, SendUpdateTranslationUnitsForEditorMessage) { - ClangBackEnd::UpdateTranslationUnitsForEditorMessage message({fileContainer}); + ClangBackEnd::DocumentsChangedMessage message({fileContainer}); - EXPECT_CALL(mockClangCodeModelServer, updateTranslationUnitsForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, documentsChanged(message)) .Times(1); - serverProxy.updateTranslationUnitsForEditor(message); + serverProxy.documentsChanged(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendUnregisterTranslationUnitsForEditorMessage) +TEST_F(ClientServerInProcess, SendDocumentsClosedMessage) { - ClangBackEnd::UnregisterTranslationUnitsForEditorMessage message({fileContainer}); + ClangBackEnd::DocumentsClosedMessage message({fileContainer}); - EXPECT_CALL(mockClangCodeModelServer, unregisterTranslationUnitsForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, documentsClosed(message)) .Times(1); - serverProxy.unregisterTranslationUnitsForEditor(message); + serverProxy.documentsClosed(message); scheduleServerMessages(); } TEST_F(ClientServerInProcess, SendRegisterUnsavedFilesForEditorMessage) { - ClangBackEnd::RegisterUnsavedFilesForEditorMessage message({fileContainer}); + ClangBackEnd::UnsavedFilesUpdatedMessage message({fileContainer}); - EXPECT_CALL(mockClangCodeModelServer, registerUnsavedFilesForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, unsavedFilesUpdated(message)) .Times(1); - serverProxy.registerUnsavedFilesForEditor(message); + serverProxy.unsavedFilesUpdated(message); scheduleServerMessages(); } TEST_F(ClientServerInProcess, SendUnregisterUnsavedFilesForEditorMessage) { - ClangBackEnd::UnregisterUnsavedFilesForEditorMessage message({fileContainer}); + ClangBackEnd::UnsavedFilesRemovedMessage message({fileContainer}); - EXPECT_CALL(mockClangCodeModelServer, unregisterUnsavedFilesForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, unsavedFilesRemoved(message)) .Times(1); - serverProxy.unregisterUnsavedFilesForEditor(message); + serverProxy.unsavedFilesRemoved(message); scheduleServerMessages(); } TEST_F(ClientServerInProcess, SendCompleteCodeMessage) { - ClangBackEnd::CompleteCodeMessage message(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); + ClangBackEnd::RequestCompletionsMessage message(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); - EXPECT_CALL(mockClangCodeModelServer, completeCode(message)) + EXPECT_CALL(mockClangCodeModelServer, requestCompletions(message)) .Times(1); - serverProxy.completeCode(message); + serverProxy.requestCompletions(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendRequestDocumentAnnotationsMessage) +TEST_F(ClientServerInProcess, SendRequestAnnotationsMessage) { - ClangBackEnd::RequestDocumentAnnotationsMessage message({Utf8StringLiteral("foo.cpp"), - Utf8StringLiteral("projectId")}); + ClangBackEnd::RequestAnnotationsMessage message( + {Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("projectId")}); - EXPECT_CALL(mockClangCodeModelServer, requestDocumentAnnotations(message)) + EXPECT_CALL(mockClangCodeModelServer, requestAnnotations(message)) .Times(1); - serverProxy.requestDocumentAnnotations(message); + serverProxy.requestAnnotations(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendCodeCompletedMessage) +TEST_F(ClientServerInProcess, SendCompletionsMessage) { ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")}); - ClangBackEnd::CodeCompletedMessage message(codeCompletions, - ClangBackEnd::CompletionCorrection::NoCorrection, - 1); + ClangBackEnd::CompletionsMessage message(codeCompletions, + ClangBackEnd::CompletionCorrection::NoCorrection, + 1); - EXPECT_CALL(mockClangCodeModelClient, codeCompleted(message)) + EXPECT_CALL(mockClangCodeModelClient, completions(message)) .Times(1); - clientProxy.codeCompleted(message); + clientProxy.completions(message); scheduleClientMessages(); } -TEST_F(ClientServerInProcess, SendRegisterProjectPartsForEditorMessage) +TEST_F(ClientServerInProcess, SendProjectPartsUpdatedMessage) { ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro")); - ClangBackEnd::RegisterProjectPartsForEditorMessage message({projectContainer}); + ClangBackEnd::ProjectPartsUpdatedMessage message({projectContainer}); - EXPECT_CALL(mockClangCodeModelServer, registerProjectPartsForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, projectPartsUpdated(message)) .Times(1); - serverProxy.registerProjectPartsForEditor(message); + serverProxy.projectPartsUpdated(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendUnregisterProjectPartsForEditorMessage) +TEST_F(ClientServerInProcess, SendProjectPartsRemovedMessage) { - ClangBackEnd::UnregisterProjectPartsForEditorMessage message({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); + ClangBackEnd::ProjectPartsRemovedMessage message({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); - EXPECT_CALL(mockClangCodeModelServer, unregisterProjectPartsForEditor(message)) + EXPECT_CALL(mockClangCodeModelServer, projectPartsRemoved(message)) .Times(1); - serverProxy.unregisterProjectPartsForEditor(message); + serverProxy.projectPartsRemoved(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, UpdateVisibleTranslationUnitsMessage) +TEST_F(ClientServerInProcess, DocumentVisibilityChangedMessage) { - ClangBackEnd::UpdateVisibleTranslationUnitsMessage message(Utf8StringLiteral(TESTDATA_DIR"/fileone.cpp"), - {Utf8StringLiteral(TESTDATA_DIR"/fileone.cpp"), - Utf8StringLiteral(TESTDATA_DIR"/filetwo.cpp")}); + ClangBackEnd::DocumentVisibilityChangedMessage + message(Utf8StringLiteral(TESTDATA_DIR "/fileone.cpp"), + {Utf8StringLiteral(TESTDATA_DIR "/fileone.cpp"), + Utf8StringLiteral(TESTDATA_DIR "/filetwo.cpp")}); - EXPECT_CALL(mockClangCodeModelServer, updateVisibleTranslationUnits(message)) + EXPECT_CALL(mockClangCodeModelServer, documentVisibilityChanged(message)) .Times(1); - serverProxy.updateVisibleTranslationUnits(message); + serverProxy.documentVisibilityChanged(message); scheduleServerMessages(); } -TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage) +TEST_F(ClientServerInProcess, SendAnnotationsMessage) { ClangBackEnd::HighlightingTypes types; types.mainHighlightingType = ClangBackEnd::HighlightingType::Keyword; @@ -239,18 +238,16 @@ TEST_F(ClientServerInProcess, SendDocumentAnnotationsChangedMessage) {}, {}); - ClangBackEnd::DocumentAnnotationsChangedMessage message(fileContainer, - {diagnostic}, - {}, - {tokenInfo}, - QVector<SourceRangeContainer>()); + ClangBackEnd::AnnotationsMessage message(fileContainer, + {diagnostic}, + {}, + {tokenInfo}, + QVector<SourceRangeContainer>()); - - - EXPECT_CALL(mockClangCodeModelClient, documentAnnotationsChanged(message)) + EXPECT_CALL(mockClangCodeModelClient, annotations(message)) .Times(1); - clientProxy.documentAnnotationsChanged(message); + clientProxy.annotations(message); scheduleClientMessages(); } diff --git a/tests/unit/unittest/clientserveroutsideprocess-test.cpp b/tests/unit/unittest/clientserveroutsideprocess-test.cpp index 3f10186ae0..2dfe6a281b 100644 --- a/tests/unit/unittest/clientserveroutsideprocess-test.cpp +++ b/tests/unit/unittest/clientserveroutsideprocess-test.cpp @@ -92,64 +92,64 @@ TEST_F(ClientServerOutsideProcessSlowTest, RestartProcessAfterTermination) ASSERT_THAT(clientSpy, SizeIs(1)); } -TEST_F(ClientServerOutsideProcess, SendRegisterTranslationUnitForEditorMessage) +TEST_F(ClientServerOutsideProcess, SendDocumentsOpenedMessage) { auto filePath = Utf8StringLiteral("foo.cpp"); ClangBackEnd::FileContainer fileContainer(filePath, Utf8StringLiteral("projectId")); - ClangBackEnd::RegisterTranslationUnitForEditorMessage registerTranslationUnitForEditorMessage({fileContainer}, - filePath, - {filePath}); - EchoMessage echoMessage(registerTranslationUnitForEditorMessage); + ClangBackEnd::DocumentsOpenedMessage documentsOpenedMessage({fileContainer}, + filePath, + {filePath}); + EchoMessage echoMessage(documentsOpenedMessage); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); - client.serverProxy().registerTranslationUnitsForEditor(registerTranslationUnitForEditorMessage); + client.serverProxy().documentsOpened(documentsOpenedMessage); ASSERT_TRUE(client.waitForEcho()); } -TEST_F(ClientServerOutsideProcess, SendUnregisterTranslationUnitsForEditorMessage) +TEST_F(ClientServerOutsideProcess, SendDocumentsClosedMessage) { FileContainer fileContainer(Utf8StringLiteral("foo.cpp"), Utf8StringLiteral("projectId")); - ClangBackEnd::UnregisterTranslationUnitsForEditorMessage unregisterTranslationUnitsForEditorMessage ({fileContainer}); - EchoMessage echoMessage(unregisterTranslationUnitsForEditorMessage); + ClangBackEnd::DocumentsClosedMessage documentsClosedMessage({fileContainer}); + EchoMessage echoMessage(documentsClosedMessage); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); - client.serverProxy().unregisterTranslationUnitsForEditor(unregisterTranslationUnitsForEditorMessage); + client.serverProxy().documentsClosed(documentsClosedMessage); ASSERT_TRUE(client.waitForEcho()); } TEST_F(ClientServerOutsideProcess, SendCompleteCodeMessage) { - CompleteCodeMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); + RequestCompletionsMessage codeCompleteMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want")); EchoMessage echoMessage(codeCompleteMessage); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); - client.serverProxy().completeCode(codeCompleteMessage); + client.serverProxy().requestCompletions(codeCompleteMessage); ASSERT_TRUE(client.waitForEcho()); } -TEST_F(ClientServerOutsideProcess, SendRegisterProjectPartsForEditorMessage) +TEST_F(ClientServerOutsideProcess, SendProjectPartsUpdatedMessage) { ClangBackEnd::ProjectPartContainer projectContainer(Utf8StringLiteral(TESTDATA_DIR"/complete.pro")); - ClangBackEnd::RegisterProjectPartsForEditorMessage registerProjectPartsForEditorMessage({projectContainer}); - EchoMessage echoMessage(registerProjectPartsForEditorMessage); + ClangBackEnd::ProjectPartsUpdatedMessage projectPartsUpdatedMessage({projectContainer}); + EchoMessage echoMessage(projectPartsUpdatedMessage); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); - client.serverProxy().registerProjectPartsForEditor(registerProjectPartsForEditorMessage); + client.serverProxy().projectPartsUpdated(projectPartsUpdatedMessage); ASSERT_TRUE(client.waitForEcho()); } -TEST_F(ClientServerOutsideProcess, SendUnregisterProjectPartsForEditorMessage) +TEST_F(ClientServerOutsideProcess, SendProjectPartsRemovedMessage) { - ClangBackEnd::UnregisterProjectPartsForEditorMessage unregisterProjectPartsForEditorMessage({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); - EchoMessage echoMessage(unregisterProjectPartsForEditorMessage); + ClangBackEnd::ProjectPartsRemovedMessage projectPartsRemovedMessage({Utf8StringLiteral(TESTDATA_DIR"/complete.pro")}); + EchoMessage echoMessage(projectPartsRemovedMessage); EXPECT_CALL(mockClangCodeModelClient, echo(echoMessage)); - client.serverProxy().unregisterProjectPartsForEditor(unregisterProjectPartsForEditorMessage); + client.serverProxy().projectPartsRemoved(projectPartsRemovedMessage); ASSERT_TRUE(client.waitForEcho()); } diff --git a/tests/unit/unittest/dummyclangipcclient.h b/tests/unit/unittest/dummyclangipcclient.h index e840b0a6c7..b58fd91284 100644 --- a/tests/unit/unittest/dummyclangipcclient.h +++ b/tests/unit/unittest/dummyclangipcclient.h @@ -34,8 +34,8 @@ public: void alive() override {} void echo(const ClangBackEnd::EchoMessage &) override {} - void codeCompleted(const ClangBackEnd::CodeCompletedMessage &) override {} - void documentAnnotationsChanged(const ClangBackEnd::DocumentAnnotationsChangedMessage &) override {} + void completions(const ClangBackEnd::CompletionsMessage &) override {} + void annotations(const ClangBackEnd::AnnotationsMessage &) override {} void references(const ClangBackEnd::ReferencesMessage &) override {} void followSymbol(const ClangBackEnd::FollowSymbolMessage &) override {} void tooltip(const ClangBackEnd::ToolTipMessage &) override {} diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 3b1a761a80..a6d6118bcc 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -228,7 +228,7 @@ std::ostream &operator<<(std::ostream &os, const SourceLocationsContainer &conta return os; } -std::ostream &operator<<(std::ostream &os, const RegisterProjectPartsForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const ProjectPartsUpdatedMessage &message) { os << "(" << message.projectContainers @@ -258,7 +258,7 @@ std::ostream &operator<<(std::ostream &os, const FollowSymbolMessage &message) return os; } -std::ostream &operator<<(std::ostream &os, const CompleteCodeMessage &message) +std::ostream &operator<<(std::ostream &os, const RequestCompletionsMessage &message) { os << "(" << message.filePath << ", " @@ -274,9 +274,9 @@ std::ostream &operator<<(std::ostream &os, const CompleteCodeMessage &message) return os; } -std::ostream &operator<<(std::ostream &os, const RegisterTranslationUnitForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const DocumentsOpenedMessage &message) { - os << "RegisterTranslationUnitForEditorMessage(" + os << "DocumentsOpenedMessage(" << message.fileContainers << ", " << message.currentEditorFilePath << ", " << message.visibleEditorFilePaths << ")"; @@ -311,7 +311,7 @@ static const char *completionCorrectionToText(CompletionCorrection correction) } #undef RETURN_TEXT_FOR_CASE -std::ostream &operator<<(std::ostream &os, const CodeCompletedMessage &message) +std::ostream &operator<<(std::ostream &os, const CompletionsMessage &message) { os << "(" << message.codeCompletions << ", " @@ -323,9 +323,9 @@ std::ostream &operator<<(std::ostream &os, const CodeCompletedMessage &message) return os; } -std::ostream &operator<<(std::ostream &os, const DocumentAnnotationsChangedMessage &message) +std::ostream &operator<<(std::ostream &os, const AnnotationsMessage &message) { - os << "DocumentAnnotationsChangedMessage(" + os << "AnnotationsMessage(" << message.fileContainer << "," << message.diagnostics.size() << "," << !message.firstHeaderErrorDiagnostic.text.isEmpty() @@ -364,7 +364,7 @@ std::ostream &operator<<(std::ostream &os, const EchoMessage &/*message*/) return os << "()"; } -std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const ProjectPartsRemovedMessage &message) { os << "(" << message.projectPartIds @@ -373,7 +373,7 @@ std::ostream &operator<<(std::ostream &os, const UnregisterProjectPartsForEditor return os; } -std::ostream &operator<<(std::ostream &os, const UnregisterTranslationUnitsForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const DocumentsClosedMessage &message) { os << "(" << message.fileContainers @@ -627,7 +627,7 @@ std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch return out; } -std::ostream &operator<<(std::ostream &os, const RegisterUnsavedFilesForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const UnsavedFilesUpdatedMessage &message) { os << "(" << message.fileContainers @@ -636,7 +636,7 @@ std::ostream &operator<<(std::ostream &os, const RegisterUnsavedFilesForEditorMe return os; } -std::ostream &operator<<(std::ostream &os, const RequestDocumentAnnotationsMessage &message) +std::ostream &operator<<(std::ostream &os, const RequestAnnotationsMessage &message) { os << "(" << message.fileContainer.filePath << "," @@ -811,7 +811,7 @@ std::ostream &operator<<(std::ostream &os, const SourceRangeWithTextContainer &c return os; } -std::ostream &operator<<(std::ostream &os, const UnregisterUnsavedFilesForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const UnsavedFilesRemovedMessage &message) { os << "(" << message.fileContainers @@ -827,16 +827,16 @@ std::ostream &operator<<(std::ostream &out, const UpdateProjectPartsMessage &mes << ")"; } -std::ostream &operator<<(std::ostream &os, const UpdateTranslationUnitsForEditorMessage &message) +std::ostream &operator<<(std::ostream &os, const DocumentsChangedMessage &message) { - os << "UpdateTranslationUnitsForEditorMessage(" + os << "DocumentsChangedMessage(" << message.fileContainers << ")"; return os; } -std::ostream &operator<<(std::ostream &os, const UpdateVisibleTranslationUnitsMessage &message) +std::ostream &operator<<(std::ostream &os, const DocumentVisibilityChangedMessage &message) { os << "(" << message.currentEditorFilePath << ", " diff --git a/tests/unit/unittest/gtest-creator-printing.h b/tests/unit/unittest/gtest-creator-printing.h index d809b18b6e..a7c200daad 100644 --- a/tests/unit/unittest/gtest-creator-printing.h +++ b/tests/unit/unittest/gtest-creator-printing.h @@ -97,21 +97,21 @@ class FilePathId; class FilePath; class WatcherEntry; class SourceLocationsContainer; -class RegisterProjectPartsForEditorMessage; +class ProjectPartsUpdatedMessage; class CancelMessage; class AliveMessage; -class CodeCompletedMessage; +class CompletionsMessage; class EchoMessage; -class DocumentAnnotationsChangedMessage; +class AnnotationsMessage; class ReferencesMessage; class ToolTipMessage; class FollowSymbolResult; class FollowSymbolMessage; -class CompleteCodeMessage; +class RequestCompletionsMessage; class EndMessage; -class RegisterTranslationUnitForEditorMessage; -class UnregisterProjectPartsForEditorMessage; -class UnregisterTranslationUnitsForEditorMessage; +class DocumentsOpenedMessage; +class ProjectPartsRemovedMessage; +class DocumentsClosedMessage; class CodeCompletion; class CodeCompletionChunk; class DiagnosticContainer; @@ -126,9 +126,9 @@ class NativeFilePath; class PrecompiledHeadersUpdatedMessage; class ProjectPartContainer; class ProjectPartPch; -class RegisterUnsavedFilesForEditorMessage; +class UnsavedFilesUpdatedMessage; class RemoveProjectPartsMessage; -class RequestDocumentAnnotationsMessage; +class RequestAnnotationsMessage; class RequestFollowSymbolMessage; class RequestReferencesMessage; class RequestToolTipMessage; @@ -145,10 +145,10 @@ class SourceRangeWithTextContainer; class TokenInfo; template<class T> class TokenProcessor; -class UnregisterUnsavedFilesForEditorMessage; +class UnsavedFilesRemovedMessage; class UpdateProjectPartsMessage; -class UpdateTranslationUnitsForEditorMessage; -class UpdateVisibleTranslationUnitsMessage; +class DocumentsChangedMessage; +class DocumentVisibilityChangedMessage; class FilePath; template <char WindowsSlash> class AbstractFilePathView; @@ -170,21 +170,21 @@ std::ostream &operator<<(std::ostream &out, const SourceLocationEntry &entry); std::ostream &operator<<(std::ostream &out, const IdPaths &idPaths); std::ostream &operator<<(std::ostream &out, const WatcherEntry &entry); std::ostream &operator<<(std::ostream &out, const SourceLocationsContainer &container); -std::ostream &operator<<(std::ostream &out, const RegisterProjectPartsForEditorMessage &message); +std::ostream &operator<<(std::ostream &out, const ProjectPartsUpdatedMessage &message); std::ostream &operator<<(std::ostream &out, const CancelMessage &message); std::ostream &operator<<(std::ostream &out, const AliveMessage &message); -std::ostream &operator<<(std::ostream &out, const CodeCompletedMessage &message); +std::ostream &operator<<(std::ostream &out, const CompletionsMessage &message); std::ostream &operator<<(std::ostream &out, const EchoMessage &message); -std::ostream &operator<<(std::ostream &out, const DocumentAnnotationsChangedMessage &message); +std::ostream &operator<<(std::ostream &out, const AnnotationsMessage &message); std::ostream &operator<<(std::ostream &out, const ReferencesMessage &message); std::ostream &operator<<(std::ostream &out, const ToolTipMessage &message); std::ostream &operator<<(std::ostream &out, const FollowSymbolResult &result); std::ostream &operator<<(std::ostream &out, const FollowSymbolMessage &message); -std::ostream &operator<<(std::ostream &out, const CompleteCodeMessage &message); +std::ostream &operator<<(std::ostream &out, const RequestCompletionsMessage &message); std::ostream &operator<<(std::ostream &out, const EndMessage &message); -std::ostream &operator<<(std::ostream &out, const RegisterTranslationUnitForEditorMessage &message); -std::ostream &operator<<(std::ostream &out, const UnregisterProjectPartsForEditorMessage &message); -std::ostream &operator<<(std::ostream &out, const UnregisterTranslationUnitsForEditorMessage &message); +std::ostream &operator<<(std::ostream &out, const DocumentsOpenedMessage &message); +std::ostream &operator<<(std::ostream &out, const ProjectPartsRemovedMessage &message); +std::ostream &operator<<(std::ostream &out, const DocumentsClosedMessage &message); std::ostream &operator<<(std::ostream &out, const CodeCompletion &message); std::ostream &operator<<(std::ostream &out, const CodeCompletionChunk &chunk); std::ostream &operator<<(std::ostream &out, const DiagnosticContainer &container); @@ -200,9 +200,9 @@ std::ostream &operator<<(std::ostream &out, const NativeFilePath &filePath); std::ostream &operator<<(std::ostream &out, const PrecompiledHeadersUpdatedMessage &message); std::ostream &operator<<(std::ostream &out, const ProjectPartContainer &container); std::ostream &operator<<(std::ostream &out, const ProjectPartPch &projectPartPch); -std::ostream &operator<<(std::ostream &out, const RegisterUnsavedFilesForEditorMessage &message); +std::ostream &operator<<(std::ostream &out, const UnsavedFilesUpdatedMessage &message); std::ostream &operator<<(std::ostream &out, const RemoveProjectPartsMessage &message); -std::ostream &operator<<(std::ostream &out, const RequestDocumentAnnotationsMessage &message); +std::ostream &operator<<(std::ostream &out, const RequestAnnotationsMessage &message); std::ostream &operator<<(std::ostream &out, const RequestFollowSymbolMessage &message); std::ostream &operator<<(std::ostream &out, const RequestReferencesMessage &message); std::ostream &operator<<(std::ostream &out, const RequestToolTipMessage &message); @@ -217,10 +217,10 @@ std::ostream &operator<<(std::ostream &out, const SourceRangesAndDiagnosticsForQ std::ostream &operator<<(std::ostream &out, const SourceRangesContainer &container); std::ostream &operator<<(std::ostream &out, const SourceRangesForQueryMessage &message); std::ostream &operator<<(std::ostream &out, const SourceRangeWithTextContainer &container); -std::ostream &operator<<(std::ostream &out, const UnregisterUnsavedFilesForEditorMessage &message); +std::ostream &operator<<(std::ostream &out, const UnsavedFilesRemovedMessage &message); std::ostream &operator<<(std::ostream &out, const UpdateProjectPartsMessage &message); -std::ostream &operator<<(std::ostream &out, const UpdateTranslationUnitsForEditorMessage &message); -std::ostream &operator<<(std::ostream &out, const UpdateVisibleTranslationUnitsMessage &message); +std::ostream &operator<<(std::ostream &out, const DocumentsChangedMessage &message); +std::ostream &operator<<(std::ostream &out, const DocumentVisibilityChangedMessage &message); std::ostream &operator<<(std::ostream &out, const FilePath &filePath); std::ostream &operator<<(std::ostream &out, const FilePathId &filePathId); std::ostream &operator<<(std::ostream &out, const TokenInfo& tokenInfo); diff --git a/tests/unit/unittest/mockclangcodemodelclient.h b/tests/unit/unittest/mockclangcodemodelclient.h index 3b5a3cfbf5..9244e05eb8 100644 --- a/tests/unit/unittest/mockclangcodemodelclient.h +++ b/tests/unit/unittest/mockclangcodemodelclient.h @@ -37,10 +37,10 @@ public: void()); MOCK_METHOD1(echo, void(const ClangBackEnd::EchoMessage &message)); - MOCK_METHOD1(codeCompleted, - void(const ClangBackEnd::CodeCompletedMessage &message)); - MOCK_METHOD1(documentAnnotationsChanged, - void(const ClangBackEnd::DocumentAnnotationsChangedMessage &message)); + MOCK_METHOD1(completions, + void(const ClangBackEnd::CompletionsMessage &message)); + MOCK_METHOD1(annotations, + void(const ClangBackEnd::AnnotationsMessage &message)); MOCK_METHOD1(references, void(const ClangBackEnd::ReferencesMessage &message)); MOCK_METHOD1(followSymbol, diff --git a/tests/unit/unittest/mockclangcodemodelserver.h b/tests/unit/unittest/mockclangcodemodelserver.h index 468f683bf5..56d48fac58 100644 --- a/tests/unit/unittest/mockclangcodemodelserver.h +++ b/tests/unit/unittest/mockclangcodemodelserver.h @@ -33,30 +33,35 @@ class MockClangCodeModelServer : public ClangBackEnd::ClangCodeModelServerInterf public: MOCK_METHOD0(end, void()); - MOCK_METHOD1(registerTranslationUnitsForEditor, - void(const ClangBackEnd::RegisterTranslationUnitForEditorMessage &message)); - MOCK_METHOD1(updateTranslationUnitsForEditor, - void(const ClangBackEnd::UpdateTranslationUnitsForEditorMessage &message)); - MOCK_METHOD1(unregisterTranslationUnitsForEditor, - void(const ClangBackEnd::UnregisterTranslationUnitsForEditorMessage &message)); - MOCK_METHOD1(registerProjectPartsForEditor, - void(const ClangBackEnd::RegisterProjectPartsForEditorMessage &message)); - MOCK_METHOD1(unregisterProjectPartsForEditor, - void(const ClangBackEnd::UnregisterProjectPartsForEditorMessage &message)); - MOCK_METHOD1(registerUnsavedFilesForEditor, - void(const ClangBackEnd::RegisterUnsavedFilesForEditorMessage &message)); - MOCK_METHOD1(unregisterUnsavedFilesForEditor, - void(const ClangBackEnd::UnregisterUnsavedFilesForEditorMessage &message)); - MOCK_METHOD1(completeCode, - void(const ClangBackEnd::CompleteCodeMessage &message)); - MOCK_METHOD1(requestDocumentAnnotations, - void(const ClangBackEnd::RequestDocumentAnnotationsMessage &message)); + + MOCK_METHOD1(documentsOpened, + void(const ClangBackEnd::DocumentsOpenedMessage &message)); + MOCK_METHOD1(documentsChanged, + void(const ClangBackEnd::DocumentsChangedMessage &message)); + MOCK_METHOD1(documentsClosed, + void(const ClangBackEnd::DocumentsClosedMessage &message)); + MOCK_METHOD1(documentVisibilityChanged, + void(const ClangBackEnd::DocumentVisibilityChangedMessage &message)); + + MOCK_METHOD1(projectPartsUpdated, + void(const ClangBackEnd::ProjectPartsUpdatedMessage &message)); + MOCK_METHOD1(projectPartsRemoved, + void(const ClangBackEnd::ProjectPartsRemovedMessage &message)); + + MOCK_METHOD1(unsavedFilesUpdated, + void(const ClangBackEnd::UnsavedFilesUpdatedMessage &message)); + MOCK_METHOD1(unsavedFilesRemoved, + void(const ClangBackEnd::UnsavedFilesRemovedMessage &message)); + + MOCK_METHOD1(requestCompletions, + void(const ClangBackEnd::RequestCompletionsMessage &message)); + MOCK_METHOD1(requestAnnotations, + void(const ClangBackEnd::RequestAnnotationsMessage &message)); MOCK_METHOD1(requestReferences, void(const ClangBackEnd::RequestReferencesMessage &message)); MOCK_METHOD1(requestFollowSymbol, void(const ClangBackEnd::RequestFollowSymbolMessage &message)); MOCK_METHOD1(requestToolTip, void(const ClangBackEnd::RequestToolTipMessage &message)); - MOCK_METHOD1(updateVisibleTranslationUnits, - void(const ClangBackEnd::UpdateVisibleTranslationUnitsMessage &message)); + }; diff --git a/tests/unit/unittest/readandwritemessageblock-test.cpp b/tests/unit/unittest/readandwritemessageblock-test.cpp index 9a1bebb078..bceeab7038 100644 --- a/tests/unit/unittest/readandwritemessageblock-test.cpp +++ b/tests/unit/unittest/readandwritemessageblock-test.cpp @@ -54,7 +54,7 @@ protected: template<class Type> void CompareMessage(const Type &message); - ClangBackEnd::MessageEnvelop writeCodeCompletedMessage(); + ClangBackEnd::MessageEnvelop writeCompletionsMessage(); void popLastCharacterFromBuffer(); void pushLastCharacterToBuffer(); void readPartialMessage(); @@ -190,38 +190,36 @@ TEST_F(ReadAndWriteMessageBlock, CompareAliveMessage) CompareMessage(ClangBackEnd::AliveMessage()); } -TEST_F(ReadAndWriteMessageBlock, CompareRegisterTranslationUnitForEditorMessage) +TEST_F(ReadAndWriteMessageBlock, CompareDocumentsOpenedMessage) { - CompareMessage(ClangBackEnd::RegisterTranslationUnitForEditorMessage({fileContainer}, filePath, {filePath})); + CompareMessage(ClangBackEnd::DocumentsOpenedMessage({fileContainer}, filePath, {filePath})); } -TEST_F(ReadAndWriteMessageBlock, CompareUpdateTranslationUnitForEditorMessage) +TEST_F(ReadAndWriteMessageBlock, CompareDocumentsChangedMessage) { - CompareMessage(ClangBackEnd::UpdateTranslationUnitsForEditorMessage({fileContainer})); + CompareMessage(ClangBackEnd::DocumentsChangedMessage({fileContainer})); } -TEST_F(ReadAndWriteMessageBlock, CompareUnregisterFileForEditorMessage) +TEST_F(ReadAndWriteMessageBlock, CompareDocumentsClosedMessage) { - CompareMessage(ClangBackEnd::UnregisterTranslationUnitsForEditorMessage({fileContainer})); + CompareMessage(ClangBackEnd::DocumentsClosedMessage({fileContainer})); } -TEST_F(ReadAndWriteMessageBlock, CompareCompleteCodeMessage) +TEST_F(ReadAndWriteMessageBlock, CompareRequestCompletionsMessage) { - CompareMessage(ClangBackEnd::CompleteCodeMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"))); + CompareMessage(ClangBackEnd::RequestCompletionsMessage(Utf8StringLiteral("foo.cpp"), 24, 33, Utf8StringLiteral("do what I want"))); } -TEST_F(ReadAndWriteMessageBlock, CompareCodeCompletedMessage) +TEST_F(ReadAndWriteMessageBlock, CompareCompletionsMessage) { ClangBackEnd::CodeCompletions codeCompletions({Utf8StringLiteral("newFunction()")}); - CompareMessage( - ClangBackEnd::CodeCompletedMessage(codeCompletions, - ClangBackEnd::CompletionCorrection::NoCorrection, - 1) - ); + CompareMessage(ClangBackEnd::CompletionsMessage(codeCompletions, + ClangBackEnd::CompletionCorrection::NoCorrection, + 1)); } -TEST_F(ReadAndWriteMessageBlock, CompareDocumentAnnotationsChangedMessage) +TEST_F(ReadAndWriteMessageBlock, CompareAnnotationsMessage) { ClangBackEnd::DiagnosticContainer diagnostic(Utf8StringLiteral("don't do that"), Utf8StringLiteral("warning"), @@ -236,39 +234,39 @@ TEST_F(ReadAndWriteMessageBlock, CompareDocumentAnnotationsChangedMessage) types.mainHighlightingType = ClangBackEnd::HighlightingType::Keyword; ClangBackEnd::TokenInfoContainer tokenInfo(1, 1, 1, types); - CompareMessage(ClangBackEnd::DocumentAnnotationsChangedMessage(fileContainer, - {diagnostic}, - {}, - {tokenInfo}, - QVector<ClangBackEnd::SourceRangeContainer>())); + CompareMessage(ClangBackEnd::AnnotationsMessage(fileContainer, + {diagnostic}, + {}, + {tokenInfo}, + QVector<ClangBackEnd::SourceRangeContainer>())); } -TEST_F(ReadAndWriteMessageBlock, CompareRegisterUnsavedFilesForEditorMessage) +TEST_F(ReadAndWriteMessageBlock, CompareUnsavedFilesUpdatedMessage) { - CompareMessage(ClangBackEnd::RegisterUnsavedFilesForEditorMessage({fileContainer})); + CompareMessage(ClangBackEnd::UnsavedFilesUpdatedMessage({fileContainer})); } -TEST_F(ReadAndWriteMessageBlock, CompareUnregisterUnsavedFilesForEditorMessage) +TEST_F(ReadAndWriteMessageBlock, CompareUnsavedFilesRemovedMessage) { - CompareMessage(ClangBackEnd::UnregisterUnsavedFilesForEditorMessage({fileContainer})); + CompareMessage(ClangBackEnd::UnsavedFilesRemovedMessage({fileContainer})); } -TEST_F(ReadAndWriteMessageBlock, CompareRequestDocumentAnnotations) +TEST_F(ReadAndWriteMessageBlock, CompareRequestAnnotationsMessage) { - CompareMessage(ClangBackEnd::RequestDocumentAnnotationsMessage(fileContainer)); + CompareMessage(ClangBackEnd::RequestAnnotationsMessage(fileContainer)); } -TEST_F(ReadAndWriteMessageBlock, CompareRequestReferences) +TEST_F(ReadAndWriteMessageBlock, CompareRequestReferencesMessage) { CompareMessage(ClangBackEnd::RequestReferencesMessage{fileContainer, 13, 37}); } -TEST_F(ReadAndWriteMessageBlock, CompareRequestFollowSymbol) +TEST_F(ReadAndWriteMessageBlock, CompareRequestFollowSymbolMessage) { CompareMessage(ClangBackEnd::RequestFollowSymbolMessage{fileContainer, 13, 37}); } -TEST_F(ReadAndWriteMessageBlock, CompareReferences) +TEST_F(ReadAndWriteMessageBlock, CompareReferencesMessage) { const QVector<ClangBackEnd::SourceRangeContainer> references{ true, @@ -280,7 +278,7 @@ TEST_F(ReadAndWriteMessageBlock, CompareReferences) TEST_F(ReadAndWriteMessageBlock, GetInvalidMessageForAPartialBuffer) { - writeCodeCompletedMessage(); + writeCompletionsMessage(); popLastCharacterFromBuffer(); buffer.seek(0); @@ -289,7 +287,7 @@ TEST_F(ReadAndWriteMessageBlock, GetInvalidMessageForAPartialBuffer) TEST_F(ReadAndWriteMessageBlock, ReadMessageAfterInterruption) { - const auto writeMessage = writeCodeCompletedMessage(); + const auto writeMessage = writeCompletionsMessage(); popLastCharacterFromBuffer(); buffer.seek(0); readPartialMessage(); @@ -298,9 +296,9 @@ TEST_F(ReadAndWriteMessageBlock, ReadMessageAfterInterruption) ASSERT_EQ(readMessageBlock.read(), writeMessage); } -ClangBackEnd::MessageEnvelop ReadAndWriteMessageBlock::writeCodeCompletedMessage() +ClangBackEnd::MessageEnvelop ReadAndWriteMessageBlock::writeCompletionsMessage() { - ClangBackEnd::CodeCompletedMessage message( + ClangBackEnd::CompletionsMessage message( ClangBackEnd::CodeCompletions({Utf8StringLiteral("newFunction()")}), ClangBackEnd::CompletionCorrection::NoCorrection, 1); diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index 622b9e00cd..88d5606250 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -117,7 +117,7 @@ SOURCES += \ clangjobs-test.cpp \ clangparsesupportivetranslationunitjob-test.cpp \ clangreferencescollector-test.cpp \ - clangrequestdocumentannotationsjob-test.cpp \ + clangrequestannotationsjob-test.cpp \ clangrequestreferencesjob-test.cpp \ clangresumedocumentjob-test.cpp \ clangstring-test.cpp \ @@ -126,7 +126,7 @@ SOURCES += \ clangtooltipinfo-test.cpp \ clangtranslationunits-test.cpp \ clangtranslationunit-test.cpp \ - clangupdatedocumentannotationsjob-test.cpp \ + clangupdateannotationsjob-test.cpp \ codecompleter-test.cpp \ codecompletionsextractor-test.cpp \ completionchunkstotextconverter-test.cpp \ |