forked from qt-creator/qt-creator
CppEditor: Tests: Refactor out BaseQuickFixTestCase
We will add another type of test case that allows us to test the list of offered operations. Change-Id: I528b3844181c139c8955091ac0bbcf6475fd8a4f Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
@@ -1637,7 +1637,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(
|
InsertVirtualMethods factory(
|
||||||
new Tests::InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
|
new Tests::InsertVirtualMethodsDialogTest(implementationMode, insertVirtualKeyword));
|
||||||
Tests::QuickFixTestCase(Tests::singleDocument(original, expected), &factory);
|
Tests::QuickFixOperationTest(Tests::singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert in implementation file
|
/// Check: Insert in implementation file
|
||||||
@@ -1683,7 +1683,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
|
InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
|
||||||
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
||||||
Tests::QuickFixTestCase(testFiles, &factory);
|
Tests::QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Qualified names.
|
/// Check: Qualified names.
|
||||||
@@ -1735,7 +1735,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
|
|||||||
|
|
||||||
InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
|
InsertVirtualMethods factory(new Tests::InsertVirtualMethodsDialogTest(
|
||||||
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
InsertVirtualMethodsDialog::ModeImplementationFile, true));
|
||||||
Tests::QuickFixTestCase(testFiles, &factory);
|
Tests::QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
#endif // WITH_TESTS
|
#endif // WITH_TESTS
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,89 @@ QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
|
|||||||
<< QuickFixTestDocument::create("file.cpp", original, expected);
|
<< QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BaseQuickFixTestCase::BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
|
const ProjectPart::HeaderPaths &headerPaths)
|
||||||
|
: m_testDocuments(testDocuments)
|
||||||
|
, m_cppCodeStylePreferences(0)
|
||||||
|
, m_restoreHeaderPaths(false)
|
||||||
|
{
|
||||||
|
QVERIFY(succeededSoFar());
|
||||||
|
m_succeededSoFar = false;
|
||||||
|
|
||||||
|
// Check if there is exactly one cursor marker
|
||||||
|
unsigned cursorMarkersCount = 0;
|
||||||
|
foreach (const QuickFixTestDocument::Ptr document, m_testDocuments) {
|
||||||
|
if (document->hasCursorMarker())
|
||||||
|
++cursorMarkersCount;
|
||||||
|
}
|
||||||
|
QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed.");
|
||||||
|
|
||||||
|
// Write documents to disk
|
||||||
|
foreach (QuickFixTestDocument::Ptr document, m_testDocuments)
|
||||||
|
document->writeToDisk();
|
||||||
|
|
||||||
|
// Set appropriate include paths
|
||||||
|
if (!headerPaths.isEmpty()) {
|
||||||
|
m_restoreHeaderPaths = true;
|
||||||
|
m_headerPathsToRestore = m_modelManager->headerPaths();
|
||||||
|
m_modelManager->setHeaderPaths(headerPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Code Model
|
||||||
|
QSet<QString> filePaths;
|
||||||
|
foreach (const QuickFixTestDocument::Ptr &document, m_testDocuments)
|
||||||
|
filePaths << document->filePath();
|
||||||
|
QVERIFY(parseFiles(filePaths));
|
||||||
|
|
||||||
|
// Open Files
|
||||||
|
foreach (QuickFixTestDocument::Ptr document, m_testDocuments) {
|
||||||
|
QVERIFY(openCppEditor(document->filePath(), &document->m_editor,
|
||||||
|
&document->m_editorWidget));
|
||||||
|
closeEditorAtEndOfTestCase(document->m_editor);
|
||||||
|
|
||||||
|
// Set cursor position
|
||||||
|
const int cursorPosition = document->hasCursorMarker()
|
||||||
|
? document->m_cursorPosition : 0;
|
||||||
|
document->m_editor->setCursorPosition(cursorPosition);
|
||||||
|
|
||||||
|
// Rehighlight
|
||||||
|
waitForRehighlightedSemanticDocument(document->m_editorWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enforce the default cpp code style, so we are independent of config file settings.
|
||||||
|
// This is needed by e.g. the GenerateGetterSetter quick fix.
|
||||||
|
m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
|
||||||
|
QVERIFY(m_cppCodeStylePreferences);
|
||||||
|
m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
|
||||||
|
m_cppCodeStylePreferences->setCurrentDelegate("qt");
|
||||||
|
|
||||||
|
// Find the document having the cursor marker
|
||||||
|
foreach (const QuickFixTestDocument::Ptr document, m_testDocuments) {
|
||||||
|
if (document->hasCursorMarker()){
|
||||||
|
m_documentWithMarker = document;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QVERIFY(m_documentWithMarker);
|
||||||
|
m_succeededSoFar = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseQuickFixTestCase::~BaseQuickFixTestCase()
|
||||||
|
{
|
||||||
|
// Restore default cpp code style
|
||||||
|
if (m_cppCodeStylePreferences)
|
||||||
|
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
|
||||||
|
|
||||||
|
// Restore include paths
|
||||||
|
if (m_restoreHeaderPaths)
|
||||||
|
m_modelManager->setHeaderPaths(m_headerPathsToRestore);
|
||||||
|
|
||||||
|
// Remove created files from file system
|
||||||
|
foreach (const QuickFixTestDocument::Ptr &testDocument, m_testDocuments)
|
||||||
|
QVERIFY(QFile::remove(testDocument->filePath()));
|
||||||
|
}
|
||||||
|
|
||||||
/// Leading whitespace is not removed, so we can check if the indetation ranges
|
/// Leading whitespace is not removed, so we can check if the indetation ranges
|
||||||
/// have been set correctly by the quick-fix.
|
/// have been set correctly by the quick-fix.
|
||||||
static QString &removeTrailingWhitespace(QString &input)
|
static QString &removeTrailingWhitespace(QString &input)
|
||||||
@@ -113,81 +196,30 @@ static QString &removeTrailingWhitespace(QString &input)
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The '@' in the originalSource is the position from where the quick-fix discovery is triggered.
|
QuickFixOperationTest::QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
/// Exactly one TestFile must contain the cursor position marker '@' in the originalSource.
|
|
||||||
QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
|
|
||||||
CppQuickFixFactory *factory,
|
CppQuickFixFactory *factory,
|
||||||
const ProjectPart::HeaderPaths &headerPaths,
|
const ProjectPart::HeaderPaths &headerPaths,
|
||||||
int resultIndex,
|
int operationIndex,
|
||||||
const QByteArray &expectedFailMessage)
|
const QByteArray &expectedFailMessage)
|
||||||
: m_testFiles(theTestFiles)
|
: BaseQuickFixTestCase(testDocuments, headerPaths)
|
||||||
, m_cppCodeStylePreferences(0)
|
|
||||||
, m_restoreHeaderPaths(false)
|
|
||||||
{
|
{
|
||||||
QVERIFY(succeededSoFar());
|
QVERIFY(succeededSoFar());
|
||||||
|
|
||||||
// Check if there is exactly one cursor marker
|
// Perform operation if there is one
|
||||||
unsigned cursorMarkersCount = 0;
|
CppQuickFixInterface quickFixInterface(m_documentWithMarker->m_editorWidget, ExplicitlyInvoked);
|
||||||
foreach (const QuickFixTestDocument::Ptr testFile, m_testFiles) {
|
TextEditor::QuickFixOperations operations;
|
||||||
if (testFile->hasCursorMarker())
|
factory->match(quickFixInterface, operations);
|
||||||
++cursorMarkersCount;
|
if (operations.isEmpty()) {
|
||||||
}
|
|
||||||
QVERIFY2(cursorMarkersCount == 1, "Exactly one cursor marker is allowed.");
|
|
||||||
|
|
||||||
// Write files to disk
|
|
||||||
foreach (QuickFixTestDocument::Ptr testFile, m_testFiles)
|
|
||||||
testFile->writeToDisk();
|
|
||||||
|
|
||||||
// Set appropriate include paths
|
|
||||||
if (!headerPaths.isEmpty()) {
|
|
||||||
m_restoreHeaderPaths = true;
|
|
||||||
m_headerPathsToRestore = m_modelManager->headerPaths();
|
|
||||||
m_modelManager->setHeaderPaths(headerPaths);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update Code Model
|
|
||||||
QSet<QString> filePaths;
|
|
||||||
foreach (const QuickFixTestDocument::Ptr &testFile, m_testFiles)
|
|
||||||
filePaths << testFile->filePath();
|
|
||||||
QVERIFY(parseFiles(filePaths));
|
|
||||||
|
|
||||||
// Open Files
|
|
||||||
foreach (QuickFixTestDocument::Ptr testFile, m_testFiles) {
|
|
||||||
QVERIFY(openCppEditor(testFile->filePath(), &testFile->m_editor,
|
|
||||||
&testFile->m_editorWidget));
|
|
||||||
closeEditorAtEndOfTestCase(testFile->m_editor);
|
|
||||||
|
|
||||||
// Set cursor position
|
|
||||||
const int cursorPosition = testFile->hasCursorMarker()
|
|
||||||
? testFile->m_cursorPosition : 0;
|
|
||||||
testFile->m_editor->setCursorPosition(cursorPosition);
|
|
||||||
|
|
||||||
// Rehighlight
|
|
||||||
waitForRehighlightedSemanticDocument(testFile->m_editorWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Enforce the default cpp code style, so we are independent of config file settings.
|
|
||||||
// This is needed by e.g. the GenerateGetterSetter quick fix.
|
|
||||||
m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
|
|
||||||
QVERIFY(m_cppCodeStylePreferences);
|
|
||||||
m_cppCodeStylePreferencesOriginalDelegateId = m_cppCodeStylePreferences->currentDelegateId();
|
|
||||||
m_cppCodeStylePreferences->setCurrentDelegate("qt");
|
|
||||||
|
|
||||||
// Run the fix in the file having the cursor marker
|
|
||||||
QuickFixTestDocument::Ptr testFile;
|
|
||||||
foreach (const QuickFixTestDocument::Ptr file, m_testFiles) {
|
|
||||||
if (file->hasCursorMarker())
|
|
||||||
testFile = file;
|
|
||||||
}
|
|
||||||
QVERIFY2(testFile, "No test file with cursor marker found");
|
|
||||||
|
|
||||||
if (QuickFixOperation::Ptr fix = getFix(factory, testFile->m_editorWidget, resultIndex))
|
|
||||||
fix->perform();
|
|
||||||
else
|
|
||||||
qDebug() << "Quickfix was not triggered";
|
qDebug() << "Quickfix was not triggered";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVERIFY(operationIndex < operations.size());
|
||||||
|
const QuickFixOperation::Ptr operation = operations.at(operationIndex);
|
||||||
|
operation->perform();
|
||||||
|
|
||||||
// Compare all files
|
// Compare all files
|
||||||
foreach (const QuickFixTestDocument::Ptr testFile, m_testFiles) {
|
foreach (const QuickFixTestDocument::Ptr testFile, m_testDocuments) {
|
||||||
// Check
|
// Check
|
||||||
QString result = testFile->m_editorWidget->document()->toPlainText();
|
QString result = testFile->m_editorWidget->document()->toPlainText();
|
||||||
removeTrailingWhitespace(result);
|
removeTrailingWhitespace(result);
|
||||||
@@ -203,27 +235,14 @@ QuickFixTestCase::QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickFixTestCase::~QuickFixTestCase()
|
void QuickFixOperationTest::run(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
|
CppQuickFixFactory *factory,
|
||||||
|
const QString &headerPath,
|
||||||
|
int operationIndex)
|
||||||
{
|
{
|
||||||
// Restore default cpp code style
|
ProjectPart::HeaderPaths headerPaths;
|
||||||
if (m_cppCodeStylePreferences)
|
headerPaths += ProjectPart::HeaderPath(headerPath, ProjectPart::HeaderPath::IncludePath);
|
||||||
m_cppCodeStylePreferences->setCurrentDelegate(m_cppCodeStylePreferencesOriginalDelegateId);
|
QuickFixOperationTest(testDocuments, factory, headerPaths, operationIndex);
|
||||||
|
|
||||||
// Restore include paths
|
|
||||||
if (m_restoreHeaderPaths)
|
|
||||||
m_modelManager->setHeaderPaths(m_headerPathsToRestore);
|
|
||||||
|
|
||||||
// Remove created files from file system
|
|
||||||
foreach (const QuickFixTestDocument::Ptr &testDocument, m_testFiles)
|
|
||||||
QVERIFY(QFile::remove(testDocument->filePath()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void QuickFixTestCase::run(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
|
|
||||||
CppQuickFixFactory *factory, const QString &incPath, int resultIndex)
|
|
||||||
{
|
|
||||||
ProjectPart::HeaderPaths hps;
|
|
||||||
hps += ProjectPart::HeaderPath(incPath, ProjectPart::HeaderPath::IncludePath);
|
|
||||||
QuickFixTestCase(theTestFiles, factory, hps, resultIndex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
|
/// Delegates directly to AddIncludeForUndefinedIdentifierOp for easier testing.
|
||||||
@@ -242,16 +261,6 @@ private:
|
|||||||
const QString m_include;
|
const QString m_include;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Apply the factory on the source and get back the resultIndex'th result or a null pointer.
|
|
||||||
QSharedPointer<TextEditor::QuickFixOperation> QuickFixTestCase::getFix(
|
|
||||||
CppQuickFixFactory *factory, CppEditorWidget *editorWidget, int resultIndex)
|
|
||||||
{
|
|
||||||
CppQuickFixInterface qfi(editorWidget, ExplicitlyInvoked);
|
|
||||||
TextEditor::QuickFixOperations results;
|
|
||||||
factory->match(qfi, results);
|
|
||||||
return results.isEmpty() ? QuickFixOperation::Ptr() : results.at(resultIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tests
|
} // namespace Tests
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
@@ -1482,7 +1491,7 @@ void CppEditorPlugin::test_quickfix()
|
|||||||
|
|
||||||
if (expected.isEmpty())
|
if (expected.isEmpty())
|
||||||
expected = original;
|
expected = original;
|
||||||
QuickFixTestCase(singleDocument(original, expected), factory.data());
|
QuickFixOperationTest(singleDocument(original, expected), factory.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
|
/// Checks: In addition to test_quickfix_GenerateGetterSetter_basicGetterWithPrefix
|
||||||
@@ -1535,7 +1544,7 @@ void CppEditorPlugin::test_quickfix_GenerateGetterSetter_basicGetterWithPrefixAn
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
GenerateGetterSetter factory;
|
GenerateGetterSetter factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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
|
||||||
@@ -1578,7 +1587,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_afterClass()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
|
QuickFixOperationTest(testFiles, &factory, ProjectPart::HeaderPaths(), 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.
|
||||||
@@ -1610,7 +1619,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic1()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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.
|
||||||
@@ -1647,7 +1656,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic2()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from source file: Insert in source file, not header file.
|
/// Check from source file: Insert in source file, not header file.
|
||||||
@@ -1677,7 +1686,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_basic3()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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
|
||||||
@@ -1711,7 +1720,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace1()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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
|
||||||
@@ -1749,7 +1758,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_headerSource_namespace2()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check definition insert inside class
|
/// Check definition insert inside class
|
||||||
@@ -1767,7 +1776,8 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_insideClass()
|
|||||||
"};";
|
"};";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(), 1);
|
QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(),
|
||||||
|
1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check not triggering when definition exists
|
/// Check not triggering when definition exists
|
||||||
@@ -1781,7 +1791,8 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitio
|
|||||||
const QByteArray expected = original;
|
const QByteArray expected = original;
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(), 1);
|
QuickFixOperationTest(singleDocument(original, expected), &factory, ProjectPart::HeaderPaths(),
|
||||||
|
1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find right implementation file.
|
/// Find right implementation file.
|
||||||
@@ -1830,7 +1841,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findRightImplementationFil
|
|||||||
testFiles << QuickFixTestDocument::create("file2.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file2.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Ignore generated functions declarations when looking at the surrounding
|
/// Ignore generated functions declarations when looking at the surrounding
|
||||||
@@ -1885,7 +1896,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_ignoreSurroundingGenerated
|
|||||||
testFiles << QuickFixTestDocument::create("file2.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file2.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -1909,7 +1920,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1(
|
|||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -1933,7 +1944,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2(
|
|||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &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
|
||||||
@@ -1975,7 +1986,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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
|
||||||
@@ -2015,7 +2026,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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.
|
||||||
@@ -2052,7 +2063,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfF
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Respect rvalue references
|
/// Check: Respect rvalue references
|
||||||
@@ -2080,7 +2091,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_rvalueReference()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find right implementation file. (QTCREATORBUG-10728)
|
/// Find right implementation file. (QTCREATORBUG-10728)
|
||||||
@@ -2119,7 +2130,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_findImplementationFile()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_unicodeIdentifier()
|
void CppEditorPlugin::test_quickfix_InsertDefFromDecl_unicodeIdentifier()
|
||||||
@@ -2163,7 +2174,7 @@ void CppEditorPlugin::test_quickfix_InsertDefFromDecl_unicodeIdentifier()
|
|||||||
#undef TEST_UNICODE_IDENTIFIER
|
#undef TEST_UNICODE_IDENTIFIER
|
||||||
|
|
||||||
InsertDefFromDecl factory;
|
InsertDefFromDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function for one of InsertDeclDef section cases
|
// Function for one of InsertDeclDef section cases
|
||||||
@@ -2199,7 +2210,7 @@ void insertToSectionDeclFromDef(const QByteArray §ion, int sectionIndex)
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
InsertDeclFromDef factory;
|
InsertDeclFromDef factory;
|
||||||
QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), sectionIndex);
|
QuickFixOperationTest(testFiles, &factory, ProjectPart::HeaderPaths(), sectionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check from source file: Insert in header file.
|
/// Check from source file: Insert in header file.
|
||||||
@@ -2249,7 +2260,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onSimpleNam
|
|||||||
+ "/afile.cpp", original, expected);
|
+ "/afile.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifier factory;
|
AddIncludeForUndefinedIdentifier factory;
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Cursor is on a qualified name (1)
|
/// Check: Cursor is on a qualified name (1)
|
||||||
@@ -2289,7 +2300,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onNameOfQua
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQualifiedName()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQualifiedName()
|
||||||
@@ -2328,7 +2339,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQua
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateName()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateName()
|
||||||
@@ -2367,7 +2378,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateN
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateNameInsideArguments()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateNameInsideArguments()
|
||||||
@@ -2406,7 +2417,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateN
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration()
|
||||||
@@ -2449,7 +2460,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration2()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration2()
|
||||||
@@ -2492,7 +2503,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardHeader()
|
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardHeader()
|
||||||
@@ -2537,7 +2548,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
|
|||||||
|
|
||||||
// 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::run(testFiles, &factory, TestIncludePaths::globalIncludePath(), 1);
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Ignore *.moc includes
|
/// Check: Ignore *.moc includes
|
||||||
@@ -2562,7 +2573,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_i
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include at top for a sorted group
|
/// Check: Insert include at top for a sorted group
|
||||||
@@ -2588,7 +2599,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include in the middle for a sorted group
|
/// Check: Insert include in the middle for a sorted group
|
||||||
@@ -2614,7 +2625,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert include at bottom for a sorted group
|
/// Check: Insert include at bottom for a sorted group
|
||||||
@@ -2640,7 +2651,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: For an unsorted group the new include is appended
|
/// Check: For an unsorted group the new include is appended
|
||||||
@@ -2666,7 +2677,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_a
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -2693,7 +2704,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_f
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -2722,7 +2733,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_f
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Prefer group with longest matching prefix
|
/// Check: Prefer group with longest matching prefix
|
||||||
@@ -2752,7 +2763,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_p
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -2779,7 +2790,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_n
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include dirs, sorted --> insert properly
|
/// Check: Include group with mixed include dirs, sorted --> insert properly
|
||||||
@@ -2807,7 +2818,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<firstlib/file.h>"));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include dirs, unsorted --> append
|
/// Check: Include group with mixed include dirs, unsorted --> append
|
||||||
@@ -2835,7 +2846,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lastlib/file.h>"));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2861,7 +2872,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"z.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2887,7 +2898,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"a.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2913,7 +2924,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"lib/file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Include group with mixed include types
|
/// Check: Include group with mixed include types
|
||||||
@@ -2939,7 +2950,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_m
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<lib/file.h>"));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert very first include
|
/// Check: Insert very first include
|
||||||
@@ -2962,7 +2973,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_n
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Insert very first include after include guard
|
/// Check: Insert very first include after include guard
|
||||||
@@ -2992,7 +3003,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_o
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -3021,7 +3032,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_v
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -3054,7 +3065,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_v
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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
|
||||||
@@ -3078,7 +3089,7 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_c
|
|||||||
+ "/file.cpp", original, expected);
|
+ "/file.cpp", original, expected);
|
||||||
|
|
||||||
AddIncludeForUndefinedIdentifier factory;
|
AddIncludeForUndefinedIdentifier factory;
|
||||||
QuickFixTestCase::run(testFiles, &factory, TestIncludePaths::globalQtCoreIncludePath());
|
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalQtCoreIncludePath());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3122,7 +3133,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCpp()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
||||||
@@ -3168,7 +3179,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class
|
/// Check: Move definition outside class
|
||||||
@@ -3202,7 +3213,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside1()
|
|||||||
"void Foo::f4() {}\n";
|
"void Foo::f4() {}\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class
|
/// Check: Move definition outside class
|
||||||
@@ -3244,7 +3255,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutside2()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
|
QuickFixOperationTest(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition from header to cpp (with namespace).
|
/// Check: Move definition from header to cpp (with namespace).
|
||||||
@@ -3286,7 +3297,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition from header to cpp (with namespace + using).
|
/// Check: Move definition from header to cpp (with namespace + using).
|
||||||
@@ -3330,7 +3341,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move definition outside class with Namespace
|
/// Check: Move definition outside class with Namespace
|
||||||
@@ -3357,7 +3368,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
|||||||
"\n}\n";
|
"\n}\n";
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move free function from header to cpp.
|
/// Check: Move free function from header to cpp.
|
||||||
@@ -3392,7 +3403,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move free function from header to cpp (with namespace).
|
/// Check: Move free function from header to cpp (with namespace).
|
||||||
@@ -3430,7 +3441,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9157).
|
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9157).
|
||||||
@@ -3470,7 +3481,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization1()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9462).
|
/// Check: Move Ctor with member initialization list (QTCREATORBUG-9462).
|
||||||
@@ -3515,7 +3526,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_CtorWithInitialization2()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &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
|
||||||
@@ -3557,7 +3568,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_afterClass()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
|
QuickFixOperationTest(testFiles, &factory, ProjectPart::HeaderPaths(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -3579,7 +3590,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1
|
|||||||
;
|
;
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if whitespace is respected for operator functions
|
/// Check if whitespace is respected for operator functions
|
||||||
@@ -3601,7 +3612,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2
|
|||||||
;
|
;
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
|
void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
|
||||||
@@ -3633,7 +3644,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefOutside_macroUses()
|
|||||||
;
|
;
|
||||||
|
|
||||||
MoveFuncDefOutside factory;
|
MoveFuncDefOutside factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory,
|
QuickFixOperationTest(singleDocument(original, expected), &factory,
|
||||||
ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3666,7 +3677,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFunc()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutside()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutside()
|
||||||
@@ -3691,7 +3702,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutside()
|
|||||||
"};\n\n\n";
|
"};\n\n\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS()
|
||||||
@@ -3731,7 +3742,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNS()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing()
|
||||||
@@ -3775,7 +3786,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNSUsing()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs()
|
||||||
@@ -3802,7 +3813,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_MemberFuncOutsideWithNs()
|
|||||||
"};\n\n\n}\n";
|
"};\n\n\n}\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCpp()
|
||||||
@@ -3834,7 +3845,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCpp()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS()
|
||||||
@@ -3872,7 +3883,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: revert test_quickfix_MoveFuncDefOutside_CtorWithInitialization()
|
/// Check: revert test_quickfix_MoveFuncDefOutside_CtorWithInitialization()
|
||||||
@@ -3911,7 +3922,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_CtorWithInitialization()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
|
/// Check: Definition should not be placed behind the variable. QTCREATORBUG-10303
|
||||||
@@ -3937,7 +3948,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable
|
|||||||
"} bar;\n";
|
"} bar;\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
|
void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
|
||||||
@@ -3967,7 +3978,7 @@ void CppEditorPlugin::test_quickfix_MoveFuncDefToDecl_macroUses()
|
|||||||
"};\n\n\n\n";
|
"};\n\n\n\n";
|
||||||
|
|
||||||
MoveFuncDefToDecl factory;
|
MoveFuncDefToDecl factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory,
|
QuickFixOperationTest(singleDocument(original, expected), &factory,
|
||||||
ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
ProjectPart::HeaderPaths(), 0, "QTCREATORBUG-12314");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4005,7 +4016,7 @@ void CppEditorPlugin::test_quickfix_AssignToLocalVariable_templates()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
AssignToLocalVariable factory;
|
AssignToLocalVariable factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction_data()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction_data()
|
||||||
@@ -4069,7 +4080,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_typeDeduction()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase(singleDocument(original, expected), &factory);
|
QuickFixOperationTest(singleDocument(original, expected), &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles()
|
||||||
@@ -4095,7 +4106,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_freeFunction_separ
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles()
|
||||||
@@ -4129,7 +4140,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_memberFunction_sep
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode()
|
void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode()
|
||||||
@@ -4147,7 +4158,7 @@ void CppEditorPlugin::test_quickfix_ExtractLiteralAsParameter_notTriggeringForIn
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ExtractLiteralAsParameter factory;
|
ExtractLiteralAsParameter factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectOutOfClass()
|
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectOutOfClass()
|
||||||
@@ -4180,7 +4191,7 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectOutOfClass()
|
|||||||
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
|
||||||
|
|
||||||
ConvertQt4Connect factory;
|
ConvertQt4Connect factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass_data()
|
void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass_data()
|
||||||
@@ -4227,7 +4238,7 @@ void CppEditorPlugin::test_quickfix_ConvertQt4Connect_connectWithinClass()
|
|||||||
prefix + expected + suffix);
|
prefix + expected + suffix);
|
||||||
|
|
||||||
ConvertQt4Connect factory;
|
ConvertQt4Connect factory;
|
||||||
QuickFixTestCase(testFiles, &factory);
|
QuickFixOperationTest(testFiles, &factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -44,13 +44,14 @@ namespace CppEditor {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
namespace Tests {
|
namespace Tests {
|
||||||
|
|
||||||
/**
|
///
|
||||||
* Represents a test document before and after applying the quick fix.
|
/// Represents a test document before and after applying the quick fix.
|
||||||
*
|
///
|
||||||
* A TestDocument's source may contain an '@' character to denote
|
/// A TestDocument's source may contain an '@' character to denote
|
||||||
* the cursor position. This marker is removed before the Editor reads
|
/// the cursor position. This marker is removed before the Editor reads
|
||||||
* the document.
|
/// the document.
|
||||||
*/
|
///
|
||||||
|
|
||||||
class QuickFixTestDocument : public TestDocument
|
class QuickFixTestDocument : public TestDocument
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -66,31 +67,21 @@ public:
|
|||||||
QString m_expectedSource;
|
QString m_expectedSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
class BaseQuickFixTestCase : public TestCase
|
||||||
* Encapsulates the whole process of setting up an editor, getting the
|
|
||||||
* quick-fix, applying it, and checking the result.
|
|
||||||
*/
|
|
||||||
class QuickFixTestCase : public TestCase
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
|
/// Exactly one QuickFixTestDocument must contain the cursor position marker '@'.
|
||||||
CppQuickFixFactory *factory,
|
BaseQuickFixTestCase(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
const CppTools::ProjectPart::HeaderPaths &includePaths =
|
const CppTools::ProjectPart::HeaderPaths &headerPaths
|
||||||
CppTools::ProjectPart::HeaderPaths(),
|
= CppTools::ProjectPart::HeaderPaths());
|
||||||
int resultIndex = 0,
|
|
||||||
const QByteArray &expectedFailMessage = QByteArray());
|
|
||||||
~QuickFixTestCase();
|
|
||||||
|
|
||||||
static void run(const QList<QuickFixTestDocument::Ptr> &theTestFiles,
|
~BaseQuickFixTestCase();
|
||||||
CppQuickFixFactory *factory, const QString &incPath, int resultIndex = 0);
|
|
||||||
private:
|
protected:
|
||||||
QSharedPointer<TextEditor::QuickFixOperation> getFix(CppQuickFixFactory *factory,
|
QuickFixTestDocument::Ptr m_documentWithMarker;
|
||||||
CppEditorWidget *editorWidget,
|
QList<QuickFixTestDocument::Ptr> m_testDocuments;
|
||||||
int resultIndex = 0);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QuickFixTestDocument::Ptr> m_testFiles;
|
|
||||||
|
|
||||||
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
|
CppTools::CppCodeStylePreferences *m_cppCodeStylePreferences;
|
||||||
QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
|
QByteArray m_cppCodeStylePreferencesOriginalDelegateId;
|
||||||
|
|
||||||
@@ -98,6 +89,23 @@ private:
|
|||||||
bool m_restoreHeaderPaths;
|
bool m_restoreHeaderPaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Tests a concrete QuickFixOperation of a given CppQuickFixFactory
|
||||||
|
class QuickFixOperationTest : public BaseQuickFixTestCase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QuickFixOperationTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
|
CppQuickFixFactory *factory,
|
||||||
|
const CppTools::ProjectPart::HeaderPaths &headerPaths
|
||||||
|
= CppTools::ProjectPart::HeaderPaths(),
|
||||||
|
int operationIndex = 0,
|
||||||
|
const QByteArray &expectedFailMessage = QByteArray());
|
||||||
|
|
||||||
|
static void run(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||||
|
CppQuickFixFactory *factory,
|
||||||
|
const QString &headerPath,
|
||||||
|
int operationIndex = 0);
|
||||||
|
};
|
||||||
|
|
||||||
QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
|
QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
|
||||||
const QByteArray &expected);
|
const QByteArray &expected);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user