Merge lp:~zsombi/ubuntu-ui-toolkit/asyncAPL into lp:ubuntu-ui-toolkit/staging

Proposed by Zsombor Egri
Status: Superseded
Proposed branch: lp:~zsombi/ubuntu-ui-toolkit/asyncAPL
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 821 lines (+164/-194)
9 files modified
components.api (+1/-0)
src/Ubuntu/Components/1.3/AdaptivePageLayout.qml (+12/-7)
src/Ubuntu/Components/plugin/plugin.cpp (+1/-1)
src/Ubuntu/Components/plugin/ucabstractbutton.cpp (+2/-2)
src/Ubuntu/Components/plugin/uchaptics.cpp (+6/-4)
src/Ubuntu/Components/plugin/uchaptics.h (+19/-13)
tests/unit_x11/tst_components/tst_adaptivepagelayout.qml (+19/-0)
tests/unit_x11/tst_inversemousearea/OverlappedMouseArea.qml (+1/-0)
tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp (+103/-167)
To merge this branch: bzr merge lp:~zsombi/ubuntu-ui-toolkit/asyncAPL
Reviewer Review Type Date Requested Status
ubuntu-sdk-build-bot continuous-integration Needs Fixing
Cris Dywan Needs Fixing
Review via email: mp+285609@code.launchpad.net

This proposal has been superseded by a proposal from 2016-02-11.

Commit message

Introduce AdaptivePageLayout.asynchronous to the API.

To post a comment you must log in.
Revision history for this message
Andrea Bernabei (faenil) wrote :

just a tiny comment

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

- property color highlightColor: theme.palette.highlight.baseText
69 + property color highlightColor: theme.palette.highlighted.baseText

Rogue change?

Other than that, looks good to me.

review: Needs Fixing
1840. By Zsombor Egri

review comments applied

Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
ubuntu-sdk-build-bot (ubuntu-sdk-build-bot) wrote :
review: Needs Fixing (continuous-integration)
1841. By Zsombor Egri

prereq sync

1842. By Zsombor Egri

