forked from qt-creator/qt-creator
Various Tests: Use typed connections in QSignalSpy
Change-Id: I0965916f5ce302e9bdcb47ae7126262327f63613 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -99,8 +99,8 @@ void AutoTestUnitTests::testCodeParser()
|
||||
CppEditor::Tests::ProjectOpenerAndCloser projectManager;
|
||||
QVERIFY(projectManager.open(projectFilePath, true, m_kit));
|
||||
|
||||
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
|
||||
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
|
||||
QSignalSpy parserSpy(m_model->parser(), &TestCodeParser::parsingFinished);
|
||||
QSignalSpy modelUpdateSpy(m_model, &TestTreeModel::sweepingDone);
|
||||
QVERIFY(parserSpy.wait(20000));
|
||||
QVERIFY(modelUpdateSpy.wait());
|
||||
|
||||
@@ -149,8 +149,8 @@ void AutoTestUnitTests::testCodeParserSwitchStartup()
|
||||
qDebug() << "Opening project" << projectFilePaths.at(i);
|
||||
QVERIFY(projectManager.open(projectFilePaths.at(i), true, m_kit));
|
||||
|
||||
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
|
||||
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
|
||||
QSignalSpy parserSpy(m_model->parser(), &TestCodeParser::parsingFinished);
|
||||
QSignalSpy modelUpdateSpy(m_model, &TestTreeModel::sweepingDone);
|
||||
QVERIFY(parserSpy.wait(20000));
|
||||
QVERIFY(modelUpdateSpy.wait());
|
||||
|
||||
@@ -199,8 +199,8 @@ void AutoTestUnitTests::testCodeParserGTest()
|
||||
CppEditor::Tests::ProjectOpenerAndCloser projectManager;
|
||||
QVERIFY(projectManager.open(projectFilePath, true, m_kit));
|
||||
|
||||
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
|
||||
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
|
||||
QSignalSpy parserSpy(m_model->parser(), &TestCodeParser::parsingFinished);
|
||||
QSignalSpy modelUpdateSpy(m_model, &TestTreeModel::sweepingDone);
|
||||
QVERIFY(parserSpy.wait(20000));
|
||||
QVERIFY(modelUpdateSpy.wait());
|
||||
|
||||
@@ -250,8 +250,8 @@ void AutoTestUnitTests::testCodeParserBoostTest()
|
||||
= projectManager.open(projectFilePath, true, m_kit);
|
||||
QVERIFY(projectInfo);
|
||||
|
||||
QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished()));
|
||||
QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone()));
|
||||
QSignalSpy parserSpy(m_model->parser(), &TestCodeParser::parsingFinished);
|
||||
QSignalSpy modelUpdateSpy(m_model, &TestTreeModel::sweepingDone);
|
||||
QVERIFY(parserSpy.wait(20000));
|
||||
QVERIFY(modelUpdateSpy.wait());
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ void PreconfiguredSessionTests::testPreconfiguredSession()
|
||||
|
||||
for (ClangTool * const tool : {ClangTidyTool::instance(), ClazyTool::instance()}) {
|
||||
tool->startTool(ClangTool::FileSelectionType::AllFiles);
|
||||
QSignalSpy waitUntilAnalyzerFinished(tool, SIGNAL(finished(bool)));
|
||||
QSignalSpy waitUntilAnalyzerFinished(tool, &ClangTool::finished);
|
||||
QVERIFY(waitUntilAnalyzerFinished.wait(30000));
|
||||
const QList<QVariant> arguments = waitUntilAnalyzerFinished.takeFirst();
|
||||
const bool analyzerFinishedSuccessfully = arguments.first().toBool();
|
||||
|
||||
@@ -105,9 +105,9 @@ void QmlProfilerClientManagerTest::testConnectionFailure()
|
||||
QFETCH(QmlProfilerStateManager *, stateManager);
|
||||
QFETCH(QUrl, serverUrl);
|
||||
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy failedSpy(&clientManager, SIGNAL(connectionFailed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
QSignalSpy failedSpy(&clientManager, &QmlProfilerClientManager::connectionFailed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -137,9 +137,9 @@ void QmlProfilerClientManagerTest::testConnectionFailure()
|
||||
|
||||
void QmlProfilerClientManagerTest::testUnresponsiveTcp()
|
||||
{
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy failedSpy(&clientManager, SIGNAL(connectionFailed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
QSignalSpy failedSpy(&clientManager, &QmlProfilerClientManager::connectionFailed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -150,7 +150,7 @@ void QmlProfilerClientManagerTest::testUnresponsiveTcp()
|
||||
|
||||
QTcpServer server;
|
||||
server.listen(QHostAddress(serverUrl.host()), serverUrl.port());
|
||||
QSignalSpy connectionSpy(&server, SIGNAL(newConnection()));
|
||||
QSignalSpy connectionSpy(&server, &QTcpServer::newConnection);
|
||||
|
||||
clientManager.connectToServer(serverUrl);
|
||||
|
||||
@@ -165,9 +165,9 @@ void QmlProfilerClientManagerTest::testUnresponsiveTcp()
|
||||
|
||||
void QmlProfilerClientManagerTest::testUnresponsiveLocal()
|
||||
{
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy failedSpy(&clientManager, SIGNAL(connectionFailed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
QSignalSpy failedSpy(&clientManager, &QmlProfilerClientManager::connectionFailed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -176,7 +176,7 @@ void QmlProfilerClientManagerTest::testUnresponsiveLocal()
|
||||
|
||||
QUrl socketUrl = Utils::urlFromLocalSocket();
|
||||
QLocalSocket socket;
|
||||
QSignalSpy connectionSpy(&socket, SIGNAL(connected()));
|
||||
QSignalSpy connectionSpy(&socket, &QLocalSocket::connected);
|
||||
|
||||
clientManager.connectToServer(socketUrl);
|
||||
|
||||
@@ -209,8 +209,8 @@ void QmlProfilerClientManagerTest::testResponsiveTcp()
|
||||
|
||||
QUrl serverUrl = Utils::urlFromLocalHostAndFreePort();
|
||||
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -267,8 +267,8 @@ void QmlProfilerClientManagerTest::testResponsiveLocal()
|
||||
|
||||
QUrl socketUrl = Utils::urlFromLocalSocket();
|
||||
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -320,9 +320,9 @@ void QmlProfilerClientManagerTest::testInvalidData()
|
||||
MessageHandler handler(&invalidHelloMessageHandler);
|
||||
Q_UNUSED(handler)
|
||||
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy failedSpy(&clientManager, SIGNAL(connectionFailed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
QSignalSpy failedSpy(&clientManager, &QmlProfilerClientManager::connectionFailed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
@@ -365,8 +365,8 @@ void QmlProfilerClientManagerTest::testStopRecording()
|
||||
QmlProfilerClientManager clientManager;
|
||||
clientManager.setRetryInterval(10);
|
||||
clientManager.setMaximumRetries(10);
|
||||
QSignalSpy openedSpy(&clientManager, SIGNAL(connectionOpened()));
|
||||
QSignalSpy closedSpy(&clientManager, SIGNAL(connectionClosed()));
|
||||
QSignalSpy openedSpy(&clientManager, &QmlProfilerClientManager::connectionOpened);
|
||||
QSignalSpy closedSpy(&clientManager, &QmlProfilerClientManager::connectionClosed);
|
||||
|
||||
QVERIFY(!clientManager.isConnected());
|
||||
|
||||
|
||||
@@ -57,9 +57,9 @@ void tst_PluginManager::init()
|
||||
m_pm = new PluginManager;
|
||||
PluginManager::setSettings(new Utils::QtcSettings);
|
||||
PluginManager::setPluginIID(QLatin1String("plugin"));
|
||||
m_objectAdded = new QSignalSpy(m_pm, SIGNAL(objectAdded(QObject*)));
|
||||
m_aboutToRemoveObject = new QSignalSpy(m_pm, SIGNAL(aboutToRemoveObject(QObject*)));
|
||||
m_pluginsChanged = new QSignalSpy(m_pm, SIGNAL(pluginsChanged()));
|
||||
m_objectAdded = new QSignalSpy(m_pm, &PluginManager::objectAdded);
|
||||
m_aboutToRemoveObject = new QSignalSpy(m_pm, &PluginManager::aboutToRemoveObject);
|
||||
m_pluginsChanged = new QSignalSpy(m_pm, &PluginManager::pluginsChanged);
|
||||
}
|
||||
|
||||
void tst_PluginManager::cleanup()
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace {
|
||||
QList<QTextCodec *>()
|
||||
<< QTextCodec::codecForLocale());
|
||||
QFutureWatcher<Utils::FileSearchResultList> watcher;
|
||||
QSignalSpy ready(&watcher, SIGNAL(resultsReadyAt(int,int)));
|
||||
QSignalSpy ready(&watcher, &QFutureWatcherBase::resultsReadyAt);
|
||||
if (regexp == tst_FileSearch::NoRegExp)
|
||||
watcher.setFuture(Utils::findInFiles(term, it, flags));
|
||||
else
|
||||
|
||||
@@ -36,7 +36,7 @@ void tst_TimelineAbstractRenderer::privateCtor()
|
||||
void tst_TimelineAbstractRenderer::selectionLocked()
|
||||
{
|
||||
TimelineAbstractRenderer renderer;
|
||||
QSignalSpy spy(&renderer, SIGNAL(selectionLockedChanged(bool)));
|
||||
QSignalSpy spy(&renderer, &TimelineAbstractRenderer::selectionLockedChanged);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
QVERIFY(renderer.selectionLocked());
|
||||
renderer.setSelectionLocked(false);
|
||||
@@ -50,7 +50,7 @@ void tst_TimelineAbstractRenderer::selectionLocked()
|
||||
void tst_TimelineAbstractRenderer::selectedItem()
|
||||
{
|
||||
TimelineAbstractRenderer renderer;
|
||||
QSignalSpy spy(&renderer, SIGNAL(selectedItemChanged(int)));
|
||||
QSignalSpy spy(&renderer, &TimelineAbstractRenderer::selectedItemChanged);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
QCOMPARE(renderer.selectedItem(), -1);
|
||||
renderer.setSelectedItem(12);
|
||||
@@ -62,7 +62,7 @@ void tst_TimelineAbstractRenderer::model()
|
||||
{
|
||||
TimelineAbstractRenderer renderer;
|
||||
TimelineModelAggregator aggregator;
|
||||
QSignalSpy spy(&renderer, SIGNAL(modelChanged(TimelineModel*)));
|
||||
QSignalSpy spy(&renderer, &TimelineAbstractRenderer::modelChanged);
|
||||
QVERIFY(!renderer.modelDirty());
|
||||
QCOMPARE(spy.count(), 0);
|
||||
TimelineModel model(&aggregator);
|
||||
@@ -80,7 +80,7 @@ void tst_TimelineAbstractRenderer::model()
|
||||
void tst_TimelineAbstractRenderer::notes()
|
||||
{
|
||||
TimelineAbstractRenderer renderer;
|
||||
QSignalSpy spy(&renderer, SIGNAL(notesChanged(TimelineNotesModel*)));
|
||||
QSignalSpy spy(&renderer, &TimelineAbstractRenderer::notesChanged);
|
||||
QVERIFY(!renderer.notesDirty());
|
||||
QCOMPARE(spy.count(), 0);
|
||||
TimelineNotesModel notes;
|
||||
@@ -98,7 +98,7 @@ void tst_TimelineAbstractRenderer::notes()
|
||||
void tst_TimelineAbstractRenderer::zoomer()
|
||||
{
|
||||
TimelineAbstractRenderer renderer;
|
||||
QSignalSpy spy(&renderer, SIGNAL(zoomerChanged(TimelineZoomControl*)));
|
||||
QSignalSpy spy(&renderer, &TimelineAbstractRenderer::zoomerChanged);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
TimelineZoomControl zoomer;
|
||||
QCOMPARE(renderer.zoomer(), static_cast<TimelineZoomControl *>(0));
|
||||
|
||||
@@ -6,17 +6,19 @@
|
||||
#include <tracing/timelinemodel_p.h>
|
||||
#include <tracing/timelinemodelaggregator.h>
|
||||
|
||||
using namespace Timeline;
|
||||
|
||||
static const int NumItems = 32;
|
||||
static const qint64 ItemDuration = 1 << 19;
|
||||
static const qint64 ItemSpacing = 1 << 20;
|
||||
|
||||
class DummyModel : public Timeline::TimelineModel
|
||||
class DummyModel : public TimelineModel
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class tst_TimelineModel;
|
||||
public:
|
||||
DummyModel(Timeline::TimelineModelAggregator *parent);
|
||||
DummyModel(QString displayName, Timeline::TimelineModelAggregator *parent);
|
||||
DummyModel(TimelineModelAggregator *parent);
|
||||
DummyModel(QString displayName, TimelineModelAggregator *parent);
|
||||
int expandedRow(int) const { return 2; }
|
||||
int collapsedRow(int) const { return 1; }
|
||||
|
||||
@@ -57,15 +59,15 @@ private slots:
|
||||
void parentingOfEqualStarts();
|
||||
|
||||
private:
|
||||
Timeline::TimelineModelAggregator aggregator;
|
||||
TimelineModelAggregator aggregator;
|
||||
};
|
||||
|
||||
DummyModel::DummyModel(Timeline::TimelineModelAggregator *parent) :
|
||||
Timeline::TimelineModel(parent)
|
||||
DummyModel::DummyModel(TimelineModelAggregator *parent) :
|
||||
TimelineModel(parent)
|
||||
{
|
||||
}
|
||||
|
||||
DummyModel::DummyModel(QString displayName, Timeline::TimelineModelAggregator *parent) :
|
||||
DummyModel::DummyModel(QString displayName, TimelineModelAggregator *parent) :
|
||||
TimelineModel(parent)
|
||||
{
|
||||
setDisplayName(displayName);
|
||||
@@ -90,7 +92,7 @@ void DummyModel::loadData()
|
||||
}
|
||||
|
||||
tst_TimelineModel::tst_TimelineModel() :
|
||||
DefaultRowHeight(Timeline::TimelineModel::defaultRowHeight())
|
||||
DefaultRowHeight(TimelineModel::defaultRowHeight())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -147,7 +149,7 @@ void tst_TimelineModel::rowHeight()
|
||||
QCOMPARE(dummy.rowHeight(0), 100);
|
||||
QCOMPARE(dummy.rowHeight(1), 50);
|
||||
|
||||
QSignalSpy expandedSpy(&dummy, SIGNAL(expandedRowHeightChanged(int,int)));
|
||||
QSignalSpy expandedSpy(&dummy, &TimelineModel::expandedRowHeightChanged);
|
||||
dummy.clear();
|
||||
QCOMPARE(expandedSpy.count(), 1);
|
||||
}
|
||||
@@ -194,7 +196,7 @@ void tst_TimelineModel::height()
|
||||
DummyModel dummy(&aggregator);
|
||||
int heightAfterLastSignal = 0;
|
||||
int heightChangedSignals = 0;
|
||||
connect(&dummy, &Timeline::TimelineModel::heightChanged, [&](){
|
||||
connect(&dummy, &TimelineModel::heightChanged, [&] {
|
||||
++heightChangedSignals;
|
||||
heightAfterLastSignal = dummy.height();
|
||||
});
|
||||
@@ -237,7 +239,7 @@ void tst_TimelineModel::count()
|
||||
QCOMPARE(dummy.count(), 0);
|
||||
dummy.loadData();
|
||||
QCOMPARE(dummy.count(), NumItems);
|
||||
QSignalSpy emptySpy(&dummy, SIGNAL(contentChanged()));
|
||||
QSignalSpy emptySpy(&dummy, &TimelineModel::contentChanged);
|
||||
dummy.clear();
|
||||
QCOMPARE(emptySpy.count(), 1);
|
||||
QCOMPARE(dummy.count(), 0);
|
||||
@@ -283,7 +285,7 @@ void tst_TimelineModel::firstLast()
|
||||
void tst_TimelineModel::expand()
|
||||
{
|
||||
DummyModel dummy(&aggregator);
|
||||
QSignalSpy spy(&dummy, SIGNAL(expandedChanged()));
|
||||
QSignalSpy spy(&dummy, &TimelineModel::expandedChanged);
|
||||
QVERIFY(!dummy.expanded());
|
||||
dummy.setExpanded(true);
|
||||
QVERIFY(dummy.expanded());
|
||||
@@ -302,7 +304,7 @@ void tst_TimelineModel::expand()
|
||||
void tst_TimelineModel::hide()
|
||||
{
|
||||
DummyModel dummy(&aggregator);
|
||||
QSignalSpy spy(&dummy, SIGNAL(hiddenChanged()));
|
||||
QSignalSpy spy(&dummy, &TimelineModel::hiddenChanged);
|
||||
QVERIFY(!dummy.hidden());
|
||||
dummy.setHidden(true);
|
||||
QVERIFY(dummy.hidden());
|
||||
@@ -322,7 +324,7 @@ void tst_TimelineModel::displayName()
|
||||
{
|
||||
QLatin1String name("testest");
|
||||
DummyModel dummy(name, &aggregator);
|
||||
QSignalSpy spy(&dummy, SIGNAL(displayNameChanged()));
|
||||
QSignalSpy spy(&dummy, &TimelineModel::displayNameChanged);
|
||||
QCOMPARE(dummy.displayName(), name);
|
||||
QCOMPARE(spy.count(), 0);
|
||||
dummy.setDisplayName(name);
|
||||
@@ -336,7 +338,7 @@ void tst_TimelineModel::displayName()
|
||||
|
||||
void tst_TimelineModel::defaultValues()
|
||||
{
|
||||
Timeline::TimelineModel dummy(&aggregator);
|
||||
TimelineModel dummy(&aggregator);
|
||||
QCOMPARE(dummy.location(0), QVariantMap());
|
||||
QCOMPARE(dummy.handlesTypeId(0), false);
|
||||
QCOMPARE(dummy.relativeHeight(0), 1.0);
|
||||
@@ -361,7 +363,7 @@ void tst_TimelineModel::row()
|
||||
|
||||
void tst_TimelineModel::colorByHue()
|
||||
{
|
||||
Timeline::TimelineModelAggregator aggregator;
|
||||
TimelineModelAggregator aggregator;
|
||||
DummyModel dummy(&aggregator);
|
||||
QCOMPARE(dummy.colorByHue(10), QColor::fromHsl(10, 150, 166).rgb());
|
||||
QCOMPARE(dummy.colorByHue(500), QColor::fromHsl(140, 150, 166).rgb());
|
||||
@@ -410,7 +412,7 @@ void tst_TimelineModel::insertStartEnd()
|
||||
void tst_TimelineModel::rowCount()
|
||||
{
|
||||
DummyModel dummy(&aggregator);
|
||||
QSignalSpy contentSpy(&dummy, SIGNAL(contentChanged()));
|
||||
QSignalSpy contentSpy(&dummy, &TimelineModel::contentChanged);
|
||||
QCOMPARE(dummy.rowCount(), 1);
|
||||
dummy.setExpanded(true);
|
||||
QCOMPARE(dummy.rowCount(), 1);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <QtTest>
|
||||
#include <tracing/timelinemodelaggregator.h>
|
||||
|
||||
using namespace Timeline;
|
||||
|
||||
class tst_TimelineModelAggregator : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -14,9 +16,9 @@ private slots:
|
||||
void prevNext();
|
||||
};
|
||||
|
||||
class HeightTestModel : public Timeline::TimelineModel {
|
||||
class HeightTestModel : public TimelineModel {
|
||||
public:
|
||||
HeightTestModel(Timeline::TimelineModelAggregator *parent) : TimelineModel(parent)
|
||||
HeightTestModel(TimelineModelAggregator *parent) : TimelineModel(parent)
|
||||
{
|
||||
insert(0, 1, 1);
|
||||
}
|
||||
@@ -24,11 +26,11 @@ public:
|
||||
|
||||
void tst_TimelineModelAggregator::height()
|
||||
{
|
||||
Timeline::TimelineModelAggregator aggregator;
|
||||
TimelineModelAggregator aggregator;
|
||||
QCOMPARE(aggregator.height(), 0);
|
||||
|
||||
QSignalSpy heightSpy(&aggregator, SIGNAL(heightChanged()));
|
||||
Timeline::TimelineModel *model = new Timeline::TimelineModel(&aggregator);
|
||||
QSignalSpy heightSpy(&aggregator, &TimelineModelAggregator::heightChanged);
|
||||
TimelineModel *model = new TimelineModel(&aggregator);
|
||||
aggregator.addModel(model);
|
||||
QCOMPARE(aggregator.height(), 0);
|
||||
QCOMPARE(heightSpy.count(), 0);
|
||||
@@ -42,15 +44,15 @@ void tst_TimelineModelAggregator::height()
|
||||
|
||||
void tst_TimelineModelAggregator::addRemoveModel()
|
||||
{
|
||||
Timeline::TimelineNotesModel notes;
|
||||
Timeline::TimelineModelAggregator aggregator;
|
||||
TimelineNotesModel notes;
|
||||
TimelineModelAggregator aggregator;
|
||||
aggregator.setNotes(¬es);
|
||||
QSignalSpy spy(&aggregator, SIGNAL(modelsChanged()));
|
||||
QSignalSpy spy(&aggregator, &TimelineModelAggregator::modelsChanged);
|
||||
|
||||
QCOMPARE(aggregator.notes(), ¬es);
|
||||
|
||||
Timeline::TimelineModel *model1 = new Timeline::TimelineModel(&aggregator);
|
||||
Timeline::TimelineModel *model2 = new Timeline::TimelineModel(&aggregator);
|
||||
TimelineModel *model1 = new TimelineModel(&aggregator);
|
||||
TimelineModel *model2 = new TimelineModel(&aggregator);
|
||||
aggregator.addModel(model1);
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(aggregator.modelCount(), 1);
|
||||
@@ -75,10 +77,10 @@ void tst_TimelineModelAggregator::addRemoveModel()
|
||||
QCOMPARE(aggregator.modelCount(), 0);
|
||||
}
|
||||
|
||||
class PrevNextTestModel : public Timeline::TimelineModel
|
||||
class PrevNextTestModel : public TimelineModel
|
||||
{
|
||||
public:
|
||||
PrevNextTestModel(Timeline::TimelineModelAggregator *parent) : TimelineModel(parent)
|
||||
PrevNextTestModel(TimelineModelAggregator *parent) : TimelineModel(parent)
|
||||
{
|
||||
for (int i = 0; i < 20; ++i)
|
||||
insert(i + modelId(), i * modelId(), modelId());
|
||||
@@ -87,14 +89,14 @@ public:
|
||||
|
||||
void tst_TimelineModelAggregator::prevNext()
|
||||
{
|
||||
Timeline::TimelineModelAggregator aggregator;
|
||||
TimelineModelAggregator aggregator;
|
||||
aggregator.generateModelId(); // start modelIds at 1
|
||||
aggregator.addModel(new PrevNextTestModel(&aggregator));
|
||||
aggregator.addModel(new PrevNextTestModel(&aggregator));
|
||||
aggregator.addModel(new PrevNextTestModel(&aggregator));
|
||||
|
||||
// Add an empty model to trigger the special code paths that skip it
|
||||
aggregator.addModel(new Timeline::TimelineModel(&aggregator));
|
||||
aggregator.addModel(new TimelineModel(&aggregator));
|
||||
QLatin1String item("item");
|
||||
QLatin1String model("model");
|
||||
QVariantMap result;
|
||||
|
||||
@@ -63,7 +63,7 @@ void tst_TimelineNotesModel::addRemove()
|
||||
TestModel model(&aggregator);
|
||||
notes.addTimelineModel(&model);
|
||||
|
||||
QSignalSpy spy(¬es, SIGNAL(changed(int,int,int)));
|
||||
QSignalSpy spy(¬es, &TestNotesModel::changed);
|
||||
int id = notes.add(model.modelId(), 0, QLatin1String("xyz"));
|
||||
QCOMPARE(spy.count(), 1);
|
||||
QCOMPARE(notes.isModified(), true);
|
||||
@@ -129,7 +129,7 @@ void tst_TimelineNotesModel::modify()
|
||||
TestNotesModel notes;
|
||||
TestModel model(&aggregator);
|
||||
notes.addTimelineModel(&model);
|
||||
QSignalSpy spy(¬es, SIGNAL(changed(int,int,int)));
|
||||
QSignalSpy spy(¬es, &TestNotesModel::changed);
|
||||
int id = notes.add(model.modelId(), 0, QLatin1String("a"));
|
||||
QCOMPARE(spy.count(), 1);
|
||||
notes.resetModified();
|
||||
|
||||
@@ -5,11 +5,13 @@
|
||||
#include <QColor>
|
||||
#include <tracing/timelinezoomcontrol.h>
|
||||
|
||||
using namespace Timeline;
|
||||
|
||||
class tst_TimelineZoomControl : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
void verifyWindow(const Timeline::TimelineZoomControl &zoomControl);
|
||||
void verifyWindow(const TimelineZoomControl &zoomControl);
|
||||
|
||||
private slots:
|
||||
void trace();
|
||||
@@ -18,7 +20,7 @@ private slots:
|
||||
void selection();
|
||||
};
|
||||
|
||||
void tst_TimelineZoomControl::verifyWindow(const Timeline::TimelineZoomControl &zoomControl)
|
||||
void tst_TimelineZoomControl::verifyWindow(const TimelineZoomControl &zoomControl)
|
||||
{
|
||||
QVERIFY(zoomControl.windowStart() <= zoomControl.rangeStart());
|
||||
QVERIFY(zoomControl.windowEnd() >= zoomControl.rangeEnd());
|
||||
@@ -28,8 +30,8 @@ void tst_TimelineZoomControl::verifyWindow(const Timeline::TimelineZoomControl &
|
||||
|
||||
void tst_TimelineZoomControl::trace()
|
||||
{
|
||||
Timeline::TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, SIGNAL(traceChanged(qint64,qint64)));
|
||||
TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, &TimelineZoomControl::traceChanged);
|
||||
QCOMPARE(zoomControl.traceStart(), -1);
|
||||
QCOMPARE(zoomControl.traceEnd(), -1);
|
||||
QCOMPARE(zoomControl.traceDuration(), 0);
|
||||
@@ -49,18 +51,18 @@ void tst_TimelineZoomControl::trace()
|
||||
|
||||
void tst_TimelineZoomControl::window()
|
||||
{
|
||||
Timeline::TimelineZoomControl zoomControl;
|
||||
TimelineZoomControl zoomControl;
|
||||
|
||||
QTimer timer;
|
||||
timer.setSingleShot(true);
|
||||
connect(&timer, &QTimer::timeout, [&](){
|
||||
connect(&timer, &QTimer::timeout, [&] {
|
||||
QVERIFY(zoomControl.windowLocked());
|
||||
zoomControl.setWindowLocked(false);
|
||||
});
|
||||
|
||||
int numWindowChanges = 0;
|
||||
|
||||
connect(&zoomControl, &Timeline::TimelineZoomControl::windowChanged,
|
||||
connect(&zoomControl, &TimelineZoomControl::windowChanged,
|
||||
[&](qint64, qint64) {
|
||||
verifyWindow(zoomControl);
|
||||
|
||||
@@ -98,8 +100,7 @@ void tst_TimelineZoomControl::window()
|
||||
zoomControl.setRange(152000, 152005); // move right
|
||||
|
||||
QMetaObject::Connection connection = connect(
|
||||
&zoomControl, &Timeline::TimelineZoomControl::windowMovingChanged,
|
||||
[&](bool moving) {
|
||||
&zoomControl, &TimelineZoomControl::windowMovingChanged, [&](bool moving) {
|
||||
if (moving)
|
||||
return;
|
||||
|
||||
@@ -129,7 +130,7 @@ void tst_TimelineZoomControl::window()
|
||||
disconnect(connection);
|
||||
|
||||
bool stopDetected = false;
|
||||
connect(&zoomControl, &Timeline::TimelineZoomControl::windowMovingChanged, [&](bool moving) {
|
||||
connect(&zoomControl, &TimelineZoomControl::windowMovingChanged, [&](bool moving) {
|
||||
if (!moving) {
|
||||
QCOMPARE(stopDetected, false);
|
||||
stopDetected = true;
|
||||
@@ -148,8 +149,8 @@ void tst_TimelineZoomControl::window()
|
||||
|
||||
void tst_TimelineZoomControl::range()
|
||||
{
|
||||
Timeline::TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, SIGNAL(rangeChanged(qint64,qint64)));
|
||||
TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, &TimelineZoomControl::rangeChanged);
|
||||
QCOMPARE(zoomControl.rangeStart(), -1);
|
||||
QCOMPARE(zoomControl.rangeEnd(), -1);
|
||||
QCOMPARE(zoomControl.rangeDuration(), 0);
|
||||
@@ -175,8 +176,8 @@ void tst_TimelineZoomControl::range()
|
||||
|
||||
void tst_TimelineZoomControl::selection()
|
||||
{
|
||||
Timeline::TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, SIGNAL(selectionChanged(qint64,qint64)));
|
||||
TimelineZoomControl zoomControl;
|
||||
QSignalSpy spy(&zoomControl, &TimelineZoomControl::selectionChanged);
|
||||
QCOMPARE(zoomControl.selectionStart(), -1);
|
||||
QCOMPARE(zoomControl.selectionEnd(), -1);
|
||||
QCOMPARE(zoomControl.selectionDuration(), 0);
|
||||
|
||||
Reference in New Issue
Block a user