diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp index cb8105a33a1..495f3c6ea3c 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp @@ -697,126 +697,6 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeInGeneratedUiFile( QVERIFY(hasItem(proposal, "setupUi")); } -void ClangCodeCompletionTest::testCompleteAfterModifyingIncludedHeaderInOtherEditor() -{ - QSKIP("We don't reparse anymore before a code completion so we get wrong completion results."); - - CppTools::Tests::TemporaryDir temporaryDir; - const TestDocument sourceDocument("mysource.cpp", &temporaryDir); - QVERIFY(sourceDocument.isCreatedAndHasValidCursorPosition()); - const TestDocument headerDocument("myheader.h", &temporaryDir); - QVERIFY(headerDocument.isCreated()); - - // Test that declarations from header file are visible in source file - OpenEditorAtCursorPosition openSource(sourceDocument); - QVERIFY(openSource.succeeded()); - TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - - // Open header and insert a new declaration - OpenEditorAtCursorPosition openHeader(headerDocument); - QVERIFY(openHeader.succeeded()); - insertTextAtTopOfEditor(openHeader.editor(), "int globalFromHeaderUnsaved;\n"); - - // Switch back to source file and check if modified header is reflected in completions. - Core::EditorManager::activateEditor(openSource.editor()); - QCoreApplication::processEvents(); // connections are queued - proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - QVERIFY(hasItem(proposal, "globalFromHeaderUnsaved")); -} - -void ClangCodeCompletionTest::testCompleteAfterModifyingIncludedHeaderByRefactoringActions() -{ - QSKIP("We don't reparse anymore before a code completion so we get wrong completion results."); - - CppTools::Tests::TemporaryDir temporaryDir; - const TestDocument sourceDocument("mysource.cpp", &temporaryDir); - QVERIFY(sourceDocument.isCreatedAndHasValidCursorPosition()); - const TestDocument headerDocument("myheader.h", &temporaryDir); - QVERIFY(headerDocument.isCreated()); - - // Open header - OpenEditorAtCursorPosition openHeader(headerDocument); - QVERIFY(openHeader.succeeded()); - - // Open source and test that declaration from header file is visible in source file - OpenEditorAtCursorPosition openSource(sourceDocument); - QVERIFY(openSource.succeeded()); - TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - - // Modify header document without switching to its editor. - // This simulates e.g. changes from refactoring actions. - ::Utils::ChangeSet cs; - cs.insert(0, QLatin1String("int globalFromHeaderUnsaved;\n")); - QTextCursor textCursor = openHeader.editor()->textCursor(); - cs.apply(&textCursor); - - // Check whether modified header is reflected in the completions. - proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - QVERIFY(hasItem(proposal, "globalFromHeaderUnsaved")); -} - -void ClangCodeCompletionTest::testCompleteAfterChangingIncludedAndOpenHeaderExternally() -{ - QSKIP("The file system watcher is doing it in backend process but we wait not long enough"); - - ChangeDocumentReloadSetting reloadSettingsChanger(Core::IDocument::ReloadUnmodified); - - CppTools::Tests::TemporaryDir temporaryDir; - const TestDocument sourceDocument("mysource.cpp", &temporaryDir); - QVERIFY(sourceDocument.isCreatedAndHasValidCursorPosition()); - const TestDocument headerDocument("myheader.h", &temporaryDir); - QVERIFY(headerDocument.isCreated()); - - // Open header - OpenEditorAtCursorPosition openHeader(headerDocument); - QVERIFY(openHeader.succeeded()); - - // Open source and test completions - OpenEditorAtCursorPosition openSource(sourceDocument); - QVERIFY(openSource.succeeded()); - TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - - // Simulate external modification and wait for reload - WriteFileAndWaitForReloadedDocument waitForReloadedDocument( - headerDocument.filePath, - "int globalFromHeaderReloaded;\n", - openHeader.editor()->document()); - QVERIFY(waitForReloadedDocument.wait()); - - // Retrigger completion and check if its updated - proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeaderReloaded")); -} - -void ClangCodeCompletionTest::testCompleteAfterChangingIncludedAndNotOpenHeaderExternally() -{ - QSKIP("The file system watcher is doing it in backend process but we wait not long enough"); - - CppTools::Tests::TemporaryDir temporaryDir; - const TestDocument sourceDocument("mysource.cpp", &temporaryDir); - QVERIFY(sourceDocument.isCreatedAndHasValidCursorPosition()); - const TestDocument headerDocument("myheader.h", &temporaryDir); - QVERIFY(headerDocument.isCreated()); - - // Open source and test completions - OpenEditorAtCursorPosition openSource(sourceDocument); - QVERIFY(openSource.succeeded()); - TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeader")); - - // Simulate external modification, e.g version control checkout - QVERIFY(writeFile(headerDocument.filePath, "int globalFromHeaderReloaded;\n")); - - // Retrigger completion and check if its updated - proposal = completionResults(openSource.editor()); - QVERIFY(hasItem(proposal, "globalFromHeaderReloaded")); -} - } // namespace Tests } // namespace Internal } // namespace ClangCodeModel diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h index b2013550cc3..f2b64048e83 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h @@ -54,11 +54,6 @@ private slots: void testCompleteProjectDependingCode(); void testCompleteProjectDependingCodeAfterChangingProject(); void testCompleteProjectDependingCodeInGeneratedUiFile(); - - void testCompleteAfterModifyingIncludedHeaderInOtherEditor(); - void testCompleteAfterModifyingIncludedHeaderByRefactoringActions(); - void testCompleteAfterChangingIncludedAndOpenHeaderExternally(); - void testCompleteAfterChangingIncludedAndNotOpenHeaderExternally(); }; } // namespace Tests