forked from qt-creator/qt-creator
CppTools: Use test objects to group related test functions
Change-Id: I9ed2ad222579f49c20c75a53c862bb7251cff28d Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -110,19 +110,19 @@ add_qtc_plugin(CppTools
|
||||
extend_qtc_plugin(CppTools
|
||||
CONDITION WITH_TESTS
|
||||
SOURCES
|
||||
compileroptionsbuilder_test.cpp
|
||||
cppcodegen_test.cpp
|
||||
cppcompletion_test.cpp
|
||||
cppheadersource_test.cpp
|
||||
cpplocalsymbols_test.cpp
|
||||
cpplocatorfilter_test.cpp
|
||||
cppmodelmanager_test.cpp
|
||||
cpppointerdeclarationformatter_test.cpp
|
||||
compileroptionsbuilder_test.cpp compileroptionsbuilder_test.h
|
||||
cppcodegen_test.cpp cppcodegen_test.h
|
||||
cppcompletion_test.cpp cppcompletion_test.h
|
||||
cppheadersource_test.cpp cppheadersource_test.h
|
||||
cpplocalsymbols_test.cpp cpplocalsymbols_test.h
|
||||
cpplocatorfilter_test.cpp cpplocatorfilter_test.h
|
||||
cppmodelmanager_test.cpp cppmodelmanager_test.h
|
||||
cpppointerdeclarationformatter_test.cpp cpppointerdeclarationformatter_test.h
|
||||
cppsourceprocessertesthelper.cpp cppsourceprocessertesthelper.h
|
||||
cppsourceprocessor_test.cpp
|
||||
cppsourceprocessor_test.cpp cppsourceprocessor_test.h
|
||||
cpptoolstestcase.cpp cpptoolstestcase.h
|
||||
modelmanagertesthelper.cpp modelmanagertesthelper.h
|
||||
projectinfo_test.cpp
|
||||
symbolsearcher_test.cpp
|
||||
typehierarchybuilder_test.cpp
|
||||
projectinfo_test.cpp projectinfo_test.h
|
||||
symbolsearcher_test.cpp symbolsearcher_test.h
|
||||
typehierarchybuilder_test.cpp typehierarchybuilder_test.h
|
||||
)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "compileroptionsbuilder_test.h"
|
||||
|
||||
#include "compileroptionsbuilder.h"
|
||||
#include "projectinfo.h"
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
namespace {
|
||||
class CompilerOptionsBuilderTest
|
||||
class TestHelper
|
||||
{
|
||||
public:
|
||||
const ProjectPart &finalize()
|
||||
@@ -113,18 +114,18 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addProjectMacros()
|
||||
void CompilerOptionsBuilderTest::testAddProjectMacros()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addProjectMacros();
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("-DprojectFoo=projectBar"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_unknownFlagsAreForwarded()
|
||||
void CompilerOptionsBuilderTest::testUnknownFlagsAreForwarded()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.flags = QStringList{"-fancyFlag"};
|
||||
ProjectPart part = t.finalize();
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{part, UseSystemHeader::No,
|
||||
@@ -134,9 +135,9 @@ void CppToolsPlugin::test_optionsBuilder_unknownFlagsAreForwarded()
|
||||
QVERIFY(compilerOptionsBuilder.options().contains(part.compilerFlags.first()));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_warningsFlagsAreNotFilteredIfRequested()
|
||||
void CompilerOptionsBuilderTest::testWarningsFlagsAreNotFilteredIfRequested()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.flags = QStringList{"-Whello"};
|
||||
ProjectPart part = t.finalize();
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{part, UseSystemHeader::No,
|
||||
@@ -147,9 +148,9 @@ void CppToolsPlugin::test_optionsBuilder_warningsFlagsAreNotFilteredIfRequested(
|
||||
QVERIFY(compilerOptionsBuilder.options().contains(part.compilerFlags.first()));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_diagnosticOptionsAreRemoved()
|
||||
void CompilerOptionsBuilderTest::testDiagnosticOptionsAreRemoved()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.flags = QStringList{"-Wbla", "-pedantic"};
|
||||
ProjectPart part = t.finalize();
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{part, UseSystemHeader::No,
|
||||
@@ -160,9 +161,9 @@ void CppToolsPlugin::test_optionsBuilder_diagnosticOptionsAreRemoved()
|
||||
QVERIFY(!compilerOptionsBuilder.options().contains(part.compilerFlags.at(1)));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_cLanguageVersionIsRewritten()
|
||||
void CompilerOptionsBuilderTest::testCLanguageVersionIsRewritten()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
// We need to set the language version here to overcome a QTC_ASSERT checking
|
||||
// consistency between ProjectFile::Kind and ProjectPart::LanguageVersion
|
||||
t.flags = QStringList{"-std=c18"};
|
||||
@@ -177,9 +178,9 @@ void CppToolsPlugin::test_optionsBuilder_cLanguageVersionIsRewritten()
|
||||
QVERIFY(compilerOptionsBuilder.options().contains("-std=c17"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_languageVersionIsExplicitlySetIfNotProvided()
|
||||
void CompilerOptionsBuilderTest::testLanguageVersionIsExplicitlySetIfNotProvided()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::No, UseLanguageDefines::Yes};
|
||||
compilerOptionsBuilder.build(ProjectFile::CXXSource, UsePrecompiledHeaders::No);
|
||||
@@ -187,9 +188,9 @@ void CppToolsPlugin::test_optionsBuilder_languageVersionIsExplicitlySetIfNotProv
|
||||
QVERIFY(compilerOptionsBuilder.options().contains("-std=c++17"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_LanguageVersionIsExplicitlySetIfNotProvidedMsvc()
|
||||
void CompilerOptionsBuilderTest::testLanguageVersionIsExplicitlySetIfNotProvidedMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::No, UseLanguageDefines::Yes};
|
||||
@@ -198,18 +199,18 @@ void CppToolsPlugin::test_optionsBuilder_LanguageVersionIsExplicitlySetIfNotProv
|
||||
QVERIFY(compilerOptionsBuilder.options().contains("/std:c++17"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addWordWidth()
|
||||
void CompilerOptionsBuilderTest::testAddWordWidth()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addWordWidth();
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("-m64"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_headerPathOptionsOrder()
|
||||
void CompilerOptionsBuilderTest::testHeaderPathOptionsOrder()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
"dummy_version", ""};
|
||||
@@ -221,9 +222,9 @@ void CppToolsPlugin::test_optionsBuilder_headerPathOptionsOrder()
|
||||
t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_HeaderPathOptionsOrderMsvc()
|
||||
void CompilerOptionsBuilderTest::testHeaderPathOptionsOrderMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
@@ -238,9 +239,9 @@ void CppToolsPlugin::test_optionsBuilder_HeaderPathOptionsOrderMsvc()
|
||||
"/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_useSystemHeader()
|
||||
void CompilerOptionsBuilderTest::testUseSystemHeader()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::Yes,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
"dummy_version", ""};
|
||||
@@ -252,9 +253,9 @@ void CppToolsPlugin::test_optionsBuilder_useSystemHeader()
|
||||
"-isystem", "", "-isystem", t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_noClangHeadersPath()
|
||||
void CompilerOptionsBuilderTest::testNoClangHeadersPath()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addHeaderPathOptions();
|
||||
|
||||
@@ -262,9 +263,9 @@ void CppToolsPlugin::test_optionsBuilder_noClangHeadersPath()
|
||||
(QStringList{"-I", t.toNative("/tmp/path"), "-I", t.toNative("/tmp/system_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderMacOs()
|
||||
void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderMacOs()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
const HeaderPaths additionalHeaderPaths = {
|
||||
t.builtIn("/usr/include/c++/4.2.1"),
|
||||
t.builtIn("/usr/include/c++/4.2.1/backward"),
|
||||
@@ -290,9 +291,9 @@ void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderMacO
|
||||
"-isystem", t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderLinux()
|
||||
void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderLinux()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.targetTriple = "x86_64-linux-gnu";
|
||||
t.headerPaths = {
|
||||
t.builtIn("/usr/include/c++/4.8"),
|
||||
@@ -319,9 +320,9 @@ void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderLinu
|
||||
"-isystem", t.toNative("/usr/include")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderNoVersion()
|
||||
void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderNoVersion()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.targetTriple = "x86_64-w64-windows-gnu";
|
||||
t.headerPaths = {
|
||||
t.builtIn("C:/mingw530/i686-w64-mingw32/include"),
|
||||
@@ -342,9 +343,9 @@ void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderNoVe
|
||||
"-isystem", t.toNative("C:/mingw530/i686-w64-mingw32/include")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderAndroidClang()
|
||||
void CompilerOptionsBuilderTest::testClangHeadersAndCppIncludePathsOrderAndroidClang()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.targetTriple = "i686-linux-android";
|
||||
t.headerPaths = {
|
||||
t.builtIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include/i686-linux-android"),
|
||||
@@ -367,27 +368,27 @@ void CppToolsPlugin::test_optionsBuilder_clangHeadersAndCppIncludePathsOrderAndr
|
||||
"-isystem", t.toNative("C:/Android/sdk/ndk-bundle/sysroot/usr/include")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_noPrecompiledHeader()
|
||||
void CompilerOptionsBuilderTest::testNoPrecompiledHeader()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addPrecompiledHeaderOptions(UsePrecompiledHeaders::No);
|
||||
|
||||
QVERIFY(t.compilerOptionsBuilder->options().empty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_usePrecompiledHeader()
|
||||
void CompilerOptionsBuilderTest::testUsePrecompiledHeader()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addPrecompiledHeaderOptions(UsePrecompiledHeaders::Yes);
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-include", t.pchFileNativePath()}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_usePrecompiledHeaderMsvc()
|
||||
void CompilerOptionsBuilderTest::testUsePrecompiledHeaderMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize()};
|
||||
compilerOptionsBuilder.evaluateCompilerFlags();
|
||||
@@ -396,27 +397,27 @@ void CppToolsPlugin::test_optionsBuilder_usePrecompiledHeaderMsvc()
|
||||
QCOMPARE(compilerOptionsBuilder.options(), (QStringList{"/FI", t.pchFileNativePath()}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addMacros()
|
||||
void CompilerOptionsBuilderTest::testAddMacros()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addMacros(Macros{Macro{"key", "value"}});
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("-Dkey=value"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addTargetTriple()
|
||||
void CompilerOptionsBuilderTest::testAddTargetTriple()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addTargetTriple();
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("--target=x86_64-apple-darwin10"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_enableCExceptions()
|
||||
void CompilerOptionsBuilderTest::testEnableCExceptions()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.languageVersion = Utils::LanguageVersion::C99;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->enableExceptions();
|
||||
@@ -424,18 +425,18 @@ void CppToolsPlugin::test_optionsBuilder_enableCExceptions()
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("-fexceptions"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_enableCxxExceptions()
|
||||
void CompilerOptionsBuilderTest::testEnableCxxExceptions()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->enableExceptions();
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-fcxx-exceptions", "-fexceptions"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_insertWrappedQtHeaders()
|
||||
void CompilerOptionsBuilderTest::testInsertWrappedQtHeaders()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize(), UseSystemHeader::Yes,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
"dummy_version", ""};
|
||||
@@ -445,9 +446,9 @@ void CppToolsPlugin::test_optionsBuilder_insertWrappedQtHeaders()
|
||||
[](const QString &o) { return o.contains("wrappedQtHeaders"); }));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_insertWrappedMingwHeadersWithNonMingwToolchain()
|
||||
void CompilerOptionsBuilderTest::testInsertWrappedMingwHeadersWithNonMingwToolchain()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
CompilerOptionsBuilder builder{t.finalize(), UseSystemHeader::Yes, UseTweakedHeaderPaths::Yes,
|
||||
UseLanguageDefines::No, UseBuildSystemWarnings::No, "dummy_version", ""};
|
||||
builder.insertWrappedMingwHeaders();
|
||||
@@ -456,9 +457,9 @@ void CppToolsPlugin::test_optionsBuilder_insertWrappedMingwHeadersWithNonMingwTo
|
||||
[](const QString &o) { return o.contains("wrappedMingwHeaders"); }));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_insertWrappedMingwHeadersWithMingwToolchain()
|
||||
void CompilerOptionsBuilderTest::testInsertWrappedMingwHeadersWithMingwToolchain()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MINGW_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder builder{t.finalize(), UseSystemHeader::Yes, UseTweakedHeaderPaths::Yes,
|
||||
UseLanguageDefines::No, UseBuildSystemWarnings::No, "dummy_version", ""};
|
||||
@@ -468,18 +469,18 @@ void CppToolsPlugin::test_optionsBuilder_insertWrappedMingwHeadersWithMingwToolc
|
||||
[](const QString &o) { return o.contains("wrappedMingwHeaders"); }));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_setLanguageVersion()
|
||||
void CompilerOptionsBuilderTest::testSetLanguageVersion()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->updateFileLanguage(ProjectFile::CXXSource);
|
||||
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-x", "c++"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_setLanguageVersionMsvc()
|
||||
void CompilerOptionsBuilderTest::testSetLanguageVersionMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize()};
|
||||
compilerOptionsBuilder.evaluateCompilerFlags();
|
||||
@@ -488,9 +489,9 @@ void CppToolsPlugin::test_optionsBuilder_setLanguageVersionMsvc()
|
||||
QCOMPARE(compilerOptionsBuilder.options(), QStringList("/TP"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_handleLanguageExtension()
|
||||
void CompilerOptionsBuilderTest::testHandleLanguageExtension()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.languageVersion = Utils::LanguageVersion::CXX17;
|
||||
t.languageExtensions = Utils::LanguageExtension::ObjectiveC;
|
||||
t.finalize();
|
||||
@@ -499,9 +500,9 @@ void CppToolsPlugin::test_optionsBuilder_handleLanguageExtension()
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-x", "objective-c++"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_updateLanguageVersion()
|
||||
void CompilerOptionsBuilderTest::testUpdateLanguageVersion()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->updateFileLanguage(ProjectFile::CXXSource);
|
||||
t.compilerOptionsBuilder->updateFileLanguage(ProjectFile::CXXHeader);
|
||||
@@ -509,9 +510,9 @@ void CppToolsPlugin::test_optionsBuilder_updateLanguageVersion()
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-x", "c++-header"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_updateLanguageVersionMsvc()
|
||||
void CompilerOptionsBuilderTest::testUpdateLanguageVersionMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize()};
|
||||
compilerOptionsBuilder.evaluateCompilerFlags();
|
||||
@@ -521,9 +522,9 @@ void CppToolsPlugin::test_optionsBuilder_updateLanguageVersionMsvc()
|
||||
QCOMPARE(compilerOptionsBuilder.options(), QStringList("/TC"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addMsvcCompatibilityVersion()
|
||||
void CompilerOptionsBuilderTest::testAddMsvcCompatibilityVersion()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.toolchainMacros.append(Macro{"_MSC_FULL_VER", "190000000"});
|
||||
t.finalize();
|
||||
@@ -532,9 +533,9 @@ void CppToolsPlugin::test_optionsBuilder_addMsvcCompatibilityVersion()
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), QStringList("-fms-compatibility-version=19.00"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_undefineCppLanguageFeatureMacrosForMsvc2015()
|
||||
void CompilerOptionsBuilderTest::testUndefineCppLanguageFeatureMacrosForMsvc2015()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.isMsvc2015 = true;
|
||||
t.finalize();
|
||||
@@ -543,9 +544,9 @@ void CppToolsPlugin::test_optionsBuilder_undefineCppLanguageFeatureMacrosForMsvc
|
||||
QVERIFY(t.compilerOptionsBuilder->options().contains("-U__cpp_aggregate_bases"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addDefineFunctionMacrosMsvc()
|
||||
void CompilerOptionsBuilderTest::testAddDefineFunctionMacrosMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addDefineFunctionMacrosMsvc();
|
||||
@@ -554,9 +555,9 @@ void CppToolsPlugin::test_optionsBuilder_addDefineFunctionMacrosMsvc()
|
||||
"-D__FUNCTION__=\"someLegalAndLongishFunctionNameThatWorksAroundQTCREATORBUG-24580\""));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addProjectConfigFileInclude()
|
||||
void CompilerOptionsBuilderTest::testAddProjectConfigFileInclude()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.projectConfigFile = "dummy_file.h";
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->addProjectConfigFileInclude();
|
||||
@@ -564,9 +565,9 @@ void CppToolsPlugin::test_optionsBuilder_addProjectConfigFileInclude()
|
||||
QCOMPARE(t.compilerOptionsBuilder->options(), (QStringList{"-include", "dummy_file.h"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_addProjectConfigFileIncludeMsvc()
|
||||
void CompilerOptionsBuilderTest::testAddProjectConfigFileIncludeMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.projectConfigFile = "dummy_file.h";
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder{t.finalize()};
|
||||
@@ -576,9 +577,9 @@ void CppToolsPlugin::test_optionsBuilder_addProjectConfigFileIncludeMsvc()
|
||||
QCOMPARE(compilerOptionsBuilder.options(), (QStringList{"/FI", "dummy_file.h"}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_noUndefineClangVersionMacrosForNewMsvc()
|
||||
void CompilerOptionsBuilderTest::testNoUndefineClangVersionMacrosForNewMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.finalize();
|
||||
t.compilerOptionsBuilder->undefineClangVersionMacrosForMsvc();
|
||||
@@ -586,9 +587,9 @@ void CppToolsPlugin::test_optionsBuilder_noUndefineClangVersionMacrosForNewMsvc(
|
||||
QVERIFY(!t.compilerOptionsBuilder->options().contains("-U__clang__"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_undefineClangVersionMacrosForOldMsvc()
|
||||
void CompilerOptionsBuilderTest::testUndefineClangVersionMacrosForOldMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.toolchainMacros = {Macro{"_MSC_FULL_VER", "1300"}, Macro{"_MSC_VER", "13"}};
|
||||
t.finalize();
|
||||
@@ -597,9 +598,9 @@ void CppToolsPlugin::test_optionsBuilder_undefineClangVersionMacrosForOldMsvc()
|
||||
QVERIFY(t.compilerOptionsBuilder->options().contains("-U__clang__"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_buildAllOptions()
|
||||
void CompilerOptionsBuilderTest::testBuildAllOptions()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.extraFlags = QStringList{"-arch", "x86_64"};
|
||||
CompilerOptionsBuilder compilerOptionsBuilder(t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
@@ -621,9 +622,9 @@ void CppToolsPlugin::test_optionsBuilder_buildAllOptions()
|
||||
"-isystem", t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_buildAllOptionsMsvc()
|
||||
void CompilerOptionsBuilderTest::testBuildAllOptionsMsvc()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
CompilerOptionsBuilder compilerOptionsBuilder(t.finalize(), UseSystemHeader::No,
|
||||
UseTweakedHeaderPaths::Yes, UseLanguageDefines::No, UseBuildSystemWarnings::No,
|
||||
@@ -649,9 +650,9 @@ void CppToolsPlugin::test_optionsBuilder_buildAllOptionsMsvc()
|
||||
"/clang:-isystem", "/clang:" + t.toNative("/tmp/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_optionsBuilder_buildAllOptionsMsvcWithExceptions()
|
||||
void CompilerOptionsBuilderTest::testBuildAllOptionsMsvcWithExceptions()
|
||||
{
|
||||
CompilerOptionsBuilderTest t;
|
||||
TestHelper t;
|
||||
t.toolchainType = Constants::MSVC_TOOLCHAIN_TYPEID;
|
||||
t.toolchainMacros.append(Macro{"_CPPUNWIND", "1"});
|
||||
CompilerOptionsBuilder compilerOptionsBuilder(t.finalize(), UseSystemHeader::No,
|
||||
|
||||
80
src/plugins/cpptools/compileroptionsbuilder_test.h
Normal file
80
src/plugins/cpptools/compileroptionsbuilder_test.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class CompilerOptionsBuilderTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testAddProjectMacros();
|
||||
void testUnknownFlagsAreForwarded();
|
||||
void testWarningsFlagsAreNotFilteredIfRequested();
|
||||
void testDiagnosticOptionsAreRemoved();
|
||||
void testCLanguageVersionIsRewritten();
|
||||
void testLanguageVersionIsExplicitlySetIfNotProvided();
|
||||
void testLanguageVersionIsExplicitlySetIfNotProvidedMsvc();
|
||||
void testAddWordWidth();
|
||||
void testHeaderPathOptionsOrder();
|
||||
void testHeaderPathOptionsOrderMsvc();
|
||||
void testUseSystemHeader();
|
||||
void testNoClangHeadersPath();
|
||||
void testClangHeadersAndCppIncludePathsOrderMacOs();
|
||||
void testClangHeadersAndCppIncludePathsOrderLinux();
|
||||
void testClangHeadersAndCppIncludePathsOrderNoVersion();
|
||||
void testClangHeadersAndCppIncludePathsOrderAndroidClang();
|
||||
void testNoPrecompiledHeader();
|
||||
void testUsePrecompiledHeader();
|
||||
void testUsePrecompiledHeaderMsvc();
|
||||
void testAddMacros();
|
||||
void testAddTargetTriple();
|
||||
void testEnableCExceptions();
|
||||
void testEnableCxxExceptions();
|
||||
void testInsertWrappedQtHeaders();
|
||||
void testInsertWrappedMingwHeadersWithNonMingwToolchain();
|
||||
void testInsertWrappedMingwHeadersWithMingwToolchain();
|
||||
void testSetLanguageVersion();
|
||||
void testSetLanguageVersionMsvc();
|
||||
void testHandleLanguageExtension();
|
||||
void testUpdateLanguageVersion();
|
||||
void testUpdateLanguageVersionMsvc();
|
||||
void testAddMsvcCompatibilityVersion();
|
||||
void testUndefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
void testAddDefineFunctionMacrosMsvc();
|
||||
void testAddProjectConfigFileInclude();
|
||||
void testAddProjectConfigFileIncludeMsvc();
|
||||
void testNoUndefineClangVersionMacrosForNewMsvc();
|
||||
void testUndefineClangVersionMacrosForOldMsvc();
|
||||
void testBuildAllOptions();
|
||||
void testBuildAllOptionsMsvc();
|
||||
void testBuildAllOptionsMsvcWithExceptions();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,7 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cppcodegen_test.h"
|
||||
|
||||
#include "cpptoolstestcase.h"
|
||||
#include "insertionpointlocator.h"
|
||||
|
||||
@@ -73,7 +74,7 @@ Document::Ptr createDocumentAndFile(Tests::TemporaryDir *temporaryDir,
|
||||
/*!
|
||||
Should insert at line 3, column 1, with "public:\n" as prefix and without suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_public_in_empty_class()
|
||||
void CodegenTest::testPublicInEmptyClass()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -106,7 +107,7 @@ void CppToolsPlugin::test_codegen_public_in_empty_class()
|
||||
/*!
|
||||
Should insert at line 3, column 1, without prefix and without suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_public_in_nonempty_class()
|
||||
void CodegenTest::testPublicInNonemptyClass()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -140,7 +141,7 @@ void CppToolsPlugin::test_codegen_public_in_nonempty_class()
|
||||
/*!
|
||||
Should insert at line 3, column 1, with "public:\n" as prefix and "\n suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_public_before_protected()
|
||||
void CodegenTest::testPublicBeforeProtected()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -175,7 +176,7 @@ void CppToolsPlugin::test_codegen_public_before_protected()
|
||||
Should insert at line 4, column 1, with "private:\n" as prefix and without
|
||||
suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_private_after_protected()
|
||||
void CodegenTest::testPrivateAfterProtected()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -210,7 +211,7 @@ void CppToolsPlugin::test_codegen_private_after_protected()
|
||||
Should insert at line 4, column 1, with "protected:\n" as prefix and without
|
||||
suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_protected_in_nonempty_class()
|
||||
void CodegenTest::testProtectedInNonemptyClass()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -244,7 +245,7 @@ void CppToolsPlugin::test_codegen_protected_in_nonempty_class()
|
||||
/*!
|
||||
Should insert at line 4, column 1, with "protected\n" as prefix and "\n" suffix.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_protected_between_public_and_private()
|
||||
void CodegenTest::testProtectedBetweenPublicAndPrivate()
|
||||
{
|
||||
const QByteArray src = "\n"
|
||||
"class Foo\n" // line 1
|
||||
@@ -283,7 +284,7 @@ void CppToolsPlugin::test_codegen_protected_between_public_and_private()
|
||||
This is the typical Qt Designer case, with test-input like what the integration
|
||||
generates.
|
||||
*/
|
||||
void CppToolsPlugin::test_codegen_qtdesigner_integration()
|
||||
void CodegenTest::testQtdesignerIntegration()
|
||||
{
|
||||
const QByteArray src = "/**** Some long (C)opyright notice ****/\n"
|
||||
"#ifndef MAINWINDOW_H\n"
|
||||
@@ -332,7 +333,7 @@ void CppToolsPlugin::test_codegen_qtdesigner_integration()
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
void CodegenTest::testDefinitionEmptyClass()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
@@ -378,7 +379,7 @@ void CppToolsPlugin::test_codegen_definition_empty_class()
|
||||
QCOMPARE(loc.column(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
void CodegenTest::testDefinitionFirstMember()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
@@ -436,7 +437,7 @@ void CppToolsPlugin::test_codegen_definition_first_member()
|
||||
QCOMPARE(loc.prefix(), QString());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
void CodegenTest::testDefinitionLastMember()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
@@ -495,7 +496,7 @@ void CppToolsPlugin::test_codegen_definition_last_member()
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
void CodegenTest::testDefinitionMiddleMember()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
@@ -561,7 +562,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member()
|
||||
QCOMPARE(loc.suffix(), QString());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefined()
|
||||
void CodegenTest::testDefinitionMiddleMemberSurroundedByUndefined()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
@@ -621,7 +622,7 @@ void CppToolsPlugin::test_codegen_definition_middle_member_surrounded_by_undefin
|
||||
QCOMPARE(loc.suffix(), QLatin1String("\n\n"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_codegen_definition_member_specific_file()
|
||||
void CodegenTest::testDefinitionMemberSpecificFile()
|
||||
{
|
||||
Tests::TemporaryDir temporaryDir;
|
||||
QVERIFY(temporaryDir.isValid());
|
||||
|
||||
53
src/plugins/cpptools/cppcodegen_test.h
Normal file
53
src/plugins/cpptools/cppcodegen_test.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class CodegenTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
private slots:
|
||||
void testPublicInEmptyClass();
|
||||
void testPublicInNonemptyClass();
|
||||
void testPublicBeforeProtected();
|
||||
void testPrivateAfterProtected();
|
||||
void testProtectedInNonemptyClass();
|
||||
void testProtectedBetweenPublicAndPrivate();
|
||||
void testQtdesignerIntegration();
|
||||
void testDefinitionEmptyClass();
|
||||
void testDefinitionFirstMember();
|
||||
void testDefinitionLastMember();
|
||||
void testDefinitionMiddleMember();
|
||||
void testDefinitionMiddleMemberSurroundedByUndefined();
|
||||
void testDefinitionMemberSpecificFile();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,10 +23,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppcompletion_test.h"
|
||||
|
||||
#include "cppcompletionassist.h"
|
||||
#include "cppdoxygen.h"
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
|
||||
#include <texteditor/codeassist/iassistproposal.h>
|
||||
@@ -34,6 +35,7 @@
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/changeset.h>
|
||||
#include <utils/textutils.h>
|
||||
#include <utils/fileutils.h>
|
||||
@@ -185,7 +187,7 @@ bool isDoxygenTagCompletion(const QStringList &list)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppToolsPlugin::test_completion_basic_1()
|
||||
void CompletionTest::testCompletionBasic1()
|
||||
{
|
||||
const QByteArray source =
|
||||
"class Foo\n"
|
||||
@@ -217,7 +219,7 @@ void CppToolsPlugin::test_completion_basic_1()
|
||||
QVERIFY(!memberCompletions.contains(QLatin1String("f")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737()
|
||||
void CompletionTest::testCompletionPrefixFirstQTCREATORBUG_8737()
|
||||
{
|
||||
const QByteArray source =
|
||||
"void f()\n"
|
||||
@@ -237,7 +239,7 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_8737()
|
||||
QVERIFY(completions.contains(QLatin1String("a_b_c")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236()
|
||||
void CompletionTest::testCompletionPrefixFirstQTCREATORBUG_9236()
|
||||
{
|
||||
const QByteArray source =
|
||||
"class r_etclass\n"
|
||||
@@ -266,7 +268,7 @@ void CppToolsPlugin::test_completion_prefix_first_QTCREATORBUG_9236()
|
||||
QVERIFY(completions.contains(QLatin1String("r_et")));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_template_function()
|
||||
void CompletionTest::testCompletionTemplateFunction()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
QFETCH(QStringList, expectedCompletions);
|
||||
@@ -282,7 +284,7 @@ void CppToolsPlugin::test_completion_template_function()
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_template_function_data()
|
||||
void CompletionTest::testCompletionTemplateFunction_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("code");
|
||||
QTest::addColumn<QStringList>("expectedCompletions");
|
||||
@@ -322,7 +324,7 @@ void CppToolsPlugin::test_completion_template_function_data()
|
||||
<< code << completions;
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion()
|
||||
void CompletionTest::testCompletion()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
QFETCH(QByteArray, prefix);
|
||||
@@ -348,7 +350,7 @@ void CppToolsPlugin::test_completion()
|
||||
QCOMPARE(actualCompletions, expectedCompletions);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_global_completion_data()
|
||||
void CompletionTest::testGlobalCompletion_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("code");
|
||||
QTest::addColumn<QByteArray>("prefix");
|
||||
@@ -378,7 +380,7 @@ void CppToolsPlugin::test_global_completion_data()
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_global_completion()
|
||||
void CompletionTest::testGlobalCompletion()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
QFETCH(QByteArray, prefix);
|
||||
@@ -391,7 +393,7 @@ void CppToolsPlugin::test_global_completion()
|
||||
QVERIFY(Utils::toSet(completions).contains(Utils::toSet(requiredCompletionItems)));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_doxygen_tag_completion_data()
|
||||
void CompletionTest::testDoxygenTagCompletion_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("code");
|
||||
|
||||
@@ -407,7 +409,7 @@ void CppToolsPlugin::test_doxygen_tag_completion_data()
|
||||
" */\n");
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_doxygen_tag_completion()
|
||||
void CompletionTest::testDoxygenTagCompletion()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
|
||||
@@ -435,7 +437,7 @@ static void enumTestCase(const QByteArray &tag, const QByteArray &source,
|
||||
<< QStringList({"val1", "val2", "val3"});
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_data()
|
||||
void CompletionTest::testCompletion_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("code");
|
||||
QTest::addColumn<QByteArray>("prefix");
|
||||
@@ -2747,7 +2749,7 @@ void CppToolsPlugin::test_completion_data()
|
||||
) << _("s.begin()->") << QStringList({"Foo", "bar"});
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_member_access_operator()
|
||||
void CompletionTest::testCompletionMemberAccessOperator()
|
||||
{
|
||||
QFETCH(QByteArray, code);
|
||||
QFETCH(QByteArray, prefix);
|
||||
@@ -2768,7 +2770,7 @@ void CppToolsPlugin::test_completion_member_access_operator()
|
||||
QCOMPARE(replaceAccessOperator, expectedReplaceAccessOperator);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_completion_member_access_operator_data()
|
||||
void CompletionTest::testCompletionMemberAccessOperator_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("code");
|
||||
QTest::addColumn<QByteArray>("prefix");
|
||||
|
||||
58
src/plugins/cpptools/cppcompletion_test.h
Normal file
58
src/plugins/cpptools/cppcompletion_test.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class CompletionTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testCompletionBasic1();
|
||||
|
||||
void testCompletionTemplateFunction_data();
|
||||
void testCompletionTemplateFunction();
|
||||
|
||||
void testCompletion_data();
|
||||
void testCompletion();
|
||||
|
||||
void testGlobalCompletion_data();
|
||||
void testGlobalCompletion();
|
||||
|
||||
void testDoxygenTagCompletion_data();
|
||||
void testDoxygenTagCompletion();
|
||||
|
||||
void testCompletionMemberAccessOperator_data();
|
||||
void testCompletionMemberAccessOperator();
|
||||
|
||||
void testCompletionPrefixFirstQTCREATORBUG_8737();
|
||||
void testCompletionPrefixFirstQTCREATORBUG_9236();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,6 +23,8 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppheadersource_test.h"
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolsreuse.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
@@ -52,7 +54,7 @@ static QString baseTestDir()
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
void CppToolsPlugin::test_headersource()
|
||||
void HeaderSourceTest::test()
|
||||
{
|
||||
QFETCH(QString, sourceFileName);
|
||||
QFETCH(QString, headerFileName);
|
||||
@@ -67,15 +69,15 @@ void CppToolsPlugin::test_headersource()
|
||||
createTempFile(headerPath);
|
||||
|
||||
bool wasHeader;
|
||||
clearHeaderSourceCache();
|
||||
CppToolsPlugin::clearHeaderSourceCache();
|
||||
QCOMPARE(correspondingHeaderOrSource(sourcePath, &wasHeader), headerPath);
|
||||
QVERIFY(!wasHeader);
|
||||
clearHeaderSourceCache();
|
||||
CppToolsPlugin::clearHeaderSourceCache();
|
||||
QCOMPARE(correspondingHeaderOrSource(headerPath, &wasHeader), sourcePath);
|
||||
QVERIFY(wasHeader);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headersource_data()
|
||||
void HeaderSourceTest::test_data()
|
||||
{
|
||||
QTest::addColumn<QString>("sourceFileName");
|
||||
QTest::addColumn<QString>("headerFileName");
|
||||
@@ -86,10 +88,10 @@ void CppToolsPlugin::test_headersource_data()
|
||||
QTest::newRow("sourceAndHeaderPrefixWithBothsub") << _("src/testc_foo.cpp") << _("include/testh_foo.h");
|
||||
}
|
||||
|
||||
void CppToolsPlugin::initTestCase()
|
||||
void HeaderSourceTest::initTestCase()
|
||||
{
|
||||
QDir(baseTestDir()).mkpath(_("."));
|
||||
CppFileSettings *fs = fileSettings();
|
||||
CppFileSettings *fs = CppToolsPlugin::fileSettings();
|
||||
fs->headerSearchPaths.append(QLatin1String("include"));
|
||||
fs->headerSearchPaths.append(QLatin1String("../include"));
|
||||
fs->sourceSearchPaths.append(QLatin1String("src"));
|
||||
@@ -98,10 +100,10 @@ void CppToolsPlugin::initTestCase()
|
||||
fs->sourcePrefixes.append(QLatin1String("testc_"));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::cleanupTestCase()
|
||||
void HeaderSourceTest::cleanupTestCase()
|
||||
{
|
||||
Utils::FilePath::fromString(baseTestDir()).removeRecursively();
|
||||
CppFileSettings *fs = fileSettings();
|
||||
CppFileSettings *fs = CppToolsPlugin::fileSettings();
|
||||
fs->headerSearchPaths.removeLast();
|
||||
fs->headerSearchPaths.removeLast();
|
||||
fs->sourceSearchPaths.removeLast();
|
||||
|
||||
44
src/plugins/cpptools/cppheadersource_test.h
Normal file
44
src/plugins/cpptools/cppheadersource_test.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class HeaderSourceTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void test_data();
|
||||
void test();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpplocalsymbols_test.h"
|
||||
|
||||
#include "cpplocalsymbols.h"
|
||||
#include "cppsemanticinfo.h"
|
||||
@@ -131,7 +131,7 @@ QT_END_NAMESPACE
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
void CppToolsPlugin::test_cpplocalsymbols_data()
|
||||
void LocalSymbolsTest::test_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
QTest::addColumn<QList<Result>>("expectedUses");
|
||||
@@ -165,7 +165,7 @@ void CppToolsPlugin::test_cpplocalsymbols_data()
|
||||
<< Result(_("func"), 3, 5, 4));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocalsymbols()
|
||||
void LocalSymbolsTest::test()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
QFETCH(QList<Result>, expectedUses);
|
||||
|
||||
41
src/plugins/cpptools/cpplocalsymbols_test.h
Normal file
41
src/plugins/cpptools/cpplocalsymbols_test.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class LocalSymbolsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test_data();
|
||||
void test();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpplocatorfilter_test.h"
|
||||
|
||||
#include "cppclassesfilter.h"
|
||||
#include "cppcurrentdocumentfilter.h"
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
|
||||
void LocatorFilterTest::testLocatorFilter()
|
||||
{
|
||||
QFETCH(QString, testFile);
|
||||
QFETCH(ILocatorFilter *, filter);
|
||||
@@ -149,7 +149,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
|
||||
CppLocatorFilterTestCase(filter, testFile, searchText, expectedResults);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
void LocatorFilterTest::testLocatorFilter_data()
|
||||
{
|
||||
QTest::addColumn<QString>("testFile");
|
||||
QTest::addColumn<ILocatorFilter *>("filter");
|
||||
@@ -321,7 +321,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
|
||||
};
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
|
||||
void LocatorFilterTest::testCurrentDocumentFilter()
|
||||
{
|
||||
MyTestDataDir testDirectory("testdata_basic");
|
||||
const QString testFile = testDirectory.file("file1.cpp");
|
||||
@@ -375,7 +375,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
|
||||
CppCurrentDocumentFilterTestCase(testFile, expectedResults);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentHighlighting()
|
||||
void LocatorFilterTest::testCurrentDocumentHighlighting()
|
||||
{
|
||||
MyTestDataDir testDirectory("testdata_basic");
|
||||
const QString testFile = testDirectory.file("file1.cpp");
|
||||
@@ -399,7 +399,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentHighlighting()
|
||||
CppCurrentDocumentFilterTestCase(testFile, expectedResults, searchText);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cpplocatorfilters_CppFunctionsFilterHighlighting()
|
||||
void LocatorFilterTest::testFunctionsFilterHighlighting()
|
||||
{
|
||||
MyTestDataDir testDirectory("testdata_basic");
|
||||
const QString testFile = testDirectory.file("file1.cpp");
|
||||
|
||||
44
src/plugins/cpptools/cpplocatorfilter_test.h
Normal file
44
src/plugins/cpptools/cpplocatorfilter_test.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class LocatorFilterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testLocatorFilter();
|
||||
void testLocatorFilter_data();
|
||||
void testCurrentDocumentFilter();
|
||||
void testCurrentDocumentHighlighting();
|
||||
void testFunctionsFilterHighlighting();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,10 +23,11 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppmodelmanager_test.h"
|
||||
|
||||
#include "baseeditordocumentprocessor.h"
|
||||
#include "builtineditordocumentparser.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
#include "editordocumenthandle.h"
|
||||
#include "modelmanagertesthelper.h"
|
||||
@@ -173,7 +174,7 @@ ProjectPart::Ptr projectPartOfEditorDocument(const QString &filePath)
|
||||
} // anonymous namespace
|
||||
|
||||
/// Check: The preprocessor cleans include and framework paths.
|
||||
void CppToolsPlugin::test_modelmanager_paths_are_clean()
|
||||
void ModelManagerTest::testPathsAreClean()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
@@ -200,7 +201,7 @@ void CppToolsPlugin::test_modelmanager_paths_are_clean()
|
||||
}
|
||||
|
||||
/// Check: Frameworks headers are resolved.
|
||||
void CppToolsPlugin::test_modelmanager_framework_headers()
|
||||
void ModelManagerTest::testFrameworkHeaders()
|
||||
{
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
QSKIP("Can't resolve framework soft links on Windows.");
|
||||
@@ -247,7 +248,7 @@ void CppToolsPlugin::test_modelmanager_framework_headers()
|
||||
/// QTCREATORBUG-9056
|
||||
/// Check: If the project configuration changes, all project files and their
|
||||
/// includes have to be reparsed.
|
||||
void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
|
||||
void ModelManagerTest::testRefreshAlsoIncludesOfProjectFiles()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
@@ -304,7 +305,7 @@ void CppToolsPlugin::test_modelmanager_refresh_also_includes_of_project_files()
|
||||
/// QTCREATORBUG-9205
|
||||
/// Check: When reparsing the same files again, no errors occur
|
||||
/// (The CppSourceProcessor's already seen files are properly cleared!).
|
||||
void CppToolsPlugin::test_modelmanager_refresh_several_times()
|
||||
void ModelManagerTest::testRefreshSeveralTimes()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
@@ -366,7 +367,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
|
||||
|
||||
/// QTCREATORBUG-9581
|
||||
/// Check: If nothing has changes, nothing should be reindexed.
|
||||
void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
|
||||
void ModelManagerTest::testRefreshTestForChanges()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
@@ -398,7 +399,7 @@ void CppToolsPlugin::test_modelmanager_refresh_test_for_changes()
|
||||
|
||||
/// Check: (1) Added project files are recognized and parsed.
|
||||
/// Check: (2) Removed project files are recognized and purged from the snapshot.
|
||||
void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
|
||||
void ModelManagerTest::testRefreshAddedAndPurgeRemoved()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
CppModelManager *mm = CppModelManager::instance();
|
||||
@@ -450,7 +451,7 @@ void CppToolsPlugin::test_modelmanager_refresh_added_and_purge_removed()
|
||||
|
||||
/// Check: Timestamp modified files are reparsed if project files are added or removed
|
||||
/// while the project configuration stays the same
|
||||
void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_change()
|
||||
void ModelManagerTest::testRefreshTimeStampModifiedIfSourcefilesChange()
|
||||
{
|
||||
QFETCH(QString, fileToChange);
|
||||
QFETCH(QStringList, initialProjectFiles);
|
||||
@@ -524,7 +525,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
QCOMPARE(document->globalSymbolAt(1)->name()->identifier()->chars(), "addedOtherGlobal");
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_change_data()
|
||||
void ModelManagerTest::testRefreshTimeStampModifiedIfSourcefilesChange_data()
|
||||
{
|
||||
QTest::addColumn<QString>("fileToChange");
|
||||
QTest::addColumn<QStringList>("initialProjectFiles");
|
||||
@@ -546,7 +547,7 @@ void CppToolsPlugin::test_modelmanager_refresh_timeStampModified_if_sourcefiles_
|
||||
|
||||
/// Check: If a second project is opened, the code model is still aware of
|
||||
/// files of the first project.
|
||||
void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
|
||||
void ModelManagerTest::testSnapshotAfterTwoProjects()
|
||||
{
|
||||
QSet<QString> refreshedFiles;
|
||||
ModelManagerTestHelper helper;
|
||||
@@ -590,7 +591,7 @@ void CppToolsPlugin::test_modelmanager_snapshot_after_two_projects()
|
||||
/// though it might not be actually generated in the build dir.
|
||||
///
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
||||
void ModelManagerTest::testExtraeditorsupportUiFiles()
|
||||
{
|
||||
VerifyCleanCppModelManager verify;
|
||||
|
||||
@@ -635,7 +636,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
|
||||
|
||||
/// QTCREATORBUG-9828: Locator shows symbols of closed files
|
||||
/// Check: The garbage collector should be run if the last CppEditor is closed.
|
||||
void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
|
||||
void ModelManagerTest::testGcIfLastCppeditorClosed()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -666,7 +667,7 @@ void CppToolsPlugin::test_modelmanager_gc_if_last_cppeditor_closed()
|
||||
}
|
||||
|
||||
/// Check: Files that are open in the editor are not garbage collected.
|
||||
void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
|
||||
void ModelManagerTest::testDontGcOpenedFiles()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -729,7 +730,7 @@ QString nameOfFirstDeclaration(const Document::Ptr &doc)
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_defines_per_project()
|
||||
void ModelManagerTest::testDefinesPerProject()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -789,7 +790,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
||||
void ModelManagerTest::testPrecompiledHeaders()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -870,7 +871,7 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
||||
void ModelManagerTest::testDefinesPerEditor()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -933,7 +934,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
|
||||
}
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
|
||||
void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
|
||||
{
|
||||
ModelManagerTestHelper helper;
|
||||
|
||||
@@ -985,7 +986,7 @@ void CppToolsPlugin::test_modelmanager_updateEditorsAfterProjectUpdate()
|
||||
QCOMPARE(documentBProjectPart->topLevelProject, pi->projectFilePath());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_renameIncludes()
|
||||
void ModelManagerTest::testRenameIncludes()
|
||||
{
|
||||
struct ModelManagerGCHelper {
|
||||
~ModelManagerGCHelper() { CppModelManager::instance()->GC(); }
|
||||
@@ -1033,7 +1034,7 @@ void CppToolsPlugin::test_modelmanager_renameIncludes()
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << newHeader);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_renameIncludesInEditor()
|
||||
void ModelManagerTest::testRenameIncludesInEditor()
|
||||
{
|
||||
struct ModelManagerGCHelper {
|
||||
~ModelManagerGCHelper() { CppModelManager::instance()->GC(); }
|
||||
@@ -1157,7 +1158,7 @@ void CppToolsPlugin::test_modelmanager_renameIncludesInEditor()
|
||||
QCOMPARE(snapshot.allIncludesForDocument(sourceFile), QSet<QString>() << renamedHeaderWithPragmaOnce);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_modelmanager_documentsAndRevisions()
|
||||
void ModelManagerTest::testDocumentsAndRevisions()
|
||||
{
|
||||
TestCase helper;
|
||||
|
||||
|
||||
58
src/plugins/cpptools/cppmodelmanager_test.h
Normal file
58
src/plugins/cpptools/cppmodelmanager_test.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class ModelManagerTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testPathsAreClean();
|
||||
void testFrameworkHeaders();
|
||||
void testRefreshAlsoIncludesOfProjectFiles();
|
||||
void testRefreshSeveralTimes();
|
||||
void testRefreshTestForChanges();
|
||||
void testRefreshAddedAndPurgeRemoved();
|
||||
void testRefreshTimeStampModifiedIfSourcefilesChange();
|
||||
void testRefreshTimeStampModifiedIfSourcefilesChange_data();
|
||||
void testSnapshotAfterTwoProjects();
|
||||
void testExtraeditorsupportUiFiles();
|
||||
void testGcIfLastCppeditorClosed();
|
||||
void testDontGcOpenedFiles();
|
||||
void testDefinesPerProject();
|
||||
void testDefinesPerEditor();
|
||||
void testUpdateEditorsAfterProjectUpdate();
|
||||
void testPrecompiledHeaders();
|
||||
void testRenameIncludes();
|
||||
void testRenameIncludesInEditor();
|
||||
void testDocumentsAndRevisions();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,8 +23,9 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpppointerdeclarationformatter_test.h"
|
||||
|
||||
#include "cpppointerdeclarationformatter.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -141,7 +142,7 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations()
|
||||
void PointerDeclarationFormatterTest::testInSimpledeclarations()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(QString, reformattedSource);
|
||||
@@ -152,7 +153,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations()
|
||||
PointerDeclarationFormatter::RespectCursor);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
|
||||
void PointerDeclarationFormatterTest::testInSimpledeclarations_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<QString>("reformattedSource");
|
||||
@@ -365,7 +366,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
|
||||
<< "C & C::operator = (const C &) {}";
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()
|
||||
void PointerDeclarationFormatterTest::testInControlflowstatements()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(QString, reformattedSource);
|
||||
@@ -376,7 +377,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()
|
||||
PointerDeclarationFormatter::RespectCursor);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_data()
|
||||
void PointerDeclarationFormatterTest::testInControlflowstatements_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<QString>("reformattedSource");
|
||||
@@ -440,7 +441,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_dat
|
||||
QTest::newRow("precondition-fail-no-pointer") << source << stripCursor(source);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators()
|
||||
void PointerDeclarationFormatterTest::testMultipleDeclarators()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(QString, reformattedSource);
|
||||
@@ -451,7 +452,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators()
|
||||
PointerDeclarationFormatter::RespectCursor);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
|
||||
void PointerDeclarationFormatterTest::testMultipleDeclarators_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<QString>("reformattedSource");
|
||||
@@ -495,7 +496,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
|
||||
<< "char *s, * (*foo)(char * s) = 0;";
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
|
||||
void PointerDeclarationFormatterTest::testMultipleMatches()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(QString, reformattedSource);
|
||||
@@ -506,7 +507,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
|
||||
PointerDeclarationFormatter::IgnoreCursor);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
|
||||
void PointerDeclarationFormatterTest::testMultipleMatches_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<QString>("reformattedSource");
|
||||
@@ -578,7 +579,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
|
||||
"}\n";
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_macros()
|
||||
void PointerDeclarationFormatterTest::testMacros()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(QString, reformattedSource);
|
||||
@@ -589,7 +590,7 @@ void CppToolsPlugin::test_format_pointerdeclaration_macros()
|
||||
PointerDeclarationFormatter::RespectCursor);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_format_pointerdeclaration_macros_data()
|
||||
void PointerDeclarationFormatterTest::testMacros_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<QString>("reformattedSource");
|
||||
|
||||
49
src/plugins/cpptools/cpppointerdeclarationformatter_test.h
Normal file
49
src/plugins/cpptools/cpppointerdeclarationformatter_test.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class PointerDeclarationFormatterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testInSimpledeclarations();
|
||||
void testInSimpledeclarations_data();
|
||||
void testInControlflowstatements();
|
||||
void testInControlflowstatements_data();
|
||||
void testMultipleDeclarators();
|
||||
void testMultipleDeclarators_data();
|
||||
void testMultipleMatches();
|
||||
void testMultipleMatches_data();
|
||||
void testMacros();
|
||||
void testMacros_data();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cppsourceprocessor_test.h"
|
||||
|
||||
#include "baseeditordocumentprocessor.h"
|
||||
#include "cppmodelmanager.h"
|
||||
@@ -90,7 +90,7 @@ private:
|
||||
};
|
||||
|
||||
/// Check: Resolved and unresolved includes are properly tracked.
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includes_resolvedUnresolved()
|
||||
void SourceProcessorTest::testIncludesResolvedUnresolved()
|
||||
{
|
||||
const QString testFilePath
|
||||
= TestIncludePaths::testFilePath(QLatin1String("test_main_resolvedUnresolved.cpp"));
|
||||
@@ -115,7 +115,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_resolvedUnresolved()
|
||||
}
|
||||
|
||||
/// Check: Avoid self-include entries due to cyclic includes.
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
|
||||
void SourceProcessorTest::testIncludesCyclic()
|
||||
{
|
||||
const QString fileName1 = TestIncludePaths::testFilePath(QLatin1String("cyclic1.h"));
|
||||
const QString fileName2 = TestIncludePaths::testFilePath(QLatin1String("cyclic2.h"));
|
||||
@@ -154,7 +154,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_cyclic()
|
||||
}
|
||||
|
||||
/// Check: All include errors are reported as diagnostic messages.
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includes_allDiagnostics()
|
||||
void SourceProcessorTest::testIncludesAllDiagnostics()
|
||||
{
|
||||
const QString testFilePath
|
||||
= TestIncludePaths::testFilePath(QLatin1String("test_main_allDiagnostics.cpp"));
|
||||
@@ -168,7 +168,7 @@ void CppToolsPlugin::test_cppsourceprocessor_includes_allDiagnostics()
|
||||
QCOMPARE(document->diagnosticMessages().size(), 3);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_cppsourceprocessor_macroUses()
|
||||
void SourceProcessorTest::testMacroUses()
|
||||
{
|
||||
const QString testFilePath
|
||||
= TestIncludePaths::testFilePath(QLatin1String("test_main_macroUses.cpp"));
|
||||
@@ -198,7 +198,7 @@ static bool isMacroDefinedInDocument(const QByteArray ¯oName, const Document
|
||||
|
||||
static inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
|
||||
|
||||
void CppToolsPlugin::test_cppsourceprocessor_includeNext()
|
||||
void SourceProcessorTest::testIncludeNext()
|
||||
{
|
||||
const Core::Tests::TestDataDir data(
|
||||
_(SRCDIR "/../../../tests/auto/cplusplus/preprocessor/data/include_next-data/"));
|
||||
|
||||
44
src/plugins/cpptools/cppsourceprocessor_test.h
Normal file
44
src/plugins/cpptools/cppsourceprocessor_test.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2016 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class SourceProcessorTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testIncludesResolvedUnresolved();
|
||||
void testIncludesCyclic();
|
||||
void testIncludesAllDiagnostics();
|
||||
void testMacroUses();
|
||||
void testIncludeNext();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -199,9 +199,21 @@ FORMS += \
|
||||
|
||||
equals(TEST, 1) {
|
||||
HEADERS += \
|
||||
compileroptionsbuilder_test.h \
|
||||
cppcodegen_test.h \
|
||||
cppcompletion_test.h \
|
||||
cppheadersource_test.h \
|
||||
cpplocalsymbols_test.h \
|
||||
cpplocatorfilter_test.h \
|
||||
cppmodelmanager_test.h \
|
||||
cpppointerdeclarationformatter_test.h \
|
||||
cppsourceprocessor_test.h \
|
||||
cppsourceprocessertesthelper.h \
|
||||
cpptoolstestcase.h \
|
||||
modelmanagertesthelper.h
|
||||
modelmanagertesthelper.h \
|
||||
projectinfo_test.h \
|
||||
symbolsearcher_test.h \
|
||||
typehierarchybuilder_test.h
|
||||
|
||||
SOURCES += \
|
||||
cppcodegen_test.cpp \
|
||||
|
||||
@@ -230,21 +230,33 @@ Project {
|
||||
condition: qtc.testsEnabled
|
||||
files: [
|
||||
"compileroptionsbuilder_test.cpp",
|
||||
"compileroptionsbuilder_test.h",
|
||||
"cppcodegen_test.cpp",
|
||||
"cppcodegen_test.h",
|
||||
"cppcompletion_test.cpp",
|
||||
"cppcompletion_test.h",
|
||||
"cppheadersource_test.cpp",
|
||||
"cppheadersource_test.h",
|
||||
"cpplocalsymbols_test.cpp",
|
||||
"cpplocalsymbols_test.h",
|
||||
"cpplocatorfilter_test.cpp",
|
||||
"cpplocatorfilter_test.h",
|
||||
"cppmodelmanager_test.cpp",
|
||||
"cppmodelmanager_test.h",
|
||||
"cpppointerdeclarationformatter_test.cpp",
|
||||
"cpppointerdeclarationformatter_test.h",
|
||||
"cppsourceprocessertesthelper.cpp",
|
||||
"cppsourceprocessertesthelper.h",
|
||||
"cppsourceprocessor_test.cpp",
|
||||
"cppsourceprocessor_test.h",
|
||||
"modelmanagertesthelper.cpp",
|
||||
"modelmanagertesthelper.h",
|
||||
"projectinfo_test.cpp",
|
||||
"projectinfo_test.h",
|
||||
"symbolsearcher_test.cpp",
|
||||
"symbolsearcher_test.h",
|
||||
"typehierarchybuilder_test.cpp",
|
||||
"typehierarchybuilder_test.h",
|
||||
]
|
||||
|
||||
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
|
||||
#include "cppcodemodelsettingspage.h"
|
||||
#include "cppcodestylesettingspage.h"
|
||||
#include "cppfilesettingspage.h"
|
||||
@@ -59,6 +60,24 @@
|
||||
#include <utils/mimetypes/mimedatabase.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
#include "compileroptionsbuilder_test.h"
|
||||
#include "cppcodegen_test.h"
|
||||
#include "cppcompletion_test.h"
|
||||
#include "cppheadersource_test.h"
|
||||
#include "cpplocalsymbols_test.h"
|
||||
#include "cpplocatorfilter_test.h"
|
||||
#include "cppmodelmanager_test.h"
|
||||
#include "cpppointerdeclarationformatter_test.h"
|
||||
#include "cppsourceprocessor_test.h"
|
||||
#include "functionutils.h"
|
||||
#include "includeutils.h"
|
||||
#include "projectinfo_test.h"
|
||||
#include "senddocumenttracker.h"
|
||||
#include "symbolsearcher_test.h"
|
||||
#include "typehierarchybuilder_test.h"
|
||||
#endif
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QDebug>
|
||||
@@ -234,6 +253,32 @@ void CppToolsPlugin::extensionsInitialized()
|
||||
d->m_clangdSettingsPage = new ClangdSettingsPage;
|
||||
}
|
||||
|
||||
QVector<QObject *> CppToolsPlugin::createTestObjects() const
|
||||
{
|
||||
return {
|
||||
#ifdef WITH_TESTS
|
||||
new CodegenTest,
|
||||
new CompilerOptionsBuilderTest,
|
||||
new CompletionTest,
|
||||
new FunctionUtilsTest,
|
||||
new HeaderPathFilterTest,
|
||||
new HeaderSourceTest,
|
||||
new IncludeGroupsTest,
|
||||
new LocalSymbolsTest,
|
||||
new LocatorFilterTest,
|
||||
new ModelManagerTest,
|
||||
new PointerDeclarationFormatterTest,
|
||||
new ProjectFileCategorizerTest,
|
||||
new ProjectInfoGeneratorTest,
|
||||
new ProjectPartChooserTest,
|
||||
new DocumentTrackerTest,
|
||||
new SourceProcessorTest,
|
||||
new SymbolSearcherTest,
|
||||
new TypeHierarchyBuilderTest,
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
CppCodeModelSettings *CppToolsPlugin::codeModelSettings()
|
||||
{
|
||||
return &d->m_codeModelSettings;
|
||||
@@ -241,7 +286,7 @@ CppCodeModelSettings *CppToolsPlugin::codeModelSettings()
|
||||
|
||||
CppFileSettings *CppToolsPlugin::fileSettings()
|
||||
{
|
||||
return &d->m_fileSettings;
|
||||
return &instance()->d->m_fileSettings;
|
||||
}
|
||||
|
||||
void CppToolsPlugin::switchHeaderSource()
|
||||
|
||||
@@ -58,232 +58,18 @@ public:
|
||||
static QString licenseTemplate();
|
||||
static bool usePragmaOnce();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||
void extensionsInitialized() final;
|
||||
|
||||
CppCodeModelSettings *codeModelSettings();
|
||||
static CppFileSettings *fileSettings();
|
||||
|
||||
public slots:
|
||||
void switchHeaderSource();
|
||||
void switchHeaderSourceInNextSplit();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
private slots:
|
||||
// Init/Cleanup methods implemented in cppheadersource_test.cpp
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
void test_codegen_public_in_empty_class();
|
||||
void test_codegen_public_in_nonempty_class();
|
||||
void test_codegen_public_before_protected();
|
||||
void test_codegen_private_after_protected();
|
||||
void test_codegen_protected_in_nonempty_class();
|
||||
void test_codegen_protected_between_public_and_private();
|
||||
void test_codegen_qtdesigner_integration();
|
||||
void test_codegen_definition_empty_class();
|
||||
void test_codegen_definition_first_member();
|
||||
void test_codegen_definition_last_member();
|
||||
void test_codegen_definition_middle_member();
|
||||
void test_codegen_definition_middle_member_surrounded_by_undefined();
|
||||
void test_codegen_definition_member_specific_file();
|
||||
|
||||
void test_completion_basic_1();
|
||||
|
||||
void test_completion_template_function_data();
|
||||
void test_completion_template_function();
|
||||
|
||||
void test_completion_data();
|
||||
void test_completion();
|
||||
|
||||
void test_global_completion_data();
|
||||
void test_global_completion();
|
||||
|
||||
void test_doxygen_tag_completion_data();
|
||||
void test_doxygen_tag_completion();
|
||||
|
||||
void test_completion_member_access_operator_data();
|
||||
void test_completion_member_access_operator();
|
||||
|
||||
void test_completion_prefix_first_QTCREATORBUG_8737();
|
||||
void test_completion_prefix_first_QTCREATORBUG_9236();
|
||||
|
||||
void test_format_pointerdeclaration_in_simpledeclarations();
|
||||
void test_format_pointerdeclaration_in_simpledeclarations_data();
|
||||
void test_format_pointerdeclaration_in_controlflowstatements();
|
||||
void test_format_pointerdeclaration_in_controlflowstatements_data();
|
||||
void test_format_pointerdeclaration_multiple_declarators();
|
||||
void test_format_pointerdeclaration_multiple_declarators_data();
|
||||
void test_format_pointerdeclaration_multiple_matches();
|
||||
void test_format_pointerdeclaration_multiple_matches_data();
|
||||
void test_format_pointerdeclaration_macros();
|
||||
void test_format_pointerdeclaration_macros_data();
|
||||
|
||||
void test_cppsourceprocessor_includes_resolvedUnresolved();
|
||||
void test_cppsourceprocessor_includes_cyclic();
|
||||
void test_cppsourceprocessor_includes_allDiagnostics();
|
||||
void test_cppsourceprocessor_macroUses();
|
||||
void test_cppsourceprocessor_includeNext();
|
||||
|
||||
void test_functionutils_virtualFunctions();
|
||||
void test_functionutils_virtualFunctions_data();
|
||||
|
||||
void test_modelmanager_paths_are_clean();
|
||||
void test_modelmanager_framework_headers();
|
||||
void test_modelmanager_refresh_also_includes_of_project_files();
|
||||
void test_modelmanager_refresh_several_times();
|
||||
void test_modelmanager_refresh_test_for_changes();
|
||||
void test_modelmanager_refresh_added_and_purge_removed();
|
||||
void test_modelmanager_refresh_timeStampModified_if_sourcefiles_change();
|
||||
void test_modelmanager_refresh_timeStampModified_if_sourcefiles_change_data();
|
||||
void test_modelmanager_snapshot_after_two_projects();
|
||||
void test_modelmanager_extraeditorsupport_uiFiles();
|
||||
void test_modelmanager_gc_if_last_cppeditor_closed();
|
||||
void test_modelmanager_dont_gc_opened_files();
|
||||
void test_modelmanager_defines_per_project();
|
||||
void test_modelmanager_defines_per_editor();
|
||||
void test_modelmanager_updateEditorsAfterProjectUpdate();
|
||||
void test_modelmanager_precompiled_headers();
|
||||
void test_modelmanager_renameIncludes();
|
||||
void test_modelmanager_renameIncludesInEditor();
|
||||
void test_modelmanager_documentsAndRevisions();
|
||||
|
||||
void test_cpplocatorfilters_CppLocatorFilter();
|
||||
void test_cpplocatorfilters_CppLocatorFilter_data();
|
||||
void test_cpplocatorfilters_CppCurrentDocumentFilter();
|
||||
void test_cpplocatorfilters_CppCurrentDocumentHighlighting();
|
||||
void test_cpplocatorfilters_CppFunctionsFilterHighlighting();
|
||||
|
||||
void test_builtinsymbolsearcher();
|
||||
void test_builtinsymbolsearcher_data();
|
||||
|
||||
void test_headersource_data();
|
||||
void test_headersource();
|
||||
|
||||
void test_typehierarchy_data();
|
||||
void test_typehierarchy();
|
||||
|
||||
void test_cpplocalsymbols_data();
|
||||
void test_cpplocalsymbols();
|
||||
|
||||
void test_includeGroups_detectIncludeGroupsByNewLines();
|
||||
void test_includeGroups_detectIncludeGroupsByIncludeDir();
|
||||
void test_includeGroups_detectIncludeGroupsByIncludeType();
|
||||
|
||||
void test_optionsBuilder_addProjectMacros();
|
||||
void test_optionsBuilder_unknownFlagsAreForwarded();
|
||||
void test_optionsBuilder_warningsFlagsAreNotFilteredIfRequested();
|
||||
void test_optionsBuilder_diagnosticOptionsAreRemoved();
|
||||
void test_optionsBuilder_cLanguageVersionIsRewritten();
|
||||
void test_optionsBuilder_languageVersionIsExplicitlySetIfNotProvided();
|
||||
void test_optionsBuilder_LanguageVersionIsExplicitlySetIfNotProvidedMsvc();
|
||||
void test_optionsBuilder_addWordWidth();
|
||||
void test_optionsBuilder_headerPathOptionsOrder();
|
||||
void test_optionsBuilder_HeaderPathOptionsOrderMsvc();
|
||||
void test_optionsBuilder_useSystemHeader();
|
||||
void test_optionsBuilder_noClangHeadersPath();
|
||||
void test_optionsBuilder_clangHeadersAndCppIncludePathsOrderMacOs();
|
||||
void test_optionsBuilder_clangHeadersAndCppIncludePathsOrderLinux();
|
||||
void test_optionsBuilder_clangHeadersAndCppIncludePathsOrderNoVersion();
|
||||
void test_optionsBuilder_clangHeadersAndCppIncludePathsOrderAndroidClang();
|
||||
void test_optionsBuilder_noPrecompiledHeader();
|
||||
void test_optionsBuilder_usePrecompiledHeader();
|
||||
void test_optionsBuilder_usePrecompiledHeaderMsvc();
|
||||
void test_optionsBuilder_addMacros();
|
||||
void test_optionsBuilder_addTargetTriple();
|
||||
void test_optionsBuilder_enableCExceptions();
|
||||
void test_optionsBuilder_enableCxxExceptions();
|
||||
void test_optionsBuilder_insertWrappedQtHeaders();
|
||||
void test_optionsBuilder_insertWrappedMingwHeadersWithNonMingwToolchain();
|
||||
void test_optionsBuilder_insertWrappedMingwHeadersWithMingwToolchain();
|
||||
void test_optionsBuilder_setLanguageVersion();
|
||||
void test_optionsBuilder_setLanguageVersionMsvc();
|
||||
void test_optionsBuilder_handleLanguageExtension();
|
||||
void test_optionsBuilder_updateLanguageVersion();
|
||||
void test_optionsBuilder_updateLanguageVersionMsvc();
|
||||
void test_optionsBuilder_addMsvcCompatibilityVersion();
|
||||
void test_optionsBuilder_undefineCppLanguageFeatureMacrosForMsvc2015();
|
||||
void test_optionsBuilder_addDefineFunctionMacrosMsvc();
|
||||
void test_optionsBuilder_addProjectConfigFileInclude();
|
||||
void test_optionsBuilder_addProjectConfigFileIncludeMsvc();
|
||||
void test_optionsBuilder_noUndefineClangVersionMacrosForNewMsvc();
|
||||
void test_optionsBuilder_undefineClangVersionMacrosForOldMsvc();
|
||||
void test_optionsBuilder_buildAllOptions();
|
||||
void test_optionsBuilder_buildAllOptionsMsvc();
|
||||
void test_optionsBuilder_buildAllOptionsMsvcWithExceptions();
|
||||
|
||||
void test_projectPartChooser_chooseManuallySet();
|
||||
void test_projectPartChooser_indicateManuallySet();
|
||||
void test_projectPartChooser_indicateManuallySetForFallbackToProjectPartFromDependencies();
|
||||
void test_projectPartChooser_doNotIndicateNotManuallySet();
|
||||
void test_projectPartChooser_forMultipleChooseFromActiveProject();
|
||||
void test_projectPartChooser_forMultiplePreferSelectedForBuilding();
|
||||
void test_projectPartChooser_forMultipleFromDependenciesChooseFromActiveProject();
|
||||
void test_projectPartChooser_forMultipleCheckIfActiveProjectChanged();
|
||||
void test_projectPartChooser_forMultipleAndAmbigiousHeaderPreferCProjectPart();
|
||||
void test_projectPartChooser_forMultipleAndAmbigiousHeaderPreferCxxProjectPart();
|
||||
void test_projectPartChooser_indicateMultiple();
|
||||
void test_projectPartChooser_indicateMultipleForFallbackToProjectPartFromDependencies();
|
||||
void test_projectPartChooser_forMultipleChooseNewIfPreviousIsGone();
|
||||
void test_projectPartChooser_fallbackToProjectPartFromDependencies();
|
||||
void test_projectPartChooser_fallbackToProjectPartFromModelManager();
|
||||
void test_projectPartChooser_continueUsingFallbackFromModelManagerIfProjectDoesNotChange();
|
||||
void test_projectPartChooser_stopUsingFallbackFromModelManagerIfProjectChanges1();
|
||||
void test_projectPartChooser_stopUsingFallbackFromModelManagerIfProjectChanges2();
|
||||
void test_projectPartChooser_indicateFallbacktoProjectPartFromModelManager();
|
||||
void test_projectPartChooser_indicateFromDependencies();
|
||||
void test_projectPartChooser_doNotIndicateFromDependencies();
|
||||
|
||||
void test_projectInfoGenerator_createNoProjectPartsForEmptyFileList();
|
||||
void test_projectInfoGenerator_createSingleProjectPart();
|
||||
void test_projectInfoGenerator_createMultipleProjectParts();
|
||||
void test_projectInfoGenerator_projectPartIndicatesObjectiveCExtensionsByDefault();
|
||||
void test_projectInfoGenerator_projectPartHasLatestLanguageVersionByDefault();
|
||||
void test_projectInfoGenerator_useMacroInspectionReportForLanguageVersion();
|
||||
void test_projectInfoGenerator_useCompilerFlagsForLanguageExtensions();
|
||||
void test_projectInfoGenerator_projectFileKindsMatchProjectPartVersion();
|
||||
void test_headerPathFilter_builtin();
|
||||
void test_headerPathFilter_system();
|
||||
void test_headerPathFilter_user();
|
||||
void test_headerPathFilter_noProjectPathSet();
|
||||
void test_headerPathFilter_dontAddInvalidPath();
|
||||
void test_headerPathFilter_clangHeadersPath();
|
||||
void test_headerPathFilter_clangHeadersPathWitoutClangVersion();
|
||||
void test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderMacOs();
|
||||
void test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderLinux();
|
||||
void test_headerPathFilter_removeGccInternalPaths();
|
||||
void test_headerPathFilter_removeGccInternalPathsExceptForStandardPaths();
|
||||
void test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderNoVersion();
|
||||
void test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderAndroidClang();
|
||||
void test_projectFileCategorizer_c();
|
||||
void test_projectFileCategorizer_cxxWithUnambiguousHeaderSuffix();
|
||||
void test_projectFileCategorizer_cxxWithAmbiguousHeaderSuffix();
|
||||
void test_projectFileCategorizer_objectiveC();
|
||||
void test_projectFileCategorizer_objectiveCxx();
|
||||
void test_projectFileCategorizer_mixedCAndCxx();
|
||||
void test_projectFileCategorizer_ambiguousHeaderOnly();
|
||||
|
||||
void test_documentTracker_defaultLastSentRevision();
|
||||
void test_documentTracker_setRevision();
|
||||
void test_documentTracker_setLastCompletionPosition();
|
||||
void test_documentTracker_applyContentChange();
|
||||
void test_documentTracker_dontSendCompletionIfPositionIsEqual();
|
||||
void test_documentTracker_sendCompletionIfPositionIsDifferent();
|
||||
void test_documentTracker_sendCompletionIfChangeIsBeforeCompletionPositionAndPositionIsEqual();
|
||||
void test_documentTracker_dontSendCompletionIfChangeIsAfterCompletionPositionAndPositionIsEqual();
|
||||
void test_documentTracker_dontSendRevisionIfRevisionIsEqual();
|
||||
void test_documentTracker_sendRevisionIfRevisionIsDifferent();
|
||||
void test_documentTracker_dontSendRevisionWithDefaults();
|
||||
void test_documentTracker_dontSendIfRevisionIsDifferentAndCompletionPositionIsEqualAndNoContentChange();
|
||||
void test_documentTracker_dontSendIfRevisionIsDifferentAndCompletionPositionIsDifferentAndNoContentChange();
|
||||
void test_documentTracker_dontSendIfRevisionIsEqualAndCompletionPositionIsDifferentAndNoContentChange();
|
||||
void test_documentTracker_sendIfChangeIsBeforeCompletionAndPositionIsEqualAndRevisionIsDifferent();
|
||||
void test_documentTracker_dontSendIfChangeIsAfterCompletionPositionAndRevisionIsDifferent();
|
||||
void test_documentTracker_sendIfChangeIsBeforeCompletionPositionAndRevisionIsDifferent();
|
||||
void test_documentTracker_resetChangedContentStartPositionIfLastRevisionIsSet();
|
||||
#endif
|
||||
|
||||
private:
|
||||
CppFileSettings *fileSettings();
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage) final;
|
||||
void extensionsInitialized() final;
|
||||
QVector<QObject *> createTestObjects() const final;
|
||||
|
||||
class CppToolsPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -215,7 +215,6 @@ QList<Function *> FunctionUtils::overrides(Function *function, Class *functionsC
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
#include "cpptoolsplugin.h"
|
||||
|
||||
#include <QTest>
|
||||
|
||||
@@ -237,7 +236,7 @@ Q_DECLARE_METATYPE(CppTools::Internal::Virtuality)
|
||||
namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
void CppToolsPlugin::test_functionutils_virtualFunctions()
|
||||
void FunctionUtilsTest::testVirtualFunctions()
|
||||
{
|
||||
// Create and parse document
|
||||
QFETCH(QByteArray, source);
|
||||
@@ -292,7 +291,7 @@ void CppToolsPlugin::test_functionutils_virtualFunctions()
|
||||
QVERIFY(firstVirtualList.isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_functionutils_virtualFunctions_data()
|
||||
void FunctionUtilsTest::testVirtualFunctions_data()
|
||||
{
|
||||
using _ = QByteArray;
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
namespace CPlusPlus {
|
||||
class Class;
|
||||
@@ -56,4 +57,17 @@ public:
|
||||
const CPlusPlus::Snapshot &snapshot);
|
||||
};
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Internal {
|
||||
class FunctionUtilsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testVirtualFunctions();
|
||||
void testVirtualFunctions_data();
|
||||
};
|
||||
} // namespace Internal
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -33,6 +33,15 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cppsourceprocessertesthelper.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
#include <QtTest>
|
||||
#endif // WITH_TESTS
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QStringList>
|
||||
@@ -42,7 +51,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
using namespace CppTools::IncludeUtils;
|
||||
using namespace Utils;
|
||||
|
||||
@@ -117,6 +125,8 @@ int lineAfterFirstComment(const QTextDocument *textDocument)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
LineForNewIncludeDirective::LineForNewIncludeDirective(const QTextDocument *textDocument,
|
||||
const Document::Ptr cppDocument,
|
||||
MocIncludeMode mocIncludeMode,
|
||||
@@ -516,17 +526,7 @@ bool IncludeGroup::hasCommonIncludeDir() const
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cppsourceprocessertesthelper.h"
|
||||
#include "cppsourceprocessor.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
using namespace Tests;
|
||||
using CppTools::Internal::CppToolsPlugin;
|
||||
|
||||
static QList<Include> includesForSource(const QString &filePath)
|
||||
{
|
||||
@@ -542,7 +542,8 @@ static QList<Include> includesForSource(const QString &filePath)
|
||||
return document->resolvedIncludes();
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByNewLines()
|
||||
namespace Internal {
|
||||
void IncludeGroupsTest::testDetectIncludeGroupsByNewLines()
|
||||
{
|
||||
const QString testFilePath = TestIncludePaths::testFilePath(
|
||||
QLatin1String("test_main_detectIncludeGroupsByNewLines.cpp"));
|
||||
@@ -584,7 +585,7 @@ void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByNewLines()
|
||||
QCOMPARE(IncludeGroup::filterMixedIncludeGroups(includeGroups).size(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByIncludeDir()
|
||||
void IncludeGroupsTest::testDetectIncludeGroupsByIncludeDir()
|
||||
{
|
||||
const QString testFilePath = TestIncludePaths::testFilePath(
|
||||
QLatin1String("test_main_detectIncludeGroupsByIncludeDir.cpp"));
|
||||
@@ -608,7 +609,7 @@ void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByIncludeDir()
|
||||
QCOMPARE(includeGroups.at(3).commonIncludeDir(), QLatin1String(""));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByIncludeType()
|
||||
void IncludeGroupsTest::testDetectIncludeGroupsByIncludeType()
|
||||
{
|
||||
const QString testFilePath = TestIncludePaths::testFilePath(
|
||||
QLatin1String("test_main_detectIncludeGroupsByIncludeType.cpp"));
|
||||
@@ -632,4 +633,8 @@ void CppToolsPlugin::test_includeGroups_detectIncludeGroupsByIncludeType()
|
||||
QVERIFY(includeGroups.at(3).hasOnlyIncludesOfType(Client::IncludeGlobal));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <cplusplus/PreprocessorClient.h>
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTextDocument)
|
||||
@@ -105,4 +106,19 @@ private:
|
||||
};
|
||||
|
||||
} // namespace IncludeUtils
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Internal {
|
||||
class IncludeGroupsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testDetectIncludeGroupsByNewLines();
|
||||
void testDetectIncludeGroupsByIncludeDir();
|
||||
void testDetectIncludeGroupsByIncludeType();
|
||||
};
|
||||
} // namespace Internal
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -23,13 +23,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "projectinfo_test.h"
|
||||
|
||||
#include "cppprojectfilecategorizer.h"
|
||||
#include "cppprojectinfogenerator.h"
|
||||
#include "cppprojectpartchooser.h"
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "headerpathfilter.h"
|
||||
#include "projectinfo.h"
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/toolchainconfigwidget.h>
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
@@ -41,10 +43,10 @@ namespace CppTools {
|
||||
namespace Internal {
|
||||
|
||||
namespace {
|
||||
class ProjectPartChooserTest
|
||||
class ProjectPartChooserTestHelper
|
||||
{
|
||||
public:
|
||||
ProjectPartChooserTest()
|
||||
ProjectPartChooserTestHelper()
|
||||
{
|
||||
chooser.setFallbackProjectPart([&]() {
|
||||
return fallbackProjectPart;
|
||||
@@ -123,56 +125,56 @@ public:
|
||||
};
|
||||
|
||||
QHash<Utils::FilePath, std::shared_ptr<Project>>
|
||||
ProjectPartChooserTest::projectMap;
|
||||
ProjectPartChooserTestHelper::projectMap;
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_chooseManuallySet()
|
||||
void ProjectPartChooserTest::testChooseManuallySet()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
|
||||
QCOMPARE(t.choose().projectPart, p2);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateManuallySet()
|
||||
void ProjectPartChooserTest::testIndicateManuallySet()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateManuallySetForFallbackToProjectPartFromDependencies()
|
||||
void ProjectPartChooserTest::testIndicateManuallySetForFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
RawProjectPart rpp2;
|
||||
rpp2.setProjectFileLocation("someId");
|
||||
ProjectPart::Ptr p2 = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.preferredProjectPartId = p2->projectFile;
|
||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsPreferredMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_doNotIndicateNotManuallySet()
|
||||
void ProjectPartChooserTest::testDoNotIndicateNotManuallySet()
|
||||
{
|
||||
QVERIFY(!(ProjectPartChooserTest().choose().hints & ProjectPartInfo::IsPreferredMatch));
|
||||
QVERIFY(!(ProjectPartChooserTestHelper().choose().hints & ProjectPartInfo::IsPreferredMatch));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleChooseFromActiveProject()
|
||||
void ProjectPartChooserTest::testForMultipleChooseFromActiveProject()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
t.projectPartsForFile += projectParts;
|
||||
@@ -181,7 +183,7 @@ void CppToolsPlugin::test_projectPartChooser_forMultipleChooseFromActiveProject(
|
||||
QCOMPARE(t.choose().projectPart, secondProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultiplePreferSelectedForBuilding()
|
||||
void ProjectPartChooserTest::testForMultiplePreferSelectedForBuilding()
|
||||
{
|
||||
RawProjectPart rpp1;
|
||||
rpp1.setSelectedForBuilding(false);
|
||||
@@ -189,16 +191,16 @@ void CppToolsPlugin::test_projectPartChooser_forMultiplePreferSelectedForBuildin
|
||||
rpp2.setSelectedForBuilding(true);
|
||||
const ProjectPart::Ptr firstProjectPart = ProjectPart::create({}, rpp1);
|
||||
const ProjectPart::Ptr secondProjectPart = ProjectPart::create({}, rpp2);
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += firstProjectPart;
|
||||
t.projectPartsForFile += secondProjectPart;
|
||||
|
||||
QCOMPARE(t.choose().projectPart, secondProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleFromDependenciesChooseFromActiveProject()
|
||||
void ProjectPartChooserTest::testForMultipleFromDependenciesChooseFromActiveProject()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
t.projectPartsFromDependenciesForFile += projectParts;
|
||||
@@ -207,9 +209,9 @@ void CppToolsPlugin::test_projectPartChooser_forMultipleFromDependenciesChooseFr
|
||||
QCOMPARE(t.choose().projectPart, secondProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleCheckIfActiveProjectChanged()
|
||||
void ProjectPartChooserTest::testForMultipleCheckIfActiveProjectChanged()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
const QList<ProjectPart::Ptr> projectParts = t.createProjectPartsWithDifferentProjects();
|
||||
const ProjectPart::Ptr firstProjectPart = projectParts.at(0);
|
||||
const ProjectPart::Ptr secondProjectPart = projectParts.at(1);
|
||||
@@ -220,9 +222,9 @@ void CppToolsPlugin::test_projectPartChooser_forMultipleCheckIfActiveProjectChan
|
||||
QCOMPARE(t.choose().projectPart, secondProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleAndAmbigiousHeaderPreferCProjectPart()
|
||||
void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCProjectPart()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.languagePreference = Language::C;
|
||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||
const ProjectPart::Ptr cProjectPart = t.projectPartsForFile.at(0);
|
||||
@@ -230,9 +232,9 @@ void CppToolsPlugin::test_projectPartChooser_forMultipleAndAmbigiousHeaderPrefer
|
||||
QCOMPARE(t.choose().projectPart, cProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleAndAmbigiousHeaderPreferCxxProjectPart()
|
||||
void ProjectPartChooserTest::testForMultipleAndAmbigiousHeaderPreferCxxProjectPart()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.languagePreference = Language::Cxx;
|
||||
t.projectPartsForFile = t.createCAndCxxProjectParts();
|
||||
const ProjectPart::Ptr cxxProjectPart = t.projectPartsForFile.at(1);
|
||||
@@ -240,56 +242,56 @@ void CppToolsPlugin::test_projectPartChooser_forMultipleAndAmbigiousHeaderPrefer
|
||||
QCOMPARE(t.choose().projectPart, cxxProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateMultiple()
|
||||
void ProjectPartChooserTest::testIndicateMultiple()
|
||||
{
|
||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += {p1, p2};
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsAmbiguousMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateMultipleForFallbackToProjectPartFromDependencies()
|
||||
void ProjectPartChooserTest::testIndicateMultipleForFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
const ProjectPart::Ptr p1 = ProjectPart::create({});
|
||||
const ProjectPart::Ptr p2 = ProjectPart::create({});
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsFromDependenciesForFile += {p1, p2};
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsAmbiguousMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_forMultipleChooseNewIfPreviousIsGone()
|
||||
void ProjectPartChooserTest::testForMultipleChooseNewIfPreviousIsGone()
|
||||
{
|
||||
const ProjectPart::Ptr newProjectPart = ProjectPart::create({});
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += newProjectPart;
|
||||
|
||||
QCOMPARE(t.choose().projectPart, newProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_fallbackToProjectPartFromDependencies()
|
||||
void ProjectPartChooserTest::testFallbackToProjectPartFromDependencies()
|
||||
{
|
||||
const ProjectPart::Ptr fromDependencies = ProjectPart::create({});
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsFromDependenciesForFile += fromDependencies;
|
||||
|
||||
QCOMPARE(t.choose().projectPart, fromDependencies);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_fallbackToProjectPartFromModelManager()
|
||||
void ProjectPartChooserTest::testFallbackToProjectPartFromModelManager()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
|
||||
QCOMPARE(t.choose().projectPart, t.fallbackProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_continueUsingFallbackFromModelManagerIfProjectDoesNotChange()
|
||||
void ProjectPartChooserTest::testContinueUsingFallbackFromModelManagerIfProjectDoesNotChange()
|
||||
{
|
||||
// ...without re-calculating the dependency table.
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||
@@ -298,9 +300,9 @@ void CppToolsPlugin::test_projectPartChooser_continueUsingFallbackFromModelManag
|
||||
QCOMPARE(t.choose().projectPart, t.fallbackProjectPart);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_stopUsingFallbackFromModelManagerIfProjectChanges1()
|
||||
void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChanges1()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||
@@ -310,9 +312,9 @@ void CppToolsPlugin::test_projectPartChooser_stopUsingFallbackFromModelManagerIf
|
||||
QCOMPARE(t.choose().projectPart, addedProject);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_stopUsingFallbackFromModelManagerIfProjectChanges2()
|
||||
void ProjectPartChooserTest::testStopUsingFallbackFromModelManagerIfProjectChanges2()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
t.currentProjectPartInfo.projectPart = t.fallbackProjectPart;
|
||||
t.currentProjectPartInfo.hints |= ProjectPartInfo::IsFallbackMatch;
|
||||
@@ -323,25 +325,25 @@ void CppToolsPlugin::test_projectPartChooser_stopUsingFallbackFromModelManagerIf
|
||||
QCOMPARE(t.choose().projectPart, addedProject);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateFallbacktoProjectPartFromModelManager()
|
||||
void ProjectPartChooserTest::testIndicateFallbacktoProjectPartFromModelManager()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.fallbackProjectPart = ProjectPart::create({});
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsFallbackMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_indicateFromDependencies()
|
||||
void ProjectPartChooserTest::testIndicateFromDependencies()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsFromDependenciesForFile += ProjectPart::create({});
|
||||
|
||||
QVERIFY(t.choose().hints & ProjectPartInfo::IsFromDependenciesMatch);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectPartChooser_doNotIndicateFromDependencies()
|
||||
void ProjectPartChooserTest::testDoNotIndicateFromDependencies()
|
||||
{
|
||||
ProjectPartChooserTest t;
|
||||
ProjectPartChooserTestHelper t;
|
||||
t.projectPartsForFile += ProjectPart::create({});
|
||||
|
||||
QVERIFY(!(t.choose().hints & ProjectPartInfo::IsFromDependenciesMatch));
|
||||
@@ -368,10 +370,10 @@ private:
|
||||
};
|
||||
};
|
||||
|
||||
class ProjectInfoGeneratorTest
|
||||
class ProjectInfoGeneratorTestHelper
|
||||
{
|
||||
public:
|
||||
ProjectInfoGeneratorTest()
|
||||
ProjectInfoGeneratorTestHelper()
|
||||
{
|
||||
TestToolchain aToolChain;
|
||||
projectUpdateInfo.cxxToolChainInfo = {&aToolChain, {}, {}};
|
||||
@@ -393,35 +395,35 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_createNoProjectPartsForEmptyFileList()
|
||||
void ProjectInfoGeneratorTest::testCreateNoProjectPartsForEmptyFileList()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
|
||||
QVERIFY(projectInfo->projectParts().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_createSingleProjectPart()
|
||||
void ProjectInfoGeneratorTest::testCreateSingleProjectPart()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h"};
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_createMultipleProjectParts()
|
||||
void ProjectInfoGeneratorTest::testCreateMultipleProjectParts()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp", "foo.h", "bar.c", "bar.h" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
|
||||
QCOMPARE(projectInfo->projectParts().size(), 2);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_projectPartIndicatesObjectiveCExtensionsByDefault()
|
||||
void ProjectInfoGeneratorTest::testProjectPartIndicatesObjectiveCExtensionsByDefault()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.mm" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
@@ -430,9 +432,9 @@ void CppToolsPlugin::test_projectInfoGenerator_projectPartIndicatesObjectiveCExt
|
||||
QVERIFY(projectPart.languageExtensions & Utils::LanguageExtension::ObjectiveC);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_projectPartHasLatestLanguageVersionByDefault()
|
||||
void ProjectInfoGeneratorTest::testProjectPartHasLatestLanguageVersionByDefault()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
QCOMPARE(projectInfo->projectParts().size(), 1);
|
||||
@@ -441,9 +443,9 @@ void CppToolsPlugin::test_projectInfoGenerator_projectPartHasLatestLanguageVersi
|
||||
QCOMPARE(projectPart.languageVersion, Utils::LanguageVersion::LatestCxx);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_useMacroInspectionReportForLanguageVersion()
|
||||
void ProjectInfoGeneratorTest::testUseMacroInspectionReportForLanguageVersion()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.projectUpdateInfo.cxxToolChainInfo.macroInspectionRunner = [](const QStringList &) {
|
||||
return TestToolchain::MacroInspectionReport{Macros(), Utils::LanguageVersion::CXX17};
|
||||
};
|
||||
@@ -456,9 +458,9 @@ void CppToolsPlugin::test_projectInfoGenerator_useMacroInspectionReportForLangua
|
||||
QCOMPARE(projectPart.languageVersion, Utils::LanguageVersion::CXX17);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_useCompilerFlagsForLanguageExtensions()
|
||||
void ProjectInfoGeneratorTest::testUseCompilerFlagsForLanguageExtensions()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.cpp" };
|
||||
t.rawProjectPart.flagsForCxx.languageExtensions = Utils::LanguageExtension::Microsoft;
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
@@ -469,9 +471,9 @@ void CppToolsPlugin::test_projectInfoGenerator_useCompilerFlagsForLanguageExtens
|
||||
QVERIFY(projectPart.languageExtensions & Utils::LanguageExtension::Microsoft);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectInfoGenerator_projectFileKindsMatchProjectPartVersion()
|
||||
void ProjectInfoGeneratorTest::testProjectFileKindsMatchProjectPartVersion()
|
||||
{
|
||||
ProjectInfoGeneratorTest t;
|
||||
ProjectInfoGeneratorTestHelper t;
|
||||
t.rawProjectPart.files = QStringList{ "foo.h" };
|
||||
const ProjectInfo::Ptr projectInfo = t.generate();
|
||||
|
||||
@@ -495,7 +497,7 @@ void CppToolsPlugin::test_projectInfoGenerator_projectFileKindsMatchProjectPartV
|
||||
}
|
||||
|
||||
namespace {
|
||||
class HeaderPathFilterTest
|
||||
class HeaderPathFilterTestHelper
|
||||
{
|
||||
public:
|
||||
const ProjectPart &finalize()
|
||||
@@ -550,18 +552,18 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_builtin()
|
||||
void HeaderPathFilterTest::testBuiltin()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.finalize();
|
||||
t.filter->process();
|
||||
|
||||
QCOMPARE(t.filter->builtInHeaderPaths, (HeaderPaths{t.builtIn("/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_system()
|
||||
void HeaderPathFilterTest::testSystem()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.finalize();
|
||||
t.filter->process();
|
||||
|
||||
@@ -571,9 +573,9 @@ void CppToolsPlugin::test_headerPathFilter_system()
|
||||
t.user("/buildb/user_path"), t.user("/projectb/user_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_user()
|
||||
void HeaderPathFilterTest::testUser()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.finalize();
|
||||
t.filter->process();
|
||||
|
||||
@@ -581,9 +583,9 @@ void CppToolsPlugin::test_headerPathFilter_user()
|
||||
t.user("/project/user_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_noProjectPathSet()
|
||||
void HeaderPathFilterTest::testNoProjectPathSet()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
HeaderPathFilter filter{t.finalize(), UseTweakedHeaderPaths::No};
|
||||
filter.process();
|
||||
|
||||
@@ -593,9 +595,9 @@ void CppToolsPlugin::test_headerPathFilter_noProjectPathSet()
|
||||
t.user("/project/user_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_dontAddInvalidPath()
|
||||
void HeaderPathFilterTest::testDontAddInvalidPath()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.finalize();
|
||||
t.filter->process();
|
||||
QCOMPARE(t.filter->builtInHeaderPaths, (HeaderPaths{t.builtIn("/builtin_path")}));
|
||||
@@ -607,9 +609,9 @@ void CppToolsPlugin::test_headerPathFilter_dontAddInvalidPath()
|
||||
t.user("/project/user_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersPath()
|
||||
void HeaderPathFilterTest::testClangHeadersPath()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
HeaderPathFilter filter(t.finalize(), UseTweakedHeaderPaths::Yes, "6.0", "clang_dir");
|
||||
filter.process();
|
||||
|
||||
@@ -617,18 +619,18 @@ void CppToolsPlugin::test_headerPathFilter_clangHeadersPath()
|
||||
t.builtIn("/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersPathWitoutClangVersion()
|
||||
void HeaderPathFilterTest::testClangHeadersPathWitoutClangVersion()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
HeaderPathFilter filter(t.finalize(), UseTweakedHeaderPaths::Yes);
|
||||
filter.process();
|
||||
|
||||
QCOMPARE(filter.builtInHeaderPaths, (HeaderPaths{t.builtIn("/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderMacOs()
|
||||
void HeaderPathFilterTest::testClangHeadersAndCppIncludesPathsOrderMacOs()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.targetTriple = "x86_64-apple-darwin10";
|
||||
const auto builtIns = {
|
||||
t.builtIn("/usr/include/c++/4.2.1"), t.builtIn("/usr/include/c++/4.2.1/backward"),
|
||||
@@ -650,9 +652,9 @@ void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderM
|
||||
t.builtIn("/builtin_path")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderLinux()
|
||||
void HeaderPathFilterTest::testClangHeadersAndCppIncludesPathsOrderLinux()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.targetTriple = "x86_64-linux-gnu";
|
||||
const auto builtIns = {
|
||||
t.builtIn("/usr/include/c++/4.8"), t.builtIn("/usr/include/c++/4.8/backward"),
|
||||
@@ -674,9 +676,9 @@ void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderL
|
||||
|
||||
// GCC-internal include paths like <installdir>/include and <installdir/include-next> might confuse
|
||||
// clang and should be filtered out. clang on the command line filters them out, too.
|
||||
void CppToolsPlugin::test_headerPathFilter_removeGccInternalPaths()
|
||||
void HeaderPathFilterTest::testRemoveGccInternalPaths()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.toolchainInstallDir = Utils::FilePath::fromUtf8("/usr/lib/gcc/x86_64-linux-gnu/7");
|
||||
t.toolchainType = Constants::GCC_TOOLCHAIN_TYPEID;
|
||||
t.headerPaths = {
|
||||
@@ -692,9 +694,9 @@ void CppToolsPlugin::test_headerPathFilter_removeGccInternalPaths()
|
||||
// Some distributions ship the standard library headers in "<installdir>/include/c++" (MinGW)
|
||||
// or e.g. "<installdir>/include/g++-v8" (Gentoo).
|
||||
// Ensure that we do not remove include paths pointing there.
|
||||
void CppToolsPlugin::test_headerPathFilter_removeGccInternalPathsExceptForStandardPaths()
|
||||
void HeaderPathFilterTest::testRemoveGccInternalPathsExceptForStandardPaths()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.toolchainInstallDir = Utils::FilePath::fromUtf8("c:/mingw/lib/gcc/x86_64-w64-mingw32/7.3.0");
|
||||
t.toolchainType = Constants::MINGW_TOOLCHAIN_TYPEID;
|
||||
t.headerPaths = {
|
||||
@@ -711,9 +713,9 @@ void CppToolsPlugin::test_headerPathFilter_removeGccInternalPathsExceptForStanda
|
||||
QCOMPARE(filter.builtInHeaderPaths, expected);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderNoVersion()
|
||||
void HeaderPathFilterTest::testClangHeadersAndCppIncludesPathsOrderNoVersion()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.headerPaths = {
|
||||
t.builtIn("C:/mingw/i686-w64-mingw32/include"),
|
||||
t.builtIn("C:/mingw/i686-w64-mingw32/include/c++"),
|
||||
@@ -732,9 +734,9 @@ void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderN
|
||||
t.builtIn("C:/mingw/i686-w64-mingw32/include")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderAndroidClang()
|
||||
void HeaderPathFilterTest::testClangHeadersAndCppIncludesPathsOrderAndroidClang()
|
||||
{
|
||||
HeaderPathFilterTest t;
|
||||
HeaderPathFilterTestHelper t;
|
||||
t.headerPaths = {
|
||||
t.builtIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include/i686-linux-android"),
|
||||
t.builtIn("C:/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include"),
|
||||
@@ -755,7 +757,7 @@ void CppToolsPlugin::test_headerPathFilter_clangHeadersAndCppIncludesPathsOrderA
|
||||
t.builtIn("C:/Android/sdk/ndk-bundle/sysroot/usr/include")}));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_c()
|
||||
void ProjectFileCategorizerTest::testC()
|
||||
{
|
||||
const ProjectFileCategorizer categorizer({}, {"foo.c", "foo.h"});
|
||||
const ProjectFiles expected {
|
||||
@@ -769,7 +771,7 @@ void CppToolsPlugin::test_projectFileCategorizer_c()
|
||||
QVERIFY(categorizer.objcxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_cxxWithUnambiguousHeaderSuffix()
|
||||
void ProjectFileCategorizerTest::testCxxWithUnambiguousHeaderSuffix()
|
||||
{
|
||||
const ProjectFileCategorizer categorizer({}, {"foo.cpp", "foo.hpp"});
|
||||
const ProjectFiles expected {
|
||||
@@ -783,7 +785,7 @@ void CppToolsPlugin::test_projectFileCategorizer_cxxWithUnambiguousHeaderSuffix(
|
||||
QVERIFY(categorizer.objcxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_cxxWithAmbiguousHeaderSuffix()
|
||||
void ProjectFileCategorizerTest::testCxxWithAmbiguousHeaderSuffix()
|
||||
{
|
||||
const ProjectFiles expected {
|
||||
ProjectFile("foo.cpp", ProjectFile::CXXSource),
|
||||
@@ -798,7 +800,7 @@ void CppToolsPlugin::test_projectFileCategorizer_cxxWithAmbiguousHeaderSuffix()
|
||||
QVERIFY(categorizer.objcxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_objectiveC()
|
||||
void ProjectFileCategorizerTest::testObjectiveC()
|
||||
{
|
||||
const ProjectFiles expected {
|
||||
ProjectFile("foo.m", ProjectFile::ObjCSource),
|
||||
@@ -813,7 +815,7 @@ void CppToolsPlugin::test_projectFileCategorizer_objectiveC()
|
||||
QVERIFY(categorizer.objcxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_objectiveCxx()
|
||||
void ProjectFileCategorizerTest::testObjectiveCxx()
|
||||
{
|
||||
const ProjectFiles expected {
|
||||
ProjectFile("foo.mm", ProjectFile::ObjCXXSource),
|
||||
@@ -828,7 +830,7 @@ void CppToolsPlugin::test_projectFileCategorizer_objectiveCxx()
|
||||
QVERIFY(categorizer.cxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_mixedCAndCxx()
|
||||
void ProjectFileCategorizerTest::testMixedCAndCxx()
|
||||
{
|
||||
const ProjectFiles expectedCxxSources {
|
||||
ProjectFile("foo.cpp", ProjectFile::CXXSource),
|
||||
@@ -849,7 +851,7 @@ void CppToolsPlugin::test_projectFileCategorizer_mixedCAndCxx()
|
||||
QVERIFY(categorizer.objcxxSources().isEmpty());
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_projectFileCategorizer_ambiguousHeaderOnly()
|
||||
void ProjectFileCategorizerTest::testAmbiguousHeaderOnly()
|
||||
{
|
||||
const ProjectFileCategorizer categorizer({}, {"foo.h"});
|
||||
|
||||
|
||||
109
src/plugins/cpptools/projectinfo_test.h
Normal file
109
src/plugins/cpptools/projectinfo_test.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class ProjectPartChooserTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testChooseManuallySet();
|
||||
void testIndicateManuallySet();
|
||||
void testIndicateManuallySetForFallbackToProjectPartFromDependencies();
|
||||
void testDoNotIndicateNotManuallySet();
|
||||
void testForMultipleChooseFromActiveProject();
|
||||
void testForMultiplePreferSelectedForBuilding();
|
||||
void testForMultipleFromDependenciesChooseFromActiveProject();
|
||||
void testForMultipleCheckIfActiveProjectChanged();
|
||||
void testForMultipleAndAmbigiousHeaderPreferCProjectPart();
|
||||
void testForMultipleAndAmbigiousHeaderPreferCxxProjectPart();
|
||||
void testIndicateMultiple();
|
||||
void testIndicateMultipleForFallbackToProjectPartFromDependencies();
|
||||
void testForMultipleChooseNewIfPreviousIsGone();
|
||||
void testFallbackToProjectPartFromDependencies();
|
||||
void testFallbackToProjectPartFromModelManager();
|
||||
void testContinueUsingFallbackFromModelManagerIfProjectDoesNotChange();
|
||||
void testStopUsingFallbackFromModelManagerIfProjectChanges1();
|
||||
void testStopUsingFallbackFromModelManagerIfProjectChanges2();
|
||||
void testIndicateFallbacktoProjectPartFromModelManager();
|
||||
void testIndicateFromDependencies();
|
||||
void testDoNotIndicateFromDependencies();
|
||||
};
|
||||
|
||||
class ProjectInfoGeneratorTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testCreateNoProjectPartsForEmptyFileList();
|
||||
void testCreateSingleProjectPart();
|
||||
void testCreateMultipleProjectParts();
|
||||
void testProjectPartIndicatesObjectiveCExtensionsByDefault();
|
||||
void testProjectPartHasLatestLanguageVersionByDefault();
|
||||
void testUseMacroInspectionReportForLanguageVersion();
|
||||
void testUseCompilerFlagsForLanguageExtensions();
|
||||
void testProjectFileKindsMatchProjectPartVersion();
|
||||
};
|
||||
|
||||
class HeaderPathFilterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testBuiltin();
|
||||
void testSystem();
|
||||
void testUser();
|
||||
void testNoProjectPathSet();
|
||||
void testDontAddInvalidPath();
|
||||
void testClangHeadersPath();
|
||||
void testClangHeadersPathWitoutClangVersion();
|
||||
void testClangHeadersAndCppIncludesPathsOrderMacOs();
|
||||
void testClangHeadersAndCppIncludesPathsOrderLinux();
|
||||
void testRemoveGccInternalPaths();
|
||||
void testRemoveGccInternalPathsExceptForStandardPaths();
|
||||
void testClangHeadersAndCppIncludesPathsOrderNoVersion();
|
||||
void testClangHeadersAndCppIncludesPathsOrderAndroidClang();
|
||||
};
|
||||
|
||||
class ProjectFileCategorizerTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testC();
|
||||
void testCxxWithUnambiguousHeaderSuffix();
|
||||
void testCxxWithAmbiguousHeaderSuffix();
|
||||
void testObjectiveC();
|
||||
void testObjectiveCxx();
|
||||
void testMixedCAndCxx();
|
||||
void testAmbiguousHeaderOnly();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -87,9 +87,9 @@ bool SendDocumentTracker::changedBeforeCompletionPosition(int newCompletionPosit
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Internal {
|
||||
namespace Internal {
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_defaultLastSentRevision()
|
||||
void DocumentTrackerTest::testDefaultLastSentRevision()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
|
||||
@@ -97,7 +97,7 @@ void CppToolsPlugin::test_documentTracker_defaultLastSentRevision()
|
||||
QCOMPARE(tracker.lastCompletionPosition(), -1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_setRevision()
|
||||
void DocumentTrackerTest::testSetRevision()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -106,7 +106,7 @@ void CppToolsPlugin::test_documentTracker_setRevision()
|
||||
QCOMPARE(tracker.lastCompletionPosition(), -1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_setLastCompletionPosition()
|
||||
void DocumentTrackerTest::testSetLastCompletionPosition()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastCompletionPosition(33);
|
||||
@@ -115,7 +115,7 @@ void CppToolsPlugin::test_documentTracker_setLastCompletionPosition()
|
||||
QCOMPARE(tracker.lastCompletionPosition(), 33);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_applyContentChange()
|
||||
void DocumentTrackerTest::testApplyContentChange()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -126,7 +126,7 @@ void CppToolsPlugin::test_documentTracker_applyContentChange()
|
||||
QCOMPARE(tracker.lastCompletionPosition(), -1);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendCompletionIfPositionIsEqual()
|
||||
void DocumentTrackerTest::testDontSendCompletionIfPositionIsEqual()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastCompletionPosition(33);
|
||||
@@ -134,7 +134,7 @@ void CppToolsPlugin::test_documentTracker_dontSendCompletionIfPositionIsEqual()
|
||||
QVERIFY(!tracker.shouldSendCompletion(33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_sendCompletionIfPositionIsDifferent()
|
||||
void DocumentTrackerTest::testSendCompletionIfPositionIsDifferent()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -143,7 +143,7 @@ void CppToolsPlugin::test_documentTracker_sendCompletionIfPositionIsDifferent()
|
||||
QVERIFY(tracker.shouldSendCompletion(22));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_sendCompletionIfChangeIsBeforeCompletionPositionAndPositionIsEqual()
|
||||
void DocumentTrackerTest::testSendCompletionIfChangeIsBeforeCompletionPositionAndPositionIsEqual()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -153,7 +153,7 @@ void CppToolsPlugin::test_documentTracker_sendCompletionIfChangeIsBeforeCompleti
|
||||
QVERIFY(tracker.shouldSendCompletion(33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendCompletionIfChangeIsAfterCompletionPositionAndPositionIsEqual()
|
||||
void DocumentTrackerTest::testDontSendCompletionIfChangeIsAfterCompletionPositionAndPositionIsEqual()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -163,7 +163,7 @@ void CppToolsPlugin::test_documentTracker_dontSendCompletionIfChangeIsAfterCompl
|
||||
QVERIFY(!tracker.shouldSendCompletion(33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendRevisionIfRevisionIsEqual()
|
||||
void DocumentTrackerTest::testDontSendRevisionIfRevisionIsEqual()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -171,7 +171,7 @@ void CppToolsPlugin::test_documentTracker_dontSendRevisionIfRevisionIsEqual()
|
||||
QVERIFY(!tracker.shouldSendRevision(46));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_sendRevisionIfRevisionIsDifferent()
|
||||
void DocumentTrackerTest::testSendRevisionIfRevisionIsDifferent()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -179,13 +179,13 @@ void CppToolsPlugin::test_documentTracker_sendRevisionIfRevisionIsDifferent()
|
||||
QVERIFY(tracker.shouldSendRevision(21));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendRevisionWithDefaults()
|
||||
void DocumentTrackerTest::testDontSendRevisionWithDefaults()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
QVERIFY(!tracker.shouldSendRevisionWithCompletionPosition(21, 33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsDifferentAndCompletionPositionIsEqualAndNoContentChange()
|
||||
void DocumentTrackerTest::testDontSendIfRevisionIsDifferentAndCompletionPositionIsEqualAndNoContentChange()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -194,7 +194,7 @@ void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsDifferentAndComple
|
||||
QVERIFY(!tracker.shouldSendRevisionWithCompletionPosition(21, 33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsDifferentAndCompletionPositionIsDifferentAndNoContentChange()
|
||||
void DocumentTrackerTest::testDontSendIfRevisionIsDifferentAndCompletionPositionIsDifferentAndNoContentChange()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -203,7 +203,7 @@ void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsDifferentAndComple
|
||||
QVERIFY(!tracker.shouldSendRevisionWithCompletionPosition(21, 44));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsEqualAndCompletionPositionIsDifferentAndNoContentChange()
|
||||
void DocumentTrackerTest::testDontSendIfRevisionIsEqualAndCompletionPositionIsDifferentAndNoContentChange()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -212,7 +212,7 @@ void CppToolsPlugin::test_documentTracker_dontSendIfRevisionIsEqualAndCompletion
|
||||
QVERIFY(!tracker.shouldSendRevisionWithCompletionPosition(46,44));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_sendIfChangeIsBeforeCompletionAndPositionIsEqualAndRevisionIsDifferent()
|
||||
void DocumentTrackerTest::testSendIfChangeIsBeforeCompletionAndPositionIsEqualAndRevisionIsDifferent()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -222,7 +222,7 @@ void CppToolsPlugin::test_documentTracker_sendIfChangeIsBeforeCompletionAndPosit
|
||||
QVERIFY(tracker.shouldSendRevisionWithCompletionPosition(45, 33));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_dontSendIfChangeIsAfterCompletionPositionAndRevisionIsDifferent()
|
||||
void DocumentTrackerTest::testDontSendIfChangeIsAfterCompletionPositionAndRevisionIsDifferent()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -232,7 +232,7 @@ void CppToolsPlugin::test_documentTracker_dontSendIfChangeIsAfterCompletionPosit
|
||||
QVERIFY(!tracker.shouldSendRevisionWithCompletionPosition(45, 36));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_sendIfChangeIsBeforeCompletionPositionAndRevisionIsDifferent()
|
||||
void DocumentTrackerTest::testSendIfChangeIsBeforeCompletionPositionAndRevisionIsDifferent()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
@@ -242,7 +242,7 @@ void CppToolsPlugin::test_documentTracker_sendIfChangeIsBeforeCompletionPosition
|
||||
QVERIFY(tracker.shouldSendRevisionWithCompletionPosition(45, 36));
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_documentTracker_resetChangedContentStartPositionIfLastRevisionIsSet()
|
||||
void DocumentTrackerTest::testResetChangedContentStartPositionIfLastRevisionIsSet()
|
||||
{
|
||||
SendDocumentTracker tracker;
|
||||
tracker.setLastSentRevision(46);
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "cpptools_global.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace CppTools {
|
||||
@@ -55,4 +57,33 @@ private:
|
||||
int m_contentChangeStartPosition = std::numeric_limits<int>::max();
|
||||
};
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Internal {
|
||||
class DocumentTrackerTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testDefaultLastSentRevision();
|
||||
void testSetRevision();
|
||||
void testSetLastCompletionPosition();
|
||||
void testApplyContentChange();
|
||||
void testDontSendCompletionIfPositionIsEqual();
|
||||
void testSendCompletionIfPositionIsDifferent();
|
||||
void testSendCompletionIfChangeIsBeforeCompletionPositionAndPositionIsEqual();
|
||||
void testDontSendCompletionIfChangeIsAfterCompletionPositionAndPositionIsEqual();
|
||||
void testDontSendRevisionIfRevisionIsEqual();
|
||||
void testSendRevisionIfRevisionIsDifferent();
|
||||
void testDontSendRevisionWithDefaults();
|
||||
void testDontSendIfRevisionIsDifferentAndCompletionPositionIsEqualAndNoContentChange();
|
||||
void testDontSendIfRevisionIsDifferentAndCompletionPositionIsDifferentAndNoContentChange();
|
||||
void testDontSendIfRevisionIsEqualAndCompletionPositionIsDifferentAndNoContentChange();
|
||||
void testSendIfChangeIsBeforeCompletionAndPositionIsEqualAndRevisionIsDifferent();
|
||||
void testDontSendIfChangeIsAfterCompletionPositionAndRevisionIsDifferent();
|
||||
void testSendIfChangeIsBeforeCompletionPositionAndRevisionIsDifferent();
|
||||
void testResetChangedContentStartPositionIfLastRevisionIsSet();
|
||||
};
|
||||
} // namespace Internal
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace CppTools
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "symbolsearcher_test.h"
|
||||
|
||||
#include "builtinindexingsupport.h"
|
||||
#include "cppmodelmanager.h"
|
||||
@@ -120,7 +120,7 @@ template<> char *toString(const ResultData &data)
|
||||
} // namespace QTest
|
||||
QT_END_NAMESPACE
|
||||
|
||||
void CppToolsPlugin::test_builtinsymbolsearcher()
|
||||
void SymbolSearcherTest::test()
|
||||
{
|
||||
QFETCH(QString, testFile);
|
||||
QFETCH(SymbolSearcher::Parameters, searchParameters);
|
||||
@@ -129,7 +129,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher()
|
||||
SymbolSearcherTestCase(testFile, searchParameters, expectedResults);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_builtinsymbolsearcher_data()
|
||||
void SymbolSearcherTest::test_data()
|
||||
{
|
||||
QTest::addColumn<QString>("testFile");
|
||||
QTest::addColumn<SymbolSearcher::Parameters>("searchParameters");
|
||||
|
||||
41
src/plugins/cpptools/symbolsearcher_test.h
Normal file
41
src/plugins/cpptools/symbolsearcher_test.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class SymbolSearcherTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test();
|
||||
void test_data();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
@@ -23,7 +23,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cpptoolsplugin.h"
|
||||
#include "typehierarchybuilder_test.h"
|
||||
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolstestcase.h"
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppToolsPlugin::test_typehierarchy_data()
|
||||
void TypeHierarchyBuilderTest::test_data()
|
||||
{
|
||||
QTest::addColumn<QList<TestDocument> >("documents");
|
||||
QTest::addColumn<QString>("expectedHierarchy");
|
||||
@@ -181,7 +181,7 @@ void CppToolsPlugin::test_typehierarchy_data()
|
||||
);
|
||||
}
|
||||
|
||||
void CppToolsPlugin::test_typehierarchy()
|
||||
void TypeHierarchyBuilderTest::test()
|
||||
{
|
||||
QFETCH(QList<TestDocument>, documents);
|
||||
QFETCH(QString, expectedHierarchy);
|
||||
|
||||
41
src/plugins/cpptools/typehierarchybuilder_test.h
Normal file
41
src/plugins/cpptools/typehierarchybuilder_test.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2021 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppTools::Internal {
|
||||
|
||||
class TypeHierarchyBuilderTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test_data();
|
||||
void test();
|
||||
};
|
||||
|
||||
} // namespace CppTools::Internal
|
||||
Reference in New Issue
Block a user