From 7b631d484d669d67dac97c1481873d988b617d38 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Wed, 16 Sep 2015 15:41:50 +0200 Subject: [PATCH] Clang: Add testUnsavedFilesTrackingByModifyingIncludedFileExternally2 Same test as the first version, but without having the header open in the editor. This one is also skipped since we can't make it reliable without adding extra messages. Follow up changes will improve the names of both tests and will make them both reliable so that the can be activated again. Change-Id: Ie3ca52e01aedd612bc07e7429dd64d92eb1a23b5 Reviewed-by: Marco Bubke --- .../test/clangcodecompletion_test.cpp | 24 +++++++++++++++++++ .../test/clangcodecompletion_test.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp index 9b938edaf86..80a8cfa7f7a 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.cpp @@ -1116,6 +1116,30 @@ void ClangCodeCompletionTest::testUnsavedFilesTrackingByModifyingIncludedFileExt QVERIFY(hasItem(proposal, "globalFromHeaderReloaded")); } +void ClangCodeCompletionTest::testUnsavedFilesTrackingByModifyingIncludedFileExternally2() +{ + 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()); + ProposalModel 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")); +} + void ClangCodeCompletionTest::testUnsavedFilesTrackingByCompletingUiObject() { CppTools::Tests::TemporaryCopiedDir testDir(qrcPath("qt-widgets-app")); diff --git a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h index 52ff5f172dc..f15c154eca6 100644 --- a/src/plugins/clangcodemodel/test/clangcodecompletion_test.h +++ b/src/plugins/clangcodemodel/test/clangcodecompletion_test.h @@ -65,6 +65,7 @@ private slots: void testUnsavedFilesTrackingByModifyingIncludedFileInCurrentEditor(); void testUnsavedFilesTrackingByModifyingIncludedFileInNotCurrentEditor(); void testUnsavedFilesTrackingByModifyingIncludedFileExternally(); + void testUnsavedFilesTrackingByModifyingIncludedFileExternally2(); void testUnsavedFilesTrackingByCompletingUiObject(); void testUpdateBackendAfterRestart();