Commit 5b12c8d6 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

CppTools: Support ObjC in member access operator tests



Actual test is added in a follow-up commit.

Change-Id: I645d1e50d4ac9d281e31a0375f64fea849bf5e25
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent b6e52b0c
...@@ -63,7 +63,8 @@ typedef QByteArray _; ...@@ -63,7 +63,8 @@ typedef QByteArray _;
class CompletionTestCase : public Tests::TestCase class CompletionTestCase : public Tests::TestCase
{ {
public: public:
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray()) CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray(),
bool isObjC = false)
: m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0) : m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
{ {
QVERIFY(succeededSoFar()); QVERIFY(succeededSoFar());
...@@ -77,7 +78,8 @@ public: ...@@ -77,7 +78,8 @@ public:
// Write source to file // Write source to file
m_temporaryDir.reset(new Tests::TemporaryDir()); m_temporaryDir.reset(new Tests::TemporaryDir());
QVERIFY(m_temporaryDir->isValid()); QVERIFY(m_temporaryDir->isValid());
const QString fileName = m_temporaryDir->createFile("file.h", m_source); const QByteArray fileExt = isObjC ? ".mm" : ".h";
const QString fileName = m_temporaryDir->createFile("file." + fileExt, m_source);
QVERIFY(!fileName.isEmpty()); QVERIFY(!fileName.isEmpty());
// Open in editor // Open in editor
...@@ -3361,9 +3363,10 @@ void CppToolsPlugin::test_completion_member_access_operator() ...@@ -3361,9 +3363,10 @@ void CppToolsPlugin::test_completion_member_access_operator()
QFETCH(QByteArray, code); QFETCH(QByteArray, code);
QFETCH(QByteArray, prefix); QFETCH(QByteArray, prefix);
QFETCH(QStringList, expectedCompletions); QFETCH(QStringList, expectedCompletions);
QFETCH(bool, isObjC);
QFETCH(bool, expectedReplaceAccessOperator); QFETCH(bool, expectedReplaceAccessOperator);
CompletionTestCase test(code, prefix); CompletionTestCase test(code, prefix, isObjC);
QVERIFY(test.succeededSoFar()); QVERIFY(test.succeededSoFar());
bool replaceAccessOperator = false; bool replaceAccessOperator = false;
...@@ -3381,6 +3384,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3381,6 +3384,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
QTest::addColumn<QByteArray>("code"); QTest::addColumn<QByteArray>("code");
QTest::addColumn<QByteArray>("prefix"); QTest::addColumn<QByteArray>("prefix");
QTest::addColumn<QStringList>("expectedCompletions"); QTest::addColumn<QStringList>("expectedCompletions");
QTest::addColumn<bool>("isObjC");
QTest::addColumn<bool>("expectedReplaceAccessOperator"); QTest::addColumn<bool>("expectedReplaceAccessOperator");
QTest::newRow("member_access_operator") << _( QTest::newRow("member_access_operator") << _(
...@@ -3391,6 +3395,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3391,6 +3395,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("s.") << (QStringList() ) << _("s.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("t")) << QLatin1String("t"))
<< false
<< true; << true;
QTest::newRow("typedef_of_type_and_decl_of_type_no_replace_access_operator") << _( QTest::newRow("typedef_of_type_and_decl_of_type_no_replace_access_operator") << _(
...@@ -3401,6 +3406,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3401,6 +3406,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< false; << false;
QTest::newRow("typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _( QTest::newRow("typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _(
...@@ -3409,6 +3415,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3409,6 +3415,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
"SType *p;\n" "SType *p;\n"
"@\n" "@\n"
) << _("p.") << (QStringList()) ) << _("p.") << (QStringList())
<< false
<< false; << false;
QTest::newRow("typedef_of_type_and_decl_of_pointer_replace_access_operator") << _( QTest::newRow("typedef_of_type_and_decl_of_pointer_replace_access_operator") << _(
...@@ -3419,6 +3426,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3419,6 +3426,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< true; << true;
QTest::newRow("typedef_of_pointer_and_decl_of_type_replace_access_operator") << _( QTest::newRow("typedef_of_pointer_and_decl_of_type_replace_access_operator") << _(
...@@ -3429,6 +3437,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3429,6 +3437,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< true; << true;
QTest::newRow("predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator") << _( QTest::newRow("predecl_typedef_of_type_and_decl_of_pointer_replace_access_operator") << _(
...@@ -3439,6 +3448,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3439,6 +3448,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< true; << true;
QTest::newRow("predecl_typedef_of_type_and_decl_type_no_replace_access_operator") << _( QTest::newRow("predecl_typedef_of_type_and_decl_type_no_replace_access_operator") << _(
...@@ -3449,6 +3459,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3449,6 +3459,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< false; << false;
QTest::newRow("predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _( QTest::newRow("predecl_typedef_of_pointer_and_decl_of_pointer_no_replace_access_operator") << _(
...@@ -3457,6 +3468,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3457,6 +3468,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
"SType *p;\n" "SType *p;\n"
"@\n" "@\n"
) << _("p.") << (QStringList()) ) << _("p.") << (QStringList())
<< false
<< false; << false;
QTest::newRow("predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator") << _( QTest::newRow("predecl_typedef_of_pointer_and_decl_of_type_replace_access_operator") << _(
...@@ -3467,6 +3479,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3467,6 +3479,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< true; << true;
QTest::newRow("typedef_of_pointer_of_type_replace_access_operator") << _( QTest::newRow("typedef_of_pointer_of_type_replace_access_operator") << _(
...@@ -3478,6 +3491,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3478,6 +3491,7 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p.") << (QStringList() ) << _("p.") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< true; << true;
QTest::newRow("typedef_of_pointer_of_type_no_replace_access_operator") << _( QTest::newRow("typedef_of_pointer_of_type_no_replace_access_operator") << _(
...@@ -3489,5 +3503,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() ...@@ -3489,5 +3503,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data()
) << _("p->") << (QStringList() ) << _("p->") << (QStringList()
<< QLatin1String("S") << QLatin1String("S")
<< QLatin1String("m")) << QLatin1String("m"))
<< false
<< false; << false;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment