From a4b747307e50f20dbaa22cf5cc66199f14067d6c Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 10 Feb 2016 10:43:31 +0100 Subject: [PATCH] AutoTest: Fix flaky unit test Since parsing and updating the tree model has been changed the respective tests became flaky. Change-Id: I82fcde51493bc86e2315018b21e9bacd8e8409a9 Reviewed-by: David Schulz --- src/plugins/autotest/autotestunittests.cpp | 6 ++++++ src/plugins/autotest/testcodeparser.h | 4 ++++ src/plugins/autotest/testtreemodel.cpp | 4 ++++ src/plugins/autotest/testtreemodel.h | 3 +++ 4 files changed, 17 insertions(+) diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index 60f931b5e0f..0ae4b4ad5ad 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -96,7 +96,9 @@ void AutoTestUnitTests::testCodeParser() QVERIFY(projectInfo.isValid()); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); + QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone())); QVERIFY(parserSpy.wait(20000)); + QVERIFY(modelUpdateSpy.wait()); if (m_isQt4) expectedNamedQuickTestsCount = expectedUnnamedQuickTestsCount = 0; @@ -148,7 +150,9 @@ void AutoTestUnitTests::testCodeParserSwitchStartup() QVERIFY(projectInfo.isValid()); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); + QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone())); QVERIFY(parserSpy.wait(20000)); + QVERIFY(modelUpdateSpy.wait()); QCOMPARE(m_model->autoTestsCount(), expectedAutoTestsCount.at(i)); QCOMPARE(m_model->namedQuickTestsCount(), @@ -198,7 +202,9 @@ void AutoTestUnitTests::testCodeParserGTest() QVERIFY(projectInfo.isValid()); QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); + QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone())); QVERIFY(parserSpy.wait(20000)); + QVERIFY(modelUpdateSpy.wait()); QCOMPARE(m_model->gtestNamesCount(), 6); diff --git a/src/plugins/autotest/testcodeparser.h b/src/plugins/autotest/testcodeparser.h index 0cdb99d3055..e9254221142 100644 --- a/src/plugins/autotest/testcodeparser.h +++ b/src/plugins/autotest/testcodeparser.h @@ -63,6 +63,10 @@ public: void setState(State state); State state() const { return m_parserState; } void setDirty() { m_dirty = true; } +#ifdef WITH_TESTS + bool furtherParsingExpected() const + { return m_singleShotScheduled || m_fullUpdatePostponed || m_partialUpdatePostponed; } +#endif signals: void aboutToPerformFullParse(); diff --git a/src/plugins/autotest/testtreemodel.cpp b/src/plugins/autotest/testtreemodel.cpp index bb4ca737a24..502a24507f8 100644 --- a/src/plugins/autotest/testtreemodel.cpp +++ b/src/plugins/autotest/testtreemodel.cpp @@ -569,6 +569,10 @@ void TestTreeModel::sweep() } if (hasChanged) emit testTreeModelChanged(); +#ifdef WITH_TESTS + if (m_parser->state() == TestCodeParser::Idle && !m_parser->furtherParsingExpected()) + emit sweepingDone(); +#endif } QMap TestTreeModel::testCaseNamesForFiles(QStringList files) diff --git a/src/plugins/autotest/testtreemodel.h b/src/plugins/autotest/testtreemodel.h index a4104eafa39..9c7f08d7b06 100644 --- a/src/plugins/autotest/testtreemodel.h +++ b/src/plugins/autotest/testtreemodel.h @@ -85,6 +85,9 @@ public: signals: void testTreeModelChanged(); +#ifdef WITH_TESTS + void sweepingDone(); +#endif public slots: