diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2021-05-19 13:22:49 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2021-06-02 10:52:50 +0000 |
commit | ff0301635e7af28df61104cc5fa15e9c407f257e (patch) | |
tree | 3dc89bfa426033e51036c5ffe801a54bc7d6e70d /src/plugins/cpptools/cpptoolstestcase.h | |
parent | 003ab51c3d6029827c661a4ee2f5834d7505ad0a (diff) | |
download | qt-creator-ff0301635e7af28df61104cc5fa15e9c407f257e.tar.gz |
CppEditor: Tweak test infrastructure
... so we can re-use the "follow symbol" test cases with clangd.
Call Creator like this (clangd needs to be version 12 or later):
$ QTC_CLANGD=<path to clangd> qtcreator -test
'CppEditor,*Follow*,*Switch*' -test 'ClangCodeModel,*dummy*'
During testing, some invalid code in the test cases was uncovered and
fixed.
Change-Id: I9dc650fdba2a27600e6a550420ee873f6fb31d23
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cpptoolstestcase.h')
-rw-r--r-- | src/plugins/cpptools/cpptoolstestcase.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cpptoolstestcase.h b/src/plugins/cpptools/cpptoolstestcase.h index aaa94f1e07..08ae5b7c70 100644 --- a/src/plugins/cpptools/cpptoolstestcase.h +++ b/src/plugins/cpptools/cpptoolstestcase.h @@ -30,7 +30,9 @@ #include <cplusplus/CppDocument.h> #include <utils/temporarydirectory.h> +#include <QEventLoop> #include <QStringList> +#include <QTimer> namespace CPlusPlus { class Document; @@ -54,6 +56,23 @@ class ProjectInfo; namespace Tests { +int CPPTOOLS_EXPORT clangdIndexingTimeout(); + +template <typename Signal> inline bool waitForSignalOrTimeout( + const typename QtPrivate::FunctionPointer<Signal>::Object *sender, Signal signal, + int timeoutInMs) +{ + QTimer timer; + timer.setSingleShot(true); + timer.setInterval(timeoutInMs); + QEventLoop loop; + QObject::connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit); + QObject::connect(sender, signal, &loop, &QEventLoop::quit); + timer.start(); + loop.exec(); + return timer.isActive(); +} + class CPPTOOLS_EXPORT TestDocument { public: |