Commit 36ce1dbb authored by Nikolai Kosjar's avatar Nikolai Kosjar

Designer/CppTools: Fix flaky test_gotoslot_withoutProject

The document was not always updated in time.

Change-Id: Iac89985d39a8784e3cbf63dfd42b1c5150775068
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 8a1eed2c
......@@ -461,7 +461,7 @@ CppEditorSupport *CppModelManager::cppEditorSupport(TextEditor::BaseTextEditor *
QMutexLocker locker(&m_cppEditorSupportsMutex);
CppEditorSupport *editorSupport = m_cppEditorSupports.value(textEditor, 0);
if (!editorSupport) {
if (!editorSupport && isCppEditor(textEditor)) {
editorSupport = new CppEditorSupport(this, textEditor);
m_cppEditorSupports.insert(textEditor, editorSupport);
}
......
......@@ -308,6 +308,11 @@ void CppEditorSupport::updateDocumentNow()
}
}
bool CppEditorSupport::isUpdatingDocument()
{
return m_updateDocumentTimer->isActive() || m_documentParser.isRunning();
}
void CppEditorSupport::onDocumentUpdated(Document::Ptr doc)
{
if (doc.isNull())
......
......@@ -125,6 +125,9 @@ public:
QSharedPointer<SnapshotUpdater> snapshotUpdater();
/// Checks whether the document is (re)parsed or about to be (re)parsed.
bool isUpdatingDocument();
signals:
void documentUpdated();
void diagnosticsChanged();
......
......@@ -37,6 +37,7 @@
#include <coreplugin/testdatadir.h>
#include <coreplugin/editormanager/editormanager.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpptoolseditorsupport.h>
#include <cplusplus/CppDocument.h>
#include <cplusplus/Overview.h>
......@@ -91,8 +92,13 @@ public:
const QString functionName = QLatin1String("on_pushButton_clicked");
const QString qualifiedFunctionName = QLatin1String("Form::") + functionName;
foreach (const QString &file, files)
QVERIFY(EditorManager::openEditor(file));
QList<TextEditor::BaseTextEditor *> editors;
foreach (const QString &file, files) {
IEditor *editor = EditorManager::openEditor(file);
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
QVERIFY(e);
editors << e;
}
QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), files.size());
while (!m_modelManager->snapshot().contains(cppFile)
|| !m_modelManager->snapshot().contains(hFile)) {
......@@ -114,15 +120,21 @@ public:
QVERIFY(integration);
integration->emitNavigateToSlot(QLatin1String("pushButton"), QLatin1String("clicked()"),
QStringList());
QApplication::processEvents();
// Checks after
m_modelManager->updateSourceFiles(QStringList() << cppFile << hFile).waitForFinished();
QCOMPARE(EditorManager::currentDocument()->filePath(), cppFile);
QVERIFY(EditorManager::currentDocument()->isModified());
// Wait for updated documents
foreach (TextEditor::BaseTextEditor *editor, editors) {
if (CppEditorSupport *editorSupport = m_modelManager->cppEditorSupport(editor)) {
while (editorSupport->isUpdatingDocument())
QApplication::processEvents();
}
}
// Checks after
Document::Ptr cppDocumentAfter = m_modelManager->snapshot().document(cppFile);
QCOMPARE(cppDocumentAfter->globalSymbolCount(), 3U);
QVERIFY(containsSymbol(cppDocumentAfter->globalNamespace(), qualifiedFunctionName));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment