forked from qt-creator/qt-creator
CppEditor/CppTools: Don't continue in test function on failure
QVERIFY/QCOMPARE are meant to be called in the test function so that on failure they just can "return" and thus skip subsequent code. Since we use reusable test code in the test functions (the *TestCase classes), we need to ensure that on failure no further test code is executed. This mostly inlines the run function of the test classes into the constructor. Change-Id: I320ee032bdde0174ddfe3fdf3f9e18e19abf1d7f Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -62,17 +62,12 @@ typedef QByteArray _;
|
|||||||
class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
|
class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DoxygenTestCase(const QByteArray &input);
|
/// The '|' in the input denotes the cursor position.
|
||||||
void run(const QByteArray &expected);
|
DoxygenTestCase(const QByteArray &original, const QByteArray &expected)
|
||||||
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
private:
|
CppEditor::Internal::Tests::TestDocument testDocument("file.cpp", original, '|');
|
||||||
CppEditor::Internal::Tests::TestDocument testDocument;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// The '|' in the input denotes the cursor position.
|
|
||||||
DoxygenTestCase::DoxygenTestCase(const QByteArray &input)
|
|
||||||
: testDocument("file.cpp", input, '|')
|
|
||||||
{
|
|
||||||
QVERIFY(testDocument.hasCursorMarker());
|
QVERIFY(testDocument.hasCursorMarker());
|
||||||
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
|
testDocument.m_source.remove(testDocument.m_cursorPosition, 1);
|
||||||
QVERIFY(testDocument.writeToDisk());
|
QVERIFY(testDocument.writeToDisk());
|
||||||
@@ -91,14 +86,11 @@ DoxygenTestCase::DoxygenTestCase(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.
|
||||||
// testDocument.m_editorWidget->unfoldAll();
|
// testDocument.m_editorWidget->unfoldAll();
|
||||||
testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
|
testDocument.m_editor->setCursorPosition(testDocument.m_cursorPosition);
|
||||||
|
|
||||||
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
|
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
|
||||||
}
|
|
||||||
|
|
||||||
void DoxygenTestCase::run(const QByteArray &expected)
|
|
||||||
{
|
|
||||||
// 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(testDocument.m_editorWidget, &event);
|
QCoreApplication::sendEvent(testDocument.m_editorWidget, &event);
|
||||||
@@ -110,7 +102,8 @@ void DoxygenTestCase::run(const QByteArray &expected)
|
|||||||
const QByteArray contentsAfterUndo
|
const QByteArray contentsAfterUndo
|
||||||
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
|
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
|
||||||
QCOMPARE(contentsAfterUndo, testDocument.m_source);
|
QCOMPARE(contentsAfterUndo, testDocument.m_source);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
@@ -257,6 +250,5 @@ void CppEditorPlugin::test_doxygen_comments()
|
|||||||
{
|
{
|
||||||
QFETCH(QByteArray, given);
|
QFETCH(QByteArray, given);
|
||||||
QFETCH(QByteArray, expected);
|
QFETCH(QByteArray, expected);
|
||||||
DoxygenTestCase test(given);
|
DoxygenTestCase(given, expected);
|
||||||
test.run(expected);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,12 @@ namespace {
|
|||||||
class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase
|
class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IncludeHierarchyTestCase(const QList<QByteArray> &sourceList)
|
IncludeHierarchyTestCase(const QList<QByteArray> &sourceList,
|
||||||
|
int includesCount,
|
||||||
|
int includedByCount)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
const int sourceListSize = sourceList.size();
|
const int sourceListSize = sourceList.size();
|
||||||
for (int i = 0; i < sourceListSize; ++i) {
|
for (int i = 0; i < sourceListSize; ++i) {
|
||||||
@@ -66,16 +70,14 @@ public:
|
|||||||
|
|
||||||
// Update Code Model
|
// Update Code Model
|
||||||
QVERIFY(parseFiles(filePaths));
|
QVERIFY(parseFiles(filePaths));
|
||||||
}
|
|
||||||
|
|
||||||
void run(int includesCount, int includedByCount)
|
// Open Editor
|
||||||
{
|
|
||||||
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
|
const QString fileName = QDir::tempPath() + QLatin1String("/file1.h");
|
||||||
|
|
||||||
CPPEditor *editor;
|
CPPEditor *editor;
|
||||||
QVERIFY(openCppEditor(fileName, &editor));
|
QVERIFY(openCppEditor(fileName, &editor));
|
||||||
closeEditorAtEndOfTestCase(editor);
|
closeEditorAtEndOfTestCase(editor);
|
||||||
|
|
||||||
|
// Test model
|
||||||
CppIncludeHierarchyModel model(0);
|
CppIncludeHierarchyModel model(0);
|
||||||
model.buildHierarchy(editor, fileName);
|
model.buildHierarchy(editor, fileName);
|
||||||
QCOMPARE(model.rowCount(model.index(0, 0)), includesCount);
|
QCOMPARE(model.rowCount(model.index(0, 0)), includesCount);
|
||||||
@@ -91,8 +93,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
|
|||||||
sourceList.append(QByteArray("#include \"file2.h\"\n"));
|
sourceList.append(QByteArray("#include \"file2.h\"\n"));
|
||||||
sourceList.append(QByteArray());
|
sourceList.append(QByteArray());
|
||||||
|
|
||||||
IncludeHierarchyTestCase testCase(sourceList);
|
IncludeHierarchyTestCase(sourceList, 1, 0);
|
||||||
testCase.run(1, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
|
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
|
||||||
@@ -101,8 +102,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
|
|||||||
sourceList.append(QByteArray());
|
sourceList.append(QByteArray());
|
||||||
sourceList.append(QByteArray("#include \"file1.h\"\n"));
|
sourceList.append(QByteArray("#include \"file1.h\"\n"));
|
||||||
|
|
||||||
IncludeHierarchyTestCase testCase(sourceList);
|
IncludeHierarchyTestCase(sourceList, 0, 1);
|
||||||
testCase.run(0, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
|
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
|
||||||
@@ -112,6 +112,5 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
|
|||||||
sourceList.append(QByteArray());
|
sourceList.append(QByteArray());
|
||||||
sourceList.append(QByteArray("#include \"file1.h\"\n"));
|
sourceList.append(QByteArray("#include \"file1.h\"\n"));
|
||||||
|
|
||||||
IncludeHierarchyTestCase testCase(sourceList);
|
IncludeHierarchyTestCase(sourceList, 1, 1);
|
||||||
testCase.run(1, 1);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,6 +97,11 @@ public:
|
|||||||
QByteArray m_expectedSource;
|
QByteArray m_expectedSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QList<TestDocumentPtr> singleDocument(const QByteArray &original, const QByteArray &expected)
|
||||||
|
{
|
||||||
|
return QList<TestDocumentPtr>() << TestDocument::create("file.cpp", original, expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
@@ -104,19 +109,15 @@ public:
|
|||||||
class QuickFixTestCase : public CppEditor::Internal::Tests::TestCase
|
class QuickFixTestCase : public CppEditor::Internal::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QuickFixTestCase(const QByteArray &originalSource, const QByteArray &expectedSource,
|
|
||||||
const QStringList &includePaths = QStringList());
|
|
||||||
QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
|
QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
|
||||||
const QStringList &includePaths = QStringList());
|
CppQuickFixFactory *factory,
|
||||||
|
const QStringList &includePaths = QStringList(),
|
||||||
|
int resultIndex = 0);
|
||||||
~QuickFixTestCase();
|
~QuickFixTestCase();
|
||||||
|
|
||||||
void run(CppQuickFixFactory *factory, int resultIndex = 0);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TestDocumentPtr testFileWithCursorMarker() const;
|
|
||||||
QuickFixOperation::Ptr getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget,
|
QuickFixOperation::Ptr getFix(CppQuickFixFactory *factory, CPPEditorWidget *editorWidget,
|
||||||
int resultIndex = 0);
|
int resultIndex = 0);
|
||||||
void init(const QStringList &includePaths);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<TestDocumentPtr> m_testFiles;
|
QList<TestDocumentPtr> m_testFiles;
|
||||||
@@ -139,29 +140,38 @@ QuickFixOperation::Ptr QuickFixTestCase::getFix(CppQuickFixFactory *factory,
|
|||||||
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
|
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
|
/// Leading whitespace is not removed, so we can check if the indetation ranges
|
||||||
QuickFixTestCase::QuickFixTestCase(const QByteArray &originalSource,
|
/// have been set correctly by the quick-fix.
|
||||||
const QByteArray &expectedSource,
|
QByteArray &removeTrailingWhitespace(QByteArray &input)
|
||||||
const QStringList &includePaths)
|
|
||||||
: m_cppCodeStylePreferences(0)
|
|
||||||
, m_restoreIncludePaths(false)
|
|
||||||
{
|
{
|
||||||
m_testFiles << TestDocument::create("file.cpp", originalSource, expectedSource);
|
QList<QByteArray> lines = input.split('\n');
|
||||||
init(includePaths);
|
input.resize(0);
|
||||||
|
foreach (QByteArray line, lines) {
|
||||||
|
while (line.length() > 0) {
|
||||||
|
char lastChar = line[line.length() - 1];
|
||||||
|
if (lastChar == ' ' || lastChar == '\t')
|
||||||
|
line = line.left(line.length() - 1);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
input.append(line);
|
||||||
|
input.append('\n');
|
||||||
|
}
|
||||||
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
|
||||||
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
|
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
|
||||||
QuickFixTestCase::QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
|
QuickFixTestCase::QuickFixTestCase(const QList<TestDocumentPtr> theTestFiles,
|
||||||
const QStringList &includePaths)
|
CppQuickFixFactory *factory,
|
||||||
|
const QStringList &includePaths,
|
||||||
|
int resultIndex)
|
||||||
: m_testFiles(theTestFiles)
|
: m_testFiles(theTestFiles)
|
||||||
, m_cppCodeStylePreferences(0)
|
, m_cppCodeStylePreferences(0)
|
||||||
, m_restoreIncludePaths(false)
|
, m_restoreIncludePaths(false)
|
||||||
{
|
{
|
||||||
init(includePaths);
|
QVERIFY(succeededSoFar());
|
||||||
}
|
|
||||||
|
|
||||||
void QuickFixTestCase::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, m_testFiles) {
|
foreach (const TestDocumentPtr testFile, m_testFiles) {
|
||||||
@@ -208,45 +218,7 @@ void QuickFixTestCase::init(const QStringList &includePaths)
|
|||||||
QVERIFY(m_cppCodeStylePreferences);
|
QVERIFY(m_cppCodeStylePreferences);
|
||||||
m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
|
m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
|
||||||
m_cppCodeStylePreferences->setCurrentDelegate("qt");
|
m_cppCodeStylePreferences->setCurrentDelegate("qt");
|
||||||
}
|
|
||||||
|
|
||||||
QuickFixTestCase::~QuickFixTestCase()
|
|
||||||
{
|
|
||||||
// Restore default cpp code style
|
|
||||||
if (m_cppCodeStylePreferences)
|
|
||||||
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
|
|
||||||
|
|
||||||
// Restore include paths
|
|
||||||
if (m_restoreIncludePaths)
|
|
||||||
m_modelManager->setIncludePaths(m_includePathsToRestore);
|
|
||||||
|
|
||||||
// Remove created files from file system
|
|
||||||
foreach (const TestDocumentPtr &testDocument, m_testFiles)
|
|
||||||
QVERIFY(QFile::remove(testDocument->filePath()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Leading whitespace is not removed, so we can check if the indetation ranges
|
|
||||||
/// have been set correctly by the quick-fix.
|
|
||||||
QByteArray &removeTrailingWhitespace(QByteArray &input)
|
|
||||||
{
|
|
||||||
QList<QByteArray> lines = input.split('\n');
|
|
||||||
input.resize(0);
|
|
||||||
foreach (QByteArray line, lines) {
|
|
||||||
while (line.length() > 0) {
|
|
||||||
char lastChar = line[line.length() - 1];
|
|
||||||
if (lastChar == ' ' || lastChar == '\t')
|
|
||||||
line = line.left(line.length() - 1);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
input.append(line);
|
|
||||||
input.append('\n');
|
|
||||||
}
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickFixTestCase::run(CppQuickFixFactory *factory, int resultIndex)
|
|
||||||
{
|
|
||||||
// Run the fix in the file having the cursor marker
|
// Run the fix in the file having the cursor marker
|
||||||
TestDocumentPtr testFile;
|
TestDocumentPtr testFile;
|
||||||
foreach (const TestDocumentPtr file, m_testFiles) {
|
foreach (const TestDocumentPtr file, m_testFiles) {
|
||||||
@@ -275,6 +247,21 @@ void QuickFixTestCase::run(CppQuickFixFactory *factory, int resultIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QuickFixTestCase::~QuickFixTestCase()
|
||||||
|
{
|
||||||
|
// Restore default cpp code style
|
||||||
|
if (m_cppCodeStylePreferences)
|
||||||
|
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
|
||||||
|
|
||||||
|
// Restore include paths
|
||||||
|
if (m_restoreIncludePaths)
|
||||||
|
m_modelManager->setIncludePaths(m_includePathsToRestore);
|
||||||
|
|
||||||
|
// Remove created files from file system
|
||||||
|
foreach (const TestDocumentPtr &testDocument, m_testFiles)
|
||||||
|
QVERIFY(QFile::remove(testDocument->filePath()));
|
||||||
|
}
|
||||||
|
|
||||||
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
|
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
|
||||||
class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory
|
class AddIncludeForUndefinedIdentifierTestFactory : public CppQuickFixFactory
|
||||||
{
|
{
|
||||||
@@ -1200,8 +1187,7 @@ void CppEditorPlugin::test_quickfix()
|
|||||||
|
|
||||||
if (expected.isEmpty())
|
if (expected.isEmpty())
|
||||||
expected = original + '\n';
|
expected = original + '\n';
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), factory.data());
|
||||||
test.run(factory.data());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
|
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
|
||||||
@@ -1254,8 +1240,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
GenerateGetterSetter factory;
|
GenerateGetterSetter factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if definition is inserted right after class for insert definition outside
|
/// Check if definition is inserted right after class for insert definition outside
|
||||||
@@ -1298,8 +1283,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory, QStringList(), 1);
|
||||||
test.run(&factory, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from header file: If there is a source file, insert the definition in the source file.
|
/// Check from header file: If there is a source file, insert the definition in the source file.
|
||||||
@@ -1332,8 +1316,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from header file: If there is a source file, insert the definition in the source file.
|
/// Check from header file: If there is a source file, insert the definition in the source file.
|
||||||
@@ -1371,8 +1354,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from source file: Insert in source file, not header file.
|
/// Check from source file: Insert in source file, not header file.
|
||||||
@@ -1403,8 +1385,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from header file: If the class is in a namespace, the added function definition
|
/// Check from header file: If the class is in a namespace, the added function definition
|
||||||
@@ -1439,8 +1420,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from header file: If the class is in namespace N and the source file has a
|
/// Check from header file: If the class is in namespace N and the source file has a
|
||||||
@@ -1479,8 +1459,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check definition insert inside class
|
/// Check definition insert inside class
|
||||||
@@ -1498,8 +1477,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
|
|||||||
"};\n";
|
"};\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory, QStringList(), 1);
|
||||||
test.run(&factory, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check not triggering when definition exists
|
/// Check not triggering when definition exists
|
||||||
@@ -1513,8 +1491,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
|
|||||||
const QByteArray expected = original + "\n";
|
const QByteArray expected = original + "\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase test(singleDocument(original, expected), &factory, QStringList(), 1);
|
||||||
test.run(&factory, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find right implementation file.
|
/// Find right implementation file.
|
||||||
@@ -1565,8 +1542,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
|
|||||||
testFiles << TestDocument::create("file2.cpp", original, expected);
|
testFiles << TestDocument::create("file2.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ignore generated functions declarations when looking at the surrounding
|
/// Ignore generated functions declarations when looking at the surrounding
|
||||||
@@ -1622,8 +1598,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
|
|||||||
testFiles << TestDocument::create("file2.cpp", original, expected);
|
testFiles << TestDocument::create("file2.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -1648,8 +1623,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1(
|
|||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -1674,8 +1648,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2(
|
|||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a function like macro use is not separated by the function to insert
|
/// Check if a function like macro use is not separated by the function to insert
|
||||||
@@ -1718,8 +1691,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a function like macro use is not separated by the function to insert
|
/// Check if a function like macro use is not separated by the function to insert
|
||||||
@@ -1760,8 +1732,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if insertion happens before syntactically erroneous statements at end of file.
|
/// Check if insertion happens before syntactically erroneous statements at end of file.
|
||||||
@@ -1799,8 +1770,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Respect rvalue references
|
/// Check: Respect rvalue references
|
||||||
@@ -1829,8 +1799,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_rvalueReference()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function for one of InsertDeclDef section cases
|
// Function for one of InsertDeclDef section cases
|
||||||
@@ -1867,8 +1836,7 @@ void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDeclFromDef factory;
|
InsertDeclFromDef factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory, QStringList(), sectionIndex);
|
||||||
test.run(&factory, sectionIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from source file: Insert in header file.
|
/// Check from source file: Insert in header file.
|
||||||
@@ -2076,8 +2044,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_normal()
|
|||||||
|
|
||||||
// Do not use the test factory, at least once we want to go through the "full stack".
|
// Do not use the test factory, at least once we want to go through the "full stack".
|
||||||
AddIncludeForUndefinedIdentifier factory;
|
AddIncludeForUndefinedIdentifier factory;
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Ignore *.moc includes
|
/// Check: Ignore *.moc includes
|
||||||
@@ -2103,8 +2070,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_ignoremoc()
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include at top for a sorted group
|
/// Check: Insert include at top for a sorted group
|
||||||
@@ -2130,8 +2096,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingTop(
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include in the middle for a sorted group
|
/// Check: Insert include in the middle for a sorted group
|
||||||
@@ -2157,8 +2122,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingMidd
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include at bottom for a sorted group
|
/// Check: Insert include at bottom for a sorted group
|
||||||
@@ -2184,8 +2148,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_sortingBott
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: For an unsorted group the new include is appended
|
/// Check: For an unsorted group the new include is appended
|
||||||
@@ -2211,8 +2174,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_appendToUns
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert a local include at front if there are only global includes
|
/// Check: Insert a local include at front if there are only global includes
|
||||||
@@ -2239,8 +2201,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstLocalI
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert a global include at back if there are only local includes
|
/// Check: Insert a global include at back if there are only local includes
|
||||||
@@ -2270,8 +2231,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_firstGlobal
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Prefer group with longest matching prefix
|
/// Check: Prefer group with longest matching prefix
|
||||||
@@ -2301,8 +2261,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_preferGroup
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Create a new include group if there are only include groups with a different include dir
|
/// Check: Create a new include group if there are only include groups with a different include dir
|
||||||
@@ -2329,8 +2288,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_newGroupIfO
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include dirs, sorted --> insert properly
|
/// Check: Include group with mixed include dirs, sorted --> insert properly
|
||||||
@@ -2358,8 +2316,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsSo
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include dirs, unsorted --> append
|
/// Check: Include group with mixed include dirs, unsorted --> append
|
||||||
@@ -2387,8 +2344,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedDirsUn
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2414,8 +2370,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2441,8 +2396,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2468,8 +2422,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2495,8 +2448,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_mixedInclud
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert very first include
|
/// Check: Insert very first include
|
||||||
@@ -2520,8 +2472,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_noinclude()
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert very first include if there is a c++ style comment on top
|
/// Check: Insert very first include if there is a c++ style comment on top
|
||||||
@@ -2551,8 +2502,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert very first include if there is a c style comment on top
|
/// Check: Insert very first include if there is a c style comment on top
|
||||||
@@ -2586,8 +2536,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_veryFirstIn
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase test(testFiles, QStringList(TestIncludePaths::globalIncludePath()));
|
QuickFixTestCase(testFiles, &factory, QStringList(TestIncludePaths::globalIncludePath()));
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: If a "Qt Class" was not found by the locator, check the header files in the Qt
|
/// Check: If a "Qt Class" was not found by the locator, check the header files in the Qt
|
||||||
@@ -2612,8 +2561,8 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_checkQSomet
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifier factory;
|
AddIncludeForUndefinedIdentifier factory;
|
||||||
QuickFixTestCase test(testFiles, QStringList(CppTools::Tests::TestIncludePaths::globalQtCoreIncludePath()));
|
QuickFixTestCase(testFiles,&factory,
|
||||||
test.run(&factory);
|
QStringList(CppTools::Tests::TestIncludePaths::globalQtCoreIncludePath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition from header to cpp.
|
/// Check: Move definition from header to cpp.
|
||||||
@@ -2656,8 +2605,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
||||||
@@ -2703,8 +2651,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class
|
/// Check: Move definition outside class
|
||||||
@@ -2738,8 +2685,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside1()
|
|||||||
"void Foo::f4() {}\n\n";
|
"void Foo::f4() {}\n\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class
|
/// Check: Move definition outside class
|
||||||
@@ -2781,8 +2727,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory, QStringList(), 1);
|
||||||
test.run(&factory, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition from header to cpp (with namespace).
|
/// Check: Move definition from header to cpp (with namespace).
|
||||||
@@ -2825,8 +2770,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition from header to cpp (with namespace + using).
|
/// Check: Move definition from header to cpp (with namespace + using).
|
||||||
@@ -2871,8 +2815,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class with Namespace
|
/// Check: Move definition outside class with Namespace
|
||||||
@@ -2899,8 +2842,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
|||||||
"\n}\n";
|
"\n}\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move free function from header to cpp.
|
/// Check: Move free function from header to cpp.
|
||||||
@@ -2936,8 +2878,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move free function from header to cpp (with namespace).
|
/// Check: Move free function from header to cpp (with namespace).
|
||||||
@@ -2977,8 +2918,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9157).
|
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9157).
|
||||||
@@ -3018,8 +2958,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization1()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9462).
|
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9462).
|
||||||
@@ -3064,8 +3003,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization2()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if definition is inserted right after class for move definition outside
|
/// Check if definition is inserted right after class for move definition outside
|
||||||
@@ -3107,8 +3045,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory, QStringList(), 1);
|
||||||
test.run(&factory, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -3130,8 +3067,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1
|
|||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -3153,8 +3089,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2
|
|||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
||||||
@@ -3186,8 +3121,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutside()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutside()
|
||||||
@@ -3213,8 +3147,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutside()
|
|||||||
"\n\n\n";
|
"\n\n\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
||||||
@@ -3254,8 +3187,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNS()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
||||||
@@ -3299,8 +3231,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNSUsing()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
||||||
@@ -3327,8 +3258,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutsideWithNs()
|
|||||||
"};\n\n\n}\n\n";
|
"};\n\n\n}\n\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
||||||
@@ -3360,8 +3290,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCpp()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
||||||
@@ -3399,8 +3328,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_CtorWithInitialization()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_CtorWithInitialization()
|
||||||
@@ -3439,8 +3367,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_CtorWithInitialization()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
|
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
|
||||||
@@ -3466,8 +3393,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable
|
|||||||
"} bar;\n\n\n";
|
"} bar;\n\n\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
|
void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
|
||||||
@@ -3504,8 +3430,7 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
AssignToLocalVariable factory;
|
AssignToLocalVariable factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction_data()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction_data()
|
||||||
@@ -3569,8 +3494,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles()
|
||||||
@@ -3596,8 +3520,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separ
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles()
|
||||||
@@ -3631,8 +3554,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
|
|||||||
testFiles << TestDocument::create("file.cpp", original, expected);
|
testFiles << TestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(InsertVirtualMethodsDialog::ImplementationMode)
|
Q_DECLARE_METATYPE(InsertVirtualMethodsDialog::ImplementationMode)
|
||||||
@@ -3937,8 +3859,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(
|
InsertVirtualMethods factory(
|
||||||
new InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
|
new InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
|
||||||
QuickFixTestCase test(original, expected);
|
QuickFixTestCase(singleDocument(original, expected), &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert in implementation file
|
/// Check: Insert in implementation file
|
||||||
@@ -3984,8 +3905,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
|
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
|
||||||
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Qualified names.
|
/// Check: Qualified names.
|
||||||
@@ -4037,6 +3957,5 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
|
InsertVirtualMethods factory(new InsertVirtualMethodsDialogTest(
|
||||||
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
||||||
QuickFixTestCase test(testFiles);
|
QuickFixTestCase(testFiles, &factory);
|
||||||
test.run(&factory);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,11 +97,9 @@ public:
|
|||||||
typedef QList<ActionPointer> Actions;
|
typedef QList<ActionPointer> Actions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestActionsTestCase();
|
|
||||||
|
|
||||||
/// Run the given fileActions for each file and the given tokenActions for each token.
|
/// Run the given fileActions for each file and the given tokenActions for each token.
|
||||||
/// The cursor is positioned on the very first character of each token.
|
/// The cursor is positioned on the very first character of each token.
|
||||||
void run(const Actions &tokenActions = Actions(),
|
TestActionsTestCase(const Actions &tokenActions = Actions(),
|
||||||
const Actions &fileActions = Actions());
|
const Actions &fileActions = Actions());
|
||||||
|
|
||||||
/// Simulate pressing ESC, which will close popups, search results pane, etc...
|
/// Simulate pressing ESC, which will close popups, search results pane, etc...
|
||||||
@@ -136,13 +134,16 @@ bool TestActionsTestCase::allProjectsConfigured = false;
|
|||||||
typedef TestActionsTestCase::Actions Actions;
|
typedef TestActionsTestCase::Actions Actions;
|
||||||
typedef TestActionsTestCase::ActionPointer ActionPointer;
|
typedef TestActionsTestCase::ActionPointer ActionPointer;
|
||||||
|
|
||||||
TestActionsTestCase::TestActionsTestCase()
|
Actions singleAction(const ActionPointer &action)
|
||||||
: CppEditor::Internal::Tests::TestCase(/*runGarbageCollector=*/false)
|
|
||||||
{
|
{
|
||||||
|
return Actions() << action;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestActionsTestCase::run(const Actions &tokenActions, const Actions &fileActions)
|
TestActionsTestCase::TestActionsTestCase(const Actions &tokenActions, const Actions &fileActions)
|
||||||
|
: CppEditor::Internal::Tests::TestCase(/*runGarbageCollector=*/false)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
// Collect files to process
|
// Collect files to process
|
||||||
QStringList filesToOpen;
|
QStringList filesToOpen;
|
||||||
QList<QPointer<ProjectExplorer::Project> > projects;
|
QList<QPointer<ProjectExplorer::Project> > projects;
|
||||||
@@ -516,88 +517,51 @@ void SwitchHeaderSourceFileAction::run(CPPEditorWidget *)
|
|||||||
|
|
||||||
void CppEditorPlugin::test_openEachFile()
|
void CppEditorPlugin::test_openEachFile()
|
||||||
{
|
{
|
||||||
TestActionsTestCase test;
|
TestActionsTestCase();
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_switchHeaderSourceOnEachFile()
|
void CppEditorPlugin::test_switchHeaderSourceOnEachFile()
|
||||||
{
|
{
|
||||||
Actions fileActions;
|
TestActionsTestCase(Actions(), singleAction(ActionPointer(new SwitchHeaderSourceFileAction)));
|
||||||
fileActions << ActionPointer(new SwitchHeaderSourceFileAction);
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(Actions(), fileActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFile()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFile()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new NoOpTokenAction)));
|
||||||
tokenActions << ActionPointer(new NoOpTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// May block if file does not exists (e.g. a not generated ui_* file).
|
/// May block if file does not exists (e.g. a not generated ui_* file).
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFollowSymbol()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFollowSymbol()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new FollowSymbolUnderCursorTokenAction)));
|
||||||
tokenActions << ActionPointer(new FollowSymbolUnderCursorTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new SwitchDeclarationDefinitionTokenAction)));
|
||||||
tokenActions << ActionPointer(new SwitchDeclarationDefinitionTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFindUsages()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFindUsages()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new FindUsagesTokenAction)));
|
||||||
tokenActions << ActionPointer(new FindUsagesTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndRenameUsages()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndRenameUsages()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new RenameSymbolUnderCursorTokenAction)));
|
||||||
tokenActions << ActionPointer(new RenameSymbolUnderCursorTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndOpenTypeHierarchy()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndOpenTypeHierarchy()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new OpenTypeHierarchyTokenAction)));
|
||||||
tokenActions << ActionPointer(new OpenTypeHierarchyTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndInvokeCompletion()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndInvokeCompletion()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new InvokeCompletionTokenAction)));
|
||||||
tokenActions << ActionPointer(new InvokeCompletionTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes()
|
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes()
|
||||||
{
|
{
|
||||||
Actions tokenActions;
|
TestActionsTestCase(singleAction(ActionPointer(new RunAllQuickFixesTokenAction)));
|
||||||
tokenActions << ActionPointer(new RunAllQuickFixesTokenAction());
|
|
||||||
|
|
||||||
TestActionsTestCase test;
|
|
||||||
test.run(tokenActions);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,6 +206,11 @@ public:
|
|||||||
int m_targetCursorPosition;
|
int m_targetCursorPosition;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QList<TestDocumentPtr> singleDocument(const QByteArray &source)
|
||||||
|
{
|
||||||
|
return QList<TestDocumentPtr>() << TestDocument::create(source, "file.cpp");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the whole process of setting up several editors, positioning the cursor,
|
* Encapsulates the whole process of setting up several editors, positioning the cursor,
|
||||||
* executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition
|
* executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition
|
||||||
@@ -219,71 +224,45 @@ public:
|
|||||||
SwitchBetweenMethodDeclarationDefinitionAction
|
SwitchBetweenMethodDeclarationDefinitionAction
|
||||||
};
|
};
|
||||||
|
|
||||||
F2TestCase(CppEditorAction action, const QByteArray &source,
|
F2TestCase(CppEditorAction action,
|
||||||
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
|
const QList<TestDocumentPtr> testFiles,
|
||||||
F2TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
|
|
||||||
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
|
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
|
||||||
|
|
||||||
void run();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
static TestDocumentPtr testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles);
|
||||||
|
static TestDocumentPtr testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles);
|
||||||
TestDocumentPtr testFileWithInitialCursorMarker();
|
|
||||||
TestDocumentPtr testFileWithTargetCursorMarker();
|
|
||||||
|
|
||||||
private:
|
|
||||||
CppEditorAction m_action;
|
|
||||||
QList<TestDocumentPtr> m_testFiles;
|
|
||||||
OverrideItemList m_expectedVirtualFunctionProposal;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Convenience function for creating a TestDocument.
|
|
||||||
/// See TestDocument.
|
|
||||||
F2TestCase::F2TestCase(CppEditorAction action,
|
|
||||||
const QByteArray &source,
|
|
||||||
const OverrideItemList &expectedVirtualFunctionProposal)
|
|
||||||
: m_action(action)
|
|
||||||
, m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
|
|
||||||
{
|
|
||||||
m_testFiles << TestDocument::create(source, "file.cpp");
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a test case with multiple test files.
|
/// Creates a test case with multiple test files.
|
||||||
/// Exactly one test document must be provided that contains '@', the initial position marker.
|
/// Exactly one test document must be provided that contains '@', the initial position marker.
|
||||||
/// Exactly one test document must be provided that contains '$', the target position marker.
|
/// Exactly one test document must be provided that contains '$', the target position marker.
|
||||||
/// It can be the same document.
|
/// It can be the same document.
|
||||||
F2TestCase::F2TestCase(CppEditorAction action,
|
F2TestCase::F2TestCase(CppEditorAction action,
|
||||||
const QList<TestDocumentPtr> theTestFiles,
|
const QList<TestDocumentPtr> testFiles,
|
||||||
const OverrideItemList &expectedVirtualFunctionProposal)
|
const OverrideItemList &expectedVirtualFunctionProposal)
|
||||||
: m_action(action)
|
|
||||||
, m_testFiles(theTestFiles)
|
|
||||||
, m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
|
|
||||||
{
|
{
|
||||||
init();
|
QVERIFY(succeededSoFar());
|
||||||
}
|
|
||||||
|
|
||||||
void F2TestCase::init()
|
|
||||||
{
|
|
||||||
// Check if there are initial and target position markers
|
// Check if there are initial and target position markers
|
||||||
QVERIFY2(testFileWithInitialCursorMarker(),
|
TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker(testFiles);
|
||||||
|
QVERIFY2(initialTestFile,
|
||||||
"No test file with initial cursor marker is provided.");
|
"No test file with initial cursor marker is provided.");
|
||||||
QVERIFY2(testFileWithTargetCursorMarker(),
|
TestDocumentPtr targetTestFile = testFileWithTargetCursorMarker(testFiles);
|
||||||
|
QVERIFY2(targetTestFile,
|
||||||
"No test file with target cursor marker is provided.");
|
"No test file with target cursor marker is provided.");
|
||||||
|
|
||||||
// Write files to disk
|
// Write files to disk
|
||||||
foreach (TestDocumentPtr testFile, m_testFiles)
|
foreach (TestDocumentPtr testFile, testFiles)
|
||||||
QVERIFY(testFile->writeToDisk());
|
QVERIFY(testFile->writeToDisk());
|
||||||
|
|
||||||
// Update Code Model
|
// Update Code Model
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
foreach (const TestDocumentPtr &testFile, m_testFiles)
|
foreach (const TestDocumentPtr &testFile, testFiles)
|
||||||
filePaths << testFile->filePath();
|
filePaths << testFile->filePath();
|
||||||
QVERIFY(parseFiles(filePaths));
|
QVERIFY(parseFiles(filePaths));
|
||||||
|
|
||||||
// Open Files
|
// Open Files
|
||||||
foreach (TestDocumentPtr testFile, m_testFiles) {
|
foreach (TestDocumentPtr testFile, testFiles) {
|
||||||
QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
|
QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
|
||||||
&testFile->m_editorWidget));
|
&testFile->m_editorWidget));
|
||||||
closeEditorAtEndOfTestCase(testFile->m_editor);
|
closeEditorAtEndOfTestCase(testFile->m_editor);
|
||||||
@@ -300,32 +279,6 @@ void F2TestCase::init()
|
|||||||
// Rehighlight
|
// Rehighlight
|
||||||
waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
|
waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker()
|
|
||||||
{
|
|
||||||
foreach (const TestDocumentPtr testFile, m_testFiles) {
|
|
||||||
if (testFile->hasCursorMarker())
|
|
||||||
return testFile;
|
|
||||||
}
|
|
||||||
return TestDocumentPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker()
|
|
||||||
{
|
|
||||||
foreach (const TestDocumentPtr testFile, m_testFiles) {
|
|
||||||
if (testFile->hasTargetCursorMarker())
|
|
||||||
return testFile;
|
|
||||||
}
|
|
||||||
return TestDocumentPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
void F2TestCase::run()
|
|
||||||
{
|
|
||||||
TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker();
|
|
||||||
QVERIFY(initialTestFile);
|
|
||||||
TestDocumentPtr targetTestFile = testFileWithTargetCursorMarker();
|
|
||||||
QVERIFY(targetTestFile);
|
|
||||||
|
|
||||||
// Activate editor of initial test file
|
// Activate editor of initial test file
|
||||||
EditorManager::activateEditor(initialTestFile->m_editor);
|
EditorManager::activateEditor(initialTestFile->m_editor);
|
||||||
@@ -338,7 +291,7 @@ void F2TestCase::run()
|
|||||||
OverrideItemList finalVirtualSymbolResults;
|
OverrideItemList finalVirtualSymbolResults;
|
||||||
|
|
||||||
// Trigger the action
|
// Trigger the action
|
||||||
switch (m_action) {
|
switch (action) {
|
||||||
case FollowSymbolUnderCursorAction: {
|
case FollowSymbolUnderCursorAction: {
|
||||||
CPPEditorWidget *widget = initialTestFile->m_editorWidget;
|
CPPEditorWidget *widget = initialTestFile->m_editorWidget;
|
||||||
FollowSymbolUnderCursor *delegate = widget->followSymbolUnderCursorDelegate();
|
FollowSymbolUnderCursor *delegate = widget->followSymbolUnderCursorDelegate();
|
||||||
@@ -385,12 +338,30 @@ void F2TestCase::run()
|
|||||||
// qDebug() << immediateVirtualSymbolResults;
|
// qDebug() << immediateVirtualSymbolResults;
|
||||||
// qDebug() << finalVirtualSymbolResults;
|
// qDebug() << finalVirtualSymbolResults;
|
||||||
OverrideItemList expectedImmediate;
|
OverrideItemList expectedImmediate;
|
||||||
if (!m_expectedVirtualFunctionProposal.isEmpty()) {
|
if (!expectedVirtualFunctionProposal.isEmpty()) {
|
||||||
expectedImmediate << m_expectedVirtualFunctionProposal.first();
|
expectedImmediate << expectedVirtualFunctionProposal.first();
|
||||||
expectedImmediate << OverrideItem(QLatin1String("...searching overrides"));
|
expectedImmediate << OverrideItem(QLatin1String("...searching overrides"));
|
||||||
}
|
}
|
||||||
QCOMPARE(immediateVirtualSymbolResults, expectedImmediate);
|
QCOMPARE(immediateVirtualSymbolResults, expectedImmediate);
|
||||||
QCOMPARE(finalVirtualSymbolResults, m_expectedVirtualFunctionProposal);
|
QCOMPARE(finalVirtualSymbolResults, expectedVirtualFunctionProposal);
|
||||||
|
}
|
||||||
|
|
||||||
|
TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles)
|
||||||
|
{
|
||||||
|
foreach (const TestDocumentPtr testFile, testFiles) {
|
||||||
|
if (testFile->hasCursorMarker())
|
||||||
|
return testFile;
|
||||||
|
}
|
||||||
|
return TestDocumentPtr();
|
||||||
|
}
|
||||||
|
|
||||||
|
TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles)
|
||||||
|
{
|
||||||
|
foreach (const TestDocumentPtr testFile, testFiles) {
|
||||||
|
if (testFile->hasTargetCursorMarker())
|
||||||
|
return testFile;
|
||||||
|
}
|
||||||
|
return TestDocumentPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -492,8 +463,7 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition()
|
|||||||
<< TestDocument::create(header, "file.h")
|
<< TestDocument::create(header, "file.h")
|
||||||
<< TestDocument::create(source, "file.cpp");
|
<< TestDocument::create(source, "file.cpp");
|
||||||
|
|
||||||
F2TestCase test(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
|
F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
||||||
@@ -853,8 +823,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
|||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor()
|
||||||
{
|
{
|
||||||
QFETCH(QByteArray, source);
|
QFETCH(QByteArray, source);
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
|
||||||
@@ -881,9 +850,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
|
|||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()
|
||||||
{
|
{
|
||||||
QFETCH(QList<TestDocumentPtr>, documents);
|
QFETCH(QList<TestDocumentPtr>, documents);
|
||||||
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, documents);
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, documents);
|
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect_data()
|
||||||
@@ -972,8 +939,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data()
|
||||||
@@ -996,8 +962,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken
|
|||||||
"}\n";
|
"}\n";
|
||||||
if (toDeclaration)
|
if (toDeclaration)
|
||||||
source.replace('@', '#').replace('$', '@').replace('#', '$');
|
source.replace('@', '#').replace('$', '@').replace('#', '$');
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_data()
|
||||||
@@ -1022,8 +987,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator()
|
|||||||
else
|
else
|
||||||
source.replace("@2", QByteArray()).replace("$2", QByteArray())
|
source.replace("@2", QByteArray()).replace("$2", QByteArray())
|
||||||
.replace("@1", "@").replace("$1", "$");
|
.replace("@1", "@").replace("$1", "$");
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp_data()
|
||||||
@@ -1048,8 +1012,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp()
|
|||||||
else
|
else
|
||||||
source.replace("@2", QByteArray()).replace("$2", QByteArray())
|
source.replace("@2", QByteArray()).replace("$2", QByteArray())
|
||||||
.replace("@1", "@").replace("$1", "$");
|
.replace("@1", "@").replace("$1", "$");
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
|
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
|
||||||
@@ -1302,8 +1265,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
|
|||||||
QFETCH(QByteArray, source);
|
QFETCH(QByteArray, source);
|
||||||
QFETCH(OverrideItemList, results);
|
QFETCH(OverrideItemList, results);
|
||||||
|
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source, results);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source), results);
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Base classes can be found although these might be defined in distinct documents.
|
/// Check: Base classes can be found although these might be defined in distinct documents.
|
||||||
@@ -1324,8 +1286,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleD
|
|||||||
<< OverrideItem(QLatin1String("A::virt"), 1)
|
<< OverrideItem(QLatin1String("A::virt"), 1)
|
||||||
<< OverrideItem(QLatin1String("B::virt"), 2);
|
<< OverrideItem(QLatin1String("B::virt"), 2);
|
||||||
|
|
||||||
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
|
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
|
||||||
test.run();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ public:
|
|||||||
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray())
|
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray())
|
||||||
: m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
|
: m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
m_succeededSoFar = false;
|
||||||
|
|
||||||
m_source = sourceText;
|
m_source = sourceText;
|
||||||
m_position = m_source.indexOf('@');
|
m_position = m_source.indexOf('@');
|
||||||
QVERIFY(m_position != -1);
|
QVERIFY(m_position != -1);
|
||||||
@@ -89,6 +92,8 @@ public:
|
|||||||
|
|
||||||
if (!textToInsert.isEmpty())
|
if (!textToInsert.isEmpty())
|
||||||
insertText(textToInsert);
|
insertText(textToInsert);
|
||||||
|
|
||||||
|
m_succeededSoFar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList getCompletions(bool *replaceAccessOperator = 0) const
|
QStringList getCompletions(bool *replaceAccessOperator = 0) const
|
||||||
@@ -162,6 +167,7 @@ void CppToolsPlugin::test_completion_basic_1()
|
|||||||
" @\n"
|
" @\n"
|
||||||
"}";
|
"}";
|
||||||
CompletionTestCase test(source);
|
CompletionTestCase test(source);
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
QStringList basicCompletions = test.getCompletions();
|
QStringList basicCompletions = test.getCompletions();
|
||||||
QVERIFY(!basicCompletions.contains(QLatin1String("foo")));
|
QVERIFY(!basicCompletions.contains(QLatin1String("foo")));
|
||||||
@@ -189,6 +195,7 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737()
|
|||||||
"}\n"
|
"}\n"
|
||||||
;
|
;
|
||||||
CompletionTestCase test(source, "a_c");
|
CompletionTestCase test(source, "a_c");
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
QStringList completions = test.getCompletions();
|
QStringList completions = test.getCompletions();
|
||||||
|
|
||||||
@@ -214,9 +221,9 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236()
|
|||||||
"};\n"
|
"};\n"
|
||||||
;
|
;
|
||||||
CompletionTestCase test(source, "ret");
|
CompletionTestCase test(source, "ret");
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
QStringList completions = test.getCompletions();
|
QStringList completions = test.getCompletions();
|
||||||
|
|
||||||
QVERIFY(completions.size() >= 2);
|
QVERIFY(completions.size() >= 2);
|
||||||
QCOMPARE(completions.at(0), QLatin1String("return"));
|
QCOMPARE(completions.at(0), QLatin1String("return"));
|
||||||
QCOMPARE(completions.at(1), QLatin1String("rETUCASE"));
|
QCOMPARE(completions.at(1), QLatin1String("rETUCASE"));
|
||||||
@@ -233,9 +240,9 @@ void CppToolsPlugin::test_completion_template_function()
|
|||||||
QFETCH(QStringList, expectedCompletions);
|
QFETCH(QStringList, expectedCompletions);
|
||||||
|
|
||||||
CompletionTestCase test(code);
|
CompletionTestCase test(code);
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
QStringList actualCompletions = test.getCompletions();
|
QStringList actualCompletions = test.getCompletions();
|
||||||
|
|
||||||
QString errorPattern(QLatin1String("Completion not found: %1"));
|
QString errorPattern(QLatin1String("Completion not found: %1"));
|
||||||
foreach (const QString &completion, expectedCompletions) {
|
foreach (const QString &completion, expectedCompletions) {
|
||||||
QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
|
QByteArray errorMessage = errorPattern.arg(completion).toUtf8();
|
||||||
@@ -290,6 +297,7 @@ void CppToolsPlugin::test_completion()
|
|||||||
QFETCH(QStringList, expectedCompletions);
|
QFETCH(QStringList, expectedCompletions);
|
||||||
|
|
||||||
CompletionTestCase test(code, prefix);
|
CompletionTestCase test(code, prefix);
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
QStringList actualCompletions = test.getCompletions();
|
QStringList actualCompletions = test.getCompletions();
|
||||||
actualCompletions.sort();
|
actualCompletions.sort();
|
||||||
@@ -2092,6 +2100,7 @@ void CppToolsPlugin::test_completion_member_access_operator()
|
|||||||
QFETCH(bool, expectedReplaceAccessOperator);
|
QFETCH(bool, expectedReplaceAccessOperator);
|
||||||
|
|
||||||
CompletionTestCase test(code, prefix);
|
CompletionTestCase test(code, prefix);
|
||||||
|
QVERIFY(test.succeededSoFar());
|
||||||
|
|
||||||
bool replaceAccessOperator = false;
|
bool replaceAccessOperator = false;
|
||||||
QStringList completions = test.getCompletions(&replaceAccessOperator);
|
QStringList completions = test.getCompletions(&replaceAccessOperator);
|
||||||
|
|||||||
@@ -67,12 +67,21 @@ class CppLocatorFilterTestCase
|
|||||||
, public CppTools::Tests::TestCase
|
, public CppTools::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppLocatorFilterTestCase(ILocatorFilter *filter, const QString &fileName)
|
CppLocatorFilterTestCase(ILocatorFilter *filter,
|
||||||
|
const QString &fileName,
|
||||||
|
const QString &searchText,
|
||||||
|
const ResultDataList &expectedResults)
|
||||||
: BasicLocatorFilterTest(filter)
|
: BasicLocatorFilterTest(filter)
|
||||||
, m_fileName(fileName)
|
, m_fileName(fileName)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
QVERIFY(!m_fileName.isEmpty());
|
QVERIFY(!m_fileName.isEmpty());
|
||||||
QVERIFY(garbageCollectGlobalSnapshot());
|
QVERIFY(garbageCollectGlobalSnapshot());
|
||||||
|
|
||||||
|
ResultDataList results = ResultData::fromFilterEntryList(matchesFor(searchText));
|
||||||
|
// ResultData::printFilterEntries(results);
|
||||||
|
QVERIFY(!results.isEmpty());
|
||||||
|
QCOMPARE(results, expectedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -88,12 +97,19 @@ class CppCurrentDocumentFilterTestCase
|
|||||||
, public CppTools::Tests::TestCase
|
, public CppTools::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CppCurrentDocumentFilterTestCase(const QString &fileName)
|
CppCurrentDocumentFilterTestCase(const QString &fileName,
|
||||||
|
const ResultDataList &expectedResults)
|
||||||
: BasicLocatorFilterTest(PluginManager::getObject<CppCurrentDocumentFilter>())
|
: BasicLocatorFilterTest(PluginManager::getObject<CppCurrentDocumentFilter>())
|
||||||
, m_editor(0)
|
, m_editor(0)
|
||||||
, m_fileName(fileName)
|
, m_fileName(fileName)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
QVERIFY(!m_fileName.isEmpty());
|
QVERIFY(!m_fileName.isEmpty());
|
||||||
|
|
||||||
|
ResultDataList results = ResultData::fromFilterEntryList(matchesFor());
|
||||||
|
// ResultData::printFilterEntries(results);
|
||||||
|
QVERIFY(!results.isEmpty());
|
||||||
|
QCOMPARE(results, expectedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -130,11 +146,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
|
|||||||
QFETCH(QString, searchText);
|
QFETCH(QString, searchText);
|
||||||
QFETCH(ResultDataList, expectedResults);
|
QFETCH(ResultDataList, expectedResults);
|
||||||
|
|
||||||
CppLocatorFilterTestCase test(filter, testFile);
|
CppLocatorFilterTestCase(filter, testFile, searchText, expectedResults);
|
||||||
ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor(searchText));
|
|
||||||
// ResultData::printFilterEntries(results);
|
|
||||||
QVERIFY(!results.isEmpty());
|
|
||||||
QCOMPARE(results, expectedResults);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||||
@@ -277,9 +289,5 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
|
|||||||
<< ResultData(_("main()"), _(""))
|
<< ResultData(_("main()"), _(""))
|
||||||
;
|
;
|
||||||
|
|
||||||
CppCurrentDocumentFilterTestCase test(testFile);
|
CppCurrentDocumentFilterTestCase(testFile, expectedResults);
|
||||||
ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor());
|
|
||||||
// ResultData::printFilterEntries(results);
|
|
||||||
QVERIFY(!results.isEmpty());
|
|
||||||
QCOMPARE(expectedResults, results);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,8 +70,13 @@ QString stripCursor(const QString &source)
|
|||||||
class PointerDeclarationFormatterTestCase : public CppTools::Tests::TestCase
|
class PointerDeclarationFormatterTestCase : public CppTools::Tests::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PointerDeclarationFormatterTestCase(const QByteArray &source, Document::ParseMode parseMode)
|
PointerDeclarationFormatterTestCase(const QByteArray &source,
|
||||||
|
const QString &expectedSource,
|
||||||
|
Document::ParseMode parseMode,
|
||||||
|
PointerDeclarationFormatter::CursorHandling cursorHandling)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
// Find cursor position and remove cursor marker '@'
|
// Find cursor position and remove cursor marker '@'
|
||||||
int cursorPosition = 0;
|
int cursorPosition = 0;
|
||||||
QString sourceWithoutCursorMarker = QLatin1String(source);
|
QString sourceWithoutCursorMarker = QLatin1String(source);
|
||||||
@@ -83,58 +88,53 @@ public:
|
|||||||
|
|
||||||
// Write source to temprorary file
|
// Write source to temprorary file
|
||||||
const QString filePath = QDir::tempPath() + QLatin1String("/file.h");
|
const QString filePath = QDir::tempPath() + QLatin1String("/file.h");
|
||||||
m_document = Document::create(filePath);
|
Document::Ptr document = Document::create(filePath);
|
||||||
QVERIFY(writeFile(m_document->fileName(), sourceWithoutCursorMarker.toLatin1()));
|
QVERIFY(writeFile(document->fileName(), sourceWithoutCursorMarker.toLatin1()));
|
||||||
|
|
||||||
// Preprocess source
|
// Preprocess source
|
||||||
Preprocessor preprocess(0, &m_env);
|
Environment env;
|
||||||
|
Preprocessor preprocess(0, &env);
|
||||||
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
|
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
|
||||||
|
|
||||||
m_document->setUtf8Source(preprocessedSource);
|
document->setUtf8Source(preprocessedSource);
|
||||||
m_document->parse(parseMode);
|
document->parse(parseMode);
|
||||||
m_document->check();
|
document->check();
|
||||||
m_translationUnit = m_document->translationUnit();
|
AST *ast = document->translationUnit()->ast();
|
||||||
m_snapshot.insert(m_document);
|
QVERIFY(ast);
|
||||||
m_editor = new TextEditor::PlainTextEditorWidget(0);
|
|
||||||
|
// Open file
|
||||||
|
QScopedPointer<TextEditor::BaseTextEditorWidget> editorWidget(
|
||||||
|
new TextEditor::PlainTextEditorWidget(0));
|
||||||
QString error;
|
QString error;
|
||||||
m_editor->open(&error, m_document->fileName(), m_document->fileName());
|
editorWidget->open(&error, document->fileName(), document->fileName());
|
||||||
|
QVERIFY(error.isEmpty());
|
||||||
|
|
||||||
// Set cursor position
|
// Set cursor position
|
||||||
QTextCursor cursor = m_editor->textCursor();
|
QTextCursor cursor = editorWidget->textCursor();
|
||||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
|
||||||
m_editor->setTextCursor(cursor);
|
editorWidget->setTextCursor(cursor);
|
||||||
|
|
||||||
m_textDocument = m_editor->document();
|
QTextDocument *textDocument = editorWidget->document();
|
||||||
m_cppRefactoringFile = CppRefactoringChanges::file(m_editor, m_document);
|
CppRefactoringFilePtr cppRefactoringFile
|
||||||
}
|
= CppRefactoringChanges::file(editorWidget.data(), document);
|
||||||
|
|
||||||
void applyFormatting(AST *ast, PointerDeclarationFormatter::CursorHandling cursorHandling)
|
// Prepare for formatting
|
||||||
{
|
|
||||||
Overview overview;
|
Overview overview;
|
||||||
overview.showReturnTypes = true;
|
overview.showReturnTypes = true;
|
||||||
overview.showArgumentNames = true;
|
overview.showArgumentNames = true;
|
||||||
overview.starBindFlags = Overview::StarBindFlags(0);
|
overview.starBindFlags = Overview::StarBindFlags(0);
|
||||||
|
|
||||||
// Run the formatter
|
// Run the formatter
|
||||||
PointerDeclarationFormatter formatter(m_cppRefactoringFile, overview, cursorHandling);
|
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
|
||||||
ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
|
ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
|
||||||
|
|
||||||
// Apply change
|
// Apply change
|
||||||
QTextCursor cursor(m_textDocument);
|
QTextCursor changeCursor(textDocument);
|
||||||
change.apply(&cursor);
|
change.apply(&changeCursor);
|
||||||
|
|
||||||
|
// Compare
|
||||||
|
QCOMPARE(textDocument->toPlainText(), expectedSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
|
||||||
QTextDocument *m_textDocument;
|
|
||||||
TranslationUnit *m_translationUnit;
|
|
||||||
|
|
||||||
private:
|
|
||||||
QByteArray m_source;
|
|
||||||
Snapshot m_snapshot;
|
|
||||||
CppRefactoringFilePtr m_cppRefactoringFile;
|
|
||||||
TextEditor::BaseTextEditorWidget *m_editor;
|
|
||||||
Document::Ptr m_document;
|
|
||||||
Environment m_env;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -144,13 +144,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations()
|
|||||||
QFETCH(QString, source);
|
QFETCH(QString, source);
|
||||||
QFETCH(QString, reformattedSource);
|
QFETCH(QString, reformattedSource);
|
||||||
|
|
||||||
PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseDeclaration);
|
PointerDeclarationFormatterTestCase(source.toLatin1(),
|
||||||
AST *ast = test.m_translationUnit->ast();
|
reformattedSource,
|
||||||
QVERIFY(ast);
|
Document::ParseDeclaration,
|
||||||
|
PointerDeclarationFormatter::RespectCursor);
|
||||||
test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
|
|
||||||
|
|
||||||
QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
|
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
|
||||||
@@ -371,13 +368,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()
|
|||||||
QFETCH(QString, source);
|
QFETCH(QString, source);
|
||||||
QFETCH(QString, reformattedSource);
|
QFETCH(QString, reformattedSource);
|
||||||
|
|
||||||
PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseStatement);
|
PointerDeclarationFormatterTestCase(source.toLatin1(),
|
||||||
AST *ast = test.m_translationUnit->ast();
|
reformattedSource,
|
||||||
QVERIFY(ast);
|
Document::ParseStatement,
|
||||||
|
PointerDeclarationFormatter::RespectCursor);
|
||||||
test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
|
|
||||||
|
|
||||||
QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_data()
|
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_data()
|
||||||
@@ -449,13 +443,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators()
|
|||||||
QFETCH(QString, source);
|
QFETCH(QString, source);
|
||||||
QFETCH(QString, reformattedSource);
|
QFETCH(QString, reformattedSource);
|
||||||
|
|
||||||
PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseDeclaration);
|
PointerDeclarationFormatterTestCase(source.toLatin1(),
|
||||||
AST *ast = test.m_translationUnit->ast();
|
reformattedSource,
|
||||||
QVERIFY(ast);
|
Document::ParseDeclaration,
|
||||||
|
PointerDeclarationFormatter::RespectCursor);
|
||||||
test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
|
|
||||||
|
|
||||||
QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
|
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
|
||||||
@@ -507,13 +498,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
|
|||||||
QFETCH(QString, source);
|
QFETCH(QString, source);
|
||||||
QFETCH(QString, reformattedSource);
|
QFETCH(QString, reformattedSource);
|
||||||
|
|
||||||
PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseTranlationUnit);
|
PointerDeclarationFormatterTestCase(source.toLatin1(),
|
||||||
AST *ast = test.m_translationUnit->ast();
|
reformattedSource,
|
||||||
QVERIFY(ast);
|
Document::ParseTranlationUnit,
|
||||||
|
PointerDeclarationFormatter::IgnoreCursor);
|
||||||
test.applyFormatting(ast, PointerDeclarationFormatter::IgnoreCursor);
|
|
||||||
|
|
||||||
QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
|
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
|
||||||
@@ -593,13 +581,10 @@ void CppToolsPlugin::test_format_pointerdeclaration_macros()
|
|||||||
QFETCH(QString, source);
|
QFETCH(QString, source);
|
||||||
QFETCH(QString, reformattedSource);
|
QFETCH(QString, reformattedSource);
|
||||||
|
|
||||||
PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseTranlationUnit);
|
PointerDeclarationFormatterTestCase(source.toLatin1(),
|
||||||
AST *ast = test.m_translationUnit->ast();
|
reformattedSource,
|
||||||
QVERIFY(ast);
|
Document::ParseTranlationUnit,
|
||||||
|
PointerDeclarationFormatter::RespectCursor);
|
||||||
test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
|
|
||||||
|
|
||||||
QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_format_pointerdeclaration_macros_data()
|
void CppToolsPlugin::test_format_pointerdeclaration_macros_data()
|
||||||
|
|||||||
@@ -70,10 +70,12 @@ bool TestDocument::writeToDisk() const
|
|||||||
|
|
||||||
TestCase::TestCase(bool runGarbageCollector)
|
TestCase::TestCase(bool runGarbageCollector)
|
||||||
: m_modelManager(CppModelManagerInterface::instance())
|
: m_modelManager(CppModelManagerInterface::instance())
|
||||||
|
, m_succeededSoFar(false)
|
||||||
, m_runGarbageCollector(runGarbageCollector)
|
, m_runGarbageCollector(runGarbageCollector)
|
||||||
{
|
{
|
||||||
if (m_runGarbageCollector)
|
if (m_runGarbageCollector)
|
||||||
QVERIFY(garbageCollectGlobalSnapshot());
|
QVERIFY(garbageCollectGlobalSnapshot());
|
||||||
|
m_succeededSoFar = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
TestCase::~TestCase()
|
TestCase::~TestCase()
|
||||||
@@ -85,6 +87,11 @@ TestCase::~TestCase()
|
|||||||
QVERIFY(garbageCollectGlobalSnapshot());
|
QVERIFY(garbageCollectGlobalSnapshot());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TestCase::succeededSoFar() const
|
||||||
|
{
|
||||||
|
return m_succeededSoFar;
|
||||||
|
}
|
||||||
|
|
||||||
CPlusPlus::Snapshot TestCase::globalSnapshot()
|
CPlusPlus::Snapshot TestCase::globalSnapshot()
|
||||||
{
|
{
|
||||||
return CppModelManagerInterface::instance()->snapshot();
|
return CppModelManagerInterface::instance()->snapshot();
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public:
|
|||||||
TestCase(bool runGarbageCollector = true);
|
TestCase(bool runGarbageCollector = true);
|
||||||
~TestCase();
|
~TestCase();
|
||||||
|
|
||||||
|
bool succeededSoFar() const;
|
||||||
void closeEditorAtEndOfTestCase(Core::IEditor *editor);
|
void closeEditorAtEndOfTestCase(Core::IEditor *editor);
|
||||||
|
|
||||||
static bool parseFiles(const QString &filePath);
|
static bool parseFiles(const QString &filePath);
|
||||||
@@ -86,6 +87,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
CppModelManagerInterface *m_modelManager;
|
CppModelManagerInterface *m_modelManager;
|
||||||
|
bool m_succeededSoFar;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Core::IEditor *> m_editorsToClose;
|
QList<Core::IEditor *> m_editorsToClose;
|
||||||
|
|||||||
@@ -91,37 +91,39 @@ class SymbolSearcherTestCase : public CppTools::Tests::TestCase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Takes no ownership of indexingSupportToUse
|
/// Takes no ownership of indexingSupportToUse
|
||||||
SymbolSearcherTestCase(const QString &testFile, CppIndexingSupport *indexingSupportToUse)
|
SymbolSearcherTestCase(const QString &testFile,
|
||||||
: m_indexingSupportToUse(indexingSupportToUse)
|
CppIndexingSupport *indexingSupportToUse,
|
||||||
, m_testFile(testFile)
|
const SymbolSearcher::Parameters &searchParameters,
|
||||||
|
const ResultDataList &expectedResults)
|
||||||
|
: m_indexingSupportToRestore(0)
|
||||||
|
, m_indexingSupportToUse(indexingSupportToUse)
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
QVERIFY(m_indexingSupportToUse);
|
QVERIFY(m_indexingSupportToUse);
|
||||||
QVERIFY(parseFiles(m_testFile));
|
QVERIFY(parseFiles(testFile));
|
||||||
m_indexingSupportToRestore = m_modelManager->indexingSupport();
|
m_indexingSupportToRestore = m_modelManager->indexingSupport();
|
||||||
m_modelManager->setIndexingSupport(m_indexingSupportToUse);
|
m_modelManager->setIndexingSupport(m_indexingSupportToUse);
|
||||||
}
|
|
||||||
|
|
||||||
ResultDataList run(const SymbolSearcher::Parameters &searchParameters) const
|
|
||||||
{
|
|
||||||
CppIndexingSupport *indexingSupport = m_modelManager->indexingSupport();
|
CppIndexingSupport *indexingSupport = m_modelManager->indexingSupport();
|
||||||
SymbolSearcher *symbolSearcher = indexingSupport->createSymbolSearcher(searchParameters,
|
SymbolSearcher *symbolSearcher = indexingSupport->createSymbolSearcher(searchParameters,
|
||||||
QSet<QString>() << m_testFile);
|
QSet<QString>() << testFile);
|
||||||
QFuture<Find::SearchResultItem> search
|
QFuture<Find::SearchResultItem> search
|
||||||
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
|
= QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
|
||||||
search.waitForFinished();
|
search.waitForFinished();
|
||||||
ResultDataList results = ResultData::fromSearchResultList(search.results());
|
ResultDataList results = ResultData::fromSearchResultList(search.results());
|
||||||
return results;
|
QCOMPARE(results, expectedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SymbolSearcherTestCase()
|
~SymbolSearcherTestCase()
|
||||||
{
|
{
|
||||||
|
if (m_indexingSupportToRestore)
|
||||||
m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
|
m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CppIndexingSupport *m_indexingSupportToRestore;
|
CppIndexingSupport *m_indexingSupportToRestore;
|
||||||
CppIndexingSupport *m_indexingSupportToUse;
|
CppIndexingSupport *m_indexingSupportToUse;
|
||||||
const QString m_testFile;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -148,10 +150,10 @@ void CppToolsPlugin::test_builtinsymbolsearcher()
|
|||||||
QFETCH(ResultDataList, expectedResults);
|
QFETCH(ResultDataList, expectedResults);
|
||||||
|
|
||||||
QScopedPointer<CppIndexingSupport> builtinIndexingSupport(new BuiltinIndexingSupport);
|
QScopedPointer<CppIndexingSupport> builtinIndexingSupport(new BuiltinIndexingSupport);
|
||||||
|
SymbolSearcherTestCase(testFile,
|
||||||
SymbolSearcherTestCase test(testFile, builtinIndexingSupport.data());
|
builtinIndexingSupport.data(),
|
||||||
const ResultDataList results = test.run(searchParameters);
|
searchParameters,
|
||||||
QCOMPARE(results, expectedResults);
|
expectedResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
||||||
|
|||||||
@@ -101,15 +101,12 @@ class TypeHierarchyBuilderTestCase : public CppTools::Tests::TestCase
|
|||||||
public:
|
public:
|
||||||
TypeHierarchyBuilderTestCase(const QList<Tests::TestDocument> &documents,
|
TypeHierarchyBuilderTestCase(const QList<Tests::TestDocument> &documents,
|
||||||
const QString &expectedHierarchy)
|
const QString &expectedHierarchy)
|
||||||
: m_documents(documents),
|
|
||||||
m_expectedHierarchy(expectedHierarchy)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void run()
|
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
// Write files
|
// Write files
|
||||||
QStringList filePaths;
|
QStringList filePaths;
|
||||||
foreach (const Tests::TestDocument &document, m_documents) {
|
foreach (const Tests::TestDocument &document, documents) {
|
||||||
QVERIFY(document.writeToDisk());
|
QVERIFY(document.writeToDisk());
|
||||||
filePaths << document.filePath();
|
filePaths << document.filePath();
|
||||||
}
|
}
|
||||||
@@ -130,12 +127,8 @@ public:
|
|||||||
const QString actualHierarchy = toString(hierarchy);
|
const QString actualHierarchy = toString(hierarchy);
|
||||||
// Uncomment for updating/generating reference data:
|
// Uncomment for updating/generating reference data:
|
||||||
// qDebug() << actualHierarchy;
|
// qDebug() << actualHierarchy;
|
||||||
QCOMPARE(actualHierarchy, m_expectedHierarchy);
|
QCOMPARE(actualHierarchy, expectedHierarchy);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
QList<Tests::TestDocument> m_documents;
|
|
||||||
QString m_expectedHierarchy;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -192,6 +185,5 @@ void CppToolsPlugin::test_typehierarchy()
|
|||||||
QFETCH(QList<Tests::TestDocument>, documents);
|
QFETCH(QList<Tests::TestDocument>, documents);
|
||||||
QFETCH(QString, expectedHierarchy);
|
QFETCH(QString, expectedHierarchy);
|
||||||
|
|
||||||
TypeHierarchyBuilderTestCase testCase(documents, expectedHierarchy);
|
TypeHierarchyBuilderTestCase(documents, expectedHierarchy);
|
||||||
testCase.run();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,15 +154,12 @@ class GoToSlotTestCase : public CppTools::Tests::TestCase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GoToSlotTestCase(const QStringList &files)
|
GoToSlotTestCase(const QStringList &files)
|
||||||
: m_files(files)
|
|
||||||
{
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
QCOMPARE(files.size(), 3);
|
QCOMPARE(files.size(), 3);
|
||||||
}
|
|
||||||
|
|
||||||
void run()
|
|
||||||
{
|
|
||||||
QList<TextEditor::BaseTextEditor *> editors;
|
QList<TextEditor::BaseTextEditor *> editors;
|
||||||
foreach (const QString &file, m_files) {
|
foreach (const QString &file, files) {
|
||||||
IEditor *editor = EditorManager::openEditor(file);
|
IEditor *editor = EditorManager::openEditor(file);
|
||||||
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
|
||||||
QVERIFY(e);
|
QVERIFY(e);
|
||||||
@@ -172,10 +169,10 @@ public:
|
|||||||
TextEditor::BaseTextEditor *cppFileEditor = editors.at(0);
|
TextEditor::BaseTextEditor *cppFileEditor = editors.at(0);
|
||||||
TextEditor::BaseTextEditor *hFileEditor = editors.at(1);
|
TextEditor::BaseTextEditor *hFileEditor = editors.at(1);
|
||||||
|
|
||||||
const QString cppFile = m_files.at(0);
|
const QString cppFile = files.at(0);
|
||||||
const QString hFile = m_files.at(1);
|
const QString hFile = files.at(1);
|
||||||
|
|
||||||
QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), m_files.size());
|
QCOMPARE(EditorManager::documentModel()->openedDocuments().size(), files.size());
|
||||||
waitForFilesInGlobalSnapshot(QStringList() << cppFile << hFile);
|
waitForFilesInGlobalSnapshot(QStringList() << cppFile << hFile);
|
||||||
|
|
||||||
// Execute "Go To Slot"
|
// Execute "Go To Slot"
|
||||||
@@ -206,9 +203,6 @@ public:
|
|||||||
QVERIFY(documentContainsMemberFunctionDeclaration(hDocument,
|
QVERIFY(documentContainsMemberFunctionDeclaration(hDocument,
|
||||||
QLatin1String("Form::on_pushButton_clicked")));
|
QLatin1String("Form::on_pushButton_clicked")));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
QStringList m_files;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -220,9 +214,7 @@ void Designer::Internal::FormEditorPlugin::test_gotoslot()
|
|||||||
{
|
{
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
QFETCH(QStringList, files);
|
QFETCH(QStringList, files);
|
||||||
|
(GoToSlotTestCase(files));
|
||||||
GoToSlotTestCase test(files);
|
|
||||||
test.run();
|
|
||||||
#else
|
#else
|
||||||
QSKIP("Available only with >= Qt5", SkipSingle);
|
QSKIP("Available only with >= Qt5", SkipSingle);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user