forked from qt-creator/qt-creator
TextEditor: Replace PlainTextDocument by Base + a setup function
Change-Id: I1088062d0b74fd0dd69e92c55cc8bb80da61ae2d Reviewed-by: Christian Stenger <christian.stenger@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
@@ -100,7 +102,10 @@ public:
|
||||
QVERIFY(ast);
|
||||
|
||||
// Open file
|
||||
TextEditor::BaseTextEditorWidget editorWidget(new TextEditor::PlainTextDocument);
|
||||
auto textDocument = new TextEditor::BaseTextDocument;
|
||||
textDocument->setupAsPlainTextDocument();
|
||||
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
|
||||
TextEditor::BaseTextEditorWidget editorWidget(textDocument);
|
||||
editorWidget.setupAsPlainEditor();
|
||||
QString error;
|
||||
editorWidget.open(&error, document->fileName(), document->fileName());
|
||||
@@ -111,7 +116,7 @@ public:
|
||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
||||
editorWidget.setTextCursor(cursor);
|
||||
|
||||
QTextDocument *textDocument = editorWidget.document();
|
||||
QTextDocument *qtextDocument = editorWidget.document();
|
||||
CppRefactoringFilePtr cppRefactoringFile
|
||||
= CppRefactoringChanges::file(&editorWidget, document);
|
||||
|
||||
@@ -126,11 +131,11 @@ public:
|
||||
Utils::ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
|
||||
|
||||
// Apply change
|
||||
QTextCursor changeCursor(textDocument);
|
||||
QTextCursor changeCursor(qtextDocument);
|
||||
change.apply(&changeCursor);
|
||||
|
||||
// Compare
|
||||
QCOMPARE(textDocument->toPlainText(), expectedSource);
|
||||
QCOMPARE(qtextDocument->toPlainText(), expectedSource);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user