Move parts of QmlEvent and QmlEventType to timeline

Timeline will become a generic trace handling library. It needs some
abstract concept of events and event types.

Move operator== and operator!= for QmlEvent into the test as we don't
use them anywhere else.

Move the operators for QmlEventType to QmlProfilerTraceClient. We want
to get rid of the hash there as soon as we can assume that no
application we want to profile doesn't support server type IDs.

Change-Id: Icde4e3e7634e387171dc1d8bef7bbe8e71684a1a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Ulf Hermann
2018-03-27 17:39:17 +02:00
parent 5c8c208f26
commit 507c2d6b5b
13 changed files with 216 additions and 94 deletions

View File

@@ -40,7 +40,9 @@ HEADERS += \
$$PWD/timelineoverviewrenderer_p.h \ $$PWD/timelineoverviewrenderer_p.h \
$$PWD/timelineoverviewrenderer.h \ $$PWD/timelineoverviewrenderer.h \
$$PWD/timelinetheme.h \ $$PWD/timelinetheme.h \
$$PWD/timelineformattime.h $$PWD/timelineformattime.h \
$$PWD/traceevent.h \
$$PWD/traceeventtype.h
RESOURCES += \ RESOURCES += \
$$PWD/qml/timeline.qrc $$PWD/qml/timeline.qrc

View File

@@ -30,7 +30,8 @@ Project {
"timelinerenderstate.cpp", "timelinerenderstate.h", "timelinerenderstate_p.h", "timelinerenderstate.cpp", "timelinerenderstate.h", "timelinerenderstate_p.h",
"timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h", "timelineselectionrenderpass.cpp", "timelineselectionrenderpass.h",
"timelinetheme.cpp", "timelinetheme.h", "timelinetheme.cpp", "timelinetheme.h",
"timelinezoomcontrol.cpp", "timelinezoomcontrol.h" "timelinezoomcontrol.cpp", "timelinezoomcontrol.h",
"traceevent.h", "traceeventtype.h",
] ]
} }

View File

@@ -0,0 +1,61 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "timeline_global.h"
#include <QHash>
#include <QMetaType>
namespace Timeline {
class TIMELINE_EXPORT TraceEvent
{
public:
TraceEvent(qint64 timestamp = -1, qint32 typeIndex = -1)
: m_timestamp(timestamp), m_typeIndex(typeIndex)
{}
qint64 timestamp() const { return m_timestamp; }
void setTimestamp(qint64 timestamp) { m_timestamp = timestamp; }
qint32 typeIndex() const { return m_typeIndex; }
void setTypeIndex(qint32 typeIndex) { m_typeIndex = typeIndex; }
bool isValid() const { return m_typeIndex != -1; }
private:
qint64 m_timestamp;
qint32 m_typeIndex;
};
} // namespace Timeline
Q_DECLARE_METATYPE(Timeline::TraceEvent)
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(Timeline::TraceEvent, Q_MOVABLE_TYPE);
QT_END_NAMESPACE

View File

@@ -0,0 +1,60 @@
/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "timeline_global.h"
#include <QHash>
#include <QMetaType>
#include <QString>
namespace Timeline {
class TIMELINE_EXPORT TraceEventType
{
public:
TraceEventType(quint8 feature = 255, const QString &displayName = QString())
: m_displayName(displayName), m_feature(feature)
{}
const QString &displayName() const { return m_displayName; }
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
quint8 feature() const { return m_feature; }
void setFeature(quint8 feature) { m_feature = feature; }
private:
QString m_displayName;
quint8 m_feature;
};
} // namespace Timeline
Q_DECLARE_METATYPE(Timeline::TraceEventType)
QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(Timeline::TraceEventType, Q_MOVABLE_TYPE);
QT_END_NAMESPACE

View File

