Merge lp:~dandrader/unity8/autoInstallTouchRegistry into lp:unity8

Proposed by Daniel d'Andrada
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1735
Merged at revision: 1784
Proposed branch: lp:~dandrader/unity8/autoInstallTouchRegistry
Merge into: lp:unity8
Prerequisite: lp:~dandrader/unity8/ddaImprovements
Diff against target: 1208 lines (+173/-201)
20 files modified
libs/UbuntuGestures/CandidateInactivityTimer.cpp (+7/-2)
libs/UbuntuGestures/CandidateInactivityTimer.h (+3/-1)
libs/UbuntuGestures/Timer.cpp (+0/-10)
libs/UbuntuGestures/Timer.h (+1/-1)
libs/UbuntuGestures/TouchRegistry.cpp (+16/-12)
libs/UbuntuGestures/TouchRegistry.h (+8/-6)
plugins/Ubuntu/Gestures/DirectionalDragArea.cpp (+2/-0)
plugins/Ubuntu/Gestures/TouchGate.cpp (+10/-0)
plugins/Ubuntu/Gestures/TouchGate.h (+1/-0)
src/Dash/main.cpp (+0/-6)
src/main.cpp (+0/-5)
tests/libs/UbuntuGestures/tst_TouchRegistry.cpp (+93/-94)
tests/plugins/Ubuntu/Gestures/GestureTest.cpp (+2/-1)
tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp (+20/-20)
tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp (+1/-2)
tests/qmltests/Components/tst_DragHandle.cpp (+0/-8)
tests/uqmlscene/main.cpp (+0/-10)
tests/utils/modules/Unity/Test/UnityTestCase.qml (+0/-2)
tests/utils/modules/Unity/Test/testutil.cpp (+8/-20)
tests/utils/modules/Unity/Test/testutil.h (+1/-1)
To merge this branch: bzr merge lp:~dandrader/unity8/autoInstallTouchRegistry
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Abstain
PS Jenkins bot (community) continuous-integration Needs Fixing
Mirco Müller (community) Approve
Daniel d'Andrada (community) Abstain
Review via email: mp+256726@code.launchpad.net

Commit message

Make Ubuntu.Gestures components install TouchRegistry by themselves

That way Ubuntu.Gestures users don't have to write C++ code to do it.
TouchRegistry then being an implementation detail they don't have to
know about.

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.
Has https://code.launchpad.net/~dandrader/unity8/ddaImprovements/+merge/255896 as a prerequisite

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes

* Did you make sure that your branch does not contain spurious tags?
Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable

* If you changed the UI, has there been a design review?
Not applicable

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mirco Müller (macslow) wrote :

tst_TouchRegistry fails with an assertion...

QFATAL : tst_TouchRegistry::requestWithNoCandidates() ASSERT: "m_instance != nullptr" in file /tmp/unity8-autoInstallTouchRegistry/libs/UbuntuGestures/TouchRegistry.cpp, line 52
FAIL! : tst_TouchRegistry::requestWithNoCandidates() Received a fatal error.

... in ./libs/UbuntuGestures/TouchRegistry.cpp there's...

TouchRegistry::~TouchRegistry()
{
    Q_ASSERT(m_instance != nullptr); // Kaboom!
    m_instance = nullptr;
    delete m_timerFactory;
}

review: Needs Fixing
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> tst_TouchRegistry fails with an assertion...
>
> QFATAL : tst_TouchRegistry::requestWithNoCandidates() ASSERT: "m_instance !=
> nullptr" in file
> /tmp/unity8-autoInstallTouchRegistry/libs/UbuntuGestures/TouchRegistry.cpp,
> line 52
> FAIL! : tst_TouchRegistry::requestWithNoCandidates() Received a fatal error.
>
> ... in ./libs/UbuntuGestures/TouchRegistry.cpp there's...
>
> TouchRegistry::~TouchRegistry()
> {
> Q_ASSERT(m_instance != nullptr); // Kaboom!
> m_instance = nullptr;
> delete m_timerFactory;
> }

Fixed. Should have spotted this before, sorry.

review: Needs Resubmitting
Revision history for this message
Daniel d'Andrada (dandrader) :
review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mirco Müller (macslow) wrote :

Looks fine to me now.

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass?
No, but failing AP-tests test_greeter_hides_on_app_open and test_slider_buffers_activations seem to be unrelated to the changes this branch introduces

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
Revision history for this message
Albert Astals Cid (aacid) wrote :

Text conflict in plugins/Ubuntu/Gestures/TouchGate.cpp
Text conflict in plugins/Ubuntu/Gestures/TouchGate.h
Text conflict in src/main.cpp
3 conflicts encountered.

review: Needs Fixing
1735. By Daniel d'Andrada

Merge trunk

