diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index d3947b478c9114675f39376bfe303b1e3d604f03..35f05f8728282a9a571ac6f77a4b0e4b2ab5fdd2 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -272,8 +272,10 @@ F2TestCase::F2TestCase(CppEditorAction action, // that is the function bodies are processed. forever { const Document::Ptr document = waitForFileInGlobalSnapshot(testFile->filePath()); - if (document->checkMode() == Document::FullCheck) + if (document->checkMode() == Document::FullCheck) { + QVERIFY(document->diagnosticMessages().isEmpty()); break; + } } // Rehighlight @@ -1132,7 +1134,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data() "void CD2::virt() {}\n" "\n" "int f(A *o) { o->$@virt(); }\n" - "}\n") + "\n") << (OverrideItemList() << OverrideItem(QLatin1String("A::virt = 0"), 2) << OverrideItem(QLatin1String("B::virt"), 5) @@ -1158,7 +1160,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data() "void CD2::virt() {}\n" "\n" "int f(B *o) { o->$@virt(); }\n" - "}\n") + "\n") << (OverrideItemList() << OverrideItem(QLatin1String("B::virt"), 5) << OverrideItem(QLatin1String("C::virt"), 8) diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 54c150cadcaf74c923c9c2d0ded91ee9ba801ce3..af8c7d78a9fe18747fa9da669710bc59b735511f 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -87,6 +87,8 @@ public: // Get Document waitForFileInGlobalSnapshot(fileName); const Document::Ptr document = globalSnapshot().document(fileName); + QVERIFY(document); + QVERIFY(document->diagnosticMessages().isEmpty()); m_snapshot.insert(document); @@ -344,7 +346,7 @@ void CppToolsPlugin::test_completion_data() "{\n" " Base *b = new Derived;\n" " if (1)\n" - " @\n" + " @;\n" "}\n" ) << _("((Derived *)b)->") << (QStringList() << QLatin1String("Derived") @@ -367,7 +369,7 @@ void CppToolsPlugin::test_completion_data() "{\n" " Base *b = new Derived;\n" " if (1)\n" - " @\n" + " @;\n" "}\n" ) << _("(static_cast(b))->") << (QStringList() << QLatin1String("Derived") @@ -1522,7 +1524,7 @@ void CppToolsPlugin::test_completion_data() " int foo2;\n" " };\n" " @\n" - "};\n" + "}\n" ) << _("foo") << (QStringList() << QLatin1String("foo1") << QLatin1String("foo2")); @@ -1704,6 +1706,7 @@ void CppToolsPlugin::test_completion_data() " int m;\n" " };\n" "}\n" + "}\n" "void foo()\n" "{\n" " namespace NS = NS1::NS2;\n" @@ -1725,6 +1728,7 @@ void CppToolsPlugin::test_completion_data() " int m;\n" " };\n" "}\n" + "}\n" "void foo()\n" "{\n" " {\n" @@ -1823,7 +1827,6 @@ void CppToolsPlugin::test_completion_data() " enum E { val1, val2, val3 };\n" " @\n" "};\n" - "@\n" ) << _("Foo::v") << (QStringList() << QLatin1String("val1") << QLatin1String("val2") @@ -1835,7 +1838,6 @@ void CppToolsPlugin::test_completion_data() " enum E { val1, val2, val3 };\n" " @\n" "};\n" - "@\n" ) << _("Foo::E::") << (QStringList() << QLatin1String("E") << QLatin1String("val1") @@ -1848,7 +1850,6 @@ void CppToolsPlugin::test_completion_data() " enum { val1, val2, val3 };\n" " @\n" "};\n" - "@\n" ) << _("Foo::v") << (QStringList() << QLatin1String("val1") << QLatin1String("val2") @@ -1859,8 +1860,7 @@ void CppToolsPlugin::test_completion_data() "{\n" " enum E { val1, val2, val3 };\n" " @\n" - "};\n" - "@\n" + "}\n" ) << _("Ns::v") << (QStringList() << QLatin1String("val1") << QLatin1String("val2") @@ -1871,8 +1871,7 @@ void CppToolsPlugin::test_completion_data() "{\n" " enum E { val1, val2, val3 };\n" " @\n" - "};\n" - "@\n" + "}\n" ) << _("Ns::E::") << (QStringList() << QLatin1String("E") << QLatin1String("val1") @@ -1884,8 +1883,7 @@ void CppToolsPlugin::test_completion_data() "{\n" " enum { val1, val2, val3 };\n" " @\n" - "};\n" - "@\n" + "}\n" ) << _("Ns::v") << (QStringList() << QLatin1String("val1") << QLatin1String("val2") @@ -2186,9 +2184,9 @@ void CppToolsPlugin::test_completion_data() "void client()\n" "{\n" " Timer *timer = new Timer;\n" - " connect(timer, SIGNAL(@\n" + " @\n" "}\n" - ) << _() << (QStringList() + ) << _("connect(timer, SIGNAL(") << (QStringList() << QLatin1String("timeout()")); QTest::newRow("member_of_class_accessed_by_using_QTCREATORBUG9037_1") << _( @@ -2230,9 +2228,9 @@ void CppToolsPlugin::test_completion_data() "\n" "double getValue(const QVector& d) const {\n" " typedef QVector::ConstIterator Iter;\n" - " double val = @\n" + " @\n" "}\n" - ) << _("d.constBegin()->") << (QStringList()); + ) << _("double val = d.constBegin()->") << (QStringList()); } void CppToolsPlugin::test_completion_member_access_operator() @@ -2277,7 +2275,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef S SType;\n" "SType p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2288,7 +2285,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef S *SType;\n" "SType *p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList()) << false; @@ -2297,7 +2293,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef S SType;\n" "SType *p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2308,7 +2303,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef S* SPtr;\n" "SPtr p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2319,7 +2313,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "struct S { int m; };\n" "SType *p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2330,7 +2323,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "struct S { int m; };\n" "SType p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2341,7 +2333,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "struct S { int m; };\n" "SType *p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList()) << false; @@ -2350,7 +2341,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "struct S { int m; };\n" "SType p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2362,7 +2352,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef struct SType *STypePtr;\n" "STypePtr p;\n" "@\n" - "}\n" ) << _("p.") << (QStringList() << QLatin1String("S") << QLatin1String("m")) @@ -2374,7 +2363,6 @@ void CppToolsPlugin::test_completion_member_access_operator_data() "typedef struct SType *STypePtr;\n" "STypePtr p;\n" "@\n" - "}\n" ) << _("p->") << (QStringList() << QLatin1String("S") << QLatin1String("m")) diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp index 1212ea006057da9ef8839fd942a0cfa3503ea997..4fd9eae00dc71b9e7d728473cd08f9b70449a94a 100644 --- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp +++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp @@ -99,6 +99,7 @@ public: document->setUtf8Source(preprocessedSource); document->parse(parseMode); document->check(); + QVERIFY(document->diagnosticMessages().isEmpty()); AST *ast = document->translationUnit()->ast(); QVERIFY(ast); @@ -614,25 +615,25 @@ void CppToolsPlugin::test_format_pointerdeclaration_macros_data() source = QLatin1String( "#define FOO int*\n" - "FOO @f() {};\n"); + "FOO @f() {}\n"); QTest::newRow("macro-in-function-definition-returntype") << source << stripCursor(source); source = QLatin1String( "#define FOO int*\n" - "int f(FOO @a) {};\n"); + "int f(FOO @a) {}\n"); QTest::newRow("macro-in-function-definition-param") << source << stripCursor(source); source = QLatin1String( "#define FOO int*\n" - "while (FOO @s = 0);\n"); + "void f() { while (FOO @s = 0) {} }\n"); QTest::newRow("macro-in-if-while-for") << source << stripCursor(source); source = QLatin1String( "#define FOO int*\n" - "foreach (FOO @s, list);\n"); + "void f() { foreach (FOO @s, list) {} }\n"); QTest::newRow("macro-in-foreach") << source << stripCursor(source); diff --git a/src/plugins/cpptools/typehierarchybuilder_test.cpp b/src/plugins/cpptools/typehierarchybuilder_test.cpp index e417383532f7413f8778ed77566ec9941e3f8180..cc175909c77b6a92bda66d7fc012481319977987 100644 --- a/src/plugins/cpptools/typehierarchybuilder_test.cpp +++ b/src/plugins/cpptools/typehierarchybuilder_test.cpp @@ -117,6 +117,8 @@ public: // Get class for which to generate the hierarchy const Document::Ptr firstDocument = snapshot.document(filePaths.first()); + QVERIFY(firstDocument); + QVERIFY(firstDocument->diagnosticMessages().isEmpty()); Class *clazz = FindFirstClassInDocument()(firstDocument); QVERIFY(clazz); diff --git a/src/plugins/designer/gotoslot_test.cpp b/src/plugins/designer/gotoslot_test.cpp index 1adafcd6381309050616c37798d222a7484bf54c..af3bed23bfc80a547a055c1a9918a306b7b063e8 100644 --- a/src/plugins/designer/gotoslot_test.cpp +++ b/src/plugins/designer/gotoslot_test.cpp @@ -196,13 +196,35 @@ public: // Compare const Document::Ptr cppDocument = m_modelManager->cppEditorSupport(cppFileEditor)->snapshotUpdater()->document(); + QVERIFY(checkDiagsnosticMessages(cppDocument)); const Document::Ptr hDocument = m_modelManager->cppEditorSupport(hFileEditor)->snapshotUpdater()->document(); + QVERIFY(checkDiagsnosticMessages(hDocument)); + QVERIFY(documentContainsFunctionDefinition(cppDocument, QLatin1String("Form::on_pushButton_clicked"))); QVERIFY(documentContainsMemberFunctionDeclaration(hDocument, QLatin1String("Form::on_pushButton_clicked"))); } + + static bool checkDiagsnosticMessages(const Document::Ptr &document) + { + if (!document) + return false; + + // Since no project is opened and the ui_*.h is not generated, + // the following diagnostic messages will be ignored. + const QStringList ignoreList = QStringList() + << QLatin1String("ui_form.h: No such file or directory") + << QLatin1String("QWidget: No such file or directory"); + QList cleanedDiagnosticMessages; + foreach (const Document::DiagnosticMessage &message, document->diagnosticMessages()) { + if (!ignoreList.contains(message.text())) + cleanedDiagnosticMessages << message; + } + + return cleanedDiagnosticMessages.isEmpty(); + } }; } // anonymous namespace