on xenial help sign in
depend on the metaobject classname instead on of the object name
commit7908b9b787a8e64b78d395599db09cb0b97702e4 authorAlbert Astals Cid <albert.astals@canonical.com> dateFri 11 Dec 2015, 12:09 (11 years ago) parent01b4aca
5 files changed+24−13
tests/plugins/Ubuntu/Gestures/tst_FloatingFlickable.cpp+7−4 tests/qmltests/Components/tst_DragHandle.cpp+7−3 tests/utils/modules/Unity/Test/UnityTestCase.qml+1−3 tests/utils/modules/Unity/Test/testutil.cpp+8−2 tests/utils/modules/Unity/Test/testutil.h+1−1
tests/plugins/Ubuntu/Gestures/tst_FloatingFlickable.cpp+7−4
@@ -61,10 +61,13 @@ void tst_FloatingFlickable::tapGoesThrough()
6161
6262static void removeTimeConstraints(QQuickItem *floatingFlickable)
6363{
64− QObject *swipeAreaPrivate = floatingFlickable->findChild<QObject*>("UCSwipeAreaPrivate");
65−
66− QMetaObject::invokeMethod(swipeAreaPrivate, "setMaxTime", Q_ARG(int, 60 * 60 * 1000));
67− QMetaObject::invokeMethod(swipeAreaPrivate, "setCompositionTime", Q_ARG(int, 0));
64+ auto children = floatingFlickable->findChildren<QObject*>();
65+ Q_FOREACH(QObject *child, children) {
66+ if (child->metaObject()->className() == QByteArray("UCSwipeAreaPrivate")) {
67+ QMetaObject::invokeMethod(child, "setMaxTime", Q_ARG(int, 60 * 60 * 1000));
68+ QMetaObject::invokeMethod(child, "setCompositionTime", Q_ARG(int, 0));
69+ }
70+ }
6871}
6972
7073void tst_FloatingFlickable::flickChangesContentX()
tests/qmltests/Components/tst_DragHandle.cpp+7−3
@@ -200,9 +200,13 @@ QQuickItem *tst_DragHandle::fetchAndSetupDragHandle(const char *objectName)
200200 QQuickItem *dragHandle =
201201 m_view->rootObject()->findChild<QQuickItem*>(objectName);
202202 Q_ASSERT(dragHandle != 0);
203− QObject *swipeAreaPrivate = dragHandle->findChild<QObject*>("UCSwipeAreaPrivate");
204− QMetaObject::invokeMethod(swipeAreaPrivate, "setRecognitionTimer", Q_ARG(UbuntuGestures::AbstractTimer*, m_fakeTimer));
205− QMetaObject::invokeMethod(swipeAreaPrivate, "setTimeSource", Q_ARG(UbuntuGestures::SharedTimeSource, m_fakeTimeSource));
203+ auto children = dragHandle->findChildren<QObject*>();
204+ Q_FOREACH(QObject *child, children) {
205+ if (child->metaObject()->className() == QByteArray("UCSwipeAreaPrivate")) {
206+ QMetaObject::invokeMethod(child, "setRecognitionTimer", Q_ARG(UbuntuGestures::AbstractTimer*, m_fakeTimer));
207+ QMetaObject::invokeMethod(child, "setTimeSource", Q_ARG(UbuntuGestures::SharedTimeSource, m_fakeTimeSource));
208+ }
209+ }
206210
207211 AxisVelocityCalculator *edgeDragEvaluator =
208212 dragHandle->findChild<AxisVelocityCalculator*>("edgeDragEvaluator");
tests/utils/modules/Unity/Test/UnityTestCase.qml+1−3
@@ -452,9 +452,7 @@ TestCase {
452452 */
453453 function removeTimeConstraintsFromSwipeAreas(item) {
454454 if (UT.Util.isInstanceOf(item, "UCSwipeArea")) {
455− var privateSwipeArea = UT.Util.findQObjectChild(item, "UCSwipeAreaPrivate");
456− privateSwipeArea.setMaxTime(60 * 60 * 1000);
457− privateSwipeArea.setCompositionTime(0);
455+ var privateSwipeArea = UT.Util.removeTimeConstraintsFromSwipeArea(item);
458456 } else {
459457 for (var i in item.children) {
460458 removeTimeConstraintsFromSwipeAreas(item.children[i]);
tests/utils/modules/Unity/Test/testutil.cpp+8−2
@@ -72,9 +72,15 @@ TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
7272 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
7373}
7474
75−QObject *TestUtil::findQObjectChild(QObject *object, const QString &objectName)
75+void TestUtil::removeTimeConstraintsFromSwipeArea(QObject *object)
7676{
77− return object->findChild<QObject*>(objectName);
77+ auto children = object->findChildren<QObject*>();
78+ Q_FOREACH(QObject *child, children) {
79+ if (child->metaObject()->className() == QByteArray("UCSwipeAreaPrivate")) {
80+ QMetaObject::invokeMethod(child, "setMaxTime", Q_ARG(int, 60 * 60 * 1000));
81+ QMetaObject::invokeMethod(child, "setCompositionTime", Q_ARG(int, 0));
82+ }
83+ }
7884}
7985
8086void TestUtil::ensureTargetWindow()
tests/utils/modules/Unity/Test/testutil.h+1−1
@@ -34,7 +34,7 @@ public:
3434
3535 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
3636 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
37− Q_INVOKABLE QObject *findQObjectChild(QObject *object, const QString &objectName);
37+ Q_INVOKABLE void removeTimeConstraintsFromSwipeArea(QObject *object);
3838
3939private:
4040 void ensureTargetWindow();