forked from qt-creator/qt-creator
QmlProfiler: Accept unknown input events
We might get more event types in the future and filtering them is harder than just displaying them. Also, traces might contain invalid input events which would trigger the assert. Change-Id: I9b38422af953ebb65363fc2b7a91facb7f757976 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
This commit is contained in:
@@ -126,7 +126,7 @@ QVariantMap InputEventsModel::details(int index) const
|
||||
type = tr("Mouse Event");
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
type = tr("Unknown");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,11 @@
|
||||
namespace QmlProfiler {
|
||||
namespace Internal {
|
||||
|
||||
static InputEventType inputType(int i)
|
||||
{
|
||||
return static_cast<InputEventType>(i % (MaximumInputEventType + 1));
|
||||
}
|
||||
|
||||
InputEventsModelTest::InputEventsModelTest(QObject *parent) :
|
||||
QObject(parent), manager(nullptr), model(&manager)
|
||||
{
|
||||
@@ -48,13 +53,14 @@ void InputEventsModelTest::initTestCase()
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
event.setTimestamp(i);
|
||||
InputEventType type = static_cast<InputEventType>(i % MaximumInputEventType);
|
||||
InputEventType type = inputType(i);
|
||||
event.setTypeIndex(type <= InputKeyUnknown ? keyTypeId : mouseTypeId);
|
||||
event.setNumbers({static_cast<qint32>(type),
|
||||
(i * 32) % 256,
|
||||
static_cast<qint32>((i * 0x02000000) & Qt::KeyboardModifierMask)});
|
||||
manager.addEvent(event);
|
||||
}
|
||||
|
||||
manager.acquiringDone();
|
||||
QCOMPARE(manager.state(), QmlProfilerModelManager::Done);
|
||||
}
|
||||
@@ -71,7 +77,7 @@ void InputEventsModelTest::testAccepted()
|
||||
void InputEventsModelTest::testTypeId()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
InputEventType type = static_cast<InputEventType>(i % MaximumInputEventType);
|
||||
InputEventType type = inputType(i);
|
||||
QCOMPARE(model.typeId(i), type <= InputKeyUnknown ? keyTypeId : mouseTypeId);
|
||||
}
|
||||
}
|
||||
@@ -81,7 +87,7 @@ void InputEventsModelTest::testColor()
|
||||
QRgb keyColor = 0;
|
||||
QRgb mouseColor = 0;
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
InputEventType type = static_cast<InputEventType>(i % MaximumInputEventType);
|
||||
InputEventType type = inputType(i);
|
||||
int selectionId = (type <= InputKeyUnknown ? Key : Mouse);
|
||||
QCOMPARE(selectionId, model.selectionId(i));
|
||||
|
||||
@@ -112,7 +118,7 @@ void InputEventsModelTest::testDetails()
|
||||
QCOMPARE(details[model.tr("Timestamp")].toString(), Timeline::formatTime(i));
|
||||
QString displayName = details[QString("displayName")].toString();
|
||||
QVERIFY(!displayName.isEmpty());
|
||||
switch (static_cast<InputEventType>(i % MaximumInputEventType)) {
|
||||
switch (inputType(i)) {
|
||||
case InputKeyPress:
|
||||
QCOMPARE(displayName, model.tr("Key Press"));
|
||||
if (i == 0) {
|
||||
@@ -177,7 +183,7 @@ void InputEventsModelTest::testDetails()
|
||||
QVERIFY(!details.contains(model.tr("Result")));
|
||||
break;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
QCOMPARE(displayName, model.tr("Unknown"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -186,7 +192,7 @@ void InputEventsModelTest::testDetails()
|
||||
void InputEventsModelTest::testExpandedRow()
|
||||
{
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
InputEventType type = static_cast<InputEventType>(i % MaximumInputEventType);
|
||||
InputEventType type = inputType(i);
|
||||
QCOMPARE(model.expandedRow(i), (type <= InputKeyUnknown ? 2 : 1));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user