staging sync

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'components.api'
2--- components.api 2016-02-08 12:03:42 +0000
3+++ components.api 2016-02-11 09:09:01 +0000
4@@ -83,6 +83,7 @@
5 property bool onScreen
6 property bool running
7 Ubuntu.Components.AdaptivePageLayout 1.3: PageTreeNode
8+ property bool asynchronous
9 readonly property int columns
10 property list<PageColumnsLayou> layouts
11 function var addPageToCurrentColumn(var sourcePage, var page, var properties)
12
13=== modified file 'src/Ubuntu/Components/1.3/AdaptivePageLayout.qml'
14--- src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2016-02-08 13:55:17 +0000
15+++ src/Ubuntu/Components/1.3/AdaptivePageLayout.qml 2016-02-11 09:09:01 +0000
16@@ -201,13 +201,17 @@
17 /*!
18 The property specifies the source of the primaryPage in case the primary
19 page is created from a Component or loaded from an external document. It
20- has precedence over \l primaryPage. The page specified in this way will
21- be cerated asynchronously and the instance will be reported through
22- \l primaryPage property.
23+ has precedence over \l primaryPage.
24 */
25 property var primaryPageSource
26
27 /*!
28+ The property drives the way the pages should be loaded, synchronously or
29+ asynchronously. Defaults to true.
30+ */
31+ property bool asynchronous: true
32+
33+ /*!
34 \qmlproperty int columns
35 \readonly
36 The property holds the number of columns shown in the layout.
37@@ -229,9 +233,10 @@
38 is created. \c sourcePage must be active.
39
40 The function creates the new page asynchronously if the new \c page to be
41- added is a Component or a QML document. In this case the function returns
42- an incubator which can be used to track the page creation.For more about
43- incubation in QML and creating components asynchronously, see
44+ added is a Component or a QML document and the \l asynchronous property is
45+ set to true. In this case the function returns an incubator which can be
46+ used to track the page creation. For more about incubation in QML and creating
47+ components asynchronously, see
48 \l {http://doc.qt.io/qt-5/qml-qtqml-component.html#incubateObject-method}
49 {Component.incubateObject()}.
50 The following example removes an element from the list model whenever the
51@@ -441,7 +446,7 @@
52 }
53
54 function createWrapper(page, properties) {
55- var wrapperObject = pageWrapperComponent.createObject(hiddenPages, {synchronous: false});
56+ var wrapperObject = pageWrapperComponent.createObject(hiddenPages, {synchronous: !layout.asynchronous});
57 wrapperObject.pageStack = layout;
58 wrapperObject.properties = properties;
59 // set reference last because it will trigger creation of the object
60
61=== modified file 'src/Ubuntu/Components/plugin/plugin.cpp'
62--- src/Ubuntu/Components/plugin/plugin.cpp 2016-02-08 12:47:32 +0000
63+++ src/Ubuntu/Components/plugin/plugin.cpp 2016-02-11 09:09:01 +0000
64@@ -306,7 +306,7 @@
65 // allocate all context property objects prior we register them
66 initializeContextProperties(engine);
67
68- HapticsProxy::instance().setEngine(engine);
69+ HapticsProxy::instance(engine);
70
71 engine->addImageProvider(QLatin1String("scaling"), new UCScalingImageProvider);
72
73
74=== modified file 'src/Ubuntu/Components/plugin/ucabstractbutton.cpp'
75--- src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2016-01-20 12:55:18 +0000
76+++ src/Ubuntu/Components/plugin/ucabstractbutton.cpp 2016-02-11 09:09:01 +0000
77@@ -95,7 +95,7 @@
78 UCActionItem::classBegin();
79
80 // make sure we have the haptics set up!
81- HapticsProxy::instance().initialize();
82+ HapticsProxy::instance()->initialize();
83
84 // set up mouse area
85 Q_D(UCAbstractButton);
86@@ -144,7 +144,7 @@
87 return;
88 }
89 // play haptics
90- HapticsProxy::instance().play(QVariant());
91+ HapticsProxy::instance()->play(QVariant());
92 onClicked();
93 }
94
95
96=== modified file 'src/Ubuntu/Components/plugin/uchaptics.cpp'
97--- src/Ubuntu/Components/plugin/uchaptics.cpp 2015-08-21 08:39:21 +0000
98+++ src/Ubuntu/Components/plugin/uchaptics.cpp 2016-02-11 09:09:01 +0000
99@@ -84,7 +84,7 @@
100 UCHaptics::UCHaptics(QObject *parent)
101 : QObject(parent)
102 {
103- connect(&HapticsProxy::instance(), &HapticsProxy::enabledChanged,
104+ connect(HapticsProxy::instance(), &HapticsProxy::enabledChanged,
105 this, &UCHaptics::enabledChanged);
106 }
107
108@@ -95,7 +95,7 @@
109 */
110 bool UCHaptics::enabled() const
111 {
112- return HapticsProxy::instance().enabled();
113+ return HapticsProxy::instance()->enabled();
114 }
115
116 /*!
117@@ -109,7 +109,7 @@
118 */
119 QObject *UCHaptics::effect() const
120 {
121- return HapticsProxy::instance().effect();
122+ return HapticsProxy::instance()->effect();
123 }
124
125 /*!
126@@ -130,12 +130,14 @@
127 */
128 void UCHaptics::play(const QVariant &customEffect)
129 {
130- HapticsProxy::instance().play(customEffect);
131+ HapticsProxy::instance()->play(customEffect);
132 }
133
134 /*********************************************************
135 * Proxy implementation
136 */
137+HapticsProxy *HapticsProxy::m_instance = nullptr;
138+
139 bool HapticsProxy::enabled()
140 {
141 initialize();
142
143=== modified file 'src/Ubuntu/Components/plugin/uchaptics.h'
144--- src/Ubuntu/Components/plugin/uchaptics.h 2015-08-20 08:10:44 +0000
145+++ src/Ubuntu/Components/plugin/uchaptics.h 2016-02-11 09:09:01 +0000
146@@ -19,6 +19,7 @@
147
148 #include <QtCore/QObject>
149 #include <QtCore/QVariant>
150+#include <QtQml/QQmlEngine>
151
152 class UCHaptics : public QObject
153 {
154@@ -46,19 +47,23 @@
155 explicit HapticsProxy(QObject *parent = 0)
156 : QObject(parent)
157 , m_proxyObject(Q_NULLPTR)
158- , m_engine(Q_NULLPTR)
159- {
160- }
161-
162- static HapticsProxy &instance()
163- {
164- static HapticsProxy instance;
165- return instance;
166- }
167-
168- void setEngine(QQmlEngine *engine)
169- {
170- m_engine = engine;
171+ , m_engine(static_cast<QQmlEngine*>(parent))
172+ {
173+ if (!m_engine) {
174+ qFatal("HaptixProxy must be a child of the QML Engine!");
175+ }
176+ }
177+ ~HapticsProxy()
178+ {
179+ m_instance = Q_NULLPTR;
180+ }
181+
182+ static HapticsProxy *instance(QQmlEngine *engine = Q_NULLPTR)
183+ {
184+ if (!m_instance) {
185+ m_instance = new HapticsProxy(engine);
186+ }
187+ return m_instance;
188 }
189
190 void initialize();
191@@ -71,6 +76,7 @@
192 void enabledChanged();
193
194 private:
195+ static HapticsProxy *m_instance;
196 QObject *m_proxyObject;
197 QQmlEngine *m_engine;
198 };
199
200=== modified file 'tests/unit_x11/tst_components/tst_adaptivepagelayout.qml'
201--- tests/unit_x11/tst_components/tst_adaptivepagelayout.qml 2016-01-18 17:06:47 +0000
202+++ tests/unit_x11/tst_components/tst_adaptivepagelayout.qml 2016-02-11 09:09:01 +0000
203@@ -160,6 +160,7 @@
204 compare(defaults.primaryPageSource, undefined, "primaryPageSource not set by default");
205 compare(defaults.layouts.length, 0, "no layouts by default");
206 compare(defaults.columns, columns, columns + " column(s) as default");
207+ compare(defaults.asynchronous, true, "default page loading is asynchronous");
208
209 verify(page1.active, "Page1 is not active but should be! Bug(1535241)");
210 verify(!page2.active, "Page2 is active but should not be! Bug(1535241)");
211@@ -290,6 +291,24 @@
212 }
213 }
214
215+ function test_forced_synchronous_loading_bug1540449_data() {
216+ return [
217+ {tag: "To current column", func: "addPageToCurrentColumn", page: pageComponent, expectedTitle: "DynamicPage"},
218+ {tag: "To next column", func: "addPageToNextColumn", page: pageComponent, expectedTitle: "DynamicPage"},
219+ ];
220+ }
221+ function test_forced_synchronous_loading_bug1540449(data) {
222+ layout[data.func](layout.primaryPage, data.page);
223+ waitForRendering(layout, 400);
224+
225+ var wrapper = getPageWrapper(layout, layout.primaryPage);
226+ verify(wrapper);
227+ var testColumn = MathUtils.clamp(wrapper.column + (data.func == "addPageToCurrentColumn" ? 0 : 1),
228+ 0, layout.columns - 1);
229+ var testHolder = getColumnHolder(layout, testColumn);
230+ compare(testHolder.pageWrapper.object.title, data.expectedTitle, "page not found");
231+ }
232+
233 function test_asynchronous_page_loading_incubator_forcecompletion() {
234 var incubator = layout.addPageToCurrentColumn(layout.primaryPage, pageComponent);
235 verify(incubator, "Page added synchronously!");
236
237=== modified file 'tests/unit_x11/tst_inversemousearea/OverlappedMouseArea.qml'
238--- tests/unit_x11/tst_inversemousearea/OverlappedMouseArea.qml 2015-03-03 13:20:06 +0000
239+++ tests/unit_x11/tst_inversemousearea/OverlappedMouseArea.qml 2016-02-11 09:09:01 +0000
240@@ -31,6 +31,7 @@
241 }
242
243 InverseMouseArea {
244+ objectName: "testObject"
245 anchors.fill: nil
246 onClicked: {
247 color.color = "red"
248
249=== modified file 'tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp'
250--- tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2016-01-30 10:51:22 +0000
251+++ tests/unit_x11/tst_inversemousearea/tst_inversemouseareatest.cpp 2016-02-11 09:09:01 +0000
252@@ -23,6 +23,7 @@
253 #include <QtCore/QEvent>
254
255 #include "uctestextras.h"
256+#include "uctestcase.h"
257 #include "inversemouseareatype.h"
258 #include "ucunits.h"
259 #include <private/qquickevents_p_p.h>
260@@ -31,48 +32,31 @@
261
262 using QTest::QTouchEventSequence;
263
264+class InverseMouseAreaTest : public UbuntuTestCase
265+{
266+ Q_OBJECT
267+public:
268+ InverseMouseAreaTest(const QString& file)
269+ : UbuntuTestCase(file)
270+ {
271+ setGeometry(0, 0, 240, 320);
272+ //add modules folder so we have access to the plugin from QML
273+ QStringList imports = engine()->importPathList();
274+ imports.prepend(QDir(UBUNTU_QML_IMPORT_PATH).absolutePath());
275+ engine()->setImportPathList(imports);
276+ }
277+};
278+
279 class tst_InverseMouseAreaTest : public QObject
280 {
281 Q_OBJECT
282
283 public:
284- tst_InverseMouseAreaTest() :
285- quickView(0), quickEngine(0), device(0)
286- {}
287+ tst_InverseMouseAreaTest() {}
288
289 private:
290- QQuickView *quickView;
291- QQmlEngine *quickEngine;
292- QTouchDevice *device;
293 QObjectCleanupHandler eventCleanup;
294
295- InverseMouseAreaType *testArea(const QString &document, const QString &imaName = QString())
296- {
297- // delete previous root
298- QObject *rootObject = quickView->rootObject();
299- if (rootObject)
300- delete rootObject;
301- QTest::waitForEvents();
302-
303- quickView->setSource(QUrl::fromLocalFile(document));
304- QCoreApplication::processEvents();
305-
306- rootObject = quickView->rootObject();
307- if (!rootObject)
308- return 0;
309-
310- if (!imaName.isEmpty()) {
311- return rootObject->findChild<InverseMouseAreaType*>(imaName);
312- }
313- QList<QQuickItem*> items = rootObject->findChildren<QQuickItem*>();
314- Q_FOREACH(QQuickItem *item, items) {
315- InverseMouseAreaType *area = qobject_cast<InverseMouseAreaType*>(item);
316- if (area)
317- return area;
318- }
319- return 0;
320- }
321-
322 QPoint guPoint(qreal guX, qreal guY)
323 {
324 return QPointF(UCUnits::instance()->gu(guX), UCUnits::instance()->gu(guY)).toPoint();
325@@ -92,26 +76,12 @@
326 UCTestExtras::registerTouchDevice();
327 QString modules(UBUNTU_QML_IMPORT_PATH);
328 QVERIFY(QDir(modules).exists());
329-
330- quickView = new QQuickView(0);
331- quickEngine = quickView->engine();
332-
333- quickView->setGeometry(0,0, 240, 320);
334- //add modules folder so we have access to the plugin from QML
335- QStringList imports = quickEngine->importPathList();
336- imports << QDir(modules).absolutePath();
337- quickEngine->setImportPathList(imports);
338- }
339-
340- void cleanupTestCase()
341- {
342- delete quickView;
343 }
344
345 void testCase_Defaults()
346 {
347- InverseMouseAreaType *area = testArea("Defaults.qml");
348- QVERIFY(area);
349+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("Defaults.qml"));
350+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("testItem");
351
352 QCOMPARE(area->pressed(), false);
353 QCOMPARE(area->acceptedButtons(), Qt::LeftButton);
354@@ -121,11 +91,12 @@
355 void testCase_DoNotPropagateEvents()
356 {
357 eventCleanup.clear();
358- InverseMouseAreaType *area = testArea("InverseMouseAreaDoNotPropagateEvents.qml");
359- QVERIFY(area);
360+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaDoNotPropagateEvents.qml"));
361+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("testObject");
362+
363 // connect pressed signal to capture mouse object
364 QObject::connect(area, SIGNAL(pressed(QQuickMouseEvent*)), this, SLOT(capturePressed(QQuickMouseEvent*)));
365- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
366+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
367 QTest::waitForEvents();
368 QVERIFY(eventCleanup.isEmpty());
369 }
370@@ -133,37 +104,34 @@
371 void testCase_PropagateEvents()
372 {
373 eventCleanup.clear();
374- InverseMouseAreaType *area = testArea("InverseMouseAreaPropagateEvents.qml");
375- QVERIFY(area);
376+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaPropagateEvents.qml"));
377+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("testObject");
378+
379 // connect pressed signal to capture mouse object
380 QObject::connect(area, SIGNAL(pressed(QQuickMouseEvent*)), this, SLOT(capturePressed(QQuickMouseEvent*)));
381- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
382+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(10, 10));
383 QTest::waitForEvents();
384 QVERIFY(eventCleanup.isEmpty());
385 }
386
387 void testCase_sensingAreaError()
388 {
389- InverseMouseAreaType *area = testArea("SensingAreaError.qml");
390- QVERIFY(area);
391+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("SensingAreaError.qml"));
392
393- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(20, 20));
394+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(20, 20));
395 QTest::waitForEvents();
396 QCOMPARE(quickView->rootObject()->property("log").toString(), QString("IMA"));
397 }
398
399 void testCase_InverseMouseAreInWindow()
400 {
401- InverseMouseAreaType *area = testArea("InverseMouseAreaInWindow.qml");
402- QVERIFY(area);
403- quickView->show();
404- QTest::qWaitForWindowExposed(quickView);
405+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaInWindow.qml"));
406
407 QList<QQuickWindow *> l = quickView->rootObject()->findChildren<QQuickWindow*>("isawindow");
408 QVERIFY(l.count());
409
410- QQuickItem *clickArea = quickView->rootObject()->findChild<QQuickItem*>("clickArea");
411- QVERIFY(clickArea);
412+ // make sure we have the clickArea present
413+ quickView->findItem<QQuickItem*>("clickArea");
414
415 QTest::mouseClick(l[0], Qt::LeftButton, 0, QPoint(20, 10));
416 QTest::waitForEvents();
417@@ -172,33 +140,27 @@
418
419 void testCase_OverlappedMouseArea()
420 {
421- InverseMouseAreaType *area = testArea("OverlappedMouseArea.qml");
422- QVERIFY(area);
423- quickView->show();
424+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("OverlappedMouseArea.qml"));
425
426- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(20, 10));
427+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(20, 10));
428 QTest::waitForEvents();
429 QCOMPARE(quickView->rootObject()->property("log").toString(), QString("MA"));
430 }
431
432 void testCase_InverseMouseAreaOnTop()
433 {
434- InverseMouseAreaType *area = testArea("InverseMouseAreaOnTop.qml");
435- QVERIFY(area);
436- quickView->show();
437- QTest::qWaitForWindowExposed(quickView);
438+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaOnTop.qml"));
439+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("IMA");
440
441- QQuickItem *ma1 = quickView->rootObject()->findChild<QQuickItem*>("MA1");
442- QVERIFY(ma1);
443- QQuickItem *ma2 = quickView->rootObject()->findChild<QQuickItem*>("MA2");
444- QVERIFY(ma2);
445+ QQuickItem *ma1 = quickView->findItem<QQuickItem*>("MA1");
446+ QQuickItem *ma2 = quickView->findItem<QQuickItem*>("MA2");
447
448 QSignalSpy imaSpy(area, SIGNAL(pressed(QQuickMouseEvent*)));
449 QSignalSpy ma1Spy(ma1, SIGNAL(pressed(QQuickMouseEvent*)));
450 QSignalSpy ma2Spy(ma2, SIGNAL(pressed(QQuickMouseEvent*)));
451
452 // click in the top rectangle, use 800msec delay to prevent dblclick detection
453- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
454+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
455 QTest::waitForEvents();
456 QCOMPARE(ma1Spy.count(), 0);
457 QCOMPARE(ma2Spy.count(), 0);
458@@ -206,7 +168,7 @@
459 imaSpy.clear();
460
461 // click in the second rectangle, use 800msec delay to prevent dblclick detection
462- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
463+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
464 QTest::waitForEvents();
465 QCOMPARE(ma1Spy.count(), 0);
466 QCOMPARE(ma2Spy.count(), 0);
467@@ -214,7 +176,7 @@
468 imaSpy.clear();
469
470 // click in the button, use 800msec delay to prevent dblclick detection
471- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(25, 85), DOUBLECLICK_TIMEOUT);
472+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(25, 85), DOUBLECLICK_TIMEOUT);
473 QTest::waitForEvents();
474 QCOMPARE(ma1Spy.count(), 0);
475 QCOMPARE(ma2Spy.count(), 1);
476@@ -222,14 +184,14 @@
477
478 // double click in the second rectangle
479 QSignalSpy imaDSpy(area, SIGNAL(doubleClicked(QQuickMouseEvent*)));
480- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 65));
481+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65));
482 QTest::waitForEvents();
483 // FIXME: this is flaky
484 QCOMPARE(imaDSpy.count(), 1);
485 imaDSpy.clear();
486
487 // double click in the first rectangle
488- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 10));
489+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10));
490 QTest::waitForEvents();
491 QCOMPARE(imaDSpy.count(), 1);
492 imaDSpy.clear();
493@@ -237,35 +199,31 @@
494
495 void testCase_InverseMouseAreaOnTopNoAccept()
496 {
497- InverseMouseAreaType *area = testArea("InverseMouseAreaOnTopNoAccept.qml");
498- QVERIFY(area);
499- quickView->show();
500- QTest::qWaitForWindowExposed(quickView);
501+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaOnTopNoAccept.qml"));
502+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("IMA");
503
504- QQuickItem *ma1 = quickView->rootObject()->findChild<QQuickItem*>("MA1");
505- QVERIFY(ma1);
506- QQuickItem *ma2 = quickView->rootObject()->findChild<QQuickItem*>("MA2");
507- QVERIFY(ma2);
508+ QQuickItem *ma1 = quickView->findItem<QQuickItem*>("MA1");
509+ QQuickItem *ma2 = quickView->findItem<QQuickItem*>("MA2");
510
511 QSignalSpy imaSpy(area, SIGNAL(pressed(QQuickMouseEvent*)));
512 QSignalSpy ma1Spy(ma1, SIGNAL(pressed(QQuickMouseEvent*)));
513 QSignalSpy ma2Spy(ma2, SIGNAL(pressed(QQuickMouseEvent*)));
514
515- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
516+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
517 QTest::waitForEvents();
518 QCOMPARE(ma1Spy.count(), 1);
519 QCOMPARE(ma2Spy.count(), 0);
520 QCOMPARE(imaSpy.count(), 1);
521 ma1Spy.clear(); imaSpy.clear();
522
523- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
524+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
525 QTest::waitForEvents();
526 QCOMPARE(ma1Spy.count(), 0);
527 QCOMPARE(ma2Spy.count(), 1);
528 QCOMPARE(imaSpy.count(), 1);
529 ma2Spy.clear(); imaSpy.clear();
530
531- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(25, 80), DOUBLECLICK_TIMEOUT);
532+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(25, 80), DOUBLECLICK_TIMEOUT);
533 QTest::waitForEvents();
534 QCOMPARE(ma1Spy.count(), 0);
535 QCOMPARE(ma2Spy.count(), 1);
536@@ -273,67 +231,62 @@
537
538 // double click should not reach inverse mouse area as onPressed did not accept the events
539 QSignalSpy imaDSpy(area, SIGNAL(doubleClicked(QQuickMouseEvent*)));
540- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 65));
541+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65));
542 QCOMPARE(imaDSpy.count(), 0);
543 imaDSpy.clear();
544
545- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 10));
546+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10));
547 QCOMPARE(imaDSpy.count(), 0);
548 imaDSpy.clear();
549 }
550
551 void testCase_InverseMouseAreaOnTopTopmost()
552 {
553- InverseMouseAreaType *area = testArea("InverseMouseAreaOnTop.qml");
554- QVERIFY(area);
555- quickView->show();
556- QTest::qWaitForWindowExposed(quickView);
557+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaOnTop.qml"));
558+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("IMA");
559 area->setProperty("topmostItem", true);
560
561- QQuickItem *ma2 = quickView->rootObject()->findChild<QQuickItem*>("MA2");
562- QVERIFY(ma2);
563+ QQuickItem *ma2 = quickView->findItem<QQuickItem*>("MA2");
564
565 QSignalSpy imaSpy(area, SIGNAL(pressed(QQuickMouseEvent*)));
566 QSignalSpy ma2Spy(ma2, SIGNAL(pressed(QQuickMouseEvent*)));
567
568 // click on the topmost rectangle
569- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
570+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10), DOUBLECLICK_TIMEOUT);
571 QTest::waitForEvents();
572 QCOMPARE(ma2Spy.count(), 0);
573 QCOMPARE(imaSpy.count(), 1);
574 imaSpy.clear();
575
576 // click on the second rectangle
577- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
578+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65), DOUBLECLICK_TIMEOUT);
579 QTest::waitForEvents();
580 QCOMPARE(ma2Spy.count(), 0);
581 QCOMPARE(imaSpy.count(), 1);
582 imaSpy.clear();
583
584 // click on the button
585- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(25, 85), DOUBLECLICK_TIMEOUT);
586+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(25, 85), DOUBLECLICK_TIMEOUT);
587 QTest::waitForEvents();
588 QCOMPARE(ma2Spy.count(), 1);
589 QCOMPARE(imaSpy.count(), 0);
590
591 // double click on the second rectangle
592 QSignalSpy imaDSpy(area, SIGNAL(doubleClicked(QQuickMouseEvent*)));
593- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 65));
594+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 65));
595 QCOMPARE(imaDSpy.count(), 1);
596 imaDSpy.clear();
597
598 // double click on the first rectangle
599- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(10, 10));
600+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(10, 10));
601 QCOMPARE(imaDSpy.count(), 1);
602 imaDSpy.clear();
603 }
604
605 void testCase_InverseMouseAreaSignals()
606 {
607- InverseMouseAreaType *area = testArea("InverseMouseAreaSignals.qml");
608- QVERIFY(area);
609- quickView->show();
610- QTest::qWaitForWindowExposed(quickView);
611+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaSignals.qml"));
612+ InverseMouseAreaType *area = quickView->findItem<InverseMouseAreaType*>("IMA");
613
614 QSignalSpy pressSpy(area, SIGNAL(pressed(QQuickMouseEvent*)));
615 QSignalSpy releaseSpy(area, SIGNAL(released(QQuickMouseEvent*)));
616@@ -341,7 +294,7 @@
617 QSignalSpy enteredSpy(area, SIGNAL(entered()));
618 QSignalSpy exitedSpy(area, SIGNAL(exited()));
619
620- QTest::mouseClick(quickView, Qt::LeftButton, 0, QPoint(5, 5), DOUBLECLICK_TIMEOUT);
621+ QTest::mouseClick(quickView.data(), Qt::LeftButton, 0, QPoint(5, 5), DOUBLECLICK_TIMEOUT);
622 QCOMPARE(pressSpy.count(), 1);
623 QCOMPARE(releaseSpy.count(), 1);
624 QCOMPARE(clickSpy.count(), 1);
625@@ -349,137 +302,125 @@
626 QCOMPARE(exitedSpy.count(), 1);
627
628 QSignalSpy doubleClickSpy(area, SIGNAL(doubleClicked(QQuickMouseEvent*)));
629- QTest::mouseDClick(quickView, Qt::LeftButton, 0, QPoint(5, 5));
630+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, 0, QPoint(5, 5));
631 QCOMPARE(doubleClickSpy.count(), 1);
632 }
633
634 void testCase_InverseMouseAreaNormalEventStack()
635 {
636- InverseMouseAreaType *ima = testArea("InverseMouseAreaNormalEventStack.qml");
637- QVERIFY(ima);
638- quickView->show();
639- QTest::qWaitForWindowExposed(quickView);
640+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaNormalEventStack.qml"));
641+ InverseMouseAreaType *ima = quickView->findItem<InverseMouseAreaType*>("IMA");
642
643- QQuickItem *ma = quickView->rootObject()->findChild<QQuickItem*>("MA");
644- QVERIFY(ma);
645+ QQuickItem *ma = quickView->findItem<QQuickItem*>("MA");
646
647 QSignalSpy imaSpy(ima, SIGNAL(pressed(QQuickMouseEvent*)));
648 QSignalSpy maSpy(ma, SIGNAL(pressed(QQuickMouseEvent*)));
649
650- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(15, 15));
651+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(15, 15));
652 QCOMPARE(imaSpy.count(), 0);
653 QCOMPARE(maSpy.count(), 0);
654
655- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(115, 15));
656+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(115, 15));
657 QCOMPARE(imaSpy.count(), 0);
658 QCOMPARE(maSpy.count(), 1);
659 maSpy.clear();
660
661- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(115, 115));
662+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(115, 115));
663 QCOMPARE(imaSpy.count(), 1);
664 QCOMPARE(maSpy.count(), 0);
665 }
666
667 void testCase_InverseMouseAreaTopmost()
668 {
669- InverseMouseAreaType *ima = testArea("InverseMouseAreaTopmostItem.qml");
670- QVERIFY(ima);
671- quickView->show();
672- QTest::qWaitForWindowExposed(quickView);
673+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaTopmostItem.qml"));
674+ InverseMouseAreaType *ima = quickView->findItem<InverseMouseAreaType*>("IMA");
675
676- QQuickItem *ma = quickView->rootObject()->findChild<QQuickItem*>("MA");
677- QVERIFY(ma);
678+ QQuickItem *ma = quickView->findItem<QQuickItem*>("MA");
679
680 QSignalSpy imaSpy(ima, SIGNAL(pressed(QQuickMouseEvent*)));
681 QSignalSpy maSpy(ma, SIGNAL(pressed(QQuickMouseEvent*)));
682 QSignalSpy imaDblClick(ima, SIGNAL(doubleClicked(QQuickMouseEvent*)));
683
684- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(15, 15), DOUBLECLICK_TIMEOUT);
685+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(15, 15), DOUBLECLICK_TIMEOUT);
686 QCOMPARE(imaSpy.count(), 0);
687 QCOMPARE(maSpy.count(), 0);
688
689- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(115, 15), DOUBLECLICK_TIMEOUT);
690+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(115, 15), DOUBLECLICK_TIMEOUT);
691 QCOMPARE(imaSpy.count(), 1);
692 QCOMPARE(maSpy.count(), 0);
693
694 imaSpy.clear();
695- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(115, 115), DOUBLECLICK_TIMEOUT);
696+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(115, 115), DOUBLECLICK_TIMEOUT);
697 QCOMPARE(imaSpy.count(), 1);
698 QCOMPARE(maSpy.count(), 0);
699
700- QTest::mouseDClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(115, 15));
701+ QTest::mouseDClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(115, 15));
702 QCOMPARE(imaDblClick.count(), 1);
703 }
704
705 void testCase_InverseMouseAreaSensingArea()
706 {
707- InverseMouseAreaType *ima = testArea("InverseMouseAreaSensingArea.qml");
708- QVERIFY(ima);
709- quickView->show();
710- QTest::qWaitForWindowExposed(quickView);
711+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaSensingArea.qml"));
712+ InverseMouseAreaType *ima = quickView->findItem<InverseMouseAreaType*>("IMA");
713
714- QQuickItem *ma = quickView->rootObject()->findChild<QQuickItem*>("MA");
715- QVERIFY(ma);
716+ QQuickItem *ma = quickView->findItem<QQuickItem*>("MA");
717
718 QSignalSpy maSpy(ma, SIGNAL(clicked(QQuickMouseEvent*)));
719 QSignalSpy imaSpy(ima, SIGNAL(clicked(QQuickMouseEvent*)));
720
721- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
722+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
723 QCOMPARE(maSpy.count(), 0);
724 QCOMPARE(imaSpy.count(), 1);
725 imaSpy.clear();
726
727- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
728+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
729 QCOMPARE(maSpy.count(), 1);
730 QCOMPARE(imaSpy.count(), 0);
731 maSpy.clear();
732
733- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
734+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
735 QCOMPARE(maSpy.count(), 1);
736 QCOMPARE(imaSpy.count(), 0);
737 }
738
739 void testCase_InverseMouseAreaSensingAreaChange()
740 {
741- InverseMouseAreaType *ima = testArea("InverseMouseAreaSensingArea.qml");
742- QVERIFY(ima);
743- quickView->show();
744- QTest::qWaitForWindowExposed(quickView);
745+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest("InverseMouseAreaSensingArea.qml"));
746+ InverseMouseAreaType *ima = quickView->findItem<InverseMouseAreaType*>("IMA");
747
748- QQuickItem *ma = quickView->rootObject()->findChild<QQuickItem*>("MA");
749- QVERIFY(ma);
750+ QQuickItem *ma = quickView->findItem<QQuickItem*>("MA");
751
752 QSignalSpy maSpy(ma, SIGNAL(clicked(QQuickMouseEvent*)));
753 QSignalSpy imaSpy(ima, SIGNAL(clicked(QQuickMouseEvent*)));
754
755- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
756+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
757 QCOMPARE(maSpy.count(), 0);
758 QCOMPARE(imaSpy.count(), 1);
759 imaSpy.clear();
760
761- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
762+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
763 QCOMPARE(maSpy.count(), 1);
764 QCOMPARE(imaSpy.count(), 0);
765 maSpy.clear();
766
767- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
768+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
769 QCOMPARE(maSpy.count(), 1);
770 QCOMPARE(imaSpy.count(), 0);
771 maSpy.clear();
772
773 ima->setProperty("sensingArea", QVariant());
774
775- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
776- QCOMPARE(maSpy.count(), 0);
777- QCOMPARE(imaSpy.count(), 1);
778- imaSpy.clear();
779-
780- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
781- QCOMPARE(maSpy.count(), 0);
782- QCOMPARE(imaSpy.count(), 1);
783- imaSpy.clear();
784-
785- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
786+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(75, 75));
787+ QCOMPARE(maSpy.count(), 0);
788+ QCOMPARE(imaSpy.count(), 1);
789+ imaSpy.clear();
790+
791+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(25, 25));
792+ QCOMPARE(maSpy.count(), 0);
793+ QCOMPARE(imaSpy.count(), 1);
794+ imaSpy.clear();
795+
796+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, QPoint(175, 175));
797 QCOMPARE(maSpy.count(), 1);
798 QCOMPARE(imaSpy.count(), 0);
799 }
800@@ -498,18 +439,13 @@
801 void test_MouseClicksOnHeaderNotSeen_bug1288876()
802 {
803 QFETCH(QString, document);
804- testArea(document);
805- InverseMouseAreaType *ima = quickView->rootObject()->
806- property("ima").value<InverseMouseAreaType*>();
807- QVERIFY(ima);
808- QCOMPARE(ima->objectName(), QString("Test_IMA"));
809- quickView->show();
810- QTest::qWaitForWindowExposed(quickView);
811+ QScopedPointer<InverseMouseAreaTest> quickView(new InverseMouseAreaTest(document));
812+ InverseMouseAreaType *ima = quickView->rootObject()->property("ima").value<InverseMouseAreaType*>();
813
814 QSignalSpy imaSpy(ima, SIGNAL(clicked(QQuickMouseEvent*)));
815
816 // make sure we click on the header
817- QTest::mouseClick(quickView, Qt::LeftButton, Qt::NoModifier, guPoint(20, 5));
818+ QTest::mouseClick(quickView.data(), Qt::LeftButton, Qt::NoModifier, guPoint(20, 5));
819 QCOMPARE(imaSpy.count(), 1);
820
821 imaSpy.clear();

Subscribers

People subscribed via source and target branches