Commit c7f3ac40 authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppEditor/CppTools: Clean up *Test* classes

* Unify class names
* Fix coding style

Change-Id: I7498192ba9e6b9fc0e97d3d4f0dbb30f1853a0c9
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 5c8df5fa
......@@ -35,7 +35,7 @@
#include <QString>
#include <QTest>
using namespace Core::Internal::Tests;
using namespace Core::Tests;
static void maybeAppendSlash(QString *string)
{
......
......@@ -36,7 +36,7 @@
#include <QString>
#define QTC_DECLARE_MYTESTDATADIR(PATH) \
class MyTestDataDir : public Core::Internal::Tests::TestDataDir \
class MyTestDataDir : public Core::Tests::TestDataDir \
{ \
public: \
MyTestDataDir(const QString &testDataDirectory = QString()) \
......@@ -44,7 +44,6 @@
};
namespace Core {
namespace Internal {
namespace Tests {
class CORE_EXPORT TestDataDir
......@@ -61,7 +60,6 @@ private:
};
} // namespace Tests
} // namespace Internal
} // namespace Core
#endif // TESTDATADIR_H
......@@ -59,18 +59,18 @@ typedef QByteArray _;
* Encapsulates the whole process of setting up an editor,
* pressing ENTER and checking the result.
*/
class TestCase : public CppEditor::Internal::Tests::TestCase
class DoxygenTestCase : public CppEditor::Internal::Tests::TestCase
{
public:
TestCase(const QByteArray &input);
void run(const QByteArray &expected, int undoCount = 1);
DoxygenTestCase(const QByteArray &input);
void run(const QByteArray &expected);
private:
CppEditor::Internal::Tests::TestDocument testDocument;
};
/// The '|' in the input denotes the cursor position.
TestCase::TestCase(const QByteArray &input)
DoxygenTestCase::DoxygenTestCase(const QByteArray &input)
: testDocument("file.cpp", input, '|')
{
QVERIFY(testDocument.hasCursorMarker());
......@@ -97,7 +97,7 @@ TestCase::TestCase(const QByteArray &input)
waitForRehighlightedSemanticDocument(testDocument.m_editorWidget);
}
void TestCase::run(const QByteArray &expected, int undoCount)
void DoxygenTestCase::run(const QByteArray &expected)
{
// Send 'ENTER' key press
QKeyEvent event(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
......@@ -106,12 +106,12 @@ void TestCase::run(const QByteArray &expected, int undoCount)
QCOMPARE(QLatin1String(result), QLatin1String(expected));
for (int i = 0; i < undoCount; ++i)
testDocument.m_editorWidget->undo();
testDocument.m_editorWidget->undo();
const QByteArray contentsAfterUndo
= testDocument.m_editorWidget->document()->toPlainText().toUtf8();
QCOMPARE(contentsAfterUndo, testDocument.m_source);
}
} // anonymous namespace
void CppEditorPlugin::test_doxygen_comments_data()
......@@ -257,6 +257,6 @@ void CppEditorPlugin::test_doxygen_comments()
{
QFETCH(QByteArray, given);
QFETCH(QByteArray, expected);
TestCase data(given);
data.run(expected);
DoxygenTestCase test(given);
test.run(expected);
}
......@@ -45,10 +45,11 @@ using namespace CppEditor::Internal;
using namespace CppTools;
namespace {
class TestCase : public CppEditor::Internal::Tests::TestCase
class IncludeHierarchyTestCase: public CppEditor::Internal::Tests::TestCase
{
public:
TestCase(const QList<QByteArray> &sourceList)
IncludeHierarchyTestCase(const QList<QByteArray> &sourceList)
{
QStringList filePaths;
const int sourceListSize = sourceList.size();
......@@ -81,7 +82,8 @@ public:
QCOMPARE(model.rowCount(model.index(1, 0)), includedByCount);
}
};
}
} // anonymous namespace
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
{
......@@ -89,7 +91,7 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludes()
sourceList.append(QByteArray("#include \"file2.h\"\n"));
sourceList.append(QByteArray());
TestCase testCase(sourceList);
IncludeHierarchyTestCase testCase(sourceList);
testCase.run(1, 0);
}
......@@ -99,18 +101,17 @@ void CppEditorPlugin::test_includeHierarchyModel_simpleIncludedBy()
sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n"));
TestCase testCase(sourceList);
IncludeHierarchyTestCase testCase(sourceList);
testCase.run(0, 1);
}
void CppEditorPlugin::test_includeHierarchyModel_simpleIncludesAndIncludedBy()
{
QList<QByteArray> sourceList;
QByteArray source;
sourceList.append(QByteArray("#include \"file2.h\"\n"));
sourceList.append(QByteArray());
sourceList.append(QByteArray("#include \"file1.h\"\n"));
TestCase testCase(sourceList);
IncludeHierarchyTestCase testCase(sourceList);
testCase.run(1, 1);
}
This diff is collapsed.
......@@ -44,7 +44,6 @@
#include <QDir>
#include <QtTest>
/*!
Tests for Follow Symbol Under Cursor and Switch Between Function Declaration/Definition
......@@ -55,6 +54,7 @@
You can find potential test code for Follow Symbol Under Cursor on the bottom of this file.
*/
using namespace CPlusPlus;
using namespace CppEditor;
using namespace CppEditor::Internal;
......@@ -211,7 +211,7 @@ public:
* executing Follow Symbol Under Cursor or Switch Between Function Declaration/Definition
* and checking the result.
*/
class TestCase : public CppEditor::Internal::Tests::TestCase
class F2TestCase : public CppEditor::Internal::Tests::TestCase
{
public:
enum CppEditorAction {
......@@ -219,17 +219,14 @@ public:
SwitchBetweenMethodDeclarationDefinitionAction
};
TestCase(CppEditorAction action, const QByteArray &source,
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
F2TestCase(CppEditorAction action, const QByteArray &source,
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
F2TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
const OverrideItemList &expectedVirtualFunctionProposal = OverrideItemList());
void run();
private:
TestCase(const TestCase &);
TestCase &operator=(const TestCase &);
void init();
TestDocumentPtr testFileWithInitialCursorMarker();
......@@ -243,8 +240,9 @@ private:
/// Convenience function for creating a TestDocument.
/// See TestDocument.
TestCase::TestCase(CppEditorAction action, const QByteArray &source,
const OverrideItemList &expectedVirtualFunctionProposal)
F2TestCase::F2TestCase(CppEditorAction action,
const QByteArray &source,
const OverrideItemList &expectedVirtualFunctionProposal)
: m_action(action)
, m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
{
......@@ -256,8 +254,9 @@ TestCase::TestCase(CppEditorAction action, const QByteArray &source,
/// 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.
/// It can be the same document.
TestCase::TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestFiles,
const OverrideItemList &expectedVirtualFunctionProposal)
F2TestCase::F2TestCase(CppEditorAction action,
const QList<TestDocumentPtr> theTestFiles,
const OverrideItemList &expectedVirtualFunctionProposal)
: m_action(action)
, m_testFiles(theTestFiles)
, m_expectedVirtualFunctionProposal(expectedVirtualFunctionProposal)
......@@ -265,7 +264,7 @@ TestCase::TestCase(CppEditorAction action, const QList<TestDocumentPtr> theTestF
init();
}
void TestCase::init()
void F2TestCase::init()
{
// Check if there are initial and target position markers
QVERIFY2(testFileWithInitialCursorMarker(),
......@@ -303,7 +302,7 @@ void TestCase::init()
}
}
TestDocumentPtr TestCase::testFileWithInitialCursorMarker()
TestDocumentPtr F2TestCase::testFileWithInitialCursorMarker()
{
foreach (const TestDocumentPtr testFile, m_testFiles) {
if (testFile->hasCursorMarker())
......@@ -312,7 +311,7 @@ TestDocumentPtr TestCase::testFileWithInitialCursorMarker()
return TestDocumentPtr();
}
TestDocumentPtr TestCase::testFileWithTargetCursorMarker()
TestDocumentPtr F2TestCase::testFileWithTargetCursorMarker()
{
foreach (const TestDocumentPtr testFile, m_testFiles) {
if (testFile->hasTargetCursorMarker())
......@@ -321,7 +320,7 @@ TestDocumentPtr TestCase::testFileWithTargetCursorMarker()
return TestDocumentPtr();
}
void TestCase::run()
void F2TestCase::run()
{
TestDocumentPtr initialTestFile = testFileWithInitialCursorMarker();
QVERIFY(initialTestFile);
......@@ -489,11 +488,11 @@ void CppEditorPlugin::test_SwitchMethodDeclarationDefinition()
QFETCH(QByteArray, header);
QFETCH(QByteArray, source);
QList<TestDocumentPtr> testFiles;
testFiles << TestDocument::create(header, "file.h");
testFiles << TestDocument::create(source, "file.cpp");
const QList<TestDocumentPtr> testFiles = QList<TestDocumentPtr>()
<< TestDocument::create(header, "file.h")
<< TestDocument::create(source, "file.cpp");
TestCase test(TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
F2TestCase test(F2TestCase::SwitchBetweenMethodDeclarationDefinitionAction, testFiles);
test.run();
}
......@@ -765,8 +764,8 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
);
// 3.3.10 Name hiding (par 2.), from text
// A class name (9.1) or enumeration name (7.2) can be hidden by the name of a variable, data member,
// function, or enumerator declared in the same scope.
// A class name (9.1) or enumeration name (7.2) can be hidden by the name of a variable,
// data member, function, or enumerator declared in the same scope.
QTest::newRow("funLocalVarHidesOuterClass") << _(
"struct C {};\n"
"\n"
......@@ -854,7 +853,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_data()
void CppEditorPlugin::test_FollowSymbolUnderCursor()
{
QFETCH(QByteArray, source);
TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
test.run();
}
......@@ -883,7 +882,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_multipleDocuments()
{
QFETCH(QList<TestDocumentPtr>, documents);
TestCase test(TestCase::FollowSymbolUnderCursorAction, documents);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, documents);
test.run();
}
......@@ -973,7 +972,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect()
return;
}
TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
test.run();
}
......@@ -997,7 +996,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_onOperatorToken
"}\n";
if (toDeclaration)
source.replace('@', '#').replace('$', '@').replace('#', '$');
TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
test.run();
}
......@@ -1023,7 +1022,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator()
else
source.replace("@2", QByteArray()).replace("$2", QByteArray())
.replace("@1", "@").replace("$1", "$");
TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
test.run();
}
......@@ -1049,7 +1048,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classOperator_inOp()
else
source.replace("@2", QByteArray()).replace("$2", QByteArray())
.replace("@1", "@").replace("$1", "$");
TestCase test(TestCase::FollowSymbolUnderCursorAction, source);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source);
test.run();
}
......@@ -1109,7 +1108,8 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data()
<< OverrideItem(QLatin1String("CD1::virt"), 11)
<< OverrideItem(QLatin1String("CD2::virt"), 14));
/// Check: Virtual function call in member of class hierarchy, only possible overrides are presented.
/// Check: Virtual function call in member of class hierarchy,
/// only possible overrides are presented.
QTest::newRow("possibleOverrides2") << _(
"struct A { virtual void virt(); };\n"
"void A::virt() {}\n"
......@@ -1302,7 +1302,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall()
QFETCH(QByteArray, source);
QFETCH(OverrideItemList, results);
TestCase test(TestCase::FollowSymbolUnderCursorAction, source, results);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, source, results);
test.run();
}
......@@ -1324,7 +1324,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_multipleD
<< OverrideItem(QLatin1String("A::virt"), 1)
<< OverrideItem(QLatin1String("B::virt"), 2);
TestCase test(TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
F2TestCase test(F2TestCase::FollowSymbolUnderCursorAction, testFiles, finalResults);
test.run();
}
......
......@@ -53,37 +53,39 @@ using namespace CppTools::Internal;
using namespace TextEditor;
using namespace Core;
namespace { typedef QByteArray _; }
namespace {
typedef QByteArray _;
class CompletionTestCase : public CppTools::Tests::TestCase
{
public:
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray())
: position(-1), editorWidget(0), textDocument(0), editor(0)
: m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
{
source = sourceText;
position = source.indexOf('@');
QVERIFY(position != -1);
source[position] = ' ';
m_source = sourceText;
m_position = m_source.indexOf('@');
QVERIFY(m_position != -1);
m_source[m_position] = ' ';
// Write source to file
const QString fileName = QDir::tempPath() + QLatin1String("/file.h");
QVERIFY(writeFile(fileName, source));
QVERIFY(writeFile(fileName, m_source));
// Open in editor
editor = EditorManager::openEditor(fileName);
QVERIFY(editor);
closeEditorAtEndOfTestCase(editor);
editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
QVERIFY(editorWidget);
m_editor = EditorManager::openEditor(fileName);
QVERIFY(m_editor);
closeEditorAtEndOfTestCase(m_editor);
m_editorWidget = qobject_cast<TextEditor::BaseTextEditorWidget *>(m_editor->widget());
QVERIFY(m_editorWidget);
textDocument = editorWidget->document();
m_textDocument = m_editorWidget->document();
// Get Document
waitForFileInGlobalSnapshot(fileName);
const Document::Ptr document = globalSnapshot().document(fileName);
snapshot.insert(document);
m_snapshot.insert(document);
if (!textToInsert.isEmpty())
insertText(textToInsert);
......@@ -93,9 +95,9 @@ public:
{
QStringList completions;
CppCompletionAssistInterface *ai
= new CppCompletionAssistInterface(editorWidget->document(), position,
editorWidget->baseTextDocument()->filePath(),
ExplicitlyInvoked, snapshot,
= new CppCompletionAssistInterface(m_editorWidget->document(), m_position,
m_editorWidget->baseTextDocument()->filePath(),
ExplicitlyInvoked, m_snapshot,
QStringList(), QStringList());
CppCompletionAssistProcessor processor;
IAssistProposal *proposal = processor.perform(ai);
......@@ -109,8 +111,9 @@ public:
return completions;
const int pos = proposal->basePosition();
const int length = position - pos;
const QString prefix = Convenience::textAt(QTextCursor(editorWidget->document()), pos, length);
const int length = m_position - pos;
const QString prefix = Convenience::textAt(QTextCursor(m_editorWidget->document()), pos,
length);
if (!prefix.isEmpty())
listmodel->filter(prefix);
if (listmodel->isSortable(prefix))
......@@ -128,21 +131,23 @@ public:
void insertText(const QByteArray &text)
{
Utils::ChangeSet change;
change.insert(position, QLatin1String(text));
QTextCursor cursor(textDocument);
change.insert(m_position, QLatin1String(text));
QTextCursor cursor(m_textDocument);
change.apply(&cursor);
position += text.length();
m_position += text.length();
}
private:
QByteArray source;
int position;
Snapshot snapshot;
BaseTextEditorWidget *editorWidget;
QTextDocument *textDocument;
IEditor *editor;
QByteArray m_source;
int m_position;
Snapshot m_snapshot;
BaseTextEditorWidget *m_editorWidget;
QTextDocument *m_textDocument;
IEditor *m_editor;
};
} // anonymous namespace
void CppToolsPlugin::test_completion_basic_1()
{
const QByteArray source =
......
......@@ -46,8 +46,8 @@ void CppToolsPlugin::test_headersource()
QFETCH(QString, headerFileName);
bool wasHeader;
Core::Internal::Tests::TestDataDir dataDir(
_(SRCDIR "/../../../tests/cppheadersource/") + _(QTest::currentDataTag()));
Core::Tests::TestDataDir dataDir(_(SRCDIR "/../../../tests/cppheadersource/")
+ _(QTest::currentDataTag()));
const QString sourcePath = dataDir.file(sourceFileName);
const QString headerPath = dataDir.file(headerFileName);
......
......@@ -47,12 +47,11 @@
#include <QtTest>
using namespace Core;
using namespace Core::Internal::Tests;
using namespace Core::Tests;
using namespace CppTools::Internal;
using namespace ExtensionSystem;
using namespace Locator;
using namespace Locator::Internal;
using namespace Locator::Internal::Tests;
using namespace Locator::Tests;
using namespace Utils;
Q_DECLARE_METATYPE(ILocatorFilter *)
......@@ -63,12 +62,12 @@ QTC_DECLARE_MYTESTDATADIR("../../../tests/cpplocators/")
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
} // anonymous namespace
class CppLocatorFilterTest : public BasicLocatorFilterTest, public CppTools::Tests::TestCase
class CppLocatorFilterTestCase
: public BasicLocatorFilterTest
, public CppTools::Tests::TestCase
{
public:
CppLocatorFilterTest(ILocatorFilter *filter, const QString &fileName)
CppLocatorFilterTestCase(ILocatorFilter *filter, const QString &fileName)
: BasicLocatorFilterTest(filter)
, m_fileName(fileName)
{
......@@ -77,18 +76,19 @@ public:
}
private:
virtual void doBeforeLocatorRun() { QVERIFY(parseFiles(m_fileName)); }
virtual void doAfterLocatorRun() { QVERIFY(garbageCollectGlobalSnapshot()); }
void doBeforeLocatorRun() { QVERIFY(parseFiles(m_fileName)); }
void doAfterLocatorRun() { QVERIFY(garbageCollectGlobalSnapshot()); }
private:
const QString m_fileName;
};
class CppCurrentDocumentFilterTest
class CppCurrentDocumentFilterTestCase
: public BasicLocatorFilterTest
, public CppTools::Tests::TestCase
{
public:
CppCurrentDocumentFilterTest(const QString &fileName)
CppCurrentDocumentFilterTestCase(const QString &fileName)
: BasicLocatorFilterTest(PluginManager::getObject<CppCurrentDocumentFilter>())
, m_editor(0)
, m_fileName(fileName)
......@@ -97,7 +97,7 @@ public:
}
private:
virtual void doBeforeLocatorRun()
void doBeforeLocatorRun()
{
QVERIFY(EditorManager::documentModel()->openedDocuments().isEmpty());
QVERIFY(garbageCollectGlobalSnapshot());
......@@ -108,7 +108,7 @@ private:
waitForFileInGlobalSnapshot(m_fileName);
}
virtual void doAfterLocatorRun()
void doAfterLocatorRun()
{
EditorManager::closeEditor(m_editor, /*askAboutModifiedEditors=*/ false);
QCoreApplication::processEvents();
......@@ -116,10 +116,13 @@ private:
QVERIFY(garbageCollectGlobalSnapshot());
}
private:
IEditor *m_editor;
const QString m_fileName;
};
} // anonymous namespace
void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
{
QFETCH(QString, testFile);
......@@ -127,7 +130,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter()
QFETCH(QString, searchText);
QFETCH(ResultDataList, expectedResults);
CppLocatorFilterTest test(filter, testFile);
CppLocatorFilterTestCase test(filter, testFile);
ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor(searchText));
// ResultData::printFilterEntries(results);
QVERIFY(!results.isEmpty());
......@@ -152,15 +155,18 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
QTest::newRow("CppFunctionsFilter")
<< testFile
<< cppFunctionsFilter
<< QString::fromLatin1("function")
<< _("function")
<< (QList<ResultData>()
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"),
_("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"),
_("<anonymous namespace>::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), testFileShort)
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
......@@ -174,7 +180,8 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< ResultData(_("MyClass()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
<< ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
);
......@@ -204,7 +211,8 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< (QList<ResultData>()
<< ResultData(_("<anonymous namespace>::MyClass"), testFileShort)
<< ResultData(_("<anonymous namespace>::MyClass::MyClass"), _("()"))
<< ResultData(_("<anonymous namespace>::MyClass::functionDefinedOutSideClass"), _("(char)"))
<< ResultData(_("<anonymous namespace>::MyClass::functionDefinedOutSideClass"),
_("(char)"))
<< ResultData(_("<anonymous namespace>::MyEnum"), testFileShort)
<< ResultData(_("<anonymous namespace>::myFunction"), _("(bool, int)"))
<< ResultData(_("MyClass"), testFileShort)
......@@ -213,8 +221,10 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< ResultData(_("MyEnum"), testFileShort)
<< ResultData(_("MyNamespace::MyClass"), testFileShort)
<< ResultData(_("MyNamespace::MyClass::MyClass"), _("()"))
<< ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClass"), _("(char)"))
<< ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace"), _("(float)"))
<< ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClass"),
_("(char)"))
<< ResultData(_("MyNamespace::MyClass::functionDefinedOutSideClassAndNamespace"),
_("(float)"))
<< ResultData(_("MyNamespace::MyEnum"), testFileShort)
<< ResultData(_("MyNamespace::myFunction"), _("(bool, int)"))
<< ResultData(_("myFunction"), _("(bool, int)"))
......@@ -248,9 +258,11 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
<< ResultData(_("functionDeclaredOnly()"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedInClass(bool, int)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClass(char)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"), _("MyNamespace::MyClass"))
<< ResultData(_("functionDefinedOutSideClassAndNamespace(float)"),
_("MyNamespace::MyClass"))
<< ResultData(_("int myVariable"), _("<anonymous namespace>"))
<< ResultData(_("myFunction(bool, int)"), _("<anonymous namespace>"))
<< ResultData(_("MyEnum"), _("<anonymous namespace>"))
......@@ -265,7 +277,7 @@ void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()
<< ResultData(_("main()"), _(""))
;
CppCurrentDocumentFilterTest test(testFile);
CppCurrentDocumentFilterTestCase test(testFile);
ResultDataList results = ResultData::fromFilterEntryList(test.matchesFor());
// ResultData::printFilterEntries(results);
QVERIFY(!results.isEmpty());
......
......@@ -63,7 +63,7 @@ namespace {
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
class MyTestDataDir : public Core::Internal::Tests::TestDataDir
class MyTestDataDir : public Core::Tests::TestDataDir
{
public:
MyTestDataDir(const QString &dir)
......
......@@ -49,11 +49,14 @@ using namespace CppTools;
using namespace CppTools::Internal;
using Utils::ChangeSet;
typedef Utils::ChangeSet::Range Range;
Q_DECLARE_METATYPE(Overview)
static QString stripCursor(const QString &source)
namespace {
typedef Utils::ChangeSet::Range Range;
QString stripCursor(const QString &source)
{
QString copy(source);
const int pos = copy.indexOf(QLatin1Char('@'));
......@@ -64,19 +67,10 @@ static QString stripCursor(const QString &source)
return copy;
}
class TestEnvironment : public CppTools::Tests::TestCase
class PointerDeclarationFormatterTestCase : public CppTools::Tests::TestCase
{
public:
QByteArray source;
Snapshot snapshot;
CppRefactoringFilePtr cppRefactoringFile;
TextEditor::BaseTextEditorWidget *editor;
Document::Ptr document;
QTextDocument *textDocument;
TranslationUnit *translationUnit;