Commit 5dd25c42 authored by Ulf Hermann's avatar Ulf Hermann

QmlProfiler: Move event handling into model manager

This is the logical place to do it. Adding the event first to the QML
model and then passing it back to the manager in order to have it
dispatched to the other models is somewhat backwards.

Change-Id: I64b1cb38f97331b62d83fa5ae49b9b2690810d40
Reviewed-by: Christian Kandeler's avatarChristian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Ulf Hermann's avatarUlf Hermann <ulf.hermann@qt.io>
parent 00d424ea
......@@ -202,9 +202,8 @@ void QmlProfilerClientManager::createConnection()
// false by default (will be set to true when connected)
m_profilerState->setServerRecording(false);
m_profilerState->setRecordedFeatures(0);
m_qmlclientplugin.reset(new QmlProfilerTraceClient(m_connection.data(),
m_modelManager->qmlModel(),
m_profilerState->requestedFeatures()));
m_qmlclientplugin.reset(new QmlProfilerTraceClient(m_connection.data(), m_modelManager,
m_profilerState->requestedFeatures()));
m_qmlclientplugin->setFlushInterval(m_flushInterval);
connectClientSignals();
}
......
......@@ -117,41 +117,46 @@ QmlProfilerDataModel::~QmlProfilerDataModel()
delete d;
}
const QmlEventType &QmlProfilerDataModel::eventType(int typeId) const
{
Q_D(const QmlProfilerDataModel);
return d->eventTypes.at(typeId);
}
const QVector<QmlEventType> &QmlProfilerDataModel::eventTypes() const
{
Q_D(const QmlProfilerDataModel);
return d->eventTypes;
}
void QmlProfilerDataModel::setEventTypes(const QVector<QmlEventType> &types)
void QmlProfilerDataModel::addEventTypes(const QVector<QmlEventType> &types)
{
Q_D(QmlProfilerDataModel);
d->eventTypes = types;
int typeIndex = d->eventTypes.length();
d->eventTypes.append(types);
for (const int end = d->eventTypes.length(); typeIndex < end; ++typeIndex)
d->rewriteType(typeIndex);
}
int QmlProfilerDataModel::addEventType(const QmlEventType &type)
void QmlProfilerDataModel::addEventType(const QmlEventType &type)
{
Q_D(QmlProfilerDataModel);
int typeIndex = d->eventTypes.length();
d->eventTypes.append(type);
d->rewriteType(typeIndex);
return typeIndex;
}
void QmlProfilerDataModel::addEvent(const QmlEvent &event)
{
Q_D(QmlProfilerDataModel);
d->modelManager->dispatch(event, d->eventTypes[event.typeIndex()]);
d->eventStream << event;
}
void QmlProfilerDataModel::addEvents(const QVector<QmlEvent> &events)
{
Q_D(QmlProfilerDataModel);
for (const QmlEvent &event : events) {
d->modelManager->dispatch(event, d->eventTypes[event.typeIndex()]);
for (const QmlEvent &event : events)
d->eventStream << event;
}
}
void QmlProfilerDataModel::clear()
......
......@@ -43,9 +43,10 @@ public:
QmlProfilerModelManager *parent);
~QmlProfilerDataModel();
const QmlEventType &eventType(int typeId) const;
const QVector<QmlEventType> &eventTypes() const;
void setEventTypes(const QVector<QmlEventType> &types);
int addEventType(const QmlEventType &type);
void addEventTypes(const QVector<QmlEventType> &types);
void addEventType(const QmlEventType &type);
void clear();
bool isEmpty() const;
......
......@@ -153,6 +153,8 @@ public:
QHash<ProfileFeature, QVector<EventLoader> > eventLoaders;
QVector<Finalizer> finalizers;
void dispatch(const QmlEvent &event, const QmlEventType &type);
};
......@@ -204,6 +206,11 @@ uint QmlProfilerModelManager::numLoadedEvents() const
return d->numLoadedEvents;
}
uint QmlProfilerModelManager::numLoadedEventTypes() const
{
return d->model->eventTypes().count();
}
int QmlProfilerModelManager::registerModelProxy()
{
return d->numRegisteredModels++;
......@@ -219,11 +226,36 @@ int QmlProfilerModelManager::numRegisteredFinalizers() const
return d->finalizers.count();
}
void QmlProfilerModelManager::dispatch(const QmlEvent &event, const QmlEventType &type)
void QmlProfilerModelManager::addEvents(const QVector<QmlEvent> &events)
{
d->model->addEvents(events);
const QVector<QmlEventType> &types = d->model->eventTypes();
for (const QmlEvent &event : events)
d->dispatch(event, types[event.typeIndex()]);
}
void QmlProfilerModelManager::addEvent(const QmlEvent &event)
{
d->model->addEvent(event);
d->dispatch(event, d->model->eventType(event.typeIndex()));
}
void QmlProfilerModelManager::addEventTypes(const QVector<QmlEventType> &types)
{
d->model->addEventTypes(types);
}
void QmlProfilerModelManager::addEventType(const QmlEventType &type)
{
d->model->addEventType(type);
}
void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event,
const QmlEventType &type)
{
foreach (const EventLoader &loader, d->eventLoaders[type.feature()])
foreach (const EventLoader &loader, eventLoaders[type.feature()])
loader(event, type);
++d->numLoadedEvents;
++numLoadedEvents;
}
void QmlProfilerModelManager::announceFeatures(quint64 features, EventLoader eventLoader,
......@@ -373,13 +405,13 @@ void QmlProfilerModelManager::load(const QString &filename)
}, Qt::QueuedConnection);
connect(reader, &QmlProfilerFileReader::typesLoaded,
d->model, &QmlProfilerDataModel::setEventTypes);
this, &QmlProfilerModelManager::addEventTypes);
connect(reader, &QmlProfilerFileReader::notesLoaded,
d->notesModel, &QmlProfilerNotesModel::setNotes);
connect(reader, &QmlProfilerFileReader::qmlEventsLoaded,
d->model, &QmlProfilerDataModel::addEvents);
this, &QmlProfilerModelManager::addEvents);
connect(reader, &QmlProfilerFileReader::success, this, [this, reader]() {
d->traceTime->setTime(reader->traceStart(), reader->traceEnd());
......@@ -464,7 +496,7 @@ void QmlProfilerModelManager::restrictToRange(qint64 startTime, qint64 endTime)
startAcquiring();
d->model->replayEvents(startTime, endTime,
std::bind(&QmlProfilerModelManager::dispatch, this,
std::bind(&QmlProfilerModelManagerPrivate::dispatch, d,
std::placeholders::_1, std::placeholders::_2));
d->notesModel->setNotes(notes);
d->traceTime->restrictToRange(startTime, endTime);
......
......@@ -100,6 +100,7 @@ public:
bool isEmpty() const;
uint numLoadedEvents() const;
uint numLoadedEventTypes() const;
int registerModelProxy();
void announceFeatures(quint64 features, EventLoader eventLoader, Finalizer finalizer);
......@@ -107,7 +108,11 @@ public:
int numFinishedFinalizers() const;
int numRegisteredFinalizers() const;
void dispatch(const QmlEvent &event, const QmlEventType &type);
void addEvents(const QVector<QmlEvent> &events);
void addEvent(const QmlEvent &event);
void addEventTypes(const QVector<QmlEventType> &types);
void addEventType(const QmlEventType &type);
quint64 availableFeatures() const;
quint64 visibleFeatures() const;
......
......@@ -38,11 +38,12 @@ namespace QmlProfiler {
class QmlProfilerTraceClientPrivate {
public:
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *_q, QmlDebug::QmlDebugConnection *client,
QmlProfilerDataModel *model)
: q(_q)
, model(model)
, engineControl(client)
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *q,
QmlDebug::QmlDebugConnection *connection,
QmlProfilerModelManager *modelManager)
: q(q)
, modelManager(modelManager)
, engineControl(connection)
, maximumTime(0)
, recording(false)
, requestedFeatures(0)
......@@ -58,7 +59,7 @@ public:
void processCurrentEvent();
QmlProfilerTraceClient *q;
QmlProfilerDataModel *model;
QmlProfilerModelManager *modelManager;
QmlDebug::QmlEngineControlClient engineControl;
QScopedPointer<QmlDebug::QDebugMessageClient> messageClient;
qint64 maximumTime;
......@@ -84,7 +85,8 @@ int QmlProfilerTraceClientPrivate::resolveType(const QmlTypedEvent &event)
if (it != serverTypeIds.constEnd()) {
typeIndex = it.value();
} else {
typeIndex = model->addEventType(event.type);
typeIndex = modelManager->numLoadedEventTypes();
modelManager->addEventType(event.type);
serverTypeIds[event.serverTypeId] = typeIndex;
}
} else {
......@@ -93,7 +95,8 @@ int QmlProfilerTraceClientPrivate::resolveType(const QmlTypedEvent &event)
if (it != eventTypeIds.constEnd()) {
typeIndex = it.value();
} else {
typeIndex = model->addEventType(event.type);
typeIndex = modelManager->numLoadedEventTypes();
modelManager->addEventType(event.type);
eventTypeIds[event.type] = typeIndex;
}
}
......@@ -114,9 +117,9 @@ int QmlProfilerTraceClientPrivate::resolveStackTop()
typedEvent.event.setTypeIndex(typeIndex);
while (!pendingMessages.isEmpty()
&& pendingMessages.head().timestamp() < typedEvent.event.timestamp()) {
model->addEvent(pendingMessages.dequeue());
modelManager->addEvent(pendingMessages.dequeue());
}
model->addEvent(typedEvent.event);
modelManager->addEvent(typedEvent.event);
return typeIndex;
}
......@@ -138,8 +141,8 @@ void QmlProfilerTraceClientPrivate::processCurrentEvent()
QTC_ASSERT(typeIndex != -1, break);
currentEvent.event.setTypeIndex(typeIndex);
while (!pendingMessages.isEmpty())
model->addEvent(pendingMessages.dequeue());
model->addEvent(currentEvent.event);
modelManager->addEvent(pendingMessages.dequeue());
modelManager->addEvent(currentEvent.event);
rangesInProgress.pop();
break;
}
......@@ -153,7 +156,7 @@ void QmlProfilerTraceClientPrivate::processCurrentEvent()
int typeIndex = resolveType(currentEvent);
currentEvent.event.setTypeIndex(typeIndex);
if (rangesInProgress.isEmpty())
model->addEvent(currentEvent.event);
modelManager->addEvent(currentEvent.event);
else
pendingMessages.enqueue(currentEvent.event);
break;
......@@ -173,10 +176,10 @@ void QmlProfilerTraceClientPrivate::sendRecordingStatus(int engineId)
}
QmlProfilerTraceClient::QmlProfilerTraceClient(QmlDebug::QmlDebugConnection *client,
QmlProfilerDataModel *model,
QmlProfilerModelManager *modelManager,
quint64 features)
: QmlDebugClient(QLatin1String("CanvasFrameRate"), client)
, d(new QmlProfilerTraceClientPrivate(this, client, model))
, d(new QmlProfilerTraceClientPrivate(this, client, modelManager))
{
setRequestedFeatures(features);
connect(&d->engineControl, &QmlDebug::QmlEngineControlClient::engineAboutToBeAdded,
......
......@@ -37,14 +37,15 @@
namespace QmlProfiler {
class QmlProfilerDataModel;
class QmlProfilerModelManager;
class QmlProfilerTraceClient : public QmlDebug::QmlDebugClient
{
Q_OBJECT
Q_PROPERTY(bool recording READ isRecording WRITE setRecording NOTIFY recordingChanged)
public:
QmlProfilerTraceClient(QmlDebug::QmlDebugConnection *client, QmlProfilerDataModel *model,
QmlProfilerTraceClient(QmlDebug::QmlDebugConnection *client,
QmlProfilerModelManager *modelManager,
quint64 features);
~QmlProfilerTraceClient();
......
......@@ -48,8 +48,9 @@ void DebugMessagesModelTest::initTestCase()
event.setString(QString::fromLatin1("message %1").arg(i));
QmlEventType type(DebugMessage, MaximumRangeType, i % (QtMsgType::QtInfoMsg + 1),
QmlEventLocation("somefile.js", i, 10 - i));
event.setTypeIndex(manager.qmlModel()->addEventType(type));
manager.qmlModel()->addEvent(event);
event.setTypeIndex(manager.numLoadedEventTypes());
manager.addEventType(type);
manager.addEvent(event);
}
manager.acquiringDone();
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
......
......@@ -57,30 +57,31 @@ int FlameGraphModelTest::generateData(QmlProfilerModelManager *manager)
QmlEventType type(MaximumMessage,
static_cast<RangeType>(static_cast<int>(Javascript) - i),
-1, QmlEventLocation("somefile.js", i, 20 - i), QString("funcfunc"));
typeIndex = manager->qmlModel()->addEventType(type);
typeIndex = manager->numLoadedEventTypes();
manager->addEventType(type);
} else {
typeIndex = typeIndices[i - 5];
}
event.setTypeIndex(typeIndex);
event.setTimestamp(++i);
event.setRangeStage(RangeStart);
manager->qmlModel()->addEvent(event);
manager->addEvent(event);
typeIndices.push(typeIndex);
}
event.setRangeStage(RangeEnd);
event.setTimestamp(++i);
manager->qmlModel()->addEvent(event);
manager->addEvent(event);
event.setRangeStage(RangeStart);
event.setTimestamp(++i);
manager->qmlModel()->addEvent(event);
manager->addEvent(event);
for (int j = 0; !typeIndices.isEmpty(); ++j) {
event.setTimestamp(i + j);
event.setRangeStage(RangeEnd);
event.setTypeIndex(typeIndices.pop());
manager->qmlModel()->addEvent(event);
manager->addEvent(event);
}
manager->acquiringDone();
......
......@@ -35,8 +35,10 @@ namespace Internal {
InputEventsModelTest::InputEventsModelTest(QObject *parent) :
QObject(parent), manager(nullptr), model(&manager)
{
keyTypeId = manager.qmlModel()->addEventType(QmlEventType(Event, MaximumRangeType, Key));
mouseTypeId = manager.qmlModel()->addEventType(QmlEventType(Event, MaximumRangeType, Mouse));
keyTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(Event, MaximumRangeType, Key));
mouseTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(Event, MaximumRangeType, Mouse));
}
void InputEventsModelTest::initTestCase()
......@@ -51,7 +53,7 @@ void InputEventsModelTest::initTestCase()
event.setNumbers({static_cast<qint32>(type),
(i * 32) % 256,
static_cast<qint32>((i * 0x02000000) & Qt::KeyboardModifierMask)});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
}
manager.acquiringDone();
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
......
......@@ -40,60 +40,61 @@ void MemoryUsageModelTest::initTestCase()
qint64 timestamp = 0;
heapPageTypeId = manager.qmlModel()->addEventType(
QmlEventType(MemoryAllocation, MaximumRangeType, HeapPage));
smallItemTypeId = manager.qmlModel()->addEventType(
QmlEventType(MemoryAllocation, MaximumRangeType, SmallItem));
largeItemTypeId = manager.qmlModel()->addEventType(
QmlEventType(MemoryAllocation, MaximumRangeType, LargeItem));
heapPageTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(MemoryAllocation, MaximumRangeType, HeapPage));
smallItemTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(MemoryAllocation, MaximumRangeType, SmallItem));
largeItemTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(MemoryAllocation, MaximumRangeType, LargeItem));
auto addMemoryEvents = [&]() {
QmlEvent event;
event.setTimestamp(++timestamp);
event.setTypeIndex(heapPageTypeId);
event.setNumbers({2048});
manager.qmlModel()->addEvent(event);
manager.qmlModel()->addEvent(event); // allocate two of them and make the model summarize
manager.addEvent(event);
manager.addEvent(event); // allocate two of them and make the model summarize
event.setTimestamp(++timestamp);
event.setTypeIndex(smallItemTypeId);
event.setNumbers({32});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
event.setTimestamp(++timestamp);
event.setTypeIndex(largeItemTypeId);
event.setNumbers({1024});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
event.setTimestamp(++timestamp);
event.setTypeIndex(smallItemTypeId);
event.setNumbers({-32});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
};
addMemoryEvents();
rangeTypeId = manager.qmlModel()->addEventType(
QmlEventType(MaximumMessage, Javascript, -1,
QmlEventLocation(QString("somefile.js"), 10, 20),
QString("funcfunc")));
rangeTypeId = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(MaximumMessage, Javascript, -1,
QmlEventLocation(QString("somefile.js"), 10, 20),
QString("funcfunc")));
QmlEvent event;
event.setRangeStage(RangeStart);
event.setTimestamp(++timestamp);
event.setTypeIndex(rangeTypeId);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
addMemoryEvents();
addMemoryEvents(); // twice to also trigger summary in first row
event.setRangeStage(RangeEnd);
event.setTimestamp(++timestamp);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
event.setTimestamp(++timestamp);
event.setTypeIndex(largeItemTypeId);
event.setNumbers({-1024});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
manager.acquiringDone();
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
......
......@@ -41,9 +41,9 @@ void PixmapCacheModelTest::initTestCase()
manager.traceTime()->setTime(1, 300);
for (int i = 0; i < MaximumPixmapEventType; ++i) {
eventTypeIndices[i] = manager.qmlModel()->addEventType(
QmlEventType(PixmapCacheEvent, MaximumRangeType, i,
QmlEventLocation("dings.png", 0, 0)));
eventTypeIndices[i] = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(PixmapCacheEvent, MaximumRangeType, i,
QmlEventLocation("dings.png", 0, 0)));
}
// random data, should still result in consistent model.
......@@ -52,13 +52,13 @@ void PixmapCacheModelTest::initTestCase()
event.setTypeIndex(eventTypeIndices[(i * 13) % MaximumPixmapEventType]);
event.setTimestamp(i);
event.setNumbers({i + 1, i - 1, i * 2});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
}
for (int i = 0; i < MaximumPixmapEventType; ++i) {
eventTypeIndices[i + MaximumPixmapEventType] = manager.qmlModel()->addEventType(
QmlEventType(PixmapCacheEvent, MaximumRangeType, i,
QmlEventLocation("blah.png", 0, 0)));
eventTypeIndices[i + MaximumPixmapEventType] = manager.numLoadedEventTypes();
manager.addEventType(QmlEventType(PixmapCacheEvent, MaximumRangeType, i,
QmlEventLocation("blah.png", 0, 0)));
}
......@@ -67,27 +67,27 @@ void PixmapCacheModelTest::initTestCase()
QmlEvent event;
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingStarted]);
event.setTimestamp(101);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapCacheCountChanged]);
event.setNumbers({0, 0, 200}); // cache count increase
event.setTimestamp(102);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::ToBeCached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingError]);
event.setTimestamp(103);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Corrupt);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Error);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapCacheCountChanged]);
event.setNumbers({0, 0, 199}); // cache count decrease
event.setTimestamp(104);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncacheable);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Error);
......@@ -96,13 +96,13 @@ void PixmapCacheModelTest::initTestCase()
QCOMPARE(model.count(), nextItem);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingStarted]);
event.setTimestamp(105);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingError]);
event.setTimestamp(106);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncacheable);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Error);
......@@ -111,7 +111,7 @@ void PixmapCacheModelTest::initTestCase()
// This way we get a corrupt cache entry ...
event.setNumbers({0, 0, 200});
event.setTimestamp(107);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem - 1), PixmapCacheModel::Corrupt);
QCOMPARE(model.loadState(nextItem - 1), PixmapCacheModel::Error);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncacheable);
......@@ -121,7 +121,7 @@ void PixmapCacheModelTest::initTestCase()
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapCacheCountChanged]);
event.setNumbers({0, 0, 199}); // cache count decrease, removes the corrupt entry
event.setTimestamp(108);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem - 1), PixmapCacheModel::Uncacheable);
QCOMPARE(model.loadState(nextItem - 1), PixmapCacheModel::Error);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncacheable);
......@@ -132,28 +132,28 @@ void PixmapCacheModelTest::initTestCase()
QCOMPARE(model.count(), nextItem);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingStarted]);
event.setTimestamp(109);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapCacheCountChanged]);
event.setNumbers({0, 0, 200}); // cache count increase
event.setTimestamp(110);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::ToBeCached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapSizeKnown]);
event.setNumbers({50, 50});
event.setTimestamp(111);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Cached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapCacheCountChanged]);
event.setNumbers({0, 0, 199}); // cache count decrease
event.setTimestamp(112);
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncached);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Loading);
......@@ -162,13 +162,13 @@ void PixmapCacheModelTest::initTestCase()
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapSizeKnown]);
event.setNumbers({20, 30});
event.setTimestamp(113);
manager.qmlModel()->addEvent(event); // Results in Uncached, with valid size
manager.addEvent(event); // Results in Uncached, with valid size
QCOMPARE(model.count(), nextItem + 3); // no item added here; we just store the size
event.setTypeIndex(eventTypeIndices[MaximumPixmapEventType + PixmapLoadingError]);
event.setTimestamp(114);
// terminates the still loading item, adding another cache count change
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
QCOMPARE(model.count(), nextItem + 4);
QCOMPARE(model.cacheState(nextItem), PixmapCacheModel::Uncacheable);
QCOMPARE(model.loadState(nextItem), PixmapCacheModel::Error);
......@@ -181,7 +181,7 @@ void PixmapCacheModelTest::initTestCase()
event.setTypeIndex(eventTypeIndices[i]);
event.setTimestamp(i + j + 200);
event.setNumbers({i + 1, i - 1, i - j});
manager.qmlModel()->addEvent(event);
manager.addEvent(event);
}
}
......
......@@ -46,12 +46,13 @@ void QmlProfilerAnimationsModelTest::initTestCase()