summaryrefslogtreecommitdiffstats
path: root/tests/auto/render/qscene2d
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2017-03-13 09:32:53 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2017-05-09 08:59:31 +0000
commit337bc59bb3a162d1a64b05d1dc82b5ec4b99049d (patch)
treebe59c1e4147cdb5b3d54a01ad00f2839108cd6aa /tests/auto/render/qscene2d
parent1178d7538bced76d1475b214cd591d86609239f3 (diff)
Scene2D cleanup - register pick events when scene is initialized
The current model where mouseGrab is connected to picker signal doesn't work. The pressed event is not sent to scene2d item, because it is already lost when scene2d gets the grabMouse message where it registers to the picker events. This breaks the mouse event sequence (press-move-release) for the quick item. Instead hook to setScene of the node to message scene2d when the scene gets initialized and always register to the picker events. Task-number: QTBUG-58876 Change-Id: Ic9ca4b0899a030336ef20ff2cffbe10b567c36f5 Reviewed-by: Antti Määttä <antti.maatta@qt.io>
Diffstat (limited to 'tests/auto/render/qscene2d')
-rw-r--r--tests/auto/render/qscene2d/tst_qscene2d.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/render/qscene2d/tst_qscene2d.cpp b/tests/auto/render/qscene2d/tst_qscene2d.cpp
index 61ac893e4..846207456 100644
--- a/tests/auto/render/qscene2d/tst_qscene2d.cpp
+++ b/tests/auto/render/qscene2d/tst_qscene2d.cpp
@@ -60,6 +60,7 @@ private Q_SLOTS:
QCOMPARE(scene2d.output(), nullptr);
QCOMPARE(scene2d.renderPolicy(), QScene2D::Continuous);
QCOMPARE(scene2d.item(), nullptr);
+ QCOMPARE(scene2d.isMouseEnabled(), true);
}
void checkPropertyChanges()
@@ -126,6 +127,26 @@ private Q_SLOTS:
QCOMPARE(scene2d.item(), newValue);
QCOMPARE(spy.count(), 0);
}
+
+ {
+ // WHEN
+ QSignalSpy spy(&scene2d, SIGNAL(mouseEnabledChanged(bool)));
+ bool newValue = false;
+ scene2d.setMouseEnabled(newValue);
+
+ // THEN
+ QVERIFY(spy.isValid());
+ QCOMPARE(scene2d.isMouseEnabled(), newValue);
+ QCOMPARE(spy.count(), 1);
+
+ // WHEN
+ spy.clear();
+ scene2d.setMouseEnabled(newValue);
+
+ // THEN
+ QCOMPARE(scene2d.isMouseEnabled(), newValue);
+ QCOMPARE(spy.count(), 0);
+ }
}
void checkCreationData()
@@ -159,6 +180,7 @@ private Q_SLOTS:
QCOMPARE(scene2d.isEnabled(), true);
QCOMPARE(scene2d.isEnabled(), creationChangeData->isNodeEnabled());
QCOMPARE(scene2d.metaObject(), creationChangeData->metaObject());
+ QCOMPARE(scene2d.isMouseEnabled(), cloneData.mouseEnabled);
}
// WHEN
@@ -254,6 +276,39 @@ private Q_SLOTS:
}
+ void checkMouseEnabledUpdate()
+ {
+ // GIVEN
+ TestArbiter arbiter;
+ Qt3DRender::Quick::QScene2D scene2d;
+ arbiter.setArbiterOnNode(&scene2d);
+
+ {
+ // WHEN
+ scene2d.setMouseEnabled(false);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 1);
+ auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "mouseEnabled");
+ QCOMPARE(change->value().toBool(), scene2d.isMouseEnabled());
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+
+ arbiter.events.clear();
+ }
+
+ {
+ // WHEN
+ scene2d.setMouseEnabled(false);
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ }
+
+ }
+
};
QTEST_MAIN(tst_QScene2D)