forked from qt-creator/qt-creator
		
	CppEditor/CppTools: Clean up *Test* classes
* Unify class names * Fix coding style Change-Id: I7498192ba9e6b9fc0e97d3d4f0dbb30f1853a0c9 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
		@@ -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;
 | 
			
		||||
    Environment env;
 | 
			
		||||
 | 
			
		||||
    TestEnvironment(const QByteArray &source, Document::ParseMode parseMode)
 | 
			
		||||
    PointerDeclarationFormatterTestCase(const QByteArray &source, Document::ParseMode parseMode)
 | 
			
		||||
    {
 | 
			
		||||
        // Find cursor position and remove cursor marker '@'
 | 
			
		||||
        int cursorPosition = 0;
 | 
			
		||||
@@ -89,29 +83,29 @@ public:
 | 
			
		||||
 | 
			
		||||
        // Write source to temprorary file
 | 
			
		||||
        const QString filePath = QDir::tempPath() + QLatin1String("/file.h");
 | 
			
		||||
        document = Document::create(filePath);
 | 
			
		||||
        QVERIFY(writeFile(document->fileName(), sourceWithoutCursorMarker.toLatin1()));
 | 
			
		||||
        m_document = Document::create(filePath);
 | 
			
		||||
        QVERIFY(writeFile(m_document->fileName(), sourceWithoutCursorMarker.toLatin1()));
 | 
			
		||||
 | 
			
		||||
        // Preprocess source
 | 
			
		||||
        Preprocessor preprocess(0, &env);
 | 
			
		||||
        Preprocessor preprocess(0, &m_env);
 | 
			
		||||
        const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
 | 
			
		||||
 | 
			
		||||
        document->setUtf8Source(preprocessedSource);
 | 
			
		||||
        document->parse(parseMode);
 | 
			
		||||
        document->check();
 | 
			
		||||
        translationUnit = document->translationUnit();
 | 
			
		||||
        snapshot.insert(document);
 | 
			
		||||
        editor = new TextEditor::PlainTextEditorWidget(0);
 | 
			
		||||
        m_document->setUtf8Source(preprocessedSource);
 | 
			
		||||
        m_document->parse(parseMode);
 | 
			
		||||
        m_document->check();
 | 
			
		||||
        m_translationUnit = m_document->translationUnit();
 | 
			
		||||
        m_snapshot.insert(m_document);
 | 
			
		||||
        m_editor = new TextEditor::PlainTextEditorWidget(0);
 | 
			
		||||
        QString error;
 | 
			
		||||
        editor->open(&error, document->fileName(), document->fileName());
 | 
			
		||||
        m_editor->open(&error, m_document->fileName(), m_document->fileName());
 | 
			
		||||
 | 
			
		||||
        // Set cursor position
 | 
			
		||||
        QTextCursor cursor = editor->textCursor();
 | 
			
		||||
        QTextCursor cursor = m_editor->textCursor();
 | 
			
		||||
        cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::MoveAnchor, cursorPosition);
 | 
			
		||||
        editor->setTextCursor(cursor);
 | 
			
		||||
        m_editor->setTextCursor(cursor);
 | 
			
		||||
 | 
			
		||||
        textDocument = editor->document();
 | 
			
		||||
        cppRefactoringFile = CppRefactoringChanges::file(editor, document);
 | 
			
		||||
        m_textDocument = m_editor->document();
 | 
			
		||||
        m_cppRefactoringFile = CppRefactoringChanges::file(m_editor, m_document);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    void applyFormatting(AST *ast, PointerDeclarationFormatter::CursorHandling cursorHandling)
 | 
			
		||||
@@ -122,27 +116,41 @@ public:
 | 
			
		||||
        overview.starBindFlags = Overview::StarBindFlags(0);
 | 
			
		||||
 | 
			
		||||
        // Run the formatter
 | 
			
		||||
        PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
 | 
			
		||||
        PointerDeclarationFormatter formatter(m_cppRefactoringFile, overview, cursorHandling);
 | 
			
		||||
        ChangeSet change = formatter.format(ast); // ChangeSet may be empty.
 | 
			
		||||
 | 
			
		||||
        // Apply change
 | 
			
		||||
        QTextCursor cursor(textDocument);
 | 
			
		||||
        QTextCursor cursor(m_textDocument);
 | 
			
		||||
        change.apply(&cursor);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    QTextDocument *m_textDocument;
 | 
			
		||||
    TranslationUnit *m_translationUnit;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QByteArray m_source;
 | 
			
		||||
    Snapshot m_snapshot;
 | 
			
		||||
    CppRefactoringFilePtr m_cppRefactoringFile;
 | 
			
		||||
    TextEditor::BaseTextEditorWidget *m_editor;
 | 
			
		||||
    Document::Ptr m_document;
 | 
			
		||||
    Environment m_env;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // anonymous namespace
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations()
 | 
			
		||||
{
 | 
			
		||||
    QFETCH(QString, source);
 | 
			
		||||
    QFETCH(QString, reformattedSource);
 | 
			
		||||
 | 
			
		||||
    TestEnvironment env(source.toLatin1(), Document::ParseDeclaration);
 | 
			
		||||
    AST *ast = env.translationUnit->ast();
 | 
			
		||||
    PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseDeclaration);
 | 
			
		||||
    AST *ast = test.m_translationUnit->ast();
 | 
			
		||||
    QVERIFY(ast);
 | 
			
		||||
 | 
			
		||||
    env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
    test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
    QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_in_simpledeclarations_data()
 | 
			
		||||
@@ -363,13 +371,13 @@ void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements()
 | 
			
		||||
    QFETCH(QString, source);
 | 
			
		||||
    QFETCH(QString, reformattedSource);
 | 
			
		||||
 | 
			
		||||
    TestEnvironment env(source.toLatin1(), Document::ParseStatement);
 | 
			
		||||
    AST *ast = env.translationUnit->ast();
 | 
			
		||||
    PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseStatement);
 | 
			
		||||
    AST *ast = test.m_translationUnit->ast();
 | 
			
		||||
    QVERIFY(ast);
 | 
			
		||||
 | 
			
		||||
    env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
    test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
    QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_in_controlflowstatements_data()
 | 
			
		||||
@@ -441,13 +449,13 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators()
 | 
			
		||||
    QFETCH(QString, source);
 | 
			
		||||
    QFETCH(QString, reformattedSource);
 | 
			
		||||
 | 
			
		||||
    TestEnvironment env(source.toLatin1(), Document::ParseDeclaration);
 | 
			
		||||
    AST *ast = env.translationUnit->ast();
 | 
			
		||||
    PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseDeclaration);
 | 
			
		||||
    AST *ast = test.m_translationUnit->ast();
 | 
			
		||||
    QVERIFY(ast);
 | 
			
		||||
 | 
			
		||||
    env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
    test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
    QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_declarators_data()
 | 
			
		||||
@@ -499,13 +507,13 @@ void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches()
 | 
			
		||||
    QFETCH(QString, source);
 | 
			
		||||
    QFETCH(QString, reformattedSource);
 | 
			
		||||
 | 
			
		||||
    TestEnvironment env(source.toLatin1(), Document::ParseTranlationUnit);
 | 
			
		||||
    AST *ast = env.translationUnit->ast();
 | 
			
		||||
    PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseTranlationUnit);
 | 
			
		||||
    AST *ast = test.m_translationUnit->ast();
 | 
			
		||||
    QVERIFY(ast);
 | 
			
		||||
 | 
			
		||||
    env.applyFormatting(ast, PointerDeclarationFormatter::IgnoreCursor);
 | 
			
		||||
    test.applyFormatting(ast, PointerDeclarationFormatter::IgnoreCursor);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
    QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_multiple_matches_data()
 | 
			
		||||
@@ -585,13 +593,13 @@ void CppToolsPlugin::test_format_pointerdeclaration_macros()
 | 
			
		||||
    QFETCH(QString, source);
 | 
			
		||||
    QFETCH(QString, reformattedSource);
 | 
			
		||||
 | 
			
		||||
    TestEnvironment env(source.toLatin1(), Document::ParseTranlationUnit);
 | 
			
		||||
    AST *ast = env.translationUnit->ast();
 | 
			
		||||
    PointerDeclarationFormatterTestCase test(source.toLatin1(), Document::ParseTranlationUnit);
 | 
			
		||||
    AST *ast = test.m_translationUnit->ast();
 | 
			
		||||
    QVERIFY(ast);
 | 
			
		||||
 | 
			
		||||
    env.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
    test.applyFormatting(ast, PointerDeclarationFormatter::RespectCursor);
 | 
			
		||||
 | 
			
		||||
    QCOMPARE(env.textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
    QCOMPARE(test.m_textDocument->toPlainText(), reformattedSource);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_format_pointerdeclaration_macros_data()
 | 
			
		||||
 
 | 
			
		||||
@@ -32,7 +32,8 @@
 | 
			
		||||
 | 
			
		||||
#include <QDir>
 | 
			
		||||
 | 
			
		||||
using namespace CppTools;
 | 
			
		||||
namespace CppTools {
 | 
			
		||||
namespace Tests {
 | 
			
		||||
 | 
			
		||||
QString TestIncludePaths::includeBaseDirectory()
 | 
			
		||||
{
 | 
			
		||||
@@ -54,3 +55,11 @@ QString TestIncludePaths::directoryOfTestFile()
 | 
			
		||||
{
 | 
			
		||||
    return QDir::cleanPath(includeBaseDirectory() + QLatin1String("/local"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString TestIncludePaths::testFilePath(const QString &fileName)
 | 
			
		||||
{
 | 
			
		||||
    return Tests::TestIncludePaths::directoryOfTestFile() + QLatin1Char('/') + fileName;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace Tests
 | 
			
		||||
} // namespace CppTools
 | 
			
		||||
 
 | 
			
		||||
@@ -34,20 +34,26 @@
 | 
			
		||||
#include "cpptools_global.h"
 | 
			
		||||
 | 
			
		||||
#include <QtGlobal>
 | 
			
		||||
#include <QString>
 | 
			
		||||
 | 
			
		||||
QT_FORWARD_DECLARE_CLASS(QString)
 | 
			
		||||
 | 
			
		||||
namespace CppTools {
 | 
			
		||||
namespace Tests {
 | 
			
		||||
 | 
			
		||||
class CPPTOOLS_EXPORT TestIncludePaths
 | 
			
		||||
{
 | 
			
		||||
    Q_DISABLE_COPY(TestIncludePaths)
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    static QString includeBaseDirectory();
 | 
			
		||||
    static QString globalQtCoreIncludePath();
 | 
			
		||||
    static QString globalIncludePath();
 | 
			
		||||
    static QString directoryOfTestFile();
 | 
			
		||||
    static QString testFilePath(const QString &fileName = QLatin1String("file.cpp"));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace Tests
 | 
			
		||||
} // namespace CppTools
 | 
			
		||||
 | 
			
		||||
#endif // CPPPREPROCESSERTESTHELPER_H
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,7 @@
 | 
			
		||||
 | 
			
		||||
using namespace CPlusPlus;
 | 
			
		||||
using namespace CppTools;
 | 
			
		||||
using namespace CppTools::Tests;
 | 
			
		||||
using namespace CppTools::Internal;
 | 
			
		||||
 | 
			
		||||
typedef Document::Include Include;
 | 
			
		||||
@@ -58,12 +59,11 @@ public:
 | 
			
		||||
 | 
			
		||||
    Document::Ptr run(const QByteArray &source)
 | 
			
		||||
    {
 | 
			
		||||
        const QString fileName = TestIncludePaths::directoryOfTestFile()
 | 
			
		||||
                + QLatin1String("/file.cpp");
 | 
			
		||||
        const QString fileName = TestIncludePaths::testFilePath();
 | 
			
		||||
        if (QFileInfo(fileName).exists())
 | 
			
		||||
            return Document::Ptr(); // Test file was not removed.
 | 
			
		||||
 | 
			
		||||
        CppTools::Tests::TestCase::writeFile(fileName, source);
 | 
			
		||||
        TestCase::writeFile(fileName, source);
 | 
			
		||||
 | 
			
		||||
        CppPreprocessor pp((QPointer<CppModelManager>(m_cmm)));
 | 
			
		||||
        pp.setIncludePaths(QStringList(TestIncludePaths::directoryOfTestFile()));
 | 
			
		||||
@@ -107,7 +107,7 @@ void CppToolsPlugin::test_cpppreprocessor_includes()
 | 
			
		||||
    QVERIFY(resolvedIncludes.at(0).type() == Client::IncludeLocal);
 | 
			
		||||
    QCOMPARE(resolvedIncludes.at(0).unresolvedFileName(), QLatin1String("header.h"));
 | 
			
		||||
    const QString expectedResolvedFileName
 | 
			
		||||
        = TestIncludePaths::directoryOfTestFile() + QLatin1String("/header.h");
 | 
			
		||||
            = TestIncludePaths::testFilePath(QLatin1String("header.h"));
 | 
			
		||||
    QCOMPARE(resolvedIncludes.at(0).resolvedFileName(), expectedResolvedFileName);
 | 
			
		||||
 | 
			
		||||
    const QList<Document::Include> unresolvedIncludes = document->unresolvedIncludes();
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,8 @@ namespace {
 | 
			
		||||
 | 
			
		||||
QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/")
 | 
			
		||||
 | 
			
		||||
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
 | 
			
		||||
 | 
			
		||||
class ResultData
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
@@ -78,17 +80,18 @@ public:
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
    QString m_symbolName;
 | 
			
		||||
    QString m_scope;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
typedef ResultData::ResultDataList ResultDataList;
 | 
			
		||||
 | 
			
		||||
class SymbolSearcherTest : public CppTools::Tests::TestCase
 | 
			
		||||
class SymbolSearcherTestCase : public CppTools::Tests::TestCase
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    /// Takes no ownership of indexingSupportToUse
 | 
			
		||||
    SymbolSearcherTest(const QString &testFile, CppIndexingSupport *indexingSupportToUse)
 | 
			
		||||
    SymbolSearcherTestCase(const QString &testFile, CppIndexingSupport *indexingSupportToUse)
 | 
			
		||||
        : m_indexingSupportToUse(indexingSupportToUse)
 | 
			
		||||
        , m_testFile(testFile)
 | 
			
		||||
    {
 | 
			
		||||
@@ -101,8 +104,8 @@ public:
 | 
			
		||||
    ResultDataList run(const SymbolSearcher::Parameters &searchParameters) const
 | 
			
		||||
    {
 | 
			
		||||
        CppIndexingSupport *indexingSupport = m_modelManager->indexingSupport();
 | 
			
		||||
        SymbolSearcher *symbolSearcher
 | 
			
		||||
            = indexingSupport->createSymbolSearcher(searchParameters, QSet<QString>() << m_testFile);
 | 
			
		||||
        SymbolSearcher *symbolSearcher = indexingSupport->createSymbolSearcher(searchParameters,
 | 
			
		||||
            QSet<QString>() << m_testFile);
 | 
			
		||||
        QFuture<Find::SearchResultItem> search
 | 
			
		||||
            = QtConcurrent::run(&SymbolSearcher::runSearch, symbolSearcher);
 | 
			
		||||
        search.waitForFinished();
 | 
			
		||||
@@ -110,7 +113,7 @@ public:
 | 
			
		||||
        return results;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ~SymbolSearcherTest()
 | 
			
		||||
    ~SymbolSearcherTestCase()
 | 
			
		||||
    {
 | 
			
		||||
        m_modelManager->setIndexingSupport(m_indexingSupportToRestore);
 | 
			
		||||
    }
 | 
			
		||||
@@ -121,8 +124,6 @@ private:
 | 
			
		||||
    const QString m_testFile;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
 | 
			
		||||
 | 
			
		||||
} // anonymous namespace
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(ResultData)
 | 
			
		||||
@@ -148,7 +149,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher()
 | 
			
		||||
 | 
			
		||||
    QScopedPointer<CppIndexingSupport> builtinIndexingSupport(new BuiltinIndexingSupport);
 | 
			
		||||
 | 
			
		||||
    SymbolSearcherTest test(testFile, builtinIndexingSupport.data());
 | 
			
		||||
    SymbolSearcherTestCase test(testFile, builtinIndexingSupport.data());
 | 
			
		||||
    const ResultDataList results = test.run(searchParameters);
 | 
			
		||||
    QCOMPARE(results, expectedResults);
 | 
			
		||||
}
 | 
			
		||||
@@ -197,9 +198,11 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
 | 
			
		||||
            << 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>"))
 | 
			
		||||
@@ -208,9 +211,12 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
 | 
			
		||||
            << ResultData(_("MyClass"), _("<anonymous namespace>"))
 | 
			
		||||
            << ResultData(_("MyClass()"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDeclaredOnly()"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedInClass(bool, int)"),
 | 
			
		||||
                          _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"),
 | 
			
		||||
                          _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"),
 | 
			
		||||
                          _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("main()"), _(""))
 | 
			
		||||
 | 
			
		||||
        );
 | 
			
		||||
@@ -246,10 +252,13 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
 | 
			
		||||
            << ResultData(_("myFunction(bool, int)"), _("MyNamespace"))
 | 
			
		||||
            << 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)"), _("<anonymous namespace>"))
 | 
			
		||||
            << ResultData(_("functionDefinedInClass(bool, int)"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"), _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedInClass(bool, int)"),
 | 
			
		||||
                          _("<anonymous namespace>::MyClass"))
 | 
			
		||||
            << ResultData(_("functionDefinedOutSideClass(char)"),
 | 
			
		||||
                          _("<anonymous namespace>::MyClass"))
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
    // Check Enums
 | 
			
		||||
 
 | 
			
		||||
@@ -44,6 +44,8 @@ using namespace CPlusPlus;
 | 
			
		||||
using namespace CppTools;
 | 
			
		||||
using namespace CppTools::Internal;
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(QList<Tests::TestDocument>)
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
bool hierarchySorter(const TypeHierarchy &h1, const TypeHierarchy &h2)
 | 
			
		||||
@@ -90,14 +92,17 @@ private:
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    Class *m_clazz;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
class TestCase : public CppTools::Tests::TestCase
 | 
			
		||||
class TypeHierarchyBuilderTestCase : public CppTools::Tests::TestCase
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
    TestCase(const QList<Tests::TestDocument> &documents, const QString &expectedHierarchy)
 | 
			
		||||
        : m_documents(documents), m_expectedHierarchy(expectedHierarchy)
 | 
			
		||||
    TypeHierarchyBuilderTestCase(const QList<Tests::TestDocument> &documents,
 | 
			
		||||
                                 const QString &expectedHierarchy)
 | 
			
		||||
        : m_documents(documents),
 | 
			
		||||
          m_expectedHierarchy(expectedHierarchy)
 | 
			
		||||
    {}
 | 
			
		||||
 | 
			
		||||
    void run()
 | 
			
		||||
@@ -135,8 +140,6 @@ private:
 | 
			
		||||
 | 
			
		||||
} // anonymous namespace
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(QList<Tests::TestDocument>)
 | 
			
		||||
 | 
			
		||||
void CppToolsPlugin::test_typehierarchy_data()
 | 
			
		||||
{
 | 
			
		||||
    QTest::addColumn<QList<Tests::TestDocument> >("documents");
 | 
			
		||||
@@ -189,6 +192,6 @@ void CppToolsPlugin::test_typehierarchy()
 | 
			
		||||
    QFETCH(QList<Tests::TestDocument>, documents);
 | 
			
		||||
    QFETCH(QString, expectedHierarchy);
 | 
			
		||||
 | 
			
		||||
    TestCase testCase(documents, expectedHierarchy);
 | 
			
		||||
    TypeHierarchyBuilderTestCase testCase(documents, expectedHierarchy);
 | 
			
		||||
    testCase.run();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user