on xenial help sign in
Use UbuntuTest.TestExtras.removeTimeConstraintsFromSwipeArea
d964917Albert Astals Cid
tests/utils/modules/Unity/Test/UnityTestCase.qml+2−1
@@ -18,6 +18,7 @@ import QtQuick 2.4
18import QtTest 1.0
18import QtTest 1.0
19import Ubuntu.Components 1.3
19import Ubuntu.Components 1.3
20import Unity.Test 0.1 as UT
20import Unity.Test 0.1 as UT
21+import Ubuntu.Test 1.0 as UbuntuTest
21
22
22TestCase {
23TestCase {
23 id: testCase
24 id: testCase
@@ -453,7 +454,7 @@ TestCase {
453 */
454 */
454 function removeTimeConstraintsFromSwipeAreas(item) {
455 function removeTimeConstraintsFromSwipeAreas(item) {
455 if (UT.Util.isInstanceOf(item, "UCSwipeArea")) {
456 if (UT.Util.isInstanceOf(item, "UCSwipeArea")) {
456− var privateSwipeArea = UT.Util.removeTimeConstraintsFromSwipeArea(item);
457+ UbuntuTest.TestExtras.removeTimeConstraintsFromSwipeArea(item);
457 } else {
458 } else {
458 for (var i in item.children) {
459 for (var i in item.children) {
459 removeTimeConstraintsFromSwipeAreas(item.children[i]);
460 removeTimeConstraintsFromSwipeAreas(item.children[i]);
tests/utils/modules/Unity/Test/testutil.cpp−11
@@ -72,17 +72,6 @@ TouchEventSequenceWrapper *TestUtil::touchEvent(QQuickItem *item)
72 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
72 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
73}
73}
74
74
75−void TestUtil::removeTimeConstraintsFromSwipeArea(QObject *object)
76−{
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− }
84−}
85−
86void TestUtil::ensureTargetWindow()
75void TestUtil::ensureTargetWindow()
87{
76{
88 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
77 if (!m_targetWindow && !QGuiApplication::topLevelWindows().isEmpty())
tests/utils/modules/Unity/Test/testutil.h−1
@@ -34,7 +34,6 @@ public:
34
34
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
35 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
36 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
36 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
37− Q_INVOKABLE void removeTimeConstraintsFromSwipeArea(QObject *object);
38
37
39private:
38private:
40 void ensureTargetWindow();
39 void ensureTargetWindow();