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 @@
#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 Internal {
namespace Tests {
......
......@@ -28,12 +28,13 @@
****************************************************************************/
#include "cppeditor.h"
#include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include <coreplugin/editormanager/editormanager.h>
#include <cplusplus/CppDocument.h>
#include <cppeditor/cppeditor.h>
#include <cppeditor/cppeditorplugin.h>
#include <cpptools/cppmodelmanagerinterface.h>
#include <cplusplus/CppDocument.h>
#include <utils/fileutils.h>
#include <QCoreApplication>
......@@ -58,46 +59,31 @@ typedef QByteArray _;
* Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result.
*/
struct TestCase
class TestCase : public CppEditor::Internal::Tests::TestCase
{
QByteArray originalText;
int pos;
CPPEditor *editor;
CPPEditorWidget *editorWidget;
public:
TestCase(const QByteArray &input);
~TestCase();
void run(const QByteArray &expected, int undoCount = 1);
private:
TestCase(const TestCase &);
TestCase &operator=(const TestCase &);
CppEditor::Internal::Tests::TestDocument testDocument;
};
/// The '|' in the input denotes the cursor position.
TestCase::TestCase(const QByteArray &input)
: originalText(input)
: testDocument("file.cpp", input, '|')
{
pos = originalText.indexOf('|');
QVERIFY(pos != -1);
originalText.remove(pos, 1);
QString fileName(QDir::tempPath() + QLatin1String("/file.cpp"));
Utils::FileSaver srcSaver(fileName);
srcSaver.write(originalText);
srcSaver.finalize();
QVERIFY(testDocument.hasCursorMarker());
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
QVERIFY(testDocument.writeToDisk());
// Update Code Model
CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
mmi->updateSourceFiles(QStringList(fileName)).waitForFinished();
QCoreApplication::processEvents();
QVERIFY(mmi->snapshot().contains(fileName));
QVERIFY(parseFiles(testDocument.filePath()));
// Open Editor
editor = dynamic_cast<CPPEditor *>(EditorManager::openEditor(fileName));
QVERIFY(editor);
editorWidget = dynamic_cast<CPPEditorWidget *>(editor->editorWidget());
QVERIFY(editorWidget);
QVERIFY(openCppEditor(testDocument.filePath(), &testDocument.m_editor,
&testDocument.m_editorWidget));
closeEditorAtEndOfTestCase(testDocument.m_editor);
// We want to test documents that start with a comment. By default, the
// editor will fold the very first comment it encounters, assuming
......@@ -105,39 +91,26 @@ TestCase::TestCase(const QByteArray &input)
// expected (some blocks are still hidden in some test cases, so the
// cursor movements are not as expected). For the time being, we just
// prepend a declaration before the initial test comment.
// editorWidget->unfoldAll();
editor->setCursorPosition(pos);
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
// testDocument.m_editorWidget->unfoldAll();
testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
// Remove the test file from the code-model
CppTools::CppModelManagerInterface *mmi = CppTools::CppModelManagerInterface::instance();
mmi->GC();
QCOMPARE(mmi->snapshot().size(), 0);
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
}
void TestCase::run(const QByteArray &expected, int undoCount)
{
// Send 'ENTER' key press
QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::sendEvent(editorWidget, &event);
const QByteArray result = editorWidget->document()->toPlainText().toUtf8();
QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
const QByteArray result = testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(QLatin1String(result), QLatin1String(expected));
for (int i = 0; i < undoCount; ++i)
editorWidget->undo();
const QByteArray contentsAfterUndo = editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, originalText);
testDocument.m_editorWidget->undo();
const QByteArray contentsAfterUndo
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
} // anonymous namespace
......
......@@ -67,9 +67,11 @@ RESOURCES += \
equals(TEST, 1) {
HEADERS += \
cppeditortestcase.h \
cppquickfix_test_utils.h
SOURCES += \
cppdoxygen_test.cpp \
cppeditortestcase.cpp \
cppincludehierarchy_test.cpp \
cppquickfix_test.cpp \
cppquickfix_test_utils.cpp \
......
......@@ -51,6 +51,7 @@ QtcPlugin {
condition: project.testsEnabled
files: [
"cppdoxygen_test.cpp",
"cppeditortestcase.cpp", "cppeditortestcase.h",
"cppincludehierarchy_test.cpp",
"cppquickfix_test.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 @@
****************************************************************************/
#include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include "cppincludehierarchymodel.h"
#include <coreplugin/editormanager/editormanager.h>
......@@ -44,12 +45,10 @@ using namespace CppEditor::Internal;
using namespace CppTools;
namespace {
class TestCase
class TestCase : public CppEditor::Internal::Tests::TestCase
{
public:
TestCase(const QList<QByteArray> &sourceList)
: m_cmm(CppModelManagerInterface::instance())
, m_editor(0)
{
QStringList filePaths;
const int sourceListSize = sourceList.size();
......@@ -59,48 +58,28 @@ public:
// Write source to file
const QString fileName = QString::fromLatin1("%1/file%2.h").arg(QDir::tempPath())
.arg(i+1);
Utils::FileSaver srcSaver(fileName);
srcSaver.write(source);
srcSaver.finalize();
QVERIFY(writeFile(fileName, source));
filePaths << fileName;
}
// Update Code Model
m_cmm->updateSourceFiles(filePaths).waitForFinished();
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());
QVERIFY(parseFiles(filePaths));
}
void run(int includesCount, int includedByCount)
{
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
m_editor = qobject_cast<CPPEditor *>(Core::EditorManager::openEditor(fileName));
QVERIFY(m_editor);
CPPEditor *editor;
QVERIFY(openCppEditor(fileName, &editor));
closeEditorAtEndOfTestCase(editor);
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(1, 0)), includedByCount);
}
private:
CppModelManagerInterface *m_cmm;
CPPEditor *m_editor;
};
}
......
......@@ -31,13 +31,14 @@
#include "cppeditor.h"
#include "cppeditorplugin.h"
#include "cppeditortestcase.h"
#include "cppquickfixassistant.h"
#include "cppquickfixes.h"
#include <cpptools/cppcodestylepreferences.h>
#include <cpptools/cppmodelmanager.h>
#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpppreprocessertesthelper.h>
#include <cpptools/cpppreprocessor.h>
#include <cpptools/cpptoolssettings.h>
#include <cpptools/includeutils.h>
......@@ -68,64 +69,39 @@ typedef QSharedPointer<TestDocument> TestDocumentPtr;
/**
* 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 document.
*/
class TestDocument
class TestDocument : public CppEditor::Internal::Tests::TestDocument
{
public:
TestDocument(const QByteArray &theOriginalSource, const QByteArray &theExpectedSource,
const QString &fileName)
: originalSource(theOriginalSource)
, expectedSource(theExpectedSource)
, 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
TestDocument(const QByteArray &fileName, const QByteArray &source,
const QByteArray &expectedSource)
: CppEditor::Internal::Tests::TestDocument(fileName, source)
, m_expectedSource(expectedSource)
{
if (!QFileInfo(fileName).isAbsolute())
return QDir::tempPath() + QLatin1Char('/') + fileName;
return fileName;
m_source.remove(m_cursorPosition, 1);
m_expectedSource.remove(expectedSource.indexOf(m_cursorMarker), 1);
}
void writeToDisk() const
static TestDocumentPtr create(const QByteArray &fileName, const QByteArray &source,
const QByteArray &expectedSource)
{
Utils::FileSaver srcSaver(filePath());
srcSaver.write(originalSource);
srcSaver.finalize();
return TestDocumentPtr(new TestDocument(fileName, source, expectedSource));
}
QByteArray originalSource;
QByteArray expectedSource;
bool changesExpected() const { return m_source != m_expectedSource; }
const QString fileName;
const int cursorMarkerPosition;
CPPEditor *editor;
CPPEditorWidget *editorWidget;
public:
QByteArray m_expectedSource;
};
/**
* Encapsulates the whole process of setting up an editor, getting the
* quick-fix, applying it, and checking the result.
*/
class TestCase
class TestCase : public CppEditor::Internal::Tests::TestCase
{
public:
TestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
......@@ -141,9 +117,6 @@ public:
void run(CppQuickFixFactory *factory, int resultIndex = 0);
private:
TestCase(const TestCase &);
TestCase &operator=(const TestCase &);
void init(const QStringList &includePaths);
private:
......@@ -171,7 +144,7 @@ TestCase::TestCase(const QByteArray &originalSource, const QByteArray &expectedS
const QStringList &includePaths)
: cppCodeStylePreferences(0), restoreIncludePaths(false)
{
testFiles << TestDocument::create(originalSource, expectedSource, QLatin1String("file.cpp"));
testFiles << TestDocument::create("file.cpp", originalSource, expectedSource);
init(includePaths);
}
......@@ -187,7 +160,7 @@ void TestCase::init(const QStringList &includePaths)
// Check if there is exactly one cursor marker
unsigned cursorMarkersCount = 0;
foreach (const TestDocumentPtr testFile, testFiles) {
if (testFile->hasCursorMarkerPosition())
if (testFile->hasCursorMarker())
++cursorMarkersCount;
}
QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed.");
......@@ -196,45 +169,31 @@ void TestCase::init(const QStringList &includePaths)
foreach (TestDocumentPtr testFile, testFiles)
testFile->writeToDisk();
CppTools::Internal::CppModelManager *cmm = CppTools::Internal::CppModelManager::instance();
// Set appropriate include paths
if (!includePaths.isEmpty()) {
restoreIncludePaths = true;
includePathsToRestore = cmm->includePaths();
cmm->setIncludePaths(includePaths);
includePathsToRestore = m_modelManager->includePaths();
m_modelManager->setIncludePaths(includePaths);
}
// Update Code Model
QStringList filePaths;
foreach (const TestDocumentPtr &testFile, testFiles)
filePaths << testFile->filePath();
cmm->updateSourceFiles(filePaths).waitForFinished();
QCoreApplication::processEvents();
const Snapshot snapshot = cmm->snapshot();
QVERIFY(!snapshot.isEmpty());
foreach (const QString &filePath, filePaths)
QVERIFY(snapshot.contains(filePath));
QVERIFY(parseFiles(filePaths));
// Open Files
foreach (TestDocumentPtr testFile, testFiles) {
testFile->editor
= dynamic_cast<CPPEditor *>(EditorManager::openEditor(testFile->filePath()));
QVERIFY(testFile->editor);
QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor, &testFile->m_editorWidget));
closeEditorAtEndOfTestCase(testFile->m_editor);
// Set cursor position
const int cursorPosition = testFile->hasCursorMarkerPosition()
? testFile->cursorMarkerPosition : 0;
testFile->editor->setCursorPosition(cursorPosition);
testFile->editorWidget = dynamic_cast<CPPEditorWidget *>(testFile->editor->editorWidget());
QVERIFY(testFile->editorWidget);
const int cursorPosition = testFile->hasCursorMarker()
? testFile->m_cursorPosition : 0;
testFile->m_editor->setCursorPosition(cursorPosition);
// Rehighlight
testFile->editorWidget->semanticRehighlight(true);
// Wait for the semantic info from the future
while (testFile->editorWidget->semanticInfo().doc.isNull())
QCoreApplication::processEvents();
waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
}
// Enforce the default cpp code style, so we are independent of config file settings.
......@@ -251,23 +210,9 @@ TestCase::~TestCase()
if (cppCodeStylePreferences)
cppCodeStylePreferences->setCurrentDelegate(cppCodeStylePreferencesOriginalDelegateId);
// Close editors
QList<Core::IEditor *> editorsToClose;
foreach (const TestDocumentPtr testFile, testFiles) {
if (testFile->editor)
editorsToClose << testFile->editor;
}
EditorManager::closeEditors(editorsToClose, false);
QCoreApplication::processEvents(); // process any pending events
// Remove the test files from the code-model
CppModelManagerInterface *mmi = CppModelManagerInterface::instance();
mmi->GC();
QCOMPARE(mmi->snapshot().size(), 0);
// Restore include paths
if (restoreIncludePaths)
CppTools::Internal::CppModelManager::instance()->setIncludePaths(includePathsToRestore);
m_modelManager->setIncludePaths(includePathsToRestore);
// Remove created files from file system
foreach (const TestDocumentPtr &testDocument, testFiles)
......@@ -299,12 +244,12 @@ void TestCase::run(CppQuickFixFactory *factory, int resultIndex)
// Run the fix in the file having the cursor marker
TestDocumentPtr testFile;
foreach (const TestDocumentPtr file, testFiles) {
if (file->hasCursorMarkerPosition())
if (file->hasCursorMarker())
testFile = file;
}
QVERIFY2(testFile, "No test file with cursor marker found");
if (QuickFixOperation::Ptr fix = getFix(factory, testFile->editorWidget, resultIndex))
if (QuickFixOperation::Ptr fix = getFix(factory, testFile->m_editorWidget, resultIndex))
fix->perform();
else
qDebug() << "Quickfix was not triggered";
......@@ -312,15 +257,15 @@ void TestCase::run(CppQuickFixFactory *factory, int resultIndex)
// Compare all files
foreach (const TestDocumentPtr testFile, testFiles) {
// Check
QByteArray result = testFile->editorWidget->document()->toPlainText().toUtf8();
QByteArray result = testFile->m_editorWidget->document()->toPlainText().toUtf8();
removeTrailingWhitespace(result);
QCOMPARE(QLatin1String(result), QLatin1String(testFile->expectedSource));
QCOMPARE(QLatin1String(result), QLatin1String(testFile->m_expectedSource));
// Undo the change
for (int i = 0; i < 100; ++i)
testFile->editorWidget->undo();
result = testFile->editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(result, testFile->originalSource);
testFile->m_editorWidget->undo();
result = testFile->m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(result, testFile->m_source);
}
}
......@@ -1280,7 +1225,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
" void setIt(int value);\n"
"};\n"
"}\n\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
......@@ -1300,7 +1245,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
" it = value;\n"
"}\n\n"
"}\n\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
testFiles << TestDocument::create("file.cpp", original, expected);
GenerateGetterSetter factory;
TestCase data(testFiles);
......@@ -1334,7 +1279,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
"{\n\n}\n"
"\n"
"class Bar {};\n\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
......@@ -1344,7 +1289,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
"{\n\n"
"}\n";
expected = original + "\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
TestCase data(testFiles);
......@@ -1367,7 +1312,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
" Foo()@;\n"
"};\n";
expected = original + "\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
testFiles << TestDocument::create("file.h", original, expected);
// Source File
original.resize(0);
......@@ -1378,7 +1323,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
"}\n"
"\n"
;
testFiles << TestDocument::create(original, expected, QLatin1String("file.cpp"));
testFiles << TestDocument::create("file.cpp", original, expected);
InsertDefFromDecl factory;
TestCase data(testFiles);
......@@ -1397,7 +1342,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
// Header File
original = "void f()@;\n";
expected = original + "\n";
testFiles << TestDocument::create(original, expected, QLatin1String("file.h"));
testFiles << TestDocument::create("file.h", original, expected);
// Source File
original =
......@@ -1417,7 +1362,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()