Commit 4a397a5f authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Erik Verbruggen
Browse files

CppEditor: Tests: Make AddIncludeForUndefinedIdentifier tests data driven



...as far as possible.

Change-Id: Ida039df7fbd4f1a9fce354dd8541c32255752082
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent 44634509
......@@ -154,34 +154,8 @@ private slots:
void test_quickfix_InsertDeclFromDef();
void test_quickfix_AddIncludeForUndefinedIdentifier_onSimpleName();
void test_quickfix_AddIncludeForUndefinedIdentifier_onNameOfQualifiedName();
void test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQualifiedName();
void test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateName();
void test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateNameInsideArguments();
void test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration();
void test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration2();
void test_quickfix_AddIncludeForUndefinedIdentifier_withForwardHeader();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_ignoremoc();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingTop();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingMiddle();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingBottom();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_appendToUnsorted();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_firstLocalIncludeAtFront();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_firstGlobalIncludeAtBack();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_preferGroupWithLongerMatchingPrefix();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_newGroupIfOnlyDifferentIncludeDirs();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedDirsSorted();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedDirsUnsorted();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedIncludeTypes1();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedIncludeTypes2();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedIncludeTypes3();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_mixedIncludeTypes4();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_noinclude();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_onlyIncludeGuard();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_veryFirstIncludeCppStyleCommentOnTop();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_veryFirstIncludeCStyleCommentOnTop();
void test_quickfix_AddIncludeForUndefinedIdentifier_inserting_checkQSomethingInQtIncludePaths();
void test_quickfix_AddIncludeForUndefinedIdentifier_data();
void test_quickfix_AddIncludeForUndefinedIdentifier();
void test_quickfix_AddIncludeForUndefinedIdentifier_noDoubleQtHeaderInclude();
void test_quickfix_MoveFuncDefOutside_MemberFuncToCpp();
......
......@@ -2300,21 +2300,26 @@ void CppEditorPlugin::test_quickfix_InsertDeclFromDef()
insertToSectionDeclFromDef("private slots", 5);
}
/// Check: Add include if there is already an include
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onSimpleName()
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_data()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QTest::addColumn<QString>("headerPath");
QTest::addColumn<QuickFixTestDocuments>("testDocuments");
QTest::addColumn<int>("refactoringOperationIndex");
QTest::addColumn<QString>("includeForTestFactory");
const int firstRefactoringOperation = 0;
const int secondRefactoringOperation = 1;
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "class Foo {};\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2334,28 +2339,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onSimpleNam
" Foo foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Cursor is on a qualified name (1)
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onNameOfQualifiedName()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("onSimpleName")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "namespace N { class Foo {}; }\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2375,28 +2370,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onNameOfQua
" N::Foo foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQualifiedName()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("onNameOfQualifiedName")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "namespace N { class Foo {}; }\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2416,28 +2401,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onBaseOfQua
" N::Foo foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("onBaseOfQualifiedName")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateName()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "namespace N { template <typename T> class Foo {}; }\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2457,28 +2432,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateN
" N::Foo<Bar> foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("onTemplateName")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateNameInsideArguments()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "namespace N { template <typename T> class Foo {}; }\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2498,28 +2463,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_onTemplateN
" N::Bar<Foo> foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("onTemplateNameInsideArguments")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "class Foo {};\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2543,28 +2498,18 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
" Foo foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("withForwardDeclaration")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardDeclaration2()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "template<class T> class Foo {};\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.h",
original, expected);
testFiles << QuickFixTestDocument::create("afile.h", original, expected);
// Source File
original =
......@@ -2588,34 +2533,23 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
" Foo foo;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForwardHeader()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("withForwardDeclaration2")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
// Header File
original = "template<class T> class QMyClass {};\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/qmyclass.h",
original, expected);
testFiles << QuickFixTestDocument::create("qmyclass.h", original, expected);
// Forward Header File
original = "#include \"qmyclass.h\"\n";
expected = original;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/QMyClass",
original, expected);
testFiles << QuickFixTestDocument::create("QMyClass", original, expected);
// Source File
original =
......@@ -2635,23 +2569,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_withForward
" QMyClass c;\n"
"}\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/afile.cpp",
original, expected);
// Do not use the test factory, at least once we want to go through the "full stack".
AddIncludeForUndefinedIdentifier factory;
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath(), 1);
}
/// Check: Ignore *.moc includes
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_ignoremoc()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("afile.cpp", original, expected);
QTest::newRow("withForwardHeader")
<< TestIncludePaths::globalIncludePath()
<< testFiles << secondRefactoringOperation << "";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"void @f();\n"
......@@ -2663,22 +2587,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_i
"void f();\n"
"#include \"file.moc\";\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include at top for a sorted group
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingTop()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("insertingIgnoreMoc")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"y.h\"\n"
......@@ -2691,22 +2606,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
"#include \"z.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include in the middle for a sorted group
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingMiddle()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("insertingSortingTop")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"a.h\"\n"
......@@ -2719,22 +2625,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
"#include \"z.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert include at bottom for a sorted group
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_sortingBottom()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("insertingSortingMiddle")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"a.h\"\n"
......@@ -2747,22 +2644,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_s
"#include \"file.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("insertingSortingBottom")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
/// Check: For an unsorted group the new include is appended
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_appendToUnsorted()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"b.h\"\n"
......@@ -2775,22 +2663,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_a
"#include \"file.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert a local include at front if there are only global includes
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_firstLocalIncludeAtFront()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("inserting_appendToUnsorted")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include <a.h>\n"
......@@ -2804,22 +2683,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_f
"#include <b.h>\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Insert a global include at back if there are only local includes
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_firstGlobalIncludeAtBack()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("inserting_firstLocalIncludeAtFront")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"file.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"a.h\"\n"
......@@ -2835,22 +2705,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_f
"\n"
"void f();\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("<file.h>"));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Prefer group with longest matching prefix
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_preferGroupWithLongerMatchingPrefix()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("firstGlobalIncludeAtBack")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "<file.h>";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"prefixa.h\"\n"
......@@ -2867,22 +2728,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_p
"#include \"foo.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"prefixc.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}
/// Check: Create a new include group if there are only include groups with a different include dir
void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_newGroupIfOnlyDifferentIncludeDirs()
{
CppTools::Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
testFiles << QuickFixTestDocument::create("file.cpp", original, expected);
QTest::newRow("inserting_preferGroupWithLongerMatchingPrefix")
<< TestIncludePaths::globalIncludePath()
<< testFiles << firstRefactoringOperation << "\"prefixc.h\"";
testFiles.clear();
QList<QuickFixTestDocument::Ptr> testFiles;
QByteArray original;
QByteArray expected;
// -------------------------------------------------------------------------------------------
original =
"#include \"lib/file.h\"\n"
......@@ -2896,22 +2748,13 @@ void CppEditorPlugin::test_quickfix_AddIncludeForUndefinedIdentifier_inserting_n
"#include \"file.h\"\n"
"\n"
;
testFiles << QuickFixTestDocument::create(temporaryDir.path().toUtf8() + "/file.cpp",
original, expected);
AddIncludeForUndefinedIdentifierTestFactory factory(QLatin1String("\"file.h\""));
QuickFixOperationTest::run(testFiles, &factory, TestIncludePaths::globalIncludePath());
}