Commit 5c8df5fa authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor/CppTools: Introduce Test{Case,Document}

Move common functionality of the 12 test classes into base classes.

Change-Id: If64d3cec876807ac6f991151189860a99b8ff4ca
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 5aa8a63f
...@@ -35,6 +35,14 @@ ...@@ -35,6 +35,14 @@
#include <QString> #include <QString>
#define QTC_DECLARE_MYTESTDATADIR(PATH) \
class MyTestDataDir : public Core::Internal::Tests::TestDataDir \
{ \
public: \
MyTestDataDir(const QString &testDataDirectory = QString()) \
: TestDataDir(QLatin1String(SRCDIR "/" PATH) + testDataDirectory) {} \
};
namespace Core { namespace Core {
namespace Internal { namespace Internal {
namespace Tests { namespace Tests {
......
...@@ -28,12 +28,13 @@ ...@@ -28,12 +28,13 @@
****************************************************************************/ ****************************************************************************/
#include "cppeditor.h" #include "cppeditor.h"
#include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
#include <cplusplus/CppDocument.h>
#include <cppeditor/cppeditor.h>
#include <cppeditor/cppeditorplugin.h>
#include <cpptools/cppmodelmanagerinterface.h> #include <cpptools/cppmodelmanagerinterface.h>
#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <QCoreApplication> #include <QCoreApplication>
...@@ -58,46 +59,31 @@ typedef QByteArray _; ...@@ -58,46 +59,31 @@ typedef QByteArray _;
* Encapsulates the whole process of setting up an editor, * Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result. * pressing ENTER and checking the result.
*/ */
struct TestCase class TestCase : public CppEditor::Internal::Tests::TestCase
{ {
QByteArray originalText; public:
int pos;
CPPEditor *editor;
CPPEditorWidget *editorWidget;
TestCase(const QByteArray &input); TestCase(const QByteArray &input);
~TestCase();
void run(const QByteArray &expected, int undoCount = 1); void run(const QByteArray &expected, int undoCount = 1);
private: private:
TestCase(const TestCase &); CppEditor::Internal::Tests::TestDocument testDocument;
TestCase &operator=(const TestCase &);
}; };
/// The '|' in the input denotes the cursor position. /// The '|' in the input denotes the cursor position.
TestCase::TestCase(const QByteArray &input) TestCase::TestCase(const QByteArray &input)
: originalText(input) : testDocument("file.cpp", input, '|')
{ {
pos = originalText.indexOf('|'); QVERIFY(testDocument.hasCursorMarker());
QVERIFY(pos != -1); testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
originalText.remove(pos, 1); QVERIFY(testDocument.writeToDisk());
QString fileName(QDir::tempPath() + QLatin1String("/file.cpp"));
Utils::FileSaver srcSaver(fileName);
srcSaver.write(originalText);
srcSaver.finalize();
// Update Code Model // Update Code Model
CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance(); QVERIFY(parseFiles(testDocument.filePath()));
mmi->updateSourceFiles(QStringList(fileName)).waitForFinished();
QCoreApplication::processEvents();
QVERIFY(mmi->snapshot().contains(fileName));
// Open Editor // Open Editor
editor = dynamic_cast<CPPEditor *>(EditorManager::openEditor(fileName)); QVERIFY(openCppEditor(testDocument.filePath(), &testDocument.m_editor,
QVERIFY(editor); &testDocument.m_editorWidget));
editorWidget = dynamic_cast<CPPEditorWidget *>(editor->editorWidget()); closeEditorAtEndOfTestCase(testDocument.m_editor);
QVERIFY(editorWidget);
// We want to test documents that start with a comment. By default, the // We want to test documents that start with a comment. By default, the
// editor will fold the very first comment it encounters, assuming // editor will fold the very first comment it encounters, assuming
...@@ -105,39 +91,26 @@ TestCase::TestCase(const QByteArray &input) ...@@ -105,39 +91,26 @@ TestCase::TestCase(const QByteArray &input)
// expected (some blocks are still hidden in some test cases, so the // expected (some blocks are still hidden in some test cases, so the
// cursor movements are not as expected). For the time being, we just // cursor movements are not as expected). For the time being, we just
// prepend a declaration before the initial test comment. // prepend a declaration before the initial test comment.
// editorWidget->unfoldAll(); // testDocument.m_editorWidget->unfoldAll();
editor->setCursorPosition(pos); testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
editorWidget->semanticRehighlight(true);
// Wait for the semantic info from the future:
while (editorWidget->semanticInfo().doc.isNull())
QCoreApplication::processEvents();
}
TestCase::~TestCase()
{
EditorManager::closeEditor(editor, false);
QCoreApplication::processEvents(); // process any pending events
// Remove the test file from the code-model waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
mmi->GC();
QCOMPARE(mmi->snapshot().size(), 0);
} }
void TestCase::run(const QByteArray &expected, int undoCount) void TestCase::run(const QByteArray &expected, int undoCount)
{ {
// Send 'ENTER' key press // Send 'ENTER' key press
QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::sendEvent(editorWidget, &event); QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
const QByteArray result = editorWidget->document()->toPlainText().toUtf8(); const QByteArray result = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(QLatin1String(result), QLatin1String(expected)); QCOMPARE(QLatin1String(result), QLatin1String(expected));
for (int i = 0; i < undoCount; ++i) for (int i = 0; i < undoCount; ++i)
editorWidget->undo(); testDocument.m_editorWidget->undo();
const QByteArray contentsAfterUndo = editorWidget->document()->toPlainText().toUtf8(); const QByteArray contentsAfterUndo
QCOMPARE(contentsAfterUndo, originalText); = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
} }
} // anonymous namespace } // anonymous namespace
......
...@@ -67,9 +67,11 @@ RESOURCES += \ ...@@ -67,9 +67,11 @@ RESOURCES += \
equals(TEST, 1) { equals(TEST, 1) {
HEADERS += \ HEADERS += \
cppeditortestcase.h \
cppquickfix_test_utils.h cppquickfix_test_utils.h
SOURCES += \ SOURCES += \
cppdoxygen_test.cpp \ cppdoxygen_test.cpp \
cppeditortestcase.cpp \
cppincludehierarchy_test.cpp \ cppincludehierarchy_test.cpp \
cppquickfix_test.cpp \ cppquickfix_test.cpp \
cppquickfix_test_utils.cpp \ cppquickfix_test_utils.cpp \
......
...@@ -51,6 +51,7 @@ QtcPlugin { ...@@ -51,6 +51,7 @@ QtcPlugin {
condition: project.testsEnabled condition: project.testsEnabled
files: [ files: [
"cppdoxygen_test.cpp", "cppdoxygen_test.cpp",
"cppeditortestcase.cpp", "cppeditortestcase.h",
"cppincludehierarchy_test.cpp", "cppincludehierarchy_test.cpp",
"cppquickfix_test.cpp", "cppquickfix_test.cpp",
"cppquickfix_test_utils.cpp", "cppquickfix_test_utils.cpp",
......
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cppeditortestcase.h"
#include "cppeditor.h"
#include <coreplugin/editormanager/editormanager.h>
#include <cplusplus/CppDocument.h>
#include <QDir>
namespace CppEditor {
namespace Internal {
namespace Tests {
TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
: CppTools::Tests::TestDocument(fileName, source, cursorMarker)
, m_cursorPosition(source.indexOf(m_cursorMarker))
, m_editor(0)
, m_editorWidget(0)
{
}
bool TestDocument::hasCursorMarker() const { return m_cursorPosition != -1; }
TestCase::TestCase(bool runGarbageCollector)
: CppTools::Tests::TestCase(runGarbageCollector)
{
}
TestCase::~TestCase()
{
}
bool TestCase::openCppEditor(const QString &fileName,
Internal::CPPEditor **editor,
Internal::CPPEditorWidget **editorWidget)
{
using namespace CppEditor::Internal;
if (CPPEditor *e = dynamic_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName))) {
if (editor)
*editor = e;
if (editorWidget) {
if (CPPEditorWidget *w = dynamic_cast<CPPEditorWidget *>(e->editorWidget())) {
*editorWidget = w;
return true;
} else {
return false; // no or wrong widget
}
} else {
return true; // ok since no widget requested
}
} else {
return false; // no or wrong editor
}
}
CPlusPlus::Document::Ptr TestCase::waitForRehighlightedSemanticDocument(
Internal::CPPEditorWidget *editorWidget)
{
editorWidget->semanticRehighlight(true);
while (editorWidget->semanticInfo().doc.isNull())
QCoreApplication::processEvents();
return editorWidget->semanticInfo().doc;
}
} // namespace Tests
} // namespace Internal
} // namespace CppEditor
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPEDITORTESTCASE_H
#define CPPEDITORTESTCASE_H
#include <cpptools/cpptoolstestcase.h>
namespace CppEditor {
namespace Internal {
class CPPEditor;
class CPPEditorWidget;
namespace Tests {
class TestDocument : public CppTools::Tests::TestDocument
{
public:
TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker = '@');
bool hasCursorMarker() const;
public:
int m_cursorPosition;
Internal::CPPEditor *m_editor;
Internal::CPPEditorWidget *m_editorWidget;
};
class TestCase : public CppTools::Tests::TestCase
{
public:
TestCase(bool runGarbageCollector = true);
~TestCase();
static bool openCppEditor(const QString &fileName,
Internal::CPPEditor **editor,
Internal::CPPEditorWidget **editorWidget = 0);
static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
Internal::CPPEditorWidget *editorWidget);
};
} // namespace Tests
} // namespace Internal
} // namespace CppEditor
#endif // CPPEDITORTESTCASE_H
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
****************************************************************************/ ****************************************************************************/
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include "cppincludehierarchymodel.h" #include "cppincludehierarchymodel.h"
#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/editormanager.h>
...@@ -44,12 +45,10 @@ using namespace CppEditor::Internal; ...@@ -44,12 +45,10 @@ using namespace CppEditor::Internal;
using namespace CppTools; using namespace CppTools;
namespace { namespace {
class TestCase class TestCase : public CppEditor::Internal::Tests::TestCase
{ {
public: public:
TestCase(const QList<QByteArray> &sourceList) TestCase(const QList<QByteArray> &sourceList)
: m_cmm(CppModelManagerInterface::instance())
, m_editor(0)
{ {
QStringList filePaths; QStringList filePaths;
const int sourceListSize = sourceList.size(); const int sourceListSize = sourceList.size();
...@@ -59,48 +58,28 @@ public: ...@@ -59,48 +58,28 @@ public:
// Write source to file // Write source to file
const QString fileName = QString::fromLatin1("%1/file%2.h").arg(QDir::tempPath()) const QString fileName = QString::fromLatin1("%1/file%2.h").arg(QDir::tempPath())
.arg(i+1); .arg(i+1);
Utils::FileSaver srcSaver(fileName); QVERIFY(writeFile(fileName, source));
srcSaver.write(source);
srcSaver.finalize();
filePaths << fileName; filePaths << fileName;
} }
// Update Code Model // Update Code Model
m_cmm->updateSourceFiles(filePaths).waitForFinished(); QVERIFY(parseFiles(filePaths));
QCoreApplication::processEvents();
const Snapshot snapshot = m_cmm->snapshot();
QVERIFY(!snapshot.isEmpty());
foreach (const QString &filePath, filePaths)
QVERIFY(snapshot.contains(filePath));
}
~TestCase()
{
// Close editor
if (m_editor)
Core::EditorManager::closeEditor(m_editor, false);
m_cmm->GC();
QVERIFY(m_cmm->snapshot().isEmpty());
} }
void run(int includesCount, int includedByCount) void run(int includesCount, int includedByCount)
{ {
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h"); const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
m_editor = qobject_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName)); CPPEditor *editor;
QVERIFY(m_editor); QVERIFY(openCppEditor(fileName, &editor));
closeEditorAtEndOfTestCase(editor);
CppIncludeHierarchyModel model(0); CppIncludeHierarchyModel model(0);
model.buildHierarchy(m_editor, fileName); model.buildHierarchy(editor, fileName);
QCOMPARE(model.rowCount(model.index(0, 0)), includesCount); QCOMPARE(model.rowCount(model.index(0, 0)), includesCount);
QCOMPARE(model.rowCount(model.index(1, 0)), includedByCount); QCOMPARE(model.rowCount(model.index(1, 0)), includedByCount);
} }
private:
CppModelManagerInterface *m_cmm;
CPPEditor *m_editor;
}; };
} }
......
...@@ -31,13 +31,14 @@ ...@@ -31,13 +31,14 @@
#include "cppeditor.h" #include "cppeditor.h"
#include "cppeditorplugin.h" #include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include "cppquickfixassistant.h" #include "cppquickfixassistant.h"
#include "cppquickfixes.h" #include "cppquickfixes.h"
#include <cpptools/cppcodestylepreferences.h> #include <cpptools/cppcodestylepreferences.h>
#include <cpptools/cppmodelmanager.h> #include <cpptools/cppmodelmanager.h>
#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpppreprocessertesthelper.h> #include <cpptools/cpppreprocessertesthelper.h>
#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpptoolssettings.h> #include <cpptools/cpptoolssettings.h>
#include <cpptools/includeutils.h> #include <cpptools/includeutils.h>
...@@ -68,64 +69,39 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr; ...@@ -68,64 +69,39 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
/** /**
* Represents a test document before and after applying the quick fix. * Represents a test document before and after applying the quick fix.
* *
* A TestDocument's originalSource may contain an '@' character to denote * A TestDocument's source may contain an '@' character to denote
* the cursor position. This marker is removed before the Editor reads * the cursor position. This marker is removed before the Editor reads
* the document. * the document.
*/ */
class TestDocument class TestDocument : public CppEditor::Internal::Tests::TestDocument
{ {
public: public:
TestDocument(const QByteArray &theOriginalSource, const QByteArray &theExpectedSource, TestDocument(const QByteArray &fileName, const QByteArray &source,
const QString &fileName) const QByteArray &expectedSource)
: originalSource(theOriginalSource) : CppEditor::Internal::Tests::TestDocument(fileName, source)
, expectedSource(theExpectedSource) , m_expectedSource(expectedSource)
, fileName(fileName)
, cursorMarkerPosition(theOriginalSource.indexOf('@'))
, editor(0)
, editorWidget(0)
{
originalSource.remove(cursorMarkerPosition, 1);
expectedSource.remove(theExpectedSource.indexOf('@'), 1);
}
static TestDocumentPtr create(const QByteArray &theOriginalSource,
const QByteArray &theExpectedSource,const QString &fileName)
{
return TestDocumentPtr(new TestDocument(theOriginalSource, theExpectedSource, fileName));
}
bool hasCursorMarkerPosition() const { return cursorMarkerPosition != -1; }
bool changesExpected() const { return originalSource != expectedSource; }
QString filePath() const
{ {
if (!QFileInfo(fileName).isAbsolute()) m_source.remove(m_cursorPosition, 1);
return QDir::tempPath() + QLatin1Char('/') + fileName; m_expectedSource.remove(expectedSource.indexOf(m_cursorMarker), 1);
return fileName;
} }
void writeToDisk() const static TestDocumentPtr create(const QByteArray &fileName, const QByteArray &source,
const QByteArray &expectedSource)
{ {
Utils::FileSaver srcSaver(filePath()); return TestDocumentPtr(new TestDocument(fileName, source, expectedSource));
srcSaver.write(originalSource);
srcSaver.finalize();
} }
QByteArray originalSource; bool changesExpected() const { return m_source != m_expectedSource; }
QByteArray expectedSource;
const QString fileName; public:
const int cursorMarkerPosition; QByteArray m_expectedSource;
CPPEditor *editor;
CPPEditorWidget *editorWidget;
}; };
/** /**
* Encapsulates the whole process of setting up an editor, getting the * Encapsulates the whole process of setting up an editor, getting the
* quick-fix, applying it, and checking the result. * quick-fix, applying it, and checking the result.
*/ */
class TestCase class TestCase : public CppEditor::Internal::Tests::TestCase
{ {
public: public:
TestCase(const QByteArray &originalSource, const QByteArray &expectedSource, TestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
...@@ -141,9 +117,6 @@ public: ...@@ -141,9 +117,6 @@ public:
void run(CppQuickFixFactory *factory, int resultIndex = 0); void run(CppQuickFixFactory *factory, int resultIndex = 0);
private: private:
TestCase(const TestCase &);
TestCase &operator=(const TestCase &);
void init(const QStringList &includePaths); void init(const QStringList &includePaths);
private: private:
...@@ -171,7 +144,7 @@ TestCase::TestCase(const QByteArray &originalSource, const QByteArray &expectedS ...@@ -171,7 +144,7 @@ TestCase::TestCase(const QByteArray &originalSource, const QByteArray &expectedS
const QStringList &includePaths) const QStringList &includePaths)
: cppCodeStylePreferences(0), restoreIncludePaths(false) : cppCodeStylePreferences(0), restoreIncludePaths(false)
{ {
testFiles << TestDocument::create(originalSource, expectedSource, QLatin1String("file.cpp")); testFiles << TestDocument::create("file.cpp", originalSource, expectedSource);
init(includePaths); init(includePaths);
} }
...@@ -187,7 +160,7 @@ void TestCase::init(const QStringList &includePaths) ...@@ -187,7 +160,7 @@ void TestCase::init(const QStringList &includePaths)
// Check if there is exactly one cursor marker // Check if there is exactly one cursor marker
unsigned cursorMarkersCount = 0; unsigned cursorMarkersCount = 0;
foreach (const TestDocumentPtr testFile, testFiles) { foreach (const TestDocumentPtr testFile, testFiles) {
if (testFile->hasCursorMarkerPosition()) if (testFile->hasCursorMarker())
++cursorMarkersCount; ++cursorMarkersCount;
} }
QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed."); QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed.");
...@@ -196,45 +169,31 @@ void TestCase::init(const QStringList &includePaths) ...@@ -196,45 +169,31 @@ void TestCase::init(const QStringList &includePaths)
foreach (TestDocumentPtr testFile, testFiles) foreach (TestDocumentPtr testFile, testFiles)
testFile->writeToDisk(); testFile->writeToDisk();
CppTools::Internal::CppModelManager *cmm = CppTools::Internal::CppModelManager::instance();
// Set appropriate include paths // Set appropriate include paths
if (!includePaths.isEmpty()) { if (!includePaths.isEmpty()) {
restoreIncludePaths = true; restoreIncludePaths = true;
includePathsToRestore = cmm->includePaths(); includePathsToRestore = m_modelManager->includePaths();
cmm->setIncludePaths(includePaths); m_modelManager->setIncludePaths(includePaths);
} }
// Update Code Model // Update Code Model
QStringList filePaths; QStringList filePaths;
foreach (const TestDocumentPtr &testFile, testFiles) foreach (const TestDocumentPtr &testFile, testFiles)
filePaths << testFile->filePath(); filePaths << testFile->filePath();
cmm->updateSourceFiles(filePaths).waitForFinished(); QVERIFY(parseFiles(filePaths));
QCoreApplication::processEvents();
const Snapshot snapshot = cmm->snapshot();
QVERIFY(!snapshot.isEmpty());
foreach (const QString &filePath, filePaths)
QVERIFY(snapshot.contains(filePath));
// Open Files // Open Files
foreach (TestDocumentPtr testFile, testFiles) { foreach (TestDocumentPtr testFile, testFiles) {
testFile->editor QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor, &testFile->m_editorWidget));
= dynamic_cast<CPPEditor *>(EditorManager::openEditor(testFile->filePath())); closeEditorAtEndOfTestCase(testFile->m_editor);
QVERIFY(testFile->editor);
// Set cursor position // Set cursor position
const int cursorPosition = testFile->hasCursorMarkerPosition() const int cursorPosition = testFile->hasCursorMarker()
? testFile->cursorMarkerPosition : 0; ? testFile->m_cursorPosition : 0;
testFile->editor->setCursorPosition(cursorPosition); testFile->m_editor->setCursorPosition(cursorPosition);
testFile->editorWidget = dynamic_cast<CPPEditorWidget *>(testFile->editor->editorWidget());
QVERIFY(testFile->editorWidget);
// Rehighlight // Rehighlight
testFile->editorWidget->semanticRehighlight(true); waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
// Wait for the semantic info from the future
while (testFile->editorWidget->semanticInfo().doc.isNull())
QCoreApplication::processEvents();