Commit 0273757c authored by Nikolai Kosjar's avatar Nikolai Kosjar Committed by Christian Stenger

GenericProjectManager: Fix plugin tests

The signal was emitted before the spy connected to it.

Change-Id: I5b70c32b8346192d6d58304f05961213ec4d5a57
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent aba863cb
......@@ -30,21 +30,20 @@
#include "cppmodelmanagerhelper.h"
#include <QCoreApplication>
#include <QSignalSpy>
#include <QTest>
#include <QThread>
using namespace CppTools;
using namespace GenericProjectManager::Internal::Tests;
CppModelManagerHelper::CppModelManagerHelper(QObject *parent) :
QObject(parent)
CppModelManagerHelper::CppModelManagerHelper(QObject *parent)
: QObject(parent)
, m_spy(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QSet<QString> &)))
{
connect(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QSet<QString> &)),
this, SLOT(onSourceFilesRefreshed(const QSet<QString> &)));
}
CppModelManagerInterface *CppModelManagerHelper::cppModelManager()
{
return CppModelManagerInterface::instance();
......@@ -59,14 +58,13 @@ void CppModelManagerHelper::waitForSourceFilesRefreshed(const QStringList &files
{
QTime t;
t.start();
QSignalSpy spy(cppModelManager(), SIGNAL(sourceFilesRefreshed(const QSet<QString> &)));
foreach (const QString &file, files) {
while (!m_refreshedSourceFiles.contains(file)) {
QVERIFY(spy.wait());
}
while (!m_refreshedSourceFiles.contains(file))
QCoreApplication::processEvents();
QVERIFY(t.elapsed() <= timeOut);
}
QCOMPARE(m_spy.count(), 1);
}
void CppModelManagerHelper::onSourceFilesRefreshed(const QSet<QString> &files)
......
......@@ -33,6 +33,7 @@
#include <cpptools/cppmodelmanagerinterface.h>
#include <QObject>
#include <QSignalSpy>
namespace GenericProjectManager {
namespace Internal {
......@@ -55,6 +56,7 @@ private slots:
private:
QSet<QString> m_refreshedSourceFiles;
QSignalSpy m_spy;
};
} // Tests namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment