TextEditor: Fix failure in cpptools autotest

The issue only appeared in the test due to the different
editor construction there. Now use the same factory access.

Change-Id: I3a8534fbe683bb88f04ad68850cecdfe32b11433
Reviewed-by: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
hjk
2014-08-27 11:19:04 +02:00
parent 59f1ffd9d2
commit 7b67701dea
7 changed files with 38 additions and 37 deletions

View File

@@ -35,6 +35,7 @@
#include <coreplugin/coreconstants.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/plaintexteditorfactory.h>
#include <utils/fileutils.h>
@@ -102,23 +103,20 @@ public:
QVERIFY(ast);
// Open file
TextEditor::BaseTextDocumentPtr textDocument(new TextEditor::BaseTextDocument);
textDocument->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID);
TextEditor::BaseTextEditorWidget editorWidget(0);
editorWidget.setTextDocument(textDocument);
editorWidget.setupAsPlainEditor();
TextEditor::BaseTextEditor *editor = TextEditor::PlainTextEditorFactory::createPlainTextEditor();
TextEditor::BaseTextEditorWidget *editorWidget = editor->editorWidget();
QString error;
editorWidget.open(&error, document->fileName(), document->fileName());
editor->open(&error, document->fileName(), document->fileName());
QVERIFY(error.isEmpty());
// Set cursor position
QTextCursor cursor = editorWidget.textCursor();
QTextCursor cursor = editorWidget->textCursor();
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
editorWidget.setTextCursor(cursor);
editorWidget->setTextCursor(cursor);
QTextDocument *qtextDocument = editorWidget.document();
QTextDocument *qtextDocument = editorWidget->document();
CppRefactoringFilePtr cppRefactoringFile
= CppRefactoringChanges::file(&editorWidget, document);
= CppRefactoringChanges::file(editorWidget, document);
// Prepare for formatting
Overview overview;