From 1cc1d986018a7057b544e0067b76020ab702cba4 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 24 Jan 2024 13:54:36 +0100 Subject: [PATCH] CppEditor: Fix completion tests Amends 2c91d4b4724d81e5324e86e5b65f644c439c1b8a. Change-Id: I6c4e8bc359acd2cd413fe86c1217ccce5321fa1e Reviewed-by: David Schulz Reviewed-by: Reviewed-by: Qt CI Bot --- src/plugins/cppeditor/cppcompletion_test.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/cppeditor/cppcompletion_test.cpp b/src/plugins/cppeditor/cppcompletion_test.cpp index 5a3cc312612..738eaa08367 100644 --- a/src/plugins/cppeditor/cppcompletion_test.cpp +++ b/src/plugins/cppeditor/cppcompletion_test.cpp @@ -63,10 +63,6 @@ public: m_editor = EditorManager::openEditor(filePath); QVERIFY(m_editor); - TextEditor::BaseTextEditor *cppEditor = qobject_cast(m_editor); - QVERIFY(cppEditor); - QTRY_VERIFY(cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated()); - closeEditorAtEndOfTestCase(m_editor); m_editorWidget = TextEditorWidget::fromEditor(m_editor); QVERIFY(m_editorWidget); @@ -145,6 +141,19 @@ public: m_position += text.length(); } + bool waitForSyntaxHighlighting() + { + TextEditor::BaseTextEditor *cppEditor = qobject_cast(m_editor); + if (!cppEditor) + return false; + if (cppEditor->textDocument()->syntaxHighlighterRunner()->syntaxInfoUpdated()) + return true; + return ::CppEditor::Tests::waitForSignalOrTimeout( + cppEditor->textDocument()->syntaxHighlighterRunner(), + &BaseSyntaxHighlighterRunner::highlightingFinished, + 5000); + } + private: QByteArray m_source; int m_position = -1; @@ -410,6 +419,7 @@ void CompletionTest::testDoxygenTagCompletion() CompletionTestCase test(code, prefix); QVERIFY(test.succeededSoFar()); + QVERIFY(test.waitForSyntaxHighlighting()); const QStringList completions = test.getCompletions(); QVERIFY(isDoxygenTagCompletion(completions)); }