diff options
author | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-02-17 15:05:22 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-02-18 12:16:29 +0000 |
commit | 93c8509a5097f3813e7e9a76e47c583b05d11991 (patch) | |
tree | d42f47e70a3f3e921d8c0f752fd7504c3759fd29 /src/plugins/cpptools/cpptoolstestcase.cpp | |
parent | 1e0b7e527ff1a8aea21c27a1ef954ca0857ef7d5 (diff) | |
download | qt-creator-93c8509a5097f3813e7e9a76e47c583b05d11991.tar.gz |
CppTools: Tests: time out in waitForFileInGlobalSnapshot()
Change-Id: I0bf7d826d53749c5fd1be1e4f3c2faa403d13342
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Diffstat (limited to 'src/plugins/cpptools/cpptoolstestcase.cpp')
-rw-r--r-- | src/plugins/cpptools/cpptoolstestcase.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp index d7a96300fc..f1839b2493 100644 --- a/src/plugins/cpptools/cpptoolstestcase.cpp +++ b/src/plugins/cpptools/cpptoolstestcase.cpp @@ -170,14 +170,19 @@ bool TestCase::closeEditorWithoutGarbageCollectorInvocation(Core::IEditor *edito return closeEditorsWithoutGarbageCollectorInvocation(QList<Core::IEditor *>() << editor); } -CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath) +CPlusPlus::Document::Ptr TestCase::waitForFileInGlobalSnapshot(const QString &filePath, + int timeOutInMs) { - return waitForFilesInGlobalSnapshot(QStringList(filePath)).first(); + const auto documents = waitForFilesInGlobalSnapshot(QStringList(filePath), timeOutInMs); + return documents.isEmpty() ? CPlusPlus::Document::Ptr() : documents.first(); } -QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot( - const QStringList &filePaths) +QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QStringList &filePaths, + int timeOutInMs) { + QTime t; + t.start(); + QList<CPlusPlus::Document::Ptr> result; foreach (const QString &filePath, filePaths) { forever { @@ -185,13 +190,15 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot( result.append(document); break; } + if (t.elapsed() > timeOutInMs) + return QList<CPlusPlus::Document::Ptr>(); QCoreApplication::processEvents(); } } return result; } -bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut) +bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOutInMs) { if (!project) return false; @@ -203,7 +210,7 @@ bool TestCase::waitUntilCppModelManagerIsAwareOf(Project *project, int timeOut) forever { if (modelManager->projectInfo(project).isValid()) return true; - if (t.elapsed() > timeOut) + if (t.elapsed() > timeOutInMs) return false; QCoreApplication::processEvents(); } |