[ Albert Astals Cid ]
* Make runtests fake a test error if make fails
* Make the test more stable
* Use dbus-test-runner instead of dbus-launch
[ Daniel d'Andrada ]
* DirectionalDragArea: improvements & API grooming (LP: #1417920)
* Fix EdgeDragEvaluator when a drag can happen both ways
  (Direction.Horizontal)
[ Josh Arenson ]
* Remove panelHeight property as it is unused.
[ Leo Arias ]
* Initial clean up of the autopilot tests set up. Removed the touch
  device from the test case. Moved the restart of unity to a fixture.
  Removed the unused DragMixin. Updated the setUpClass to use
  process_helpers. Removed the workaround for bug #1238417, already
  fixed. Use the toolkit helper to set the testability environment
  variable. Fixed the indicators base class that was restarting unity
  twice. (LP: #1238417, #1447206)
* Use the base class from the toolkit in autopilot tests.
[ Michael Zanetti ]
* emit application-stop when we're going down (LP: #1326513)
[ Michał Sawicz ]
* UNITY_SCOPES_LIST is no more
[ handsome_feng<email address hidden> ]
* When click the favorite scope in Dash Manager , it just return to
  the corresponding scope page. (LP: #1447056)
[ Albert Astals Cid ]
* Compile with Qt 5.5 (LP: #1437238)
* Different way of top aligning labels when the other one in the row
  is multiline (LP: #1442085)
* make pot_file
[ Andrea Cimitan ]
* Set sourceSize for DashBackground.qml Image
[ CI Train Bot ]
* New rebuild forced.
* Resync trunk. added: po/sk.po
[ Daniel d'Andrada ]
* Move handling of command line options to a separate class
* Refactor tst_PhysicalKeysMapper.qml
[ Leo Arias ]
* For autopilot tests, use the device simulation scenarios from the
  toolkit.
[ Leonardo Arias Fonseca ]
* For autopilot tests, use the device simulation scenarios from the
  toolkit.
[ Michael Zanetti ]
* Make sure dnd mode is ended properly when drag gesture is cancelled
  (LP: #1444949)
[ Michał Sawicz ]
* Fix flake8 warnings (LP: #1444170)
* Move mock indicator service to unity8-fake-env, as it's a binary-
  dependent package.
[ Nick Dedekind ]
* Use asynchronous dbus requests for property updates. (LP: #1436982)

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

On 11/05/15 04:20, Albert Astals Cid wrote:
> Review: Needs Fixing
>
> Text conflict in plugins/Ubuntu/Gestures/TouchGate.cpp
> Text conflict in plugins/Ubuntu/Gestures/TouchGate.h
> Text conflict in src/main.cpp
> 3 conflicts encountered.
Fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) :
review: Abstain

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libs/UbuntuGestures/CandidateInactivityTimer.cpp'
2--- libs/UbuntuGestures/CandidateInactivityTimer.cpp 2014-10-01 13:20:32 +0000
3+++ libs/UbuntuGestures/CandidateInactivityTimer.cpp 2015-05-11 09:54:47 +0000
4@@ -19,12 +19,12 @@
5 namespace UbuntuGestures {
6
7 CandidateInactivityTimer::CandidateInactivityTimer(int touchId, QQuickItem *candidate,
8- AbstractTimerFactory &timerFactory, QObject *parent)
9+ AbstractTimer *timer, QObject *parent)
10 : QObject(parent)
11+ , m_timer(timer)
12 , m_touchId(touchId)
13 , m_candidate(candidate)
14 {
15- m_timer = timerFactory.createTimer(this);
16 connect(m_timer, &AbstractTimer::timeout,
17 this, &CandidateInactivityTimer::onTimeout);
18 m_timer->setInterval(durationMs);
19@@ -32,6 +32,11 @@
20 m_timer->start();
21 }
22
23+CandidateInactivityTimer::~CandidateInactivityTimer()
24+{
25+ delete m_timer;
26+}
27+
28 void CandidateInactivityTimer::onTimeout()
29 {
30 qWarning("[TouchRegistry] Candidate for touch %d defaulted!", m_touchId);
31
32=== modified file 'libs/UbuntuGestures/CandidateInactivityTimer.h'
33--- libs/UbuntuGestures/CandidateInactivityTimer.h 2015-04-10 21:16:37 +0000
34+++ libs/UbuntuGestures/CandidateInactivityTimer.h 2015-05-11 09:54:47 +0000
35@@ -29,9 +29,11 @@
36 Q_OBJECT
37 public:
38 CandidateInactivityTimer(int touchId, QQuickItem *candidate,
39- AbstractTimerFactory &timerFactory,
40+ AbstractTimer *timer,
41 QObject *parent = nullptr);
42
43+ virtual ~CandidateInactivityTimer();
44+
45 const int durationMs = 1000;
46
47 Q_SIGNALS:
48
49=== modified file 'libs/UbuntuGestures/Timer.cpp'
50--- libs/UbuntuGestures/Timer.cpp 2015-04-10 21:16:37 +0000
51+++ libs/UbuntuGestures/Timer.cpp 2015-05-11 09:54:47 +0000
52@@ -115,16 +115,6 @@
53 m_timeSource.reset(new FakeTimeSource);
54 }
55
56-FakeTimerFactory::~FakeTimerFactory()
57-{
58- for (int i = 0; i < timers.count(); ++i) {
59- FakeTimer *timer = timers[i].data();
60- if (timer) {
61- delete timer;
62- }
63- }
64-}
65-
66 void FakeTimerFactory::updateTime(qint64 targetTime)
67 {
68 qint64 minTimeoutTime = targetTime;
69
70=== modified file 'libs/UbuntuGestures/Timer.h'
71--- libs/UbuntuGestures/Timer.h 2015-04-10 21:16:37 +0000
72+++ libs/UbuntuGestures/Timer.h 2015-05-11 09:54:47 +0000
73@@ -101,7 +101,7 @@
74 {
75 public:
76 FakeTimerFactory();
77- virtual ~FakeTimerFactory();
78+ virtual ~FakeTimerFactory() {}
79
80 void updateTime(qint64 msecsSinceReference);
81 QSharedPointer<TimeSource> timeSource() { return m_timeSource; }
82
83=== modified file 'libs/UbuntuGestures/TouchRegistry.cpp'
84--- libs/UbuntuGestures/TouchRegistry.cpp 2015-04-10 21:16:37 +0000
85+++ libs/UbuntuGestures/TouchRegistry.cpp 2015-05-11 09:54:47 +0000
86@@ -41,20 +41,10 @@
87 TouchRegistry *TouchRegistry::m_instance = nullptr;
88
89 TouchRegistry::TouchRegistry(QObject *parent)
90- : TouchRegistry(parent, new TimerFactory)
91-{
92-}
93-
94-TouchRegistry::TouchRegistry(QObject *parent, AbstractTimerFactory *timerFactory)
95 : QObject(parent)
96 , m_inDispatchLoop(false)
97- , m_timerFactory(timerFactory)
98+ , m_timerFactory(new TimerFactory)
99 {
100- if (m_instance == nullptr) {
101- m_instance = this;
102- } else {
103- qFatal("Cannot have more than one instance of TouchRegistry. It must be a singleton.");
104- }
105 }
106
107 TouchRegistry::~TouchRegistry()
108@@ -64,6 +54,20 @@
109 delete m_timerFactory;
110 }
111
112+TouchRegistry *TouchRegistry::instance()
113+{
114+ if (m_instance == nullptr) {
115+ m_instance = new TouchRegistry;
116+ }
117+ return m_instance;
118+}
119+
120+void TouchRegistry::setTimerFactory(AbstractTimerFactory *timerFactory)
121+{
122+ delete m_timerFactory;
123+ m_timerFactory = timerFactory;
124+}
125+
126 void TouchRegistry::update(const QTouchEvent *event)
127 {
128 #if TOUCHREGISTRY_DEBUG
129@@ -261,7 +265,7 @@
130 candidateInfo.state = CandidateInfo::Undecided;
131 candidateInfo.item = candidate;
132 candidateInfo.inactivityTimer = new CandidateInactivityTimer(id, candidate,
133- *m_timerFactory,
134+ m_timerFactory->createTimer(),
135 this);
136 connect(candidateInfo.inactivityTimer, &CandidateInactivityTimer::candidateDefaulted,
137 this, &TouchRegistry::rejectCandidateOwnerForTouch);
138
139=== modified file 'libs/UbuntuGestures/TouchRegistry.h'
140--- libs/UbuntuGestures/TouchRegistry.h 2015-04-10 21:16:37 +0000
141+++ libs/UbuntuGestures/TouchRegistry.h 2015-05-11 09:54:47 +0000
142@@ -25,6 +25,7 @@
143
144 #include "UbuntuGesturesGlobal.h"
145 #include "CandidateInactivityTimer.h"
146+#include "Timer.h"
147 #include "Pool.h"
148
149 namespace UbuntuGestures {
150@@ -93,15 +94,10 @@
151 {
152 Q_OBJECT
153 public:
154- TouchRegistry(QObject *parent = nullptr);
155- // Useful for tests, where you should feed a fake timer
156- TouchRegistry(QObject *parent, UbuntuGestures::AbstractTimerFactory *timerFactory);
157-
158 virtual ~TouchRegistry();
159
160 // Returns a pointer to the application's TouchRegistry instance.
161- // If no instance has been allocated, null is returned.
162- static TouchRegistry *instance() { return m_instance; }
163+ static TouchRegistry *instance();
164
165 void update(const QTouchEvent *event);
166
167@@ -128,10 +124,16 @@
168 // but would nonetheless like to be kept up-to-date on its state.
169 void addTouchWatcher(int touchId, QQuickItem *watcherItem);
170
171+ // Useful for tests, where you should use fake timers
172+ void setTimerFactory(UbuntuGestures::AbstractTimerFactory *timerFactory);
173+
174 private Q_SLOTS:
175 void rejectCandidateOwnerForTouch(int id, QQuickItem *candidate);
176
177 private:
178+ // Only instance() can cronstruct one
179+ TouchRegistry(QObject *parent = nullptr);
180+
181 class CandidateInfo {
182 public:
183 enum {
184
185=== modified file 'plugins/Ubuntu/Gestures/DirectionalDragArea.cpp'
186--- plugins/Ubuntu/Gestures/DirectionalDragArea.cpp 2015-04-15 20:02:08 +0000
187+++ plugins/Ubuntu/Gestures/DirectionalDragArea.cpp 2015-05-11 09:54:47 +0000
188@@ -712,6 +712,8 @@
189 {
190 if (change == QQuickItem::ItemSceneChange) {
191 if (value.window != nullptr) {
192+ value.window->installEventFilter(TouchRegistry::instance());
193+
194 // TODO: Handle window->screen() changes (ie window changing screens)
195 qreal pixelsPerMm = value.window->screen()->physicalDotsPerInch() / 25.4;
196 d->setPixelsPerMm(pixelsPerMm);
197
198=== modified file 'plugins/Ubuntu/Gestures/TouchGate.cpp'
199--- plugins/Ubuntu/Gestures/TouchGate.cpp 2015-05-05 14:46:11 +0000
200+++ plugins/Ubuntu/Gestures/TouchGate.cpp 2015-05-11 09:54:47 +0000
201@@ -18,6 +18,7 @@
202
203 #include <QCoreApplication>
204 #include <QDebug>
205+#include <QQuickWindow>
206
207 #include <TouchOwnershipEvent.h>
208 #include <TouchRegistry.h>
209@@ -102,6 +103,15 @@
210 }
211 }
212
213+void TouchGate::itemChange(ItemChange change, const ItemChangeData &value)
214+{
215+ if (change == QQuickItem::ItemSceneChange) {
216+ if (value.window != nullptr) {
217+ value.window->installEventFilter(TouchRegistry::instance());
218+ }
219+ }
220+}
221+
222 void TouchGate::touchOwnershipEvent(TouchOwnershipEvent *event)
223 {
224 // TODO: Optimization: batch those actions as TouchOwnershipEvents
225
226=== modified file 'plugins/Ubuntu/Gestures/TouchGate.h'
227--- plugins/Ubuntu/Gestures/TouchGate.h 2015-05-05 14:46:11 +0000
228+++ plugins/Ubuntu/Gestures/TouchGate.h 2015-05-11 09:54:47 +0000
229@@ -57,6 +57,7 @@
230
231 protected:
232 void touchEvent(QTouchEvent *event) override;
233+ void itemChange(ItemChange change, const ItemChangeData &value) override;
234
235 private Q_SLOTS:
236 void onEnabledChanged();
237
238=== modified file 'src/Dash/main.cpp'
239--- src/Dash/main.cpp 2015-04-15 15:20:24 +0000
240+++ src/Dash/main.cpp 2015-05-11 09:54:47 +0000
241@@ -31,9 +31,6 @@
242 #include "../ApplicationArguments.h"
243 #include "../CachingNetworkManagerFactory.h"
244
245-// Ubuntu Gestures
246-#include <TouchRegistry.h>
247-
248 int main(int argc, const char *argv[])
249 {
250 QGuiApplication *application = new QGuiApplication(argc, (char**)argv);
251@@ -91,9 +88,6 @@
252 view->setTitle("Scopes");
253 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
254
255- TouchRegistry touchRegistry;
256- view->installEventFilter(&touchRegistry);
257-
258 // You will need this if you want to interact with touch-only components using a mouse
259 // Needed only when manually testing on a desktop.
260 MouseTouchAdaptor *mouseTouchAdaptor = 0;
261
262=== modified file 'src/main.cpp'
263--- src/main.cpp 2015-04-15 15:20:24 +0000
264+++ src/main.cpp 2015-05-11 09:54:47 +0000
265@@ -32,9 +32,6 @@
266 #include "CachingNetworkManagerFactory.h"
267 #include "UnityCommandLineParser.h"
268
269-// Ubuntu Gestures
270-#include <TouchRegistry.h>
271-
272 int main(int argc, const char *argv[])
273 {
274 bool isMirServer = false;
275@@ -89,8 +86,6 @@
276 if (parser.hasFrameless()) {
277 view->setFlags(Qt::FramelessWindowHint);
278 }
279- TouchRegistry touchRegistry;
280- view->installEventFilter(&touchRegistry);
281
282 // You will need this if you want to interact with touch-only components using a mouse
283 // Needed only when manually testing on a desktop.
284
285=== modified file 'tests/libs/UbuntuGestures/tst_TouchRegistry.cpp'
286--- tests/libs/UbuntuGestures/tst_TouchRegistry.cpp 2015-04-10 21:16:37 +0000
287+++ tests/libs/UbuntuGestures/tst_TouchRegistry.cpp 2015-05-11 09:54:47 +0000
288@@ -53,8 +53,8 @@
289 void initTestCase() {} // will be called before the first test function is executed
290 void cleanupTestCase() {} // will be called after the last test function was executed.
291
292- void init() {} // called right before each and every test function is executed
293- void cleanup() {} // called right after each and every test function is executed
294+ void init(); // called right before each and every test function is executed
295+ void cleanup(); // called right after each and every test function is executed
296
297 void requestWithNoCandidates();
298 void lateCandidateRequestGetsNothing();
299@@ -67,11 +67,23 @@
300 void rejectingTouchfterItsEnd();
301 void removeOldUndecidedCandidates();
302 void interimOwnerWontGetUnownedTouchEvents();
303+
304+private:
305+ TouchRegistry *touchRegistry;
306 };
307
308+void tst_TouchRegistry::init()
309+{
310+ touchRegistry = TouchRegistry::instance();
311+}
312+
313+void tst_TouchRegistry::cleanup()
314+{
315+ delete touchRegistry;
316+}
317+
318 void tst_TouchRegistry::requestWithNoCandidates()
319 {
320- TouchRegistry touchRegistry;
321 DummyCandidate candidate;
322
323 {
324@@ -83,17 +95,16 @@
325 Qt::NoModifier,
326 Qt::TouchPointPressed,
327 touchPoints);
328- touchRegistry.update(&touchEvent);
329+ touchRegistry->update(&touchEvent);
330 }
331
332- touchRegistry.requestTouchOwnership(0, &candidate);
333+ touchRegistry->requestTouchOwnership(0, &candidate);
334
335 QVERIFY(candidate.ownedTouches.contains(0));
336 }
337
338 void tst_TouchRegistry::lateCandidateRequestGetsNothing()
339 {
340- TouchRegistry touchRegistry;
341 DummyCandidate earlyCandidate;
342 earlyCandidate.setObjectName("early");
343 DummyCandidate lateCandidate;
344@@ -108,21 +119,21 @@
345 Qt::NoModifier,
346 Qt::TouchPointPressed,
347 touchPoints);
348- touchRegistry.update(&touchEvent);
349+ touchRegistry->update(&touchEvent);
350 }
351
352- touchRegistry.addCandidateOwnerForTouch(0, &earlyCandidate);
353- touchRegistry.addCandidateOwnerForTouch(0, &lateCandidate);
354-
355- QVERIFY(earlyCandidate.ownedTouches.isEmpty());
356- QVERIFY(lateCandidate.ownedTouches.isEmpty());
357-
358- touchRegistry.requestTouchOwnership(0, &lateCandidate);
359-
360- QVERIFY(earlyCandidate.ownedTouches.isEmpty());
361- QVERIFY(lateCandidate.ownedTouches.isEmpty());
362-
363- touchRegistry.requestTouchOwnership(0, &earlyCandidate);
364+ touchRegistry->addCandidateOwnerForTouch(0, &earlyCandidate);
365+ touchRegistry->addCandidateOwnerForTouch(0, &lateCandidate);
366+
367+ QVERIFY(earlyCandidate.ownedTouches.isEmpty());
368+ QVERIFY(lateCandidate.ownedTouches.isEmpty());
369+
370+ touchRegistry->requestTouchOwnership(0, &lateCandidate);
371+
372+ QVERIFY(earlyCandidate.ownedTouches.isEmpty());
373+ QVERIFY(lateCandidate.ownedTouches.isEmpty());
374+
375+ touchRegistry->requestTouchOwnership(0, &earlyCandidate);
376
377 QVERIFY(earlyCandidate.ownedTouches.contains(0));
378 QVERIFY(lateCandidate.ownedTouches.isEmpty());
379@@ -130,7 +141,6 @@
380
381 void tst_TouchRegistry::lateCandidateGestOwnershipOnceEarlyCandidateQuits()
382 {
383- TouchRegistry touchRegistry;
384 DummyCandidate earlyCandidate;
385 DummyCandidate lateCandidate;
386
387@@ -143,21 +153,21 @@
388 Qt::NoModifier,
389 Qt::TouchPointPressed,
390 touchPoints);
391- touchRegistry.update(&touchEvent);
392+ touchRegistry->update(&touchEvent);
393 }
394
395- touchRegistry.addCandidateOwnerForTouch(0, &earlyCandidate);
396- touchRegistry.addCandidateOwnerForTouch(0, &lateCandidate);
397-
398- QVERIFY(earlyCandidate.ownedTouches.isEmpty());
399- QVERIFY(lateCandidate.ownedTouches.isEmpty());
400-
401- touchRegistry.requestTouchOwnership(0, &lateCandidate);
402-
403- QVERIFY(earlyCandidate.ownedTouches.isEmpty());
404- QVERIFY(lateCandidate.ownedTouches.isEmpty());
405-
406- touchRegistry.removeCandidateOwnerForTouch(0, &earlyCandidate);
407+ touchRegistry->addCandidateOwnerForTouch(0, &earlyCandidate);
408+ touchRegistry->addCandidateOwnerForTouch(0, &lateCandidate);
409+
410+ QVERIFY(earlyCandidate.ownedTouches.isEmpty());
411+ QVERIFY(lateCandidate.ownedTouches.isEmpty());
412+
413+ touchRegistry->requestTouchOwnership(0, &lateCandidate);
414+
415+ QVERIFY(earlyCandidate.ownedTouches.isEmpty());
416+ QVERIFY(lateCandidate.ownedTouches.isEmpty());
417+
418+ touchRegistry->removeCandidateOwnerForTouch(0, &earlyCandidate);
419
420 QVERIFY(earlyCandidate.ownedTouches.isEmpty());
421 QVERIFY(lateCandidate.ownedTouches.contains(0));
422@@ -165,7 +175,6 @@
423
424 void tst_TouchRegistry::dispatchesTouchEventsToCandidates()
425 {
426- TouchRegistry touchRegistry;
427 QQuickItem rootItem;
428
429 DummyCandidate candidate0;
430@@ -190,10 +199,10 @@
431 Qt::NoModifier,
432 Qt::TouchPointPressed,
433 touchPoints);
434- touchRegistry.update(&touchEvent);
435+ touchRegistry->update(&touchEvent);
436 }
437
438- touchRegistry.addCandidateOwnerForTouch(0, &candidate0);
439+ touchRegistry->addCandidateOwnerForTouch(0, &candidate0);
440
441 {
442 QList<QTouchEvent::TouchPoint> touchPoints;
443@@ -208,7 +217,7 @@
444 Qt::NoModifier,
445 Qt::TouchPointPressed | Qt::TouchPointMoved,
446 touchPoints);
447- touchRegistry.update(&touchEvent);
448+ touchRegistry->update(&touchEvent);
449 }
450
451 // candidate0 should have received an update on the touch he's interested on.
452@@ -220,7 +229,7 @@
453 QCOMPARE(candidate0.unownedTouchEvents[0].touchPoints[0].rect().x(), 11 - candidate0.x());
454 QCOMPARE(candidate0.unownedTouchEvents[0].touchPoints[0].rect().y(), 11 - candidate0.y());
455
456- touchRegistry.addCandidateOwnerForTouch(1, &candidate1);
457+ touchRegistry->addCandidateOwnerForTouch(1, &candidate1);
458
459 {
460 QList<QTouchEvent::TouchPoint> touchPoints;
461@@ -235,7 +244,7 @@
462 Qt::NoModifier,
463 Qt::TouchPointPressed | Qt::TouchPointMoved,
464 touchPoints);
465- touchRegistry.update(&touchEvent);
466+ touchRegistry->update(&touchEvent);
467 }
468
469 // candidate0 gets updates only for touch 0 and
470@@ -252,7 +261,6 @@
471
472 void tst_TouchRegistry::dispatchesTouchEventsToWatchers()
473 {
474- TouchRegistry touchRegistry;
475 QQuickItem rootItem;
476
477 DummyCandidate watcher;
478@@ -271,10 +279,10 @@
479 Qt::NoModifier,
480 Qt::TouchPointPressed,
481 touchPoints);
482- touchRegistry.update(&touchEvent);
483+ touchRegistry->update(&touchEvent);
484 }
485
486- touchRegistry.addTouchWatcher(0, &watcher);
487+ touchRegistry->addTouchWatcher(0, &watcher);
488
489 {
490 QList<QTouchEvent::TouchPoint> touchPoints;
491@@ -289,7 +297,7 @@
492 Qt::NoModifier,
493 Qt::TouchPointPressed | Qt::TouchPointMoved,
494 touchPoints);
495- touchRegistry.update(&touchEvent);
496+ touchRegistry->update(&touchEvent);
497 }
498
499 // watcher should have received an update on the touch he's interested on.
500@@ -314,7 +322,7 @@
501 Qt::NoModifier,
502 Qt::TouchPointPressed | Qt::TouchPointMoved,
503 touchPoints);
504- touchRegistry.update(&touchEvent);
505+ touchRegistry->update(&touchEvent);
506 }
507
508 // watcher gets updates only for touch 0
509@@ -326,7 +334,6 @@
510
511 void tst_TouchRegistry::keepDispatchingToWatchersAfterLastCandidateGivesUp()
512 {
513- TouchRegistry touchRegistry;
514 DummyCandidate item;
515
516 {
517@@ -338,10 +345,10 @@
518 Qt::NoModifier,
519 Qt::TouchPointPressed,
520 touchPoints);
521- touchRegistry.update(&touchEvent);
522+ touchRegistry->update(&touchEvent);
523 }
524
525- touchRegistry.addCandidateOwnerForTouch(0, &item);
526+ touchRegistry->addCandidateOwnerForTouch(0, &item);
527
528 {
529 QList<QTouchEvent::TouchPoint> touchPoints;
530@@ -354,7 +361,7 @@
531 Qt::NoModifier,
532 Qt::TouchPointPressed | Qt::TouchPointMoved,
533 touchPoints);
534- touchRegistry.update(&touchEvent);
535+ touchRegistry->update(&touchEvent);
536 }
537
538 QCOMPARE(item.unownedTouchEvents.count(), 1);
539@@ -362,7 +369,7 @@
540 QCOMPARE(item.unownedTouchEvents[0].touchPoints[0].id(), 0);
541 item.unownedTouchEvents.clear();
542
543- touchRegistry.addTouchWatcher(1, &item);
544+ touchRegistry->addTouchWatcher(1, &item);
545
546 {
547 QList<QTouchEvent::TouchPoint> touchPoints;
548@@ -375,7 +382,7 @@
549 Qt::NoModifier,
550 Qt::TouchPointMoved,
551 touchPoints);
552- touchRegistry.update(&touchEvent);
553+ touchRegistry->update(&touchEvent);
554 }
555
556 QCOMPARE(item.unownedTouchEvents.count(), 1);
557@@ -395,7 +402,7 @@
558 Qt::NoModifier,
559 Qt::TouchPointReleased | Qt::TouchPointMoved,
560 touchPoints);
561- touchRegistry.update(&touchEvent);
562+ touchRegistry->update(&touchEvent);
563 }
564
565 QCOMPARE(item.unownedTouchEvents.count(), 1);
566@@ -404,7 +411,7 @@
567 QVERIFY(item.unownedTouchEvents[0].containsTouchWithId(1));
568 item.unownedTouchEvents.clear();
569
570- touchRegistry.removeCandidateOwnerForTouch(0, &item);
571+ touchRegistry->removeCandidateOwnerForTouch(0, &item);
572
573 {
574 QList<QTouchEvent::TouchPoint> touchPoints;
575@@ -415,7 +422,7 @@
576 Qt::NoModifier,
577 Qt::TouchPointReleased,
578 touchPoints);
579- touchRegistry.update(&touchEvent);
580+ touchRegistry->update(&touchEvent);
581 }
582
583 QCOMPARE(item.unownedTouchEvents.count(), 1);
584@@ -423,7 +430,7 @@
585 QVERIFY(item.unownedTouchEvents[0].containsTouchWithId(1));
586 item.unownedTouchEvents.clear();
587
588- QVERIFY(touchRegistry.m_touchInfoPool.isEmpty());
589+ QVERIFY(touchRegistry->m_touchInfoPool.isEmpty());
590 }
591
592 /*
593@@ -432,7 +439,6 @@
594 */
595 void tst_TouchRegistry::candidatesAndWatchers_1()
596 {
597- TouchRegistry touchRegistry;
598 DummyCandidate item;
599
600 {
601@@ -444,10 +450,10 @@
602 Qt::NoModifier,
603 Qt::TouchPointPressed,
604 touchPoints);
605- touchRegistry.update(&touchEvent);
606+ touchRegistry->update(&touchEvent);
607 }
608
609- touchRegistry.addCandidateOwnerForTouch(0, &item);
610+ touchRegistry->addCandidateOwnerForTouch(0, &item);
611
612 {
613 QList<QTouchEvent::TouchPoint> touchPoints;
614@@ -460,14 +466,14 @@
615 Qt::NoModifier,
616 Qt::TouchPointPressed | Qt::TouchPointMoved,
617 touchPoints);
618- touchRegistry.update(&touchEvent);
619+ touchRegistry->update(&touchEvent);
620 }
621
622- touchRegistry.addTouchWatcher(1, &item);
623-
624- touchRegistry.removeCandidateOwnerForTouch(0, &item);
625-
626- touchRegistry.addTouchWatcher(0, &item);
627+ touchRegistry->addTouchWatcher(1, &item);
628+
629+ touchRegistry->removeCandidateOwnerForTouch(0, &item);
630+
631+ touchRegistry->addTouchWatcher(0, &item);
632
633 {
634 QList<QTouchEvent::TouchPoint> touchPoints;
635@@ -480,7 +486,7 @@
636 Qt::NoModifier,
637 Qt::TouchPointReleased | Qt::TouchPointMoved,
638 touchPoints);
639- touchRegistry.update(&touchEvent);
640+ touchRegistry->update(&touchEvent);
641 }
642
643 {
644@@ -492,10 +498,10 @@
645 Qt::NoModifier,
646 Qt::TouchPointReleased,
647 touchPoints);
648- touchRegistry.update(&touchEvent);
649+ touchRegistry->update(&touchEvent);
650 }
651
652- QVERIFY(touchRegistry.m_touchInfoPool.isEmpty());
653+ QVERIFY(touchRegistry->m_touchInfoPool.isEmpty());
654
655 item.unownedTouchEvents.clear();
656
657@@ -508,7 +514,7 @@
658 Qt::NoModifier,
659 Qt::TouchPointPressed,
660 touchPoints);
661- touchRegistry.update(&touchEvent);
662+ touchRegistry->update(&touchEvent);
663 }
664
665 // Haven't made any subscription for that new touch 0.
666@@ -521,8 +527,6 @@
667 */
668 void tst_TouchRegistry::candidatesAndWatchers_2()
669 {
670- TouchRegistry touchRegistry;
671-
672 DummyCandidate directionalDragArea;
673 directionalDragArea.setObjectName("DirectionalDragArea");
674
675@@ -539,14 +543,14 @@
676 Qt::NoModifier,
677 Qt::TouchPointPressed,
678 touchPoints);
679- touchRegistry.update(&touchEvent);
680+ touchRegistry->update(&touchEvent);
681 }
682
683 // [TouchRegistry] addCandidateOwnerForTouch id 0 candidate DirectionalDragArea
684- touchRegistry.addCandidateOwnerForTouch(0, &directionalDragArea);
685+ touchRegistry->addCandidateOwnerForTouch(0, &directionalDragArea);
686
687 // [TouchRegistry] requestTouchOwnership id 0 candidate TouchGate
688- touchRegistry.requestTouchOwnership(0, &touchGate);
689+ touchRegistry->requestTouchOwnership(0, &touchGate);
690
691 //[TouchRegistry] got TouchUpdate (id:0, state:moved, scenePos:(147,1023)) (id:1, state:pressed, scenePos:(327,792))
692 {
693@@ -560,24 +564,24 @@
694 Qt::NoModifier,
695 Qt::TouchPointPressed | Qt::TouchPointMoved,
696 touchPoints);
697- touchRegistry.update(&touchEvent);
698+ touchRegistry->update(&touchEvent);
699 }
700
701 // [TouchRegistry] addTouchWatcher id 1 watcher DirectionalDragArea
702- touchRegistry.addTouchWatcher(1, &directionalDragArea);
703+ touchRegistry->addTouchWatcher(1, &directionalDragArea);
704
705 // [TouchRegistry] removeCandidateOwnerForTouch id 0 candidate DirectionalDragArea
706- touchRegistry.removeCandidateOwnerForTouch(0, &directionalDragArea);
707+ touchRegistry->removeCandidateOwnerForTouch(0, &directionalDragArea);
708
709 //[TouchRegistry] sending TouchWonershipEvent(id = 0 gained) to candidate TouchGate
710 QCOMPARE(touchGate.ownedTouches.count(), 1);
711 QVERIFY(touchGate.ownedTouches.contains(0));
712
713 // [TouchRegistry] addTouchWatcher id 0 watcher DirectionalDragArea
714- touchRegistry.addTouchWatcher(0, &directionalDragArea);
715+ touchRegistry->addTouchWatcher(0, &directionalDragArea);
716
717 // [TouchRegistry] requestTouchOwnership id 1 candidate TouchGate
718- touchRegistry.requestTouchOwnership(1, &touchGate);
719+ touchRegistry->requestTouchOwnership(1, &touchGate);
720
721 //[TouchRegistry] sending TouchWonershipEvent(id = 1 gained) to candidate TouchGate
722 QCOMPARE(touchGate.ownedTouches.count(), 2);
723@@ -598,7 +602,7 @@
724 Qt::NoModifier,
725 Qt::TouchPointMoved,
726 touchPoints);
727- touchRegistry.update(&touchEvent);
728+ touchRegistry->update(&touchEvent);
729 }
730
731 //vvvvv DDA Watchers are being ignored from now on vvvvvvv
732@@ -624,7 +628,7 @@
733 Qt::NoModifier,
734 Qt::TouchPointMoved | Qt::TouchPointReleased,
735 touchPoints);
736- touchRegistry.update(&touchEvent);
737+ touchRegistry->update(&touchEvent);
738 }
739
740 QCOMPARE(directionalDragArea.unownedTouchEvents.count(), 1);
741@@ -646,7 +650,7 @@
742 Qt::NoModifier,
743 Qt::TouchPointReleased,
744 touchPoints);
745- touchRegistry.update(&touchEvent);
746+ touchRegistry->update(&touchEvent);
747 }
748
749 QCOMPARE(directionalDragArea.unownedTouchEvents.count(), 1);
750@@ -658,7 +662,6 @@
751
752 void tst_TouchRegistry::rejectingTouchfterItsEnd()
753 {
754- TouchRegistry touchRegistry;
755 DummyCandidate earlyCandidate;
756 DummyCandidate lateCandidate;
757
758@@ -671,16 +674,16 @@
759 Qt::NoModifier,
760 Qt::TouchPointPressed,
761 touchPoints);
762- touchRegistry.update(&touchEvent);
763+ touchRegistry->update(&touchEvent);
764 }
765
766- touchRegistry.addCandidateOwnerForTouch(0, &earlyCandidate);
767- touchRegistry.addCandidateOwnerForTouch(0, &lateCandidate);
768+ touchRegistry->addCandidateOwnerForTouch(0, &earlyCandidate);
769+ touchRegistry->addCandidateOwnerForTouch(0, &lateCandidate);
770
771 QVERIFY(earlyCandidate.ownedTouches.isEmpty());
772 QVERIFY(lateCandidate.ownedTouches.isEmpty());
773
774- touchRegistry.requestTouchOwnership(0, &lateCandidate);
775+ touchRegistry->requestTouchOwnership(0, &lateCandidate);
776
777 QVERIFY(earlyCandidate.ownedTouches.isEmpty());
778 QVERIFY(lateCandidate.ownedTouches.isEmpty());
779@@ -694,25 +697,25 @@
780 Qt::NoModifier,
781 Qt::TouchPointPressed,
782 touchPoints);
783- touchRegistry.update(&touchEvent);
784+ touchRegistry->update(&touchEvent);
785 }
786
787 QVERIFY(earlyCandidate.ownedTouches.isEmpty());
788 QVERIFY(lateCandidate.ownedTouches.isEmpty());
789
790- touchRegistry.removeCandidateOwnerForTouch(0, &earlyCandidate);
791+ touchRegistry->removeCandidateOwnerForTouch(0, &earlyCandidate);
792
793 QCOMPARE(lateCandidate.ownedTouches.count(), 1);
794 QCOMPARE(lateCandidate.ownedTouches.contains(0), 1);
795
796 // Check that there's no trace left of touch 0 as we no longer need to keep tabs on it.
797- QVERIFY(!touchRegistry.findTouchInfo(0));
798+ QVERIFY(!touchRegistry->findTouchInfo(0));
799 }
800
801 void tst_TouchRegistry::removeOldUndecidedCandidates()
802 {
803 FakeTimerFactory *fakeTimerFactory = new FakeTimerFactory;
804- TouchRegistry *touchRegistry = new TouchRegistry(nullptr, fakeTimerFactory);
805+ touchRegistry->setTimerFactory(fakeTimerFactory);
806
807 DummyCandidate undecidedCandidate;
808 undecidedCandidate.setObjectName("undecided");
809@@ -749,8 +752,6 @@
810 QVERIFY(undecidedCandidate.lostTouches.contains(0));
811 QVERIFY(candidateThatWantsTouch.ownedTouches.contains(0));
812 QVERIFY(candidateThatWantsTouch.lostTouches.isEmpty());
813-
814- delete touchRegistry;
815 }
816
817 /*
818@@ -762,7 +763,7 @@
819 void tst_TouchRegistry::interimOwnerWontGetUnownedTouchEvents()
820 {
821 FakeTimerFactory *fakeTimerFactory = new FakeTimerFactory;
822- TouchRegistry *touchRegistry = new TouchRegistry(nullptr, fakeTimerFactory);
823+ touchRegistry->setTimerFactory(fakeTimerFactory);
824
825 DummyCandidate undecidedCandidate;
826 undecidedCandidate.setObjectName("undecided");
827@@ -814,8 +815,6 @@
828
829 QCOMPARE(undecidedCandidate.unownedTouchEvents.count(), 2);
830 QCOMPARE(interimOwner.unownedTouchEvents.count(), 0);
831-
832- delete touchRegistry;
833 }
834
835 ////////////// TouchMemento //////////
836
837=== modified file 'tests/plugins/Ubuntu/Gestures/GestureTest.cpp'
838--- tests/plugins/Ubuntu/Gestures/GestureTest.cpp 2015-04-10 21:16:37 +0000
839+++ tests/plugins/Ubuntu/Gestures/GestureTest.cpp 2015-05-11 09:54:47 +0000
840@@ -53,7 +53,8 @@
841
842 m_fakeTimerFactory = new FakeTimerFactory;
843
844- m_touchRegistry = new TouchRegistry(nullptr, m_fakeTimerFactory);
845+ m_touchRegistry = TouchRegistry::instance();
846+ m_touchRegistry->setTimerFactory(m_fakeTimerFactory);
847 m_view->installEventFilter(m_touchRegistry);
848
849 qApp->processEvents();
850
851=== modified file 'tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp'
852--- tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp 2015-04-10 21:16:37 +0000
853+++ tests/plugins/Ubuntu/Gestures/tst_DirectionalDragArea.cpp 2015-05-11 09:54:47 +0000
854@@ -202,7 +202,7 @@
855 DirectionalDragArea *edgeDragArea =
856 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
857 QVERIFY(edgeDragArea != 0);
858- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
859+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
860 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
861
862 QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea);
863@@ -297,7 +297,7 @@
864 DirectionalDragArea *edgeDragArea =
865 m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
866 QVERIFY(edgeDragArea != 0);
867- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
868+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
869 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
870 edgeDragArea->setImmediateRecognition(true);
871
872@@ -326,7 +326,7 @@
873 DirectionalDragArea *edgeDragArea =
874 m_view->rootObject()->findChild<DirectionalDragArea*>("vnDragArea");
875 QVERIFY(edgeDragArea != 0);
876- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
877+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
878 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
879 edgeDragArea->setImmediateRecognition(true);
880
881@@ -357,7 +357,7 @@
882 DirectionalDragArea *edgeDragArea =
883 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
884 QVERIFY(edgeDragArea != 0);
885- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
886+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
887 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
888
889 // Make touches evenly spaced along the edgeDragArea
890@@ -439,7 +439,7 @@
891 DirectionalDragArea *edgeDragArea =
892 rightwardsLauncher->findChild<DirectionalDragArea*>("hpDragArea");
893 Q_ASSERT(edgeDragArea != 0);
894- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
895+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
896 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
897
898 QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea);
899@@ -479,7 +479,7 @@
900 DirectionalDragArea *edgeDragArea =
901 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
902 Q_ASSERT(edgeDragArea != 0);
903- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
904+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
905 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
906
907 // Make touches evenly spaced along the edgeDragArea
908@@ -542,7 +542,7 @@
909 DirectionalDragArea *edgeDragArea =
910 rightwardsLauncher->findChild<DirectionalDragArea*>("hpDragArea");
911 Q_ASSERT(edgeDragArea != 0);
912- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
913+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
914 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
915
916 QPointF initialTouchPos = calculateInitialTouchPos(edgeDragArea);
917@@ -582,7 +582,7 @@
918 DirectionalDragArea *edgeDragArea =
919 rightwardsLauncher->findChild<DirectionalDragArea*>("hpDragArea");
920 Q_ASSERT(edgeDragArea != 0);
921- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
922+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
923 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
924
925 // to disable the position smoothing so that we can more easily check sceneDistance values
926@@ -640,7 +640,7 @@
927 DirectionalDragArea *edgeDragArea =
928 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
929 Q_ASSERT(edgeDragArea != 0);
930- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
931+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
932 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
933
934 QPointF touchPoint = calculateInitialTouchPos(edgeDragArea);
935@@ -678,7 +678,7 @@
936 DirectionalDragArea *edgeDragArea =
937 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
938 Q_ASSERT(edgeDragArea != 0);
939- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
940+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
941 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
942
943 // Disable some constraints we're not interested in
944@@ -753,7 +753,7 @@
945 DirectionalDragArea *edgeDragArea =
946 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
947 Q_ASSERT(edgeDragArea != 0);
948- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
949+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
950 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
951
952 // Disable some constraints we're not interested in
953@@ -798,7 +798,7 @@
954 DirectionalDragArea *edgeDragArea =
955 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
956 Q_ASSERT(edgeDragArea != 0);
957- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
958+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
959 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
960
961 // Disable some constraints we're not interested in
962@@ -867,7 +867,7 @@
963 DirectionalDragArea *edgeDragArea =
964 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
965 Q_ASSERT(edgeDragArea != 0);
966- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
967+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
968 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
969
970 // Disable the minimum amount of constraints to ensure immediate recognition
971@@ -900,7 +900,7 @@
972 DirectionalDragArea *edgeDragArea =
973 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
974 Q_ASSERT(edgeDragArea != 0);
975- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
976+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
977 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
978
979 QPointF touchPoint = calculateInitialTouchPos(edgeDragArea);
980@@ -964,7 +964,7 @@
981 DirectionalDragArea *edgeDragArea =
982 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
983 QVERIFY(edgeDragArea != nullptr);
984- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
985+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
986 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
987
988 QQuickMouseArea *mouseArea =
989@@ -1014,7 +1014,7 @@
990 DirectionalDragArea *edgeDragArea =
991 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
992 QVERIFY(edgeDragArea != 0);
993- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
994+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
995 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
996
997 QPointF touch0 = edgeDragArea->mapToScene(
998@@ -1109,7 +1109,7 @@
999 DirectionalDragArea *edgeDragArea =
1000 m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
1001 QVERIFY(edgeDragArea != nullptr);
1002- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
1003+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
1004 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
1005
1006 StatusSpy *statusSpy = new StatusSpy(edgeDragArea);
1007@@ -1154,7 +1154,7 @@
1008 DirectionalDragArea *edgeDragArea =
1009 m_view->rootObject()->findChild<DirectionalDragArea*>("hnDragArea");
1010 QVERIFY(edgeDragArea != nullptr);
1011- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
1012+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
1013 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
1014
1015 edgeDragArea->d->setPixelsPerMm(320.0 /*mako ppi*/ * 0.03937 /* inches per mm*/);
1016@@ -1198,7 +1198,7 @@
1017 DirectionalDragArea *edgeDragArea =
1018 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
1019 QVERIFY(edgeDragArea != nullptr);
1020- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
1021+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
1022 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
1023
1024 edgeDragArea->d->setPixelsPerMm(320.0 /*mako ppi*/ * 0.03937 /* inches per mm*/);
1025@@ -1262,7 +1262,7 @@
1026 DirectionalDragArea *edgeDragArea =
1027 m_view->rootObject()->findChild<DirectionalDragArea*>("hpDragArea");
1028 QVERIFY(edgeDragArea != nullptr);
1029- edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer());
1030+ edgeDragArea->d->setRecognitionTimer(m_fakeTimerFactory->createTimer(edgeDragArea));
1031 edgeDragArea->d->setTimeSource(m_fakeTimerFactory->timeSource());
1032
1033 edgeDragArea->d->setPixelsPerMm(320.0 /*mako ppi*/ * 0.03937 /* inches per mm*/);
1034
1035=== modified file 'tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp'
1036--- tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp 2015-04-10 21:16:37 +0000
1037+++ tests/plugins/Ubuntu/Gestures/tst_TouchGate.cpp 2015-05-11 09:54:47 +0000
1038@@ -104,10 +104,9 @@
1039
1040 void tst_TouchGate::init()
1041 {
1042- touchRegistry = new TouchRegistry;
1043+ touchRegistry = TouchRegistry::instance();
1044
1045 view = createView();
1046- view->installEventFilter(touchRegistry);
1047 view->setSource(QUrl::fromLocalFile("touchGateExample.qml"));
1048 view->show();
1049 QVERIFY(QTest::qWaitForWindowExposed(view));
1050
1051=== modified file 'tests/qmltests/Components/tst_DragHandle.cpp'
1052--- tests/qmltests/Components/tst_DragHandle.cpp 2015-04-10 21:16:37 +0000
1053+++ tests/qmltests/Components/tst_DragHandle.cpp 2015-05-11 09:54:47 +0000
1054@@ -26,7 +26,6 @@
1055 #include <DirectionalDragArea.h>
1056 #include <DirectionalDragArea_p.h>
1057 #include <Timer.h>
1058-#include <TouchRegistry.h>
1059
1060 using namespace UbuntuGestures;
1061
1062@@ -61,7 +60,6 @@
1063
1064 QQuickView *createView();
1065 QQuickView *m_view;
1066- TouchRegistry *m_touchRegistry;
1067 QTouchDevice *m_device;
1068 FakeTimer *m_fakeTimer;
1069 QSharedPointer<FakeTimeSource> m_fakeTimeSource;
1070@@ -85,10 +83,7 @@
1071
1072 void tst_DragHandle::init()
1073 {
1074- m_touchRegistry = new TouchRegistry;
1075-
1076 m_view = createView();
1077- m_view->installEventFilter(m_touchRegistry);
1078 m_view->setSource(QUrl::fromLocalFile(TEST_DIR"/tst_DragHandle.qml"));
1079 m_view->show();
1080 QVERIFY(QTest::qWaitForWindowExposed(m_view));
1081@@ -108,9 +103,6 @@
1082 delete m_view;
1083 m_view = 0;
1084
1085- delete m_touchRegistry;
1086- m_touchRegistry = 0;
1087-
1088 delete m_fakeTimer;
1089 m_fakeTimer = 0;
1090
1091
1092=== modified file 'tests/uqmlscene/main.cpp'
1093--- tests/uqmlscene/main.cpp 2015-03-02 12:41:17 +0000
1094+++ tests/uqmlscene/main.cpp 2015-05-11 09:54:47 +0000
1095@@ -63,9 +63,6 @@
1096 #include <QtCore/QTranslator>
1097 #include <QtCore/QLibraryInfo>
1098
1099-// UbuntuGestures lib
1100-#include <TouchRegistry.h>
1101-
1102 #define UQMLSCENE_DEBUG_ACTIVE_FOCUS 0
1103
1104 #if UQMLSCENE_DEBUG_ACTIVE_FOCUS
1105@@ -434,11 +431,6 @@
1106 app.setOrganizationName("Qt Project");
1107 app.setOrganizationDomain("qt-project.org");
1108
1109- // Create it before loading the module, so that TestUtil
1110- // doesn't create one with a fake timer factory.
1111- // When interacting manually with a test we want the real deal.
1112- new TouchRegistry;
1113-
1114 #ifndef QT_NO_TRANSLATION
1115 QTranslator translator;
1116 QTranslator qtTranslator;
1117@@ -512,8 +504,6 @@
1118 #if UQMLSCENE_DEBUG_ACTIVE_FOCUS
1119 activeFocusLogger.setWindow(qxView);
1120 #endif
1121- TouchRegistry::instance()->setParent(qxView);
1122- qxView->installEventFilter(TouchRegistry::instance());
1123 window = qxView;
1124 // Set window default properties; the qml can still override them
1125 QString oname = contentItem->objectName();
1126
1127=== modified file 'tests/utils/modules/Unity/Test/UnityTestCase.qml'
1128--- tests/utils/modules/Unity/Test/UnityTestCase.qml 2015-04-15 19:32:03 +0000
1129+++ tests/utils/modules/Unity/Test/UnityTestCase.qml 2015-05-11 09:54:47 +0000
1130@@ -382,8 +382,6 @@
1131 }
1132
1133 Component.onCompleted: {
1134- UT.Util.ensureTouchRegistryInstalled();
1135-
1136 var rootItem = parent;
1137 while (rootItem.parent != undefined) {
1138 rootItem = rootItem.parent;
1139
1140=== modified file 'tests/utils/modules/Unity/Test/testutil.cpp'
1141--- tests/utils/modules/Unity/Test/testutil.cpp 2015-02-17 15:06:33 +0000
1142+++ tests/utils/modules/Unity/Test/testutil.cpp 2015-05-11 09:54:47 +0000
1143@@ -31,6 +31,7 @@
1144 : QObject(parent)
1145 , m_targetWindow(0)
1146 , m_touchDevice(0)
1147+ , m_putFakeTimerFactoryInTouchRegistry(false)
1148 {
1149 }
1150
1151@@ -59,7 +60,13 @@
1152 {
1153 ensureTargetWindow();
1154 ensureTouchDevice();
1155- ensureTouchRegistryInstalled();
1156+
1157+ // Tests can be *very* slow to run and we don't want things timing out because
1158+ // of that. So give it fake timers to use (they will never time out)
1159+ if (!m_putFakeTimerFactoryInTouchRegistry) {
1160+ TouchRegistry::instance()->setTimerFactory(new FakeTimerFactory);
1161+ m_putFakeTimerFactoryInTouchRegistry = true;
1162+ }
1163
1164 return new TouchEventSequenceWrapper(
1165 QTest::touchEvent(m_targetWindow, m_touchDevice, /* autoCommit */ false), item);
1166@@ -79,22 +86,3 @@
1167 QWindowSystemInterface::registerTouchDevice(m_touchDevice);
1168 }
1169 }
1170-
1171-void TestUtil::ensureTouchRegistryInstalled()
1172-{
1173- if (TouchRegistry::instance())
1174- return;
1175-
1176- if (!m_targetWindow)
1177- return;
1178-
1179- // Tests can be *very* slow to run and we don't want things timing out because
1180- // of that. So give it fake timers to use (they will never time out)
1181- TouchRegistry *touchRegistry = new TouchRegistry(this, new FakeTimerFactory);
1182-
1183- QQuickView *view = qobject_cast<QQuickView*>(m_targetWindow);
1184- if (view) {
1185- view->installEventFilter(touchRegistry);
1186- touchRegistry->setParent(view);
1187- }
1188-}
1189
1190=== modified file 'tests/utils/modules/Unity/Test/testutil.h'
1191--- tests/utils/modules/Unity/Test/testutil.h 2015-02-17 15:06:33 +0000
1192+++ tests/utils/modules/Unity/Test/testutil.h 2015-05-11 09:54:47 +0000
1193@@ -34,7 +34,6 @@
1194
1195 Q_INVOKABLE bool isInstanceOf(QObject*, QString);
1196 Q_INVOKABLE TouchEventSequenceWrapper *touchEvent(QQuickItem *item);
1197- Q_INVOKABLE void ensureTouchRegistryInstalled();
1198
1199 private:
1200 void ensureTargetWindow();
1201@@ -42,6 +41,7 @@
1202
1203 QWindow *m_targetWindow;
1204 QTouchDevice *m_touchDevice;
1205+ bool m_putFakeTimerFactoryInTouchRegistry;
1206 };
1207
1208 QML_DECLARE_TYPE(TestUtil)

Subscribers

People subscribed via source and target branches