Merge remote-tracking branch 'origin/4.10'

Conflicts:
	src/plugins/baremetal/iarewtoolchain.cpp

Change-Id: I483e81d7e920e724fb7cde84a8f6fa9bce4cd518
This commit is contained in:
Eike Ziller
2019-07-25 09:38:09 +02:00
60 changed files with 227 additions and 257 deletions

View File

@@ -84,15 +84,6 @@ bool writeFile(const QString &filePath, const QByteArray &contents)
return true;
}
void insertTextAtTopOfEditor(TextEditor::BaseTextEditor *editor, const QByteArray &text)
{
QTC_ASSERT(editor, return);
::Utils::ChangeSet cs;
cs.insert(0, QString::fromUtf8(text));
QTextCursor textCursor = editor->textCursor();
cs.apply(&textCursor);
}
class ChangeDocumentReloadSetting
{
public:
@@ -697,126 +688,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

View File

@@ -54,11 +54,6 @@ private slots:
void testCompleteProjectDependingCode();
void testCompleteProjectDependingCodeAfterChangingProject();
void testCompleteProjectDependingCodeInGeneratedUiFile();
void testCompleteAfterModifyingIncludedHeaderInOtherEditor();
void testCompleteAfterModifyingIncludedHeaderByRefactoringActions();
void testCompleteAfterChangingIncludedAndOpenHeaderExternally();
void testCompleteAfterChangingIncludedAndNotOpenHeaderExternally();
};
} // namespace Tests