forked from qt-creator/qt-creator
CppEditor: Fix tests
Change-Id: I9e656bc13109603a877b3685c122c4d2a467fd62 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
#include <cplusplus/MatchingText.h>
|
#include <cplusplus/MatchingText.h>
|
||||||
|
|
||||||
#include <texteditor/tabsettings.h>
|
#include <texteditor/tabsettings.h>
|
||||||
|
#include <texteditor/syntaxhighlighterrunner.h>
|
||||||
|
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QTextCursor>
|
#include <QTextCursor>
|
||||||
@@ -182,14 +183,19 @@ static QChar closingChar(QChar c)
|
|||||||
return QChar();
|
return QChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
static QTextCursor openEditor(const QString &text)
|
static TextEditor::BaseTextEditor *creteCppEditor(const QString &text)
|
||||||
{
|
{
|
||||||
QTextCursor tc;
|
|
||||||
QString name(QLatin1String("auto_complete_test"));
|
QString name(QLatin1String("auto_complete_test"));
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
||||||
Constants::CPPEDITOR_ID, &name, text.toLocal8Bit());
|
Constants::CPPEDITOR_ID, &name, text.toLocal8Bit());
|
||||||
|
|
||||||
|
return qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
static QTextCursor openEditor(TextEditor::BaseTextEditor *cppEditor)
|
||||||
|
{
|
||||||
|
QTextCursor tc;
|
||||||
|
|
||||||
const auto cppEditor = qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
|
||||||
if (cppEditor == 0)
|
if (cppEditor == 0)
|
||||||
return tc;
|
return tc;
|
||||||
tc = cppEditor->editorWidget()->textCursor();
|
tc = cppEditor->editorWidget()->textCursor();
|
||||||
@@ -268,7 +274,12 @@ void AutoCompleterTest::testAutoComplete()
|
|||||||
QVERIFY(text.contains(QLatin1Char('|')));
|
QVERIFY(text.contains(QLatin1Char('|')));
|
||||||
|
|
||||||
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
||||||
QTextCursor tc = openEditor(text);
|
|
||||||
|
TextEditor::BaseTextEditor *cppEditor = creteCppEditor(text);
|
||||||
|
QVERIFY(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
QTextCursor tc = openEditor(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
|
||||||
QVERIFY(!tc.isNull());
|
QVERIFY(!tc.isNull());
|
||||||
|
|
||||||
@@ -327,7 +338,11 @@ void AutoCompleterTest::testSurroundWithSelection()
|
|||||||
QVERIFY(text.count(QLatin1Char('|')) == 2);
|
QVERIFY(text.count(QLatin1Char('|')) == 2);
|
||||||
|
|
||||||
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
||||||
QTextCursor tc = openEditor(text);
|
TextEditor::BaseTextEditor *cppEditor = creteCppEditor(text);
|
||||||
|
QVERIFY(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
QTextCursor tc = openEditor(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
|
||||||
QVERIFY(!tc.isNull());
|
QVERIFY(!tc.isNull());
|
||||||
|
|
||||||
@@ -360,7 +375,11 @@ void AutoCompleterTest::testAutoBackspace()
|
|||||||
QVERIFY(text.contains(QLatin1Char('|')));
|
QVERIFY(text.contains(QLatin1Char('|')));
|
||||||
|
|
||||||
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
||||||
QTextCursor tc = openEditor(text);
|
TextEditor::BaseTextEditor *cppEditor = creteCppEditor(text);
|
||||||
|
QVERIFY(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
QTextCursor tc = openEditor(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
|
||||||
QVERIFY(!tc.isNull());
|
QVERIFY(!tc.isNull());
|
||||||
|
|
||||||
@@ -400,7 +419,11 @@ void AutoCompleterTest::testInsertParagraph()
|
|||||||
QVERIFY(text.contains(QLatin1Char('|')));
|
QVERIFY(text.contains(QLatin1Char('|')));
|
||||||
|
|
||||||
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
const QScopeGuard cleanup([] { Core::EditorManager::closeAllEditors(false); });
|
||||||
QTextCursor tc = openEditor(text);
|
TextEditor::BaseTextEditor *cppEditor = creteCppEditor(text);
|
||||||
|
QVERIFY(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
QTextCursor tc = openEditor(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
|
||||||
QVERIFY(!tc.isNull());
|
QVERIFY(!tc.isNull());
|
||||||
|
|
||||||
|
@@ -8,10 +8,11 @@
|
|||||||
#include "cppmodelmanager.h"
|
#include "cppmodelmanager.h"
|
||||||
#include "cpptoolstestcase.h"
|
#include "cpptoolstestcase.h"
|
||||||
|
|
||||||
#include <texteditor/codeassist/iassistproposal.h>
|
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
#include <texteditor/textdocument.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <texteditor/codeassist/iassistproposal.h>
|
||||||
|
#include <texteditor/syntaxhighlighterrunner.h>
|
||||||
|
#include <texteditor/textdocument.h>
|
||||||
|
#include <texteditor/texteditor.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/changeset.h>
|
#include <utils/changeset.h>
|
||||||
@@ -61,6 +62,11 @@ public:
|
|||||||
// Open in editor
|
// Open in editor
|
||||||
m_editor = EditorManager::openEditor(filePath);
|
m_editor = EditorManager::openEditor(filePath);
|
||||||
QVERIFY(m_editor);
|
QVERIFY(m_editor);
|
||||||
|
|
||||||
|
TextEditor::BaseTextEditor *cppEditor = qobject_cast<TextEditor::BaseTextEditor *>(m_editor);
|
||||||
|
QVERIFY(cppEditor);
|
||||||
|
QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated());
|
||||||
|
|
||||||
closeEditorAtEndOfTestCase(m_editor);
|
closeEditorAtEndOfTestCase(m_editor);
|
||||||
m_editorWidget = TextEditorWidget::fromEditor(m_editor);
|
m_editorWidget = TextEditorWidget::fromEditor(m_editor);
|
||||||
QVERIFY(m_editorWidget);
|
QVERIFY(m_editorWidget);
|
||||||
|
Reference in New Issue
Block a user