@@ -29,20 +29,6 @@
namespace QmlProfiler { namespace QmlProfiler {
bool operator==(const QmlEvent &event1, const QmlEvent &event2)
{
if (event1.timestamp() != event2.timestamp() || event1.typeIndex() != event2.typeIndex())
return false;
// This is not particularly efficient, but we also don't need to do this very often.
return event1.numbers<QVarLengthArray<qint64>>() == event2.numbers<QVarLengthArray<qint64>>();
}
bool operator!=(const QmlEvent &event1, const QmlEvent &event2)
{
return !(event1 == event2);
}
enum SerializationType { enum SerializationType {
OneByte = 0, OneByte = 0,
TwoByte = 1, TwoByte = 1,
@@ -100,8 +86,8 @@ QDataStream &operator>>(QDataStream &stream, QmlEvent &event)
qint8 type; qint8 type;
stream >> type; stream >> type;
event.m_timestamp = readNumber<qint64>(stream, (type >> TimestampOffset) & TypeMask); event.setTimestamp(readNumber<qint64>(stream, (type >> TimestampOffset) & TypeMask));
event.m_typeIndex = readNumber<qint32>(stream, (type >> TypeIndexOffset) & TypeMask); event.setTypeIndex(readNumber<qint32>(stream, (type >> TypeIndexOffset) & TypeMask));
event.m_dataLength = readNumber<qint16>(stream, (type >> DataLengthOffset) & TypeMask); event.m_dataLength = readNumber<qint16>(stream, (type >> DataLengthOffset) & TypeMask);
quint8 bytesPerNumber = 1 << ((type >> DataOffset) & TypeMask); quint8 bytesPerNumber = 1 << ((type >> DataOffset) & TypeMask);
@@ -224,14 +210,14 @@ static inline void writeNumber(QDataStream &stream, Number number, qint8 type)
QDataStream &operator<<(QDataStream &stream, const QmlEvent &event) QDataStream &operator<<(QDataStream &stream, const QmlEvent &event)
{ {
qint8 type = minimumType(event.m_timestamp) << TimestampOffset; qint8 type = minimumType(event.timestamp()) << TimestampOffset;
type |= minimumType(event.m_typeIndex) << TypeIndexOffset; type |= minimumType(event.typeIndex()) << TypeIndexOffset;
type |= minimumType(event.m_dataLength) << DataLengthOffset; type |= minimumType(event.m_dataLength) << DataLengthOffset;
type |= minimumType(event, event.m_dataLength, event.m_dataType) << DataOffset; type |= minimumType(event, event.m_dataLength, event.m_dataType) << DataOffset;
stream << type; stream << type;
writeNumber(stream, event.m_timestamp, (type >> TimestampOffset) & TypeMask); writeNumber(stream, event.timestamp(), (type >> TimestampOffset) & TypeMask);
writeNumber(stream, event.m_typeIndex, (type >> TypeIndexOffset) & TypeMask); writeNumber(stream, event.typeIndex(), (type >> TypeIndexOffset) & TypeMask);
writeNumber(stream, event.m_dataLength, (type >> DataLengthOffset) & TypeMask); writeNumber(stream, event.m_dataLength, (type >> DataLengthOffset) & TypeMask);
switch ((type >> DataOffset) & TypeMask) { switch ((type >> DataOffset) & TypeMask) {

View File

@@ -26,6 +26,8 @@
#include "qmlprofilereventtypes.h" #include "qmlprofilereventtypes.h"
#include <timeline/traceevent.h>
#include <QString> #include <QString>
#include <QByteArray> #include <QByteArray>
#include <QVarLengthArray> #include <QVarLengthArray>
@@ -36,32 +38,31 @@
namespace QmlProfiler { namespace QmlProfiler {
struct QmlEvent { struct QmlEvent : public Timeline::TraceEvent {
QmlEvent() : m_timestamp(-1), m_typeIndex(-1), m_dataType(Inline8Bit), m_dataLength(0) {} QmlEvent() : m_dataType(Inline8Bit), m_dataLength(0) {}
template<typename Number> template<typename Number>
QmlEvent(qint64 timestamp, int typeIndex, std::initializer_list<Number> list) QmlEvent(qint64 timestamp, int typeIndex, std::initializer_list<Number> list)
: m_timestamp(timestamp), m_typeIndex(typeIndex) : TraceEvent(timestamp, typeIndex)
{ {
assignNumbers<std::initializer_list<Number>, Number>(list); assignNumbers<std::initializer_list<Number>, Number>(list);
} }
QmlEvent(qint64 timestamp, int typeIndex, const QString &data) QmlEvent(qint64 timestamp, int typeIndex, const QString &data)
: m_timestamp(timestamp), m_typeIndex(typeIndex) : TraceEvent(timestamp, typeIndex)
{ {
assignNumbers<QByteArray, qint8>(data.toUtf8()); assignNumbers<QByteArray, qint8>(data.toUtf8());
} }
template<typename Number> template<typename Number>
QmlEvent(qint64 timestamp, int typeIndex, const QVector<Number> &data) QmlEvent(qint64 timestamp, int typeIndex, const QVector<Number> &data)
: m_timestamp(timestamp), m_typeIndex(typeIndex) : TraceEvent(timestamp, typeIndex)
{ {
assignNumbers<QVector<Number>, Number>(data); assignNumbers<QVector<Number>, Number>(data);
} }
QmlEvent(const QmlEvent &other) QmlEvent(const QmlEvent &other)
: m_timestamp(other.m_timestamp), m_typeIndex(other.m_typeIndex), : TraceEvent(other), m_dataType(other.m_dataType), m_dataLength(other.m_dataLength)
m_dataType(other.m_dataType), m_dataLength(other.m_dataLength)
{ {
assignData(other); assignData(other);
} }
@@ -76,8 +77,7 @@ struct QmlEvent {
{ {
if (this != &other) { if (this != &other) {
clearPointer(); clearPointer();
m_timestamp = other.m_timestamp; TraceEvent::operator=(other);
m_typeIndex = other.m_typeIndex;
m_dataType = other.m_dataType; m_dataType = other.m_dataType;
m_dataLength = other.m_dataLength; m_dataLength = other.m_dataLength;
assignData(other); assignData(other);
@@ -99,12 +99,6 @@ struct QmlEvent {
clearPointer(); clearPointer();
} }
qint64 timestamp() const { return m_timestamp; }
void setTimestamp(qint64 timestamp) { m_timestamp = timestamp; }
int typeIndex() const { return m_typeIndex; }
void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; }
template<typename Number> template<typename Number>
Number number(int i) const Number number(int i) const
{ {
@@ -203,11 +197,6 @@ struct QmlEvent {
m_data.internal8bit[0] = stage; m_data.internal8bit[0] = stage;
} }
bool isValid() const
{
return m_timestamp != -1;
}
private: private:
enum Type: quint16 { enum Type: quint16 {
External = 1, External = 1,
@@ -221,7 +210,8 @@ private:
External64Bit = Inline64Bit | External External64Bit = Inline64Bit | External
}; };
qint64 m_timestamp; Type m_dataType;
quint16 m_dataLength;
static const int s_internalDataLength = 8; static const int s_internalDataLength = 8;
union { union {
@@ -233,10 +223,6 @@ private:
qint64 internal64bit[s_internalDataLength / 8]; qint64 internal64bit[s_internalDataLength / 8];
} m_data; } m_data;
qint32 m_typeIndex;
Type m_dataType;
quint16 m_dataLength;
void assignData(const QmlEvent &other) void assignData(const QmlEvent &other)
{ {
if (m_dataType & External) { if (m_dataType & External) {
@@ -309,9 +295,6 @@ private:
friend QDataStream &operator<<(QDataStream &stream, const QmlEvent &event); friend QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
}; };
bool operator==(const QmlEvent &event1, const QmlEvent &event2);
bool operator!=(const QmlEvent &event1, const QmlEvent &event2);
QDataStream &operator>>(QDataStream &stream, QmlEvent &event); QDataStream &operator>>(QDataStream &stream, QmlEvent &event);
QDataStream &operator<<(QDataStream &stream, const QmlEvent &event); QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);

View File

@@ -32,8 +32,10 @@ QDataStream &operator>>(QDataStream &stream, QmlEventType &type)
{ {
quint8 message; quint8 message;
quint8 rangeType; quint8 rangeType;
stream >> type.m_displayName >> type.m_data >> type.m_location >> message >> rangeType QString displayName;
stream >> displayName >> type.m_data >> type.m_location >> message >> rangeType
>> type.m_detailType; >> type.m_detailType;
type.setDisplayName(displayName);
type.m_message = static_cast<Message>(message); type.m_message = static_cast<Message>(message);
type.m_rangeType = static_cast<RangeType>(rangeType); type.m_rangeType = static_cast<RangeType>(rangeType);
return stream; return stream;
@@ -41,16 +43,16 @@ QDataStream &operator>>(QDataStream &stream, QmlEventType &type)
QDataStream &operator<<(QDataStream &stream, const QmlEventType &type) QDataStream &operator<<(QDataStream &stream, const QmlEventType &type)
{ {
return stream << type.m_displayName << type.m_data << type.m_location return stream << type.displayName() << type.m_data << type.m_location
<< static_cast<quint8>(type.m_message) << static_cast<quint8>(type.m_rangeType) << static_cast<quint8>(type.m_message) << static_cast<quint8>(type.m_rangeType)
<< type.m_detailType; << type.m_detailType;
} }
ProfileFeature QmlEventType::feature() const static ProfileFeature qmlFeatureFromType(Message message, RangeType rangeType, int detailType)
{ {
switch (m_message) { switch (message) {
case Event: { case Event: {
switch (m_detailType) { switch (detailType) {
case Mouse: case Mouse:
case Key: case Key:
return ProfileInputEvents; return ProfileInputEvents;
@@ -69,9 +71,18 @@ ProfileFeature QmlEventType::feature() const
case DebugMessage: case DebugMessage:
return ProfileDebugMessages; return ProfileDebugMessages;
default: default:
return featureFromRangeType(m_rangeType); return featureFromRangeType(rangeType);
} }
} }
QmlEventType::QmlEventType(Message message, RangeType rangeType, int detailType,
const QmlEventLocation &location, const QString &data,
const QString displayName) :
TraceEventType(qmlFeatureFromType(message, rangeType, detailType)),
m_data(data), m_location(location), m_message(message),
m_rangeType(rangeType), m_detailType(detailType)
{
setDisplayName(displayName);
}
} // namespace QmlProfiler } // namespace QmlProfiler

View File

@@ -26,27 +26,24 @@
#include "qmleventlocation.h" #include "qmleventlocation.h"
#include "qmlprofilereventtypes.h" #include "qmlprofilereventtypes.h"
#include <timeline/traceeventtype.h>
#include <QString> #include <QString>
#include <QMetaType> #include <QMetaType>
#include <QHash> #include <QHash>
namespace QmlProfiler { namespace QmlProfiler {
class QmlEventType { class QmlEventType : public Timeline::TraceEventType {
public: public:
QmlEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType, QmlEventType(Message message = MaximumMessage, RangeType rangeType = MaximumRangeType,
int detailType = -1, const QmlEventLocation &location = QmlEventLocation(), int detailType = -1, const QmlEventLocation &location = QmlEventLocation(),
const QString &data = QString(), const QString displayName = QString()) : const QString &data = QString(), const QString displayName = QString());
m_displayName(displayName), m_data(data), m_location(location), m_message(message),
m_rangeType(rangeType), m_detailType(detailType)
{}
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
void setData(const QString &data) { m_data = data; } void setData(const QString &data) { m_data = data; }
void setLocation(const QmlEventLocation &location) { m_location = location; } void setLocation(const QmlEventLocation &location) { m_location = location; }
ProfileFeature feature() const;
QString displayName() const { return m_displayName; }
QString data() const { return m_data; } QString data() const { return m_data; }
QmlEventLocation location() const { return m_location; } QmlEventLocation location() const { return m_location; }
Message message() const { return m_message; } Message message() const { return m_message; }
@@ -57,7 +54,6 @@ private:
friend QDataStream &operator>>(QDataStream &stream, QmlEventType &type); friend QDataStream &operator>>(QDataStream &stream, QmlEventType &type);
friend QDataStream &operator<<(QDataStream &stream, const QmlEventType &type); friend QDataStream &operator<<(QDataStream &stream, const QmlEventType &type);
QString m_displayName;
QString m_data; QString m_data;
QmlEventLocation m_location; QmlEventLocation m_location;
Message m_message; Message m_message;
@@ -68,25 +64,6 @@ private:
QDataStream &operator>>(QDataStream &stream, QmlEventType &type); QDataStream &operator>>(QDataStream &stream, QmlEventType &type);
QDataStream &operator<<(QDataStream &stream, const QmlEventType &type); QDataStream &operator<<(QDataStream &stream, const QmlEventType &type);
inline uint qHash(const QmlEventType &type)
{
return qHash(type.location())
^ (((type.message() << 12) & 0xf000) // 4 bits of message
| ((type.rangeType() << 24) & 0xf000000) // 4 bits of rangeType
| ((type.detailType() << 28) & 0xf0000000)); // 4 bits of detailType
}
inline bool operator==(const QmlEventType &type1, const QmlEventType &type2)
{
return type1.message() == type2.message() && type1.rangeType() == type2.rangeType()
&& type1.detailType() == type2.detailType() && type1.location() == type2.location();
}
inline bool operator!=(const QmlEventType &type1, const QmlEventType &type2)
{
return !(type1 == type2);
}
} // namespace QmlProfiler } // namespace QmlProfiler
Q_DECLARE_METATYPE(QmlProfiler::QmlEventType) Q_DECLARE_METATYPE(QmlProfiler::QmlEventType)

View File

@@ -377,8 +377,10 @@ bool QmlProfilerModelManager::replayEvents(qint64 rangeStart, qint64 rangeEnd,
void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event, void QmlProfilerModelManager::QmlProfilerModelManagerPrivate::dispatch(const QmlEvent &event,
const QmlEventType &type) const QmlEventType &type)
{ {
for (const EventLoader &loader : eventLoaders.value(type.feature())) for (const EventLoader &loader : eventLoaders.value(
static_cast<ProfileFeature>(type.feature()))) {
loader(event, type); loader(event, type);
}
++numLoadedEvents; ++numLoadedEvents;
} }

View File

@@ -36,6 +36,25 @@
namespace QmlProfiler { namespace QmlProfiler {
inline uint qHash(const QmlEventType &type)
{
return qHash(type.location())
^ (((type.message() << 12) & 0xf000) // 4 bits of message
| ((type.rangeType() << 24) & 0xf000000) // 4 bits of rangeType
| ((type.detailType() << 28) & 0xf0000000)); // 4 bits of detailType
}
inline bool operator==(const QmlEventType &type1, const QmlEventType &type2)
{
return type1.message() == type2.message() && type1.rangeType() == type2.rangeType()
&& type1.detailType() == type2.detailType() && type1.location() == type2.location();
}
inline bool operator!=(const QmlEventType &type1, const QmlEventType &type2)
{
return !(type1 == type2);
}
class QmlProfilerTraceClientPrivate { class QmlProfilerTraceClientPrivate {
public: public:
QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *q, QmlProfilerTraceClientPrivate(QmlProfilerTraceClient *q,
@@ -53,7 +72,7 @@ public:
} }
void sendRecordingStatus(int engineId); void sendRecordingStatus(int engineId);
bool updateFeatures(ProfileFeature feature); bool updateFeatures(quint8 feature);
int resolveType(const QmlTypedEvent &type); int resolveType(const QmlTypedEvent &type);
int resolveStackTop(); int resolveStackTop();
void forwardEvents(const QmlEvent &last); void forwardEvents(const QmlEvent &last);
@@ -321,7 +340,7 @@ void QmlProfilerTraceClient::setFlushInterval(quint32 flushInterval)
d->flushInterval = flushInterval; d->flushInterval = flushInterval;
} }
bool QmlProfilerTraceClientPrivate::updateFeatures(ProfileFeature feature) bool QmlProfilerTraceClientPrivate::updateFeatures(quint8 feature)
{ {
quint64 flag = 1ULL << feature; quint64 flag = 1ULL << feature;
if (!(requestedFeatures & flag)) if (!(requestedFeatures & flag))

View File

@@ -400,7 +400,7 @@ void QmlProfilerFileReader::loadEventTypes(QXmlStreamReader &stream)
QmlEventType type(messageAndRange.first, messageAndRange.second, detailType, QmlEventType type(messageAndRange.first, messageAndRange.second, detailType,
QmlEventLocation(filename, line, column), data, displayName); QmlEventLocation(filename, line, column), data, displayName);
m_eventTypes[typeIndex] = type; m_eventTypes[typeIndex] = type;
ProfileFeature feature = type.feature(); quint8 feature = type.feature();
if (feature != MaximumProfileFeature) if (feature != MaximumProfileFeature)
m_loadedFeatures |= (1ULL << static_cast<uint>(feature)); m_loadedFeatures |= (1ULL << static_cast<uint>(feature));
} }

View File

@@ -31,6 +31,21 @@
#include <cstring> #include <cstring>
namespace QmlProfiler { namespace QmlProfiler {
static inline bool operator==(const QmlEvent &event1, const QmlEvent &event2)
{
if (event1.timestamp() != event2.timestamp() || event1.typeIndex() != event2.typeIndex())
return false;
// This is not particularly efficient, but we also don't need to do this very often.
return event1.numbers<QVarLengthArray<qint64>>() == event2.numbers<QVarLengthArray<qint64>>();
}
static inline bool operator!=(const QmlEvent &event1, const QmlEvent &event2)
{
return !(event1 == event2);
}
namespace Internal { namespace Internal {
QmlEventTest::QmlEventTest(QObject *parent) : QObject(parent) QmlEventTest::QmlEventTest(QObject *parent) : QObject(parent)

View File

@@ -43,7 +43,7 @@ void QmlEventTypeTest::testAccessors()
QVERIFY(!type.location().isValid()); QVERIFY(!type.location().isValid());
QVERIFY(type.data().isEmpty()); QVERIFY(type.data().isEmpty());
QVERIFY(type.displayName().isEmpty()); QVERIFY(type.displayName().isEmpty());
QCOMPARE(type.feature(), MaximumProfileFeature); QCOMPARE(static_cast<ProfileFeature>(type.feature()), MaximumProfileFeature);
type.setLocation(QmlEventLocation("blah.js", 12, 13)); type.setLocation(QmlEventLocation("blah.js", 12, 13));
QCOMPARE(type.location().filename(), QString("blah.js")); QCOMPARE(type.location().filename(), QString("blah.js"));
@@ -64,12 +64,12 @@ void QmlEventTypeTest::testAccessors()
QCOMPARE(type2.location(), QmlEventLocation("lala.js", 2, 3)); QCOMPARE(type2.location(), QmlEventLocation("lala.js", 2, 3));
QCOMPARE(type2.data(), QString("nehhh")); QCOMPARE(type2.data(), QString("nehhh"));
QCOMPARE(type2.displayName(), QString("brbr")); QCOMPARE(type2.displayName(), QString("brbr"));
QCOMPARE(type2.feature(), ProfileJavaScript); QCOMPARE(static_cast<ProfileFeature>(type2.feature()), ProfileJavaScript);
} }
void QmlEventTypeTest::testFeature() void QmlEventTypeTest::testFeature()
{ {
const ProfileFeature features[][MaximumEventType] = { const quint8 features[][MaximumEventType] = {
// Event // Event
{MaximumProfileFeature, ProfileInputEvents, ProfileInputEvents, {MaximumProfileFeature, ProfileInputEvents, ProfileInputEvents,
ProfileAnimations, MaximumProfileFeature, MaximumProfileFeature}, ProfileAnimations, MaximumProfileFeature, MaximumProfileFeature},
@@ -111,7 +111,8 @@ void QmlEventTypeTest::testFeature()
for (int i = 0; i < MaximumRangeType; ++i) { for (int i = 0; i < MaximumRangeType; ++i) {
QmlEventType type(MaximumMessage, static_cast<RangeType>(i)); QmlEventType type(MaximumMessage, static_cast<RangeType>(i));
QCOMPARE(type.feature(), featureFromRangeType(static_cast<RangeType>(i))); QCOMPARE(static_cast<ProfileFeature>(type.feature()),
featureFromRangeType(static_cast<RangeType>(i)));
} }
} }
@@ -131,10 +132,14 @@ void QmlEventTypeTest::testStreamOps()
QDataStream rstream(&rbuffer); QDataStream rstream(&rbuffer);
QmlEventType type2; QmlEventType type2;
QVERIFY(type != type2); QVERIFY(type.rangeType() != type2.rangeType());
rstream >> type2; rstream >> type2;
QCOMPARE(type2, type); QCOMPARE(type.message(), type2.message());
QCOMPARE(type.rangeType(), type2.rangeType());
QCOMPARE(type.detailType(), type2.detailType());
QCOMPARE(type.location(), type2.location());
} }
} // namespace Internal } // namespace Internal