forked from qt-creator/qt-creator
CppEditor: Use test objects to group related test functions
Change-Id: I65089f2a00d8d168f123becf160f82bfcca4c68c Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -46,11 +46,12 @@ extend_qtc_plugin(CppEditor
|
||||
SOURCES
|
||||
cppdoxygen_test.cpp cppdoxygen_test.h
|
||||
cppeditortestcase.cpp cppeditortestcase.h
|
||||
cppincludehierarchy_test.cpp
|
||||
cppincludehierarchy_test.cpp cppincludehierarchy_test.h
|
||||
cppquickfix_test.cpp cppquickfix_test.h
|
||||
cppuseselections_test.cpp
|
||||
fileandtokenactions_test.cpp
|
||||
followsymbol_switchmethoddecldef_test.cpp
|
||||
cppuseselections_test.cpp cppuseselections_test.h
|
||||
fileandtokenactions_test.cpp fileandtokenactions_test.h
|
||||
followsymbol_switchmethoddecldef_test.cpp followsymbol_switchmethoddecldef_test.h
|
||||
EXPLICIT_MOC
|
||||
cppdoxygen_test.h
|
||||
cppquickfix_test.h
|
||||
)
|
||||
|
@@ -32,8 +32,23 @@
|
||||
#include <QTextBlock>
|
||||
#include <QTextCursor>
|
||||
|
||||
using namespace CppEditor;
|
||||
using namespace Internal;
|
||||
#ifdef WITH_TESTS
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditorwidget.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <utils/executeondestruction.h>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#endif // WITH_TESTS
|
||||
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
bool CppAutoCompleter::contextAllowsAutoBrackets(const QTextCursor &cursor,
|
||||
const QString &textToInsert) const
|
||||
@@ -84,22 +99,7 @@ QString CppAutoCompleter::insertParagraphSeparator(const QTextCursor &cursor) co
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorconstants.h"
|
||||
#include "cppeditorplugin.h"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <texteditor/icodestylepreferences.h>
|
||||
#include <texteditor/textdocument.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
#include <utils/executeondestruction.h>
|
||||
namespace Tests {
|
||||
|
||||
enum FileContent {
|
||||
EmptyFile,
|
||||
@@ -204,7 +204,6 @@ static QChar closingChar(QChar c)
|
||||
return QChar();
|
||||
}
|
||||
|
||||
namespace CppEditor { // MSVC Workaround: error C2872: 'CppEditor': ambiguous symbol
|
||||
static QTextCursor openEditor(const QString &text)
|
||||
{
|
||||
QTextCursor tc;
|
||||
@@ -232,9 +231,8 @@ static QTextCursor openEditor(const QString &text)
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
} // namespace CppEditor
|
||||
|
||||
void CppEditorPlugin::test_autoComplete_data()
|
||||
void AutoCompleterTest::testAutoComplete_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
QTest::addColumn<QString>("textToInsert");
|
||||
@@ -282,7 +280,7 @@ void CppEditorPlugin::test_autoComplete_data()
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_autoComplete()
|
||||
void AutoCompleterTest::testAutoComplete()
|
||||
{
|
||||
QFETCH(QString, text);
|
||||
QFETCH(QString, textToInsert);
|
||||
@@ -307,7 +305,7 @@ void CppEditorPlugin::test_autoComplete()
|
||||
QCOMPARE(skippedChars, expectedSkippedChars);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_surroundWithSelection_data()
|
||||
void AutoCompleterTest::testSurroundWithSelection_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
QTest::addColumn<QString>("textToInsert");
|
||||
@@ -344,7 +342,7 @@ void CppEditorPlugin::test_surroundWithSelection_data()
|
||||
+ closingChar(c));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_surroundWithSelection()
|
||||
void AutoCompleterTest::testSurroundWithSelection()
|
||||
{
|
||||
QFETCH(QString, text);
|
||||
QFETCH(QString, textToInsert);
|
||||
@@ -365,7 +363,7 @@ void CppEditorPlugin::test_surroundWithSelection()
|
||||
QCOMPARE(matchingText, expectedText);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_autoBackspace_data()
|
||||
void AutoCompleterTest::testAutoBackspace_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
QTest::addColumn<bool>("expectedStopHandling");
|
||||
@@ -380,7 +378,7 @@ void CppEditorPlugin::test_autoBackspace_data()
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_autoBackspace()
|
||||
void AutoCompleterTest::testAutoBackspace()
|
||||
{
|
||||
QFETCH(QString, text);
|
||||
QFETCH(bool, expectedStopHandling);
|
||||
@@ -399,7 +397,7 @@ void CppEditorPlugin::test_autoBackspace()
|
||||
QCOMPARE(stopHandling, expectedStopHandling);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_insertParagraph_data()
|
||||
void AutoCompleterTest::testInsertParagraph_data()
|
||||
{
|
||||
QTest::addColumn<QString>("text");
|
||||
QTest::addColumn<int>("expectedBlockCount");
|
||||
@@ -422,7 +420,7 @@ void CppEditorPlugin::test_insertParagraph_data()
|
||||
<< 1;
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_insertParagraph()
|
||||
void AutoCompleterTest::testInsertParagraph()
|
||||
{
|
||||
QFETCH(QString, text);
|
||||
QFETCH(int, expectedBlockCount);
|
||||
@@ -444,4 +442,7 @@ void CppEditorPlugin::test_insertParagraph()
|
||||
QCOMPARE(blockCount, expectedBlockCount);
|
||||
}
|
||||
|
||||
#endif
|
||||
} // namespace Tests
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace CppEditor::Internal
|
||||
|
@@ -27,6 +27,8 @@
|
||||
|
||||
#include <texteditor/autocompleter.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
@@ -53,5 +55,24 @@ public:
|
||||
QString insertParagraphSeparator(const QTextCursor &cursor) const override;
|
||||
};
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Tests {
|
||||
class AutoCompleterTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testAutoComplete_data();
|
||||
void testAutoComplete();
|
||||
void testSurroundWithSelection_data();
|
||||
void testSurroundWithSelection();
|
||||
void testAutoBackspace_data();
|
||||
void testAutoBackspace();
|
||||
void testInsertParagraph_data();
|
||||
void testInsertParagraph();
|
||||
};
|
||||
} // namespace Tests
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // Internal
|
||||
} // CppEditor
|
||||
|
@@ -75,7 +75,12 @@ equals(TEST, 1) {
|
||||
HEADERS += \
|
||||
cppeditortestcase.h \
|
||||
cppdoxygen_test.h \
|
||||
cppquickfix_test.h
|
||||
cppincludehierarchy_test.h \
|
||||
cppquickfix_test.h \
|
||||
cppuseselections_test.h \
|
||||
fileandtokenactions_test.h \
|
||||
followsymbol_switchmethoddecldef_test.h
|
||||
|
||||
SOURCES += \
|
||||
cppdoxygen_test.cpp \
|
||||
cppeditortestcase.cpp \
|
||||
|
@@ -95,11 +95,15 @@ QtcPlugin {
|
||||
"cppeditortestcase.cpp",
|
||||
"cppeditortestcase.h",
|
||||
"cppincludehierarchy_test.cpp",
|
||||
"cppincludehierarchy_test.h",
|
||||
"cppquickfix_test.cpp",
|
||||
"cppquickfix_test.h",
|
||||
"cppuseselections_test.cpp",
|
||||
"cppuseselections_test.h",
|
||||
"fileandtokenactions_test.cpp",
|
||||
"fileandtokenactions_test.h",
|
||||
"followsymbol_switchmethoddecldef_test.cpp",
|
||||
"followsymbol_switchmethoddecldef_test.h",
|
||||
]
|
||||
|
||||
cpp.defines: outer.concat(['SRCDIR="' + FileInfo.path(filePath) + '"'])
|
||||
|
@@ -45,7 +45,13 @@
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
# include "cppdoxygen_test.h"
|
||||
#include "cppdoxygen_test.h"
|
||||
#include "cppincludehierarchy_test.h"
|
||||
#include "cppinsertvirtualmethods.h"
|
||||
#include "cppquickfix_test.h"
|
||||
#include "cppuseselections_test.h"
|
||||
#include "fileandtokenactions_test.h"
|
||||
#include "followsymbol_switchmethoddecldef_test.h"
|
||||
#endif
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -392,12 +398,21 @@ void CppEditorPluginPrivate::inspectCppCodeModel()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
QVector<QObject *> CppEditorPlugin::createTestObjects() const
|
||||
{
|
||||
return {new Tests::DoxygenTest};
|
||||
}
|
||||
return {
|
||||
#ifdef WITH_TESTS
|
||||
new FollowSymbolTest,
|
||||
new Tests::AutoCompleterTest,
|
||||
new Tests::DoxygenTest,
|
||||
new Tests::FileAndTokenActionsTest,
|
||||
new Tests::IncludeHierarchyTest,
|
||||
new Tests::InsertVirtualMethodsTest,
|
||||
new Tests::QuickfixTest,
|
||||
new Tests::SelectionsTest,
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
void CppEditorPlugin::openTypeHierarchy()
|
||||
{
|
||||
|
@@ -27,10 +27,6 @@
|
||||
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace ProjectExplorer { class Kit; }
|
||||
#endif
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
@@ -53,10 +49,6 @@ public:
|
||||
|
||||
CppQuickFixAssistProvider *quickFixProvider() const;
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
ProjectExplorer::Kit *m_testKit = nullptr;
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void outlineSortingChanged(bool sort);
|
||||
void typeHierarchyRequested();
|
||||
@@ -70,236 +62,9 @@ public:
|
||||
void renameSymbolUnderCursor();
|
||||
void switchDeclarationDefinition();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
private:
|
||||
QVector<QObject *> createTestObjects() const override;
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
// The following tests expect that no projects are loaded on start-up.
|
||||
void test_SwitchMethodDeclarationDefinition_data();
|
||||
void test_SwitchMethodDeclarationDefinition();
|
||||
|
||||
void test_FollowSymbolUnderCursor_multipleDocuments_data();
|
||||
void test_FollowSymbolUnderCursor_multipleDocuments();
|
||||
|
||||
void test_FollowSymbolUnderCursor_data();
|
||||
void test_FollowSymbolUnderCursor();
|
||||
|
||||
void test_FollowSymbolUnderCursor_QTCREATORBUG7903_data();
|
||||
void test_FollowSymbolUnderCursor_QTCREATORBUG7903();
|
||||
|
||||
void test_FollowSymbolUnderCursor_followCall_data();
|
||||
void test_FollowSymbolUnderCursor_followCall();
|
||||
|
||||
void test_FollowSymbolUnderCursor_QObject_connect_data();
|
||||
void test_FollowSymbolUnderCursor_QObject_connect();
|
||||
void test_FollowSymbolUnderCursor_QObject_oldStyleConnect();
|
||||
|
||||
void test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data();
|
||||
void test_FollowSymbolUnderCursor_classOperator_onOperatorToken();
|
||||
|
||||
void test_FollowSymbolUnderCursor_classOperator_data();
|
||||
void test_FollowSymbolUnderCursor_classOperator();
|
||||
|
||||
void test_FollowSymbolUnderCursor_classOperator_inOp_data();
|
||||
void test_FollowSymbolUnderCursor_classOperator_inOp();
|
||||
|
||||
void test_FollowSymbolUnderCursor_virtualFunctionCall_data();
|
||||
void test_FollowSymbolUnderCursor_virtualFunctionCall();
|
||||
void test_FollowSymbolUnderCursor_virtualFunctionCall_multipleDocuments();
|
||||
|
||||
void test_quickfix_data();
|
||||
void test_quickfix();
|
||||
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingCreate_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingCreate();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingAddUsing_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingAddUsing();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingFullyQualify_data();
|
||||
void test_quickfix_GenerateGetterSetter_namespaceHandlingFullyQualify();
|
||||
void test_quickfix_GenerateGetterSetter_customNames_data();
|
||||
void test_quickfix_GenerateGetterSetter_customNames();
|
||||
void test_quickfix_GenerateGetterSetter_valueTypes_data();
|
||||
void test_quickfix_GenerateGetterSetter_valueTypes();
|
||||
void test_quickfix_GenerateGetterSetter_customTemplate();
|
||||
void test_quickfix_GenerateGetterSetter_needThis();
|
||||
void test_quickfix_GenerateGetterSetter_offeredFixes_data();
|
||||
void test_quickfix_GenerateGetterSetter_offeredFixes();
|
||||
void test_quickfix_GenerateGetterSetter_generalTests_data();
|
||||
void test_quickfix_GenerateGetterSetter_generalTests();
|
||||
void test_quickfix_GenerateGetterSetter_onlyGetter();
|
||||
void test_quickfix_GenerateGetterSetter_onlySetter();
|
||||
void test_quickfix_GenerateGetterSetter_inlineInHeaderFile();
|
||||
void test_quickfix_GenerateGetterSetter_onlySetterHeaderFileWithIncludeGuard();
|
||||
void test_quickfix_GenerateGettersSetters_data();
|
||||
void test_quickfix_GenerateGettersSetters();
|
||||
|
||||
void test_quickfix_InsertQtPropertyMembers_data();
|
||||
void test_quickfix_InsertQtPropertyMembers();
|
||||
|
||||
void test_quickfix_InsertMemberFromInitialization_data();
|
||||
void test_quickfix_InsertMemberFromInitialization();
|
||||
|
||||
void test_quickfix_ConvertQt4Connect_connectOutOfClass();
|
||||
void test_quickfix_ConvertQt4Connect_connectWithinClass_data();
|
||||
void test_quickfix_ConvertQt4Connect_connectWithinClass();
|
||||
void test_quickfix_ConvertQt4Connect_differentNamespace();
|
||||
|
||||
void test_quickfix_InsertDefFromDecl_afterClass();
|
||||
void test_quickfix_InsertDefFromDecl_headerSource_basic1();
|
||||
void test_quickfix_InsertDefFromDecl_headerSource_basic2();
|
||||
void test_quickfix_InsertDefFromDecl_headerSource_basic3();
|
||||
void test_quickfix_InsertDefFromDecl_headerSource_namespace1();
|
||||
void test_quickfix_InsertDefFromDecl_headerSource_namespace2();
|
||||
void test_quickfix_InsertDefFromDecl_insideClass();
|
||||
void test_quickfix_InsertDefFromDecl_notTriggeringWhenDefinitionExists();
|
||||
void test_quickfix_InsertDefFromDecl_findRightImplementationFile();
|
||||
void test_quickfix_InsertDefFromDecl_ignoreSurroundingGeneratedDeclarations();
|
||||
void test_quickfix_InsertDefFromDecl_respectWsInOperatorNames1();
|
||||
void test_quickfix_InsertDefFromDecl_respectWsInOperatorNames2();
|
||||
void test_quickfix_InsertDefFromDecl_noexcept_specifier();
|
||||
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile1();
|
||||
void test_quickfix_InsertDefFromDecl_macroUsesAtEndOfFile2();
|
||||
void test_quickfix_InsertDefFromDecl_erroneousStatementAtEndOfFile();
|
||||
void test_quickfix_InsertDefFromDecl_rvalueReference();
|
||||
void test_quickfix_InsertDefFromDecl_functionTryBlock();
|
||||
void test_quickfix_InsertDefFromDecl_usingDecl();
|
||||
void test_quickfix_InsertDefFromDecl_findImplementationFile();
|
||||
void test_quickfix_InsertDefFromDecl_unicodeIdentifier();
|
||||
void test_quickfix_InsertDefFromDecl_templateClass();
|
||||
void test_quickfix_InsertDefFromDecl_templateClassWithValueParam();
|
||||
void test_quickfix_InsertDefFromDecl_templateFunction();
|
||||
void test_quickfix_InsertDefFromDecl_notTriggeredForFriendFunc();
|
||||
void test_quickfix_InsertDefFromDecl_minimalFunctionParameterType();
|
||||
void test_quickfix_InsertDefsFromDecls_data();
|
||||
void test_quickfix_InsertDefsFromDecls();
|
||||
|
||||
void test_quickfix_InsertDeclFromDef();
|
||||
void test_quickfix_InsertDeclFromDef_templateFuncTypename();
|
||||
void test_quickfix_InsertDeclFromDef_templateFuncInt();
|
||||
void test_quickfix_InsertDeclFromDef_notTriggeredForTemplateFunc();
|
||||
|
||||
void test_quickfix_AddIncludeForUndefinedIdentifier_data();
|
||||
void test_quickfix_AddIncludeForUndefinedIdentifier();
|
||||
void test_quickfix_AddIncludeForUndefinedIdentifier_noDoubleQtHeaderInclude();
|
||||
|
||||
void test_quickfix_AddForwardDeclForUndefinedIdentifier_data();
|
||||
void test_quickfix_AddForwardDeclForUndefinedIdentifier();
|
||||
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCpp();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCppInsideNS();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncOutside1();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncOutside2();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCppNS();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCppNSUsing();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncOutsideWithNs();
|
||||
void test_quickfix_MoveFuncDefOutside_FreeFuncToCpp();
|
||||
void test_quickfix_MoveFuncDefOutside_FreeFuncToCppNS();
|
||||
void test_quickfix_MoveFuncDefOutside_CtorWithInitialization1();
|
||||
void test_quickfix_MoveFuncDefOutside_CtorWithInitialization2();
|
||||
void test_quickfix_MoveFuncDefOutside_afterClass();
|
||||
void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames1();
|
||||
void test_quickfix_MoveFuncDefOutside_respectWsInOperatorNames2();
|
||||
void test_quickfix_MoveFuncDefOutside_macroUses();
|
||||
void test_quickfix_MoveFuncDefOutside_template();
|
||||
void test_quickfix_MoveFuncDefOutside_template_specializedClass();
|
||||
void test_quickfix_MoveFuncDefOutside_unnamedTemplate();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCpp_Static();
|
||||
void test_quickfix_MoveFuncDefOutside_MemberFuncToCpp_WithInlinePartOfName();
|
||||
|
||||
void test_quickfix_MoveAllFuncDefOutside_MemberFuncToCpp();
|
||||
void test_quickfix_MoveAllFuncDefOutside_MemberFuncOutside();
|
||||
void test_quickfix_MoveAllFuncDefOutside_DoNotTriggerOnBaseClass();
|
||||
void test_quickfix_MoveAllFuncDefOutside_classWithBaseClass();
|
||||
void test_quickfix_MoveAllFuncDefOutside_ignoreMacroCode();
|
||||
|
||||
void test_quickfix_MoveFuncDefToDecl_MemberFunc();
|
||||
void test_quickfix_MoveFuncDefToDecl_MemberFuncOutside();
|
||||
void test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNS();
|
||||
void test_quickfix_MoveFuncDefToDecl_MemberFuncToCppNSUsing();
|
||||
void test_quickfix_MoveFuncDefToDecl_MemberFuncOutsideWithNs();
|
||||
void test_quickfix_MoveFuncDefToDecl_FreeFuncToCpp();
|
||||
void test_quickfix_MoveFuncDefToDecl_FreeFuncToCppNS();
|
||||
void test_quickfix_MoveFuncDefToDecl_CtorWithInitialization();
|
||||
void test_quickfix_MoveFuncDefToDecl_structWithAssignedVariable();
|
||||
void test_quickfix_MoveFuncDefToDecl_macroUses();
|
||||
void test_quickfix_MoveFuncDefToDecl_override();
|
||||
void test_quickfix_MoveFuncDefToDecl_template();
|
||||
void test_quickfix_MoveFuncDefToDecl_templateFunction();
|
||||
|
||||
void test_quickfix_AssignToLocalVariable_templates();
|
||||
|
||||
void test_quickfix_ExtractFunction_data();
|
||||
void test_quickfix_ExtractFunction();
|
||||
|
||||
void test_quickfix_ExtractLiteralAsParameter_typeDeduction_data();
|
||||
void test_quickfix_ExtractLiteralAsParameter_typeDeduction();
|
||||
void test_quickfix_ExtractLiteralAsParameter_freeFunction_separateFiles();
|
||||
void test_quickfix_ExtractLiteralAsParameter_memberFunction_separateFiles();
|
||||
void test_quickfix_ExtractLiteralAsParameter_notTriggeringForInvalidCode();
|
||||
|
||||
void test_quickfix_addCurlyBraces();
|
||||
|
||||
void test_quickfix_removeUsingNamespace_data();
|
||||
void test_quickfix_removeUsingNamespace();
|
||||
void test_quickfix_removeUsingNamespace_simple_data();
|
||||
void test_quickfix_removeUsingNamespace_simple();
|
||||
void test_quickfix_removeUsingNamespace_differentSymbols();
|
||||
|
||||
void test_quickfix_generateConstructor_data();
|
||||
void test_quickfix_generateConstructor();
|
||||
|
||||
void test_quickfix_InsertVirtualMethods_data();
|
||||
void test_quickfix_InsertVirtualMethods();
|
||||
void test_quickfix_InsertVirtualMethods_implementationFile();
|
||||
void test_quickfix_InsertVirtualMethods_BaseClassInNamespace();
|
||||
|
||||
void test_useSelections_data();
|
||||
void test_useSelections();
|
||||
|
||||
void test_selectionFiltering_data();
|
||||
void test_selectionFiltering();
|
||||
|
||||
// tests for "Include Hierarchy"
|
||||
void test_includehierarchy_data();
|
||||
void test_includehierarchy();
|
||||
|
||||
// The following tests operate on a project and require special invocation:
|
||||
//
|
||||
// Ensure that the project is properly configured for a given settings path:
|
||||
// $ ./qtcreator -settingspath /your/settings/path /path/to/project
|
||||
//
|
||||
// ...and that it builds, which might prevent blocking dialogs for not
|
||||
// existing files (e.g. ui_*.h).
|
||||
//
|
||||
// Run a test:
|
||||
// $ export QTC_TEST_WAIT_FOR_LOADED_PROJECT=1
|
||||
// $ ./qtcreator -settingspath /your/settings/path -test CppEditor,test_openEachFile /path/to/project
|
||||
void test_openEachFile();
|
||||
void test_switchHeaderSourceOnEachFile();
|
||||
void test_moveTokenWiseThroughEveryFile();
|
||||
void test_moveTokenWiseThroughEveryFileAndFollowSymbol();
|
||||
void test_moveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition();
|
||||
void test_moveTokenWiseThroughEveryFileAndFindUsages();
|
||||
void test_moveTokenWiseThroughEveryFileAndRenameUsages();
|
||||
void test_moveTokenWiseThroughEveryFileAndOpenTypeHierarchy();
|
||||
void test_moveTokenWiseThroughEveryFileAndInvokeCompletion();
|
||||
void test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes();
|
||||
|
||||
// CppAutoCompleter tests
|
||||
void test_autoComplete_data();
|
||||
void test_autoComplete();
|
||||
void test_surroundWithSelection_data();
|
||||
void test_surroundWithSelection();
|
||||
void test_autoBackspace_data();
|
||||
void test_autoBackspace();
|
||||
void test_insertParagraph_data();
|
||||
void test_insertParagraph();
|
||||
#endif // WITH_TESTS
|
||||
|
||||
private:
|
||||
CppEditorPluginPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
|
@@ -78,22 +78,10 @@ bool TestDocument::hasCursorMarker() const { return m_cursorPosition != -1; }
|
||||
bool TestDocument::hasAnchorMarker() const { return m_anchorPosition != -1; }
|
||||
|
||||
TestCase::TestCase(bool runGarbageCollector)
|
||||
: CppTools::Tests::TestCase(runGarbageCollector),
|
||||
m_prevUseClangd(CppTools::ClangdSettings::instance().useClangd())
|
||||
: CppTools::Tests::TestCase(runGarbageCollector)
|
||||
{
|
||||
}
|
||||
|
||||
TestCase::~TestCase()
|
||||
{
|
||||
CppTools::ClangdSettings::setUseClangd(m_prevUseClangd);
|
||||
}
|
||||
|
||||
void TestCase::setUseClangd()
|
||||
{
|
||||
if (CppEditorPlugin::instance()->m_testKit)
|
||||
CppTools::ClangdSettings::setUseClangd(true);
|
||||
}
|
||||
|
||||
bool TestCase::openCppEditor(const QString &fileName, CppEditor **editor, CppEditorWidget **editorWidget)
|
||||
{
|
||||
if (CppEditor *e = dynamic_cast<CppEditor *>(Core::EditorManager::openEditor(fileName))) {
|
||||
|
@@ -60,9 +60,6 @@ class TestCase : public CppTools::Tests::TestCase
|
||||
{
|
||||
public:
|
||||
TestCase(bool runGarbageCollector = true);
|
||||
~TestCase();
|
||||
|
||||
void setUseClangd();
|
||||
|
||||
static bool openCppEditor(const QString &fileName,
|
||||
CppEditor **editor,
|
||||
@@ -70,9 +67,6 @@ public:
|
||||
|
||||
static CPlusPlus::Document::Ptr waitForRehighlightedSemanticDocument(
|
||||
CppEditorWidget *editorWidget);
|
||||
|
||||
private:
|
||||
const bool m_prevUseClangd;
|
||||
};
|
||||
|
||||
} // namespace Tests
|
||||
|
@@ -23,9 +23,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppincludehierarchy_test.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppincludehierarchy.h"
|
||||
|
||||
@@ -40,8 +41,7 @@
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppEditor::Internal::Tests {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppEditorPlugin::test_includehierarchy_data()
|
||||
void IncludeHierarchyTest::test_data()
|
||||
{
|
||||
QTest::addColumn<QList<QByteArray> >("documents");
|
||||
QTest::addColumn<QString>("expectedHierarchy");
|
||||
@@ -177,7 +177,7 @@ void CppEditorPlugin::test_includehierarchy_data()
|
||||
);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_includehierarchy()
|
||||
void IncludeHierarchyTest::test()
|
||||
{
|
||||
QFETCH(QList<QByteArray>, documents);
|
||||
QFETCH(QString, expectedHierarchy);
|
||||
@@ -185,5 +185,4 @@ void CppEditorPlugin::test_includehierarchy()
|
||||
IncludeHierarchyTestCase(documents, expectedHierarchy);
|
||||
}
|
||||
|
||||
} // namespace CppEditor
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor::Internal::Tests
|
||||
|
41
src/plugins/cppeditor/cppincludehierarchy_test.h
Normal file
41
src/plugins/cppeditor/cppincludehierarchy_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 CppEditor::Internal::Tests {
|
||||
|
||||
class IncludeHierarchyTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test_data();
|
||||
void test();
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal::Tests
|
@@ -1299,15 +1299,7 @@ public:
|
||||
void saveSettings() { }
|
||||
};
|
||||
|
||||
} // namespace Tests
|
||||
|
||||
InsertVirtualMethods *InsertVirtualMethods::createTestFactory()
|
||||
{
|
||||
return new InsertVirtualMethods(new Tests::InsertVirtualMethodsDialogTest(
|
||||
InsertVirtualMethodsDialog::ModeOutsideClass, true, false));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
|
||||
void InsertVirtualMethodsTest::test_data()
|
||||
{
|
||||
QTest::addColumn<InsertVirtualMethodsDialog::ImplementationMode>("implementationMode");
|
||||
QTest::addColumn<bool>("insertVirtualKeyword");
|
||||
@@ -1882,7 +1874,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_data()
|
||||
"};\n");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
|
||||
void InsertVirtualMethodsTest::test()
|
||||
{
|
||||
QFETCH(InsertVirtualMethodsDialog::ImplementationMode, implementationMode);
|
||||
QFETCH(bool, insertVirtualKeyword);
|
||||
@@ -1898,7 +1890,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods()
|
||||
}
|
||||
|
||||
/// Check: Insert in implementation file
|
||||
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
|
||||
void InsertVirtualMethodsTest::testImplementationFile()
|
||||
{
|
||||
QList<Tests::QuickFixTestDocument::Ptr> testFiles;
|
||||
QByteArray original;
|
||||
@@ -1946,7 +1938,7 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_implementationFile()
|
||||
}
|
||||
|
||||
/// Check: Qualified names.
|
||||
void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
|
||||
void InsertVirtualMethodsTest::testBaseClassInNamespace()
|
||||
{
|
||||
QList<Tests::QuickFixTestDocument::Ptr> testFiles;
|
||||
QByteArray original;
|
||||
@@ -1998,6 +1990,15 @@ void CppEditorPlugin::test_quickfix_InsertVirtualMethods_BaseClassInNamespace()
|
||||
false));
|
||||
Tests::QuickFixOperationTest(testFiles, &factory);
|
||||
}
|
||||
|
||||
} // namespace Tests
|
||||
|
||||
InsertVirtualMethods *InsertVirtualMethods::createTestFactory()
|
||||
{
|
||||
return new InsertVirtualMethods(new Tests::InsertVirtualMethodsDialogTest(
|
||||
InsertVirtualMethodsDialog::ModeOutsideClass, true, false));
|
||||
}
|
||||
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -47,5 +47,20 @@ private:
|
||||
InsertVirtualMethodsDialog *m_dialog;
|
||||
};
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
namespace Tests {
|
||||
class InsertVirtualMethodsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void test_data();
|
||||
void test();
|
||||
void testImplementationFile();
|
||||
void testBaseClassInNamespace();
|
||||
};
|
||||
} // namespace Tests
|
||||
#endif // WITH_TESTS
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,11 +30,10 @@
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QStringList>
|
||||
|
||||
typedef QByteArray _;
|
||||
|
||||
namespace CppTools { class CppCodeStylePreferences; }
|
||||
namespace TextEditor { class QuickFixOperation; }
|
||||
|
||||
@@ -69,8 +68,6 @@ public:
|
||||
QString m_expectedSource;
|
||||
};
|
||||
|
||||
typedef QList<QuickFixTestDocument::Ptr> QuickFixTestDocuments;
|
||||
|
||||
class BaseQuickFixTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
@@ -113,22 +110,156 @@ public:
|
||||
int operationIndex = 0);
|
||||
};
|
||||
|
||||
/// Tests the offered operations provided by a given CppQuickFixFactory
|
||||
class QuickFixOfferedOperationsTest : public BaseQuickFixTestCase
|
||||
{
|
||||
public:
|
||||
QuickFixOfferedOperationsTest(const QList<QuickFixTestDocument::Ptr> &testDocuments,
|
||||
CppQuickFixFactory *factory,
|
||||
const ProjectExplorer::HeaderPaths &headerPaths
|
||||
= ProjectExplorer::HeaderPaths(),
|
||||
const QStringList &expectedOperations = QStringList());
|
||||
};
|
||||
|
||||
QList<QuickFixTestDocument::Ptr> singleDocument(const QByteArray &original,
|
||||
const QByteArray &expected);
|
||||
|
||||
class QuickfixTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testGeneric_data();
|
||||
void testGeneric();
|
||||
|
||||
void testGenerateGetterSetterNamespaceHandlingCreate_data();
|
||||
void testGenerateGetterSetterNamespaceHandlingCreate();
|
||||
void testGenerateGetterSetterNamespaceHandlingAddUsing_data();
|
||||
void testGenerateGetterSetterNamespaceHandlingAddUsing();
|
||||
void testGenerateGetterSetterNamespaceHandlingFullyQualify_data();
|
||||
void testGenerateGetterSetterNamespaceHandlingFullyQualify();
|
||||
void testGenerateGetterSetterCustomNames_data();
|
||||
void testGenerateGetterSetterCustomNames();
|
||||
void testGenerateGetterSetterValueTypes_data();
|
||||
void testGenerateGetterSetterValueTypes();
|
||||
void testGenerateGetterSetterCustomTemplate();
|
||||
void testGenerateGetterSetterNeedThis();
|
||||
void testGenerateGetterSetterOfferedFixes_data();
|
||||
void testGenerateGetterSetterOfferedFixes();
|
||||
void testGenerateGetterSetterGeneralTests_data();
|
||||
void testGenerateGetterSetterGeneralTests();
|
||||
void testGenerateGetterSetterOnlyGetter();
|
||||
void testGenerateGetterSetterOnlySetter();
|
||||
void testGenerateGetterSetterInlineInHeaderFile();
|
||||
void testGenerateGetterSetterOnlySetterHeaderFileWithIncludeGuard();
|
||||
void testGenerateGettersSetters_data();
|
||||
void testGenerateGettersSetters();
|
||||
|
||||
void testInsertQtPropertyMembers_data();
|
||||
void testInsertQtPropertyMembers();
|
||||
|
||||
void testInsertMemberFromInitialization_data();
|
||||
void testInsertMemberFromInitialization();
|
||||
|
||||
void testConvertQt4ConnectConnectOutOfClass();
|
||||
void testConvertQt4ConnectConnectWithinClass_data();
|
||||
void testConvertQt4ConnectConnectWithinClass();
|
||||
void testConvertQt4ConnectDifferentNamespace();
|
||||
|
||||
void testInsertDefFromDeclAfterClass();
|
||||
void testInsertDefFromDeclHeaderSourceBasic1();
|
||||
void testInsertDefFromDeclHeaderSourceBasic2();
|
||||
void testInsertDefFromDeclHeaderSourceBasic3();
|
||||
void testInsertDefFromDeclHeaderSourceNamespace1();
|
||||
void testInsertDefFromDeclHeaderSourceNamespace2();
|
||||
void testInsertDefFromDeclInsideClass();
|
||||
void testInsertDefFromDeclNotTriggeringWhenDefinitionExists();
|
||||
void testInsertDefFromDeclFindRightImplementationFile();
|
||||
void testInsertDefFromDeclIgnoreSurroundingGeneratedDeclarations();
|
||||
void testInsertDefFromDeclRespectWsInOperatorNames1();
|
||||
void testInsertDefFromDeclRespectWsInOperatorNames2();
|
||||
void testInsertDefFromDeclNoexceptSpecifier();
|
||||
void testInsertDefFromDeclMacroUsesAtEndOfFile1();
|
||||
void testInsertDefFromDeclMacroUsesAtEndOfFile2();
|
||||
void testInsertDefFromDeclErroneousStatementAtEndOfFile();
|
||||
void testInsertDefFromDeclRvalueReference();
|
||||
void testInsertDefFromDeclFunctionTryBlock();
|
||||
void testInsertDefFromDeclUsingDecl();
|
||||
void testInsertDefFromDeclFindImplementationFile();
|
||||
void testInsertDefFromDeclUnicodeIdentifier();
|
||||
void testInsertDefFromDeclTemplateClass();
|
||||
void testInsertDefFromDeclTemplateClassWithValueParam();
|
||||
void testInsertDefFromDeclTemplateFunction();
|
||||
void testInsertDefFromDeclNotTriggeredForFriendFunc();
|
||||
void testInsertDefFromDeclMinimalFunctionParameterType();
|
||||
void testInsertDefsFromDecls_data();
|
||||
void testInsertDefsFromDecls();
|
||||
|
||||
void testInsertDeclFromDef();
|
||||
void testInsertDeclFromDefTemplateFuncTypename();
|
||||
void testInsertDeclFromDefTemplateFuncInt();
|
||||
void testInsertDeclFromDefNotTriggeredForTemplateFunc();
|
||||
|
||||
void testAddIncludeForUndefinedIdentifier_data();
|
||||
void testAddIncludeForUndefinedIdentifier();
|
||||
void testAddIncludeForUndefinedIdentifierNoDoubleQtHeaderInclude();
|
||||
|
||||
void testAddForwardDeclForUndefinedIdentifier_data();
|
||||
void testAddForwardDeclForUndefinedIdentifier();
|
||||
|
||||
void testMoveFuncDefOutsideMemberFuncToCpp();
|
||||
void testMoveFuncDefOutsideMemberFuncToCppInsideNS();
|
||||
void testMoveFuncDefOutsideMemberFuncOutside1();
|
||||
void testMoveFuncDefOutsideMemberFuncOutside2();
|
||||
void testMoveFuncDefOutsideMemberFuncToCppNS();
|
||||
void testMoveFuncDefOutsideMemberFuncToCppNSUsing();
|
||||
void testMoveFuncDefOutsideMemberFuncOutsideWithNs();
|
||||
void testMoveFuncDefOutsideFreeFuncToCpp();
|
||||
void testMoveFuncDefOutsideFreeFuncToCppNS();
|
||||
void testMoveFuncDefOutsideCtorWithInitialization1();
|
||||
void testMoveFuncDefOutsideCtorWithInitialization2();
|
||||
void testMoveFuncDefOutsideAfterClass();
|
||||
void testMoveFuncDefOutsideRespectWsInOperatorNames1();
|
||||
void testMoveFuncDefOutsideRespectWsInOperatorNames2();
|
||||
void testMoveFuncDefOutsideMacroUses();
|
||||
void testMoveFuncDefOutsideTemplate();
|
||||
void testMoveFuncDefOutsideTemplateSpecializedClass();
|
||||
void testMoveFuncDefOutsideUnnamedTemplate();
|
||||
void testMoveFuncDefOutsideMemberFuncToCppStatic();
|
||||
void testMoveFuncDefOutsideMemberFuncToCppWithInlinePartOfName();
|
||||
|
||||
void testMoveAllFuncDefOutsideMemberFuncToCpp();
|
||||
void testMoveAllFuncDefOutsideMemberFuncOutside();
|
||||
void testMoveAllFuncDefOutsideDoNotTriggerOnBaseClass();
|
||||
void testMoveAllFuncDefOutsideClassWithBaseClass();
|
||||
void testMoveAllFuncDefOutsideIgnoreMacroCode();
|
||||
|
||||
void testMoveFuncDefToDeclMemberFunc();
|
||||
void testMoveFuncDefToDeclMemberFuncOutside();
|
||||
void testMoveFuncDefToDeclMemberFuncToCppNS();
|
||||
void testMoveFuncDefToDeclMemberFuncToCppNSUsing();
|
||||
void testMoveFuncDefToDeclMemberFuncOutsideWithNs();
|
||||
void testMoveFuncDefToDeclFreeFuncToCpp();
|
||||
void testMoveFuncDefToDeclFreeFuncToCppNS();
|
||||
void testMoveFuncDefToDeclCtorWithInitialization();
|
||||
void testMoveFuncDefToDeclStructWithAssignedVariable();
|
||||
void testMoveFuncDefToDeclMacroUses();
|
||||
void testMoveFuncDefToDeclOverride();
|
||||
void testMoveFuncDefToDeclTemplate();
|
||||
void testMoveFuncDefToDeclTemplateFunction();
|
||||
|
||||
void testAssignToLocalVariableTemplates();
|
||||
|
||||
void testExtractFunction_data();
|
||||
void testExtractFunction();
|
||||
|
||||
void testExtractLiteralAsParameterTypeDeduction_data();
|
||||
void testExtractLiteralAsParameterTypeDeduction();
|
||||
void testExtractLiteralAsParameterFreeFunctionSeparateFiles();
|
||||
void testExtractLiteralAsParameterMemberFunctionSeparateFiles();
|
||||
void testExtractLiteralAsParameterNotTriggeringForInvalidCode();
|
||||
|
||||
void testAddCurlyBraces();
|
||||
|
||||
void testRemoveUsingNamespace_data();
|
||||
void testRemoveUsingNamespace();
|
||||
void testRemoveUsingNamespaceSimple_data();
|
||||
void testRemoveUsingNamespaceSimple();
|
||||
void testRemoveUsingNamespaceDifferentSymbols();
|
||||
|
||||
void testGenerateConstructor_data();
|
||||
void testGenerateConstructor();
|
||||
};
|
||||
|
||||
} // namespace Tests
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
||||
Q_DECLARE_METATYPE(CppEditor::Internal::Tests::QuickFixTestDocuments)
|
||||
|
@@ -23,9 +23,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "cppuseselections_test.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
@@ -157,9 +158,7 @@ SelectionList UseSelectionsTestCase::waitForUseSelections(bool *hasTimedOut) con
|
||||
return toSelectionList(extraSelections);
|
||||
}
|
||||
|
||||
} // namespace Tests
|
||||
|
||||
void CppEditorPlugin::test_useSelections_data()
|
||||
void SelectionsTest::testUseSelections_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
QTest::addColumn<SelectionList>("expectedSelections");
|
||||
@@ -249,7 +248,7 @@ void CppEditorPlugin::test_useSelections_data()
|
||||
<< macroUseSelections;
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_useSelections()
|
||||
void SelectionsTest::testUseSelections()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
QFETCH(SelectionList, expectedSelections);
|
||||
@@ -258,7 +257,7 @@ void CppEditorPlugin::test_useSelections()
|
||||
Tests::UseSelectionsTestCase(testDocument, expectedSelections);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_selectionFiltering_data()
|
||||
void SelectionsTest::testSelectionFiltering_data()
|
||||
{
|
||||
QTest::addColumn<QString>("source");
|
||||
QTest::addColumn<SelectionList>("original");
|
||||
@@ -284,7 +283,7 @@ void CppEditorPlugin::test_selectionFiltering_data()
|
||||
<< SelectionList{{3, 4, 27}, {4, 8, 11}, {5, 4, 1}};
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_selectionFiltering()
|
||||
void SelectionsTest::testSelectionFiltering()
|
||||
{
|
||||
QFETCH(QString, source);
|
||||
QFETCH(SelectionList, original);
|
||||
@@ -323,5 +322,6 @@ void CppEditorPlugin::test_selectionFiltering()
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Tests
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
|
44
src/plugins/cppeditor/cppuseselections_test.h
Normal file
44
src/plugins/cppeditor/cppuseselections_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 CppEditor::Internal::Tests {
|
||||
|
||||
class SelectionsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testUseSelections_data();
|
||||
void testUseSelections();
|
||||
|
||||
void testSelectionFiltering_data();
|
||||
void testSelectionFiltering();
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal::Tests
|
@@ -23,10 +23,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "fileandtokenactions_test.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppquickfix.h"
|
||||
#include "cppquickfixassistant.h"
|
||||
#include "cppquickfixes.h"
|
||||
@@ -72,8 +74,7 @@ using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
using namespace TextEditor;
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
namespace CppEditor::Internal::Tests {
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -493,56 +494,55 @@ void SwitchHeaderSourceFileAction::run(CppEditorWidget *)
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void CppEditorPlugin::test_openEachFile()
|
||||
void FileAndTokenActionsTest::testOpenEachFile()
|
||||
{
|
||||
TestActionsTestCase();
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_switchHeaderSourceOnEachFile()
|
||||
void FileAndTokenActionsTest::testSwitchHeaderSourceOnEachFile()
|
||||
{
|
||||
TestActionsTestCase(Actions(), singleAction(ActionPointer(new SwitchHeaderSourceFileAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFile()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFile()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new NoOpTokenAction)));
|
||||
}
|
||||
|
||||
/// May block if file does not exist (e.g. a not generated ui_* file).
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFollowSymbol()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndFollowSymbol()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new FollowSymbolUnderCursorTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new SwitchDeclarationDefinitionTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndFindUsages()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndFindUsages()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new FindUsagesTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndRenameUsages()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndRenameUsages()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new RenameSymbolUnderCursorTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndOpenTypeHierarchy()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndOpenTypeHierarchy()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new OpenTypeHierarchyTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndInvokeCompletion()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndInvokeCompletion()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new InvokeCompletionTokenAction)));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_moveTokenWiseThroughEveryFileAndTriggerQuickFixes()
|
||||
void FileAndTokenActionsTest::testMoveTokenWiseThroughEveryFileAndTriggerQuickFixes()
|
||||
{
|
||||
TestActionsTestCase(singleAction(ActionPointer(new RunAllQuickFixesTokenAction)));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CppEditor
|
||||
} // namespace CppEditor::Internal::Tests
|
||||
|
60
src/plugins/cppeditor/fileandtokenactions_test.h
Normal file
60
src/plugins/cppeditor/fileandtokenactions_test.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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 CppEditor::Internal::Tests {
|
||||
|
||||
// These tests operate on a project and require special invocation:
|
||||
//
|
||||
// Ensure that the project is properly configured for a given settings path:
|
||||
// $ ./qtcreator -settingspath /your/settings/path /path/to/project
|
||||
//
|
||||
// ...and that it builds, which might prevent blocking dialogs for not
|
||||
// existing files (e.g. ui_*.h).
|
||||
//
|
||||
// Run the tests:
|
||||
// $ export QTC_TEST_WAIT_FOR_LOADED_PROJECT=1
|
||||
// $ ./qtcreator -settingspath /your/settings/path -test CppEditor,FileAndTokenActionsTest /path/to/project
|
||||
class FileAndTokenActionsTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void testOpenEachFile();
|
||||
void testSwitchHeaderSourceOnEachFile();
|
||||
void testMoveTokenWiseThroughEveryFile();
|
||||
void testMoveTokenWiseThroughEveryFileAndFollowSymbol();
|
||||
void testMoveTokenWiseThroughEveryFileAndSwitchDeclarationDefinition();
|
||||
void testMoveTokenWiseThroughEveryFileAndFindUsages();
|
||||
void testMoveTokenWiseThroughEveryFileAndRenameUsages();
|
||||
void testMoveTokenWiseThroughEveryFileAndOpenTypeHierarchy();
|
||||
void testMoveTokenWiseThroughEveryFileAndInvokeCompletion();
|
||||
void testMoveTokenWiseThroughEveryFileAndTriggerQuickFixes();
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal::Tests
|
@@ -23,10 +23,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "followsymbol_switchmethoddecldef_test.h"
|
||||
|
||||
#include "cppeditor.h"
|
||||
#include "cppeditorwidget.h"
|
||||
#include "cppeditorplugin.h"
|
||||
#include "cppeditortestcase.h"
|
||||
#include "cppeditorwidget.h"
|
||||
|
||||
#include <cpptools/cppcodemodelsettings.h>
|
||||
#include <cpptools/cppelementevaluator.h>
|
||||
@@ -258,11 +260,21 @@ public:
|
||||
const QList<TestDocumentPtr> &testFiles,
|
||||
OverrideItemList expectedVirtualFunctionProposal = OverrideItemList());
|
||||
|
||||
~F2TestCase()
|
||||
{
|
||||
CppTools::ClangdSettings::setUseClangd(m_prevUseClangd);
|
||||
}
|
||||
|
||||
static ProjectExplorer::Kit *m_testKit;
|
||||
private:
|
||||
static TestDocumentPtr testFileWithInitialCursorMarker(const QList<TestDocumentPtr> &testFiles);
|
||||
static TestDocumentPtr testFileWithTargetCursorMarker(const QList<TestDocumentPtr> &testFiles);
|
||||
|
||||
const bool m_prevUseClangd;
|
||||
};
|
||||
|
||||
ProjectExplorer::Kit *F2TestCase::m_testKit = nullptr;
|
||||
|
||||
/// Creates a test case with multiple test files.
|
||||
/// Exactly one test document must be provided that contains '@', the initial position marker.
|
||||
/// Exactly one test document must be provided that contains '$', the target position marker.
|
||||
@@ -270,10 +282,12 @@ private:
|
||||
F2TestCase::F2TestCase(CppEditorAction action,
|
||||
const QList<TestDocumentPtr> &testFiles,
|
||||
OverrideItemList expectedVirtualFunctionProposal)
|
||||
: m_prevUseClangd(CppTools::ClangdSettings::instance().useClangd())
|
||||
{
|
||||
QVERIFY(succeededSoFar());
|
||||
|
||||
setUseClangd();
|
||||
if (m_testKit)
|
||||
CppTools::ClangdSettings::setUseClangd(true);
|
||||
|
||||
// Check if there are initial and target position markers
|
||||
TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker(testFiles);
|
||||
@@ -287,11 +301,11 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
const QString tag = QLatin1String(QTest::currentDataTag());
|
||||
const bool useClangd = CppTools::ClangdSettings::instance().useClangd();
|
||||
if (useClangd) {
|
||||
if (curTestName == "test_FollowSymbolUnderCursor_QObject_connect"
|
||||
|| curTestName == "test_FollowSymbolUnderCursor_QObject_oldStyleConnect") {
|
||||
if (curTestName == "testFollowSymbolQObjectConnect"
|
||||
|| curTestName == "testFollowSymbolQObjectOldStyleConnect") {
|
||||
QSKIP("TODO: Implement fall-back");
|
||||
}
|
||||
if (curTestName == "test_FollowSymbolUnderCursor_classOperator" && tag == "backward")
|
||||
if (curTestName == "testFollowClassOperator" && tag == "backward")
|
||||
QSKIP("clangd goes to operator name first");
|
||||
if (tag.toLower().contains("fuzzy"))
|
||||
QSKIP("fuzzy matching is not supposed to work with clangd"); // TODO: Implement fallback as we do with libclang
|
||||
@@ -301,7 +315,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
|| tag == "fromDestructorBody") {
|
||||
QSKIP("clangd wants the cursor before the ~ character");
|
||||
}
|
||||
if (curTestName == "test_FollowSymbolUnderCursor_classOperator_inOp")
|
||||
if (curTestName == "testFollowClassOperatorInOp")
|
||||
QSKIP("clangd goes to operator name first");
|
||||
}
|
||||
|
||||
@@ -335,8 +349,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
QVERIFY2(openProjectResult && openProjectResult.project(),
|
||||
qPrintable(openProjectResult.errorMessage()));
|
||||
projectCloser.setProject(openProjectResult.project());
|
||||
openProjectResult.project()->configureAsExampleProject(
|
||||
CppEditorPlugin::instance()->m_testKit);
|
||||
openProjectResult.project()->configureAsExampleProject(m_testKit);
|
||||
|
||||
// Wait until project is fully indexed.
|
||||
QVERIFY(CppTools::Tests::waitForSignalOrTimeout(openProjectResult.project(),
|
||||
@@ -392,7 +405,7 @@ F2TestCase::F2TestCase(CppEditorAction action,
|
||||
FollowSymbolInterface &delegate = CppModelManager::instance()->followSymbolInterface();
|
||||
auto* builtinFollowSymbol = dynamic_cast<FollowSymbolUnderCursor *>(&delegate);
|
||||
if (!builtinFollowSymbol) {
|
||||
if (curTestName == "test_FollowSymbolUnderCursor_QTCREATORBUG7903")
|
||||
if (curTestName == "testFollowSymbolQTCREATORBUG7903")
|
||||
QSKIP((curTestName + " is not supported by Clang FollowSymbol").toLatin1());
|
||||
widget->inTestMode = true;
|
||||
widget->openLinkUnderCursor();
|
||||
@@ -541,7 +554,7 @@ Q_DECLARE_METATYPE(QList<CppEditor::Internal::TestDocumentPtr>)
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
void CppEditorPlugin::initTestCase()
|
||||
void FollowSymbolTest::initTestCase()
|
||||
{
|
||||
const QString clangdFromEnv = qEnvironmentVariable("QTC_CLANGD");
|
||||
if (clangdFromEnv.isEmpty())
|
||||
@@ -552,14 +565,14 @@ void CppEditorPlugin::initTestCase()
|
||||
return;
|
||||
|
||||
// Find suitable kit.
|
||||
m_testKit = Utils::findOr(KitManager::kits(), nullptr, [](const Kit *k) {
|
||||
F2TestCase::m_testKit = Utils::findOr(KitManager::kits(), nullptr, [](const Kit *k) {
|
||||
return k->isValid();
|
||||
});
|
||||
if (!m_testKit)
|
||||
if (!F2TestCase::m_testKit)
|
||||
QSKIP("This test requires at least one kit to be present");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data()
|
||||
void FollowSymbolTest::testSwitchMethodDeclDef_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("header");
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
@@ -851,7 +864,7 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition_data()
|
||||
"Foo::@operator int() const { return {}; }\n");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_SwitchMethodDeclarationDefinition()
|
||||
void FollowSymbolTest::testSwitchMethodDeclDef()
|
||||
{
|
||||
QFETCH(QByteArray, header);
|
||||
QFETCH(QByteArray, source);
|
||||
@@ -863,7 +876,7 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition()
|
||||
F2TestCase(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
||||
void FollowSymbolTest::testFollowSymbol_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
|
||||
@@ -1308,13 +1321,13 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
|
||||
);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor()
|
||||
void FollowSymbolTest::testFollowSymbol()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QTCREATORBUG7903_data()
|
||||
void FollowSymbolTest::testFollowSymbolQTCREATORBUG7903_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
QTest::newRow("using_QTCREATORBUG7903_globalNamespace") << _(
|
||||
@@ -1353,13 +1366,13 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QTCREATORBUG7903_data()
|
||||
);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QTCREATORBUG7903()
|
||||
void FollowSymbolTest::testFollowSymbolQTCREATORBUG7903()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_followCall_data()
|
||||
void FollowSymbolTest::testFollowCall_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("variableDeclaration"); // without semicolon, can be ""
|
||||
QTest::addColumn<QByteArray>("callArgument");
|
||||
@@ -1398,7 +1411,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_followCall_data()
|
||||
<< _("const Bar &");
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_followCall()
|
||||
void FollowSymbolTest::testFollowCall()
|
||||
{
|
||||
QFETCH(QByteArray, variableDeclaration);
|
||||
QFETCH(QByteArray, callArgument);
|
||||
@@ -1426,7 +1439,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_followCall()
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
|
||||
void FollowSymbolTest::testFollowSymbolMultipleDocuments_data()
|
||||
{
|
||||
QTest::addColumn<QList<TestDocumentPtr> >("documents");
|
||||
|
||||
@@ -1537,13 +1550,13 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments_data()
|
||||
"}\n", "file.cpp")};
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()
|
||||
void FollowSymbolTest::testFollowSymbolMultipleDocuments()
|
||||
{
|
||||
QFETCH(QList<TestDocumentPtr>, documents);
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, documents);
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect_data()
|
||||
void FollowSymbolTest::testFollowSymbolQObjectConnect_data()
|
||||
{
|
||||
#define TAG(str) secondQObjectParam ? str : str ", no 2nd QObject"
|
||||
QTest::addColumn<char>("start");
|
||||
@@ -1595,7 +1608,7 @@ static void selectMarker(QByteArray *source, char marker, char number)
|
||||
}
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect()
|
||||
void FollowSymbolTest::testFollowSymbolQObjectConnect()
|
||||
{
|
||||
QFETCH(char, start);
|
||||
QFETCH(char, target);
|
||||
@@ -1646,7 +1659,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect()
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_oldStyleConnect()
|
||||
void FollowSymbolTest::testFollowSymbolQObjectOldStyleConnect()
|
||||
{
|
||||
const QByteArray source =
|
||||
"class O : public QObject {\n"
|
||||
@@ -1666,14 +1679,14 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_oldStyleConnect()
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data()
|
||||
void FollowSymbolTest::testFollowClassOperatorOnOperatorToken_data()
|
||||
{
|
||||
QTest::addColumn<bool>("toDeclaration");
|
||||
QTest::newRow("forward") << false;
|
||||
QTest::newRow("backward") << true;
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken()
|
||||
void FollowSymbolTest::testFollowClassOperatorOnOperatorToken()
|
||||
{
|
||||
QFETCH(bool, toDeclaration);
|
||||
|
||||
@@ -1689,12 +1702,12 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_data()
|
||||
void FollowSymbolTest::testFollowClassOperator_data()
|
||||
{
|
||||
test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data();
|
||||
testFollowClassOperatorOnOperatorToken_data();
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator()
|
||||
void FollowSymbolTest::testFollowClassOperator()
|
||||
{
|
||||
QFETCH(bool, toDeclaration);
|
||||
|
||||
@@ -1714,12 +1727,12 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator()
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp_data()
|
||||
void FollowSymbolTest::testFollowClassOperatorInOp_data()
|
||||
{
|
||||
test_FollowSymbolUnderCursor_classOperator_onOperatorToken_data();
|
||||
testFollowClassOperatorOnOperatorToken_data();
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp()
|
||||
void FollowSymbolTest::testFollowClassOperatorInOp()
|
||||
{
|
||||
QFETCH(bool, toDeclaration);
|
||||
|
||||
@@ -1739,7 +1752,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp()
|
||||
F2TestCase(F2TestCase::FollowSymbolUnderCursorAction, singleDocument(source));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
|
||||
void FollowSymbolTest::testFollowVirtualFunctionCall_data()
|
||||
{
|
||||
QTest::addColumn<QByteArray>("source");
|
||||
QTest::addColumn<OverrideItemList>("results");
|
||||
@@ -2038,7 +2051,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
|
||||
<< OverrideItem(QLatin1String("Derived::virt"), 2));
|
||||
}
|
||||
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
|
||||
void FollowSymbolTest::testFollowVirtualFunctionCall()
|
||||
{
|
||||
QFETCH(QByteArray, source);
|
||||
QFETCH(OverrideItemList, results);
|
||||
@@ -2047,7 +2060,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
|
||||
}
|
||||
|
||||
/// Check: Base classes can be found although these might be defined in distinct documents.
|
||||
void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleDocuments()
|
||||
void FollowSymbolTest::testFollowVirtualFunctionCallMultipleDocuments()
|
||||
{
|
||||
QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
|
||||
<< TestDocument::create("struct A { virtual void virt(int) = 0; };\n",
|
||||
|
@@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** 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>
|
||||
|
||||
// Can't use Tests namespace because someone had the clever idea to create two
|
||||
// non-local TestDocument classes in this plugin.
|
||||
namespace CppEditor::Internal {
|
||||
|
||||
class FollowSymbolTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
|
||||
void testSwitchMethodDeclDef_data();
|
||||
void testSwitchMethodDeclDef();
|
||||
|
||||
void testFollowSymbolMultipleDocuments_data();
|
||||
void testFollowSymbolMultipleDocuments();
|
||||
|
||||
void testFollowSymbol_data();
|
||||
void testFollowSymbol();
|
||||
|
||||
void testFollowSymbolQTCREATORBUG7903_data();
|
||||
void testFollowSymbolQTCREATORBUG7903();
|
||||
|
||||
void testFollowCall_data();
|
||||
void testFollowCall();
|
||||
|
||||
void testFollowSymbolQObjectConnect_data();
|
||||
void testFollowSymbolQObjectConnect();
|
||||
void testFollowSymbolQObjectOldStyleConnect();
|
||||
|
||||
void testFollowClassOperatorOnOperatorToken_data();
|
||||
void testFollowClassOperatorOnOperatorToken();
|
||||
|
||||
void testFollowClassOperator_data();
|
||||
void testFollowClassOperator();
|
||||
|
||||
void testFollowClassOperatorInOp_data();
|
||||
void testFollowClassOperatorInOp();
|
||||
|
||||
void testFollowVirtualFunctionCall_data();
|
||||
void testFollowVirtualFunctionCall();
|
||||
void testFollowVirtualFunctionCallMultipleDocuments();
|
||||
};
|
||||
|
||||
} // namespace CppEditor::Internal
|
Reference in New Issue
Block a user