diff options
author | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-09-27 17:16:51 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@digia.com> | 2013-10-01 12:12:00 +0200 |
commit | 166a0dff4afe23212ec9a34b26d281f9126e2e6a (patch) | |
tree | 0e3ab6cb6556ca92e5777e290baf77e4607b0afe /src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | |
parent | 59a578d4a9de614c5597589f10235d07d5ea734f (diff) | |
download | qt-creator-166a0dff4afe23212ec9a34b26d281f9126e2e6a.tar.gz |
CppEditor: add autotest
Add an autotests for follow symbol under cursor in
QObject::connect calls.
Task-number: QTCREATORBUG-10264
Task-number: QTCREATORBUG-10265
Change-Id: Ie72d49476e173e82027a3579fd71ed5f8ac3f95b
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
Diffstat (limited to 'src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp')
-rw-r--r-- | src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 5e115202ff..46ff3e159b 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -898,6 +898,100 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_classDestructor() test.run(); } +void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect_data() +{ +#define TAG(str) secondQObjectParam ? str : str ", no 2nd QObject" + QTest::addColumn<char>("start"); + QTest::addColumn<char>("target"); + QTest::addColumn<bool>("secondQObjectParam"); + for (int i = 0; i < 2; ++i) { + bool secondQObjectParam = (i == 0); + QTest::newRow(TAG("SIGNAL: before keyword")) + << '1' << '1' << secondQObjectParam; + QTest::newRow(TAG("SIGNAL: in keyword")) + << '2' << '1' << secondQObjectParam; + QTest::newRow(TAG("SIGNAL: before parenthesis")) + << '3' << '1' << secondQObjectParam; + QTest::newRow(TAG("SIGNAL: before identifier")) + << '4' << '1' << secondQObjectParam; + QTest::newRow(TAG("SIGNAL: in identifier")) + << '5' << '1' << secondQObjectParam; + QTest::newRow(TAG("SIGNAL: before identifier parenthesis")) + << '6' << '1' << secondQObjectParam; + QTest::newRow(TAG("SLOT: before keyword")) + << '7' << '2' << secondQObjectParam; + QTest::newRow(TAG("SLOT: in keyword")) + << '8' << '2' << secondQObjectParam; + QTest::newRow(TAG("SLOT: before parenthesis")) + << '9' << '2' << secondQObjectParam; + QTest::newRow(TAG("SLOT: before identifier")) + << 'A' << '2' << secondQObjectParam; + QTest::newRow(TAG("SLOT: in identifier")) + << 'B' << '2' << secondQObjectParam; + QTest::newRow(TAG("SLOT: before identifier parenthesis")) + << 'C' << '2' << secondQObjectParam; + } +#undef TAG +} + +static void selectMarker(QByteArray *source, char marker, char number) +{ + int idx = 0; + forever { + idx = source->indexOf(marker, idx); + if (idx == -1) + break; + if (source->at(idx + 1) == number) { + ++idx; + source->remove(idx, 1); + } else { + source->remove(idx, 2); + } + } +} + +void CppEditorPlugin::test_FollowSymbolUnderCursor_QObject_connect() +{ + QFETCH(char, start); + QFETCH(char, target); + QFETCH(bool, secondQObjectParam); + QByteArray source = + "class Foo : public QObject\n" + "{\n" + "signals:\n" + " void $1endOfWorld();\n" + "public slots:\n" + " void $2onWorldEnded()\n" + " {\n" + " }\n" + "};\n" + "\n" + "void bla()\n" + "{\n" + " Foo foo;\n" + " connect(&foo, @1SI@2GNAL@3(@4end@5OfWorld@6()),\n" + " &foo, @7SL@8OT@9(@Aon@BWorldEnded@C()));\n" + "}\n"; + + selectMarker(&source, '@', start); + selectMarker(&source, '$', target); + + if (!secondQObjectParam) + source.replace(" &foo, ", QByteArray()); + + if (start == '4' || start == 'A') { + qWarning("SIGNAL/SLOT before identifier triggers QTCREATORBUG-10264. Skipping."); + return; + } + if (start >= '7' && !secondQObjectParam) { + qWarning("SLOT jump triggers QTCREATORBUG-10265. Skipping."); + return; + } + + TestCase test(TestCase::FollowSymbolUnderCursor, source); + test.run(); +} + void CppEditorPlugin::test_FollowSymbolUnderCursor_using_QTCREATORBUG7903_globalNamespace() { const QByteArray source = |