[dali_1.0.12] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-TouchEventCombiner.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19
20 #include <stdlib.h>
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-combiner.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali/integration-api/events/hover-event-integ.h>
25 #include <dali-test-suite-utils.h>
26
27 using namespace Dali;
28 using namespace Dali::Integration;
29
30 void utc_dali_touch_event_combiner_startup(void)
31 {
32   test_return_value = TET_UNDEF;
33 }
34
35 void utc_dali_touch_event_combiner_cleanup(void)
36 {
37   test_return_value = TET_PASS;
38 }
39
40
41 int UtcDaliTouchEventCombinerConstructors(void)
42 {
43   TouchEventCombiner combiner1;
44   DALI_TEST_EQUALS( combiner1.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(1), TEST_LOCATION );
45   DALI_TEST_EQUALS( combiner1.GetMinimumMotionDistanceThreshold(), Vector2( 1.0f, 1.0f ), TEST_LOCATION );
46
47   TouchEventCombiner combiner2( 10, 20.0f, 31.0f );
48   DALI_TEST_EQUALS( combiner2.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
49   DALI_TEST_EQUALS( combiner2.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
50
51   TouchEventCombiner combiner3( 10, Vector2( 20.0f, 31.0f ) );
52   DALI_TEST_EQUALS( combiner3.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
53   DALI_TEST_EQUALS( combiner3.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
54
55   // Boundary Checks
56
57   TouchEventCombiner combiner4( 10, 0.0f, 0.0f );
58   DALI_TEST_EQUALS( combiner4.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
59
60   TouchEventCombiner combiner5( 10, Vector2( 0.0f, 0.0f ) );
61   DALI_TEST_EQUALS( combiner5.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
62   END_TEST;
63 }
64
65 int UtcDaliTouchEventCombinerConstructorsNegative(void)
66 {
67   try
68   {
69     TouchEventCombiner combiner( 10, -20.0f, 31.0f );
70     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
71     tet_result( TET_FAIL );
72   }
73   catch ( Dali::DaliException& e )
74   {
75     tet_result( TET_PASS );
76   }
77
78   try
79   {
80     TouchEventCombiner combiner( 10, 20.0f, -31.0f );
81     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
82     tet_result( TET_FAIL );
83   }
84   catch ( Dali::DaliException& e )
85   {
86     tet_result( TET_PASS );
87   }
88
89   try
90   {
91     TouchEventCombiner combiner( 10, Vector2( -20.0f, 31.0f ) );
92     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
93     tet_result( TET_FAIL );
94   }
95   catch ( Dali::DaliException& e )
96   {
97     tet_result( TET_PASS );
98   }
99
100   try
101   {
102     TouchEventCombiner combiner( 10, Vector2( 20.0f, -31.0f ) );
103     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
104     tet_result( TET_FAIL );
105   }
106   catch ( Dali::DaliException& e )
107   {
108     tet_result( TET_PASS );
109   }
110   END_TEST;
111 }
112
113 int UtcDaliTouchEventCombinerSettersAndGetters(void)
114 {
115   TouchEventCombiner combiner;
116   unsigned long time( 10u );
117   Vector2 distance( 40.0f, 30.0f );
118
119   DALI_TEST_CHECK( combiner.GetMinimumMotionTimeThreshold() != time );
120   DALI_TEST_CHECK( combiner.GetMinimumMotionDistanceThreshold() != distance );
121
122   combiner.SetMinimumMotionTimeThreshold( time );
123   DALI_TEST_EQUALS( combiner.GetMinimumMotionTimeThreshold(), time, TEST_LOCATION );
124
125   combiner.SetMinimumMotionDistanceThreshold( distance.x );
126   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2( distance.x, distance.x ), TEST_LOCATION );
127
128   distance.x = 20.0f;
129   distance.y = 50.0f;
130   combiner.SetMinimumMotionDistanceThreshold( distance.x, distance.y );
131   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
132
133   distance.x = 100.0f;
134   distance.y = 20.0f;
135   combiner.SetMinimumMotionDistanceThreshold( distance );
136   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
137
138   // Boundary Checks
139
140   combiner.SetMinimumMotionDistanceThreshold( 0.0f );
141   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
142
143   combiner.SetMinimumMotionDistanceThreshold( 0.0f, 0.0f );
144   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
145
146   combiner.SetMinimumMotionDistanceThreshold( Vector2::ZERO );
147   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
148   END_TEST;
149 }
150
151 int UtcDaliTouchEventCombinerSettersNegative(void)
152 {
153   TouchEventCombiner combiner;
154
155   try
156   {
157     combiner.SetMinimumMotionDistanceThreshold( -100.0f );
158     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
159     tet_result( TET_FAIL );
160   }
161   catch ( Dali::DaliException& e )
162   {
163     tet_result( TET_PASS );
164   }
165
166   try
167   {
168     combiner.SetMinimumMotionDistanceThreshold( -100.0f, 20.0f );
169     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
170     tet_result( TET_FAIL );
171   }
172   catch ( Dali::DaliException& e )
173   {
174     tet_result( TET_PASS );
175   }
176
177   try
178   {
179     combiner.SetMinimumMotionDistanceThreshold( 100.0f, -20.0f );
180     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
181     tet_result( TET_FAIL );
182   }
183   catch ( Dali::DaliException& e )
184   {
185     tet_result( TET_PASS );
186   }
187
188   try
189   {
190     combiner.SetMinimumMotionDistanceThreshold( Vector2( -100.0f, 20.0f ) );
191     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
192     tet_result( TET_FAIL );
193   }
194   catch ( Dali::DaliException& e )
195   {
196     tet_result( TET_PASS );
197   }
198
199   try
200   {
201     combiner.SetMinimumMotionDistanceThreshold( Vector2( 100.0f, -20.0f ) );
202     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
203     tet_result( TET_FAIL );
204   }
205   catch ( Dali::DaliException& e )
206   {
207     tet_result( TET_PASS );
208   }
209   END_TEST;
210 }
211
212 int UtcDaliTouchEventCombinerSingleTouchNormal(void)
213 {
214   TouchEventCombiner combiner;
215   unsigned long time( 0u );
216
217   // Down event
218   {
219     Integration::TouchEvent touchEvent;
220     Integration::HoverEvent hoverEvent;
221     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
222
223     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
224     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
225     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
226     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
227     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
228   }
229
230   time++;
231
232   // Motion in X direction
233   {
234     Integration::TouchEvent touchEvent;
235     Integration::HoverEvent hoverEvent;
236     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f );
237
238     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
239     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
240     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
241     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
242     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
243   }
244
245   time++;
246
247   // Motion in Y direction
248   {
249     Integration::TouchEvent touchEvent;
250     Integration::HoverEvent hoverEvent;
251     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 101.0f );
252
253     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
254     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
255     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
256     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
257     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
258   }
259
260   // Motion event, but same time
261   {
262     Integration::TouchEvent touchEvent;
263     Integration::HoverEvent hoverEvent;
264     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
265
266     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
267   }
268
269   time++;
270
271   // Motion event, both X and Y movement
272   {
273     Integration::TouchEvent touchEvent;
274     Integration::HoverEvent hoverEvent;
275     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
276
277     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
278     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
279     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
280     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
281     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
282   }
283
284   time++;
285
286   // Motion event, no movement
287   {
288     Integration::TouchEvent touchEvent;
289     Integration::HoverEvent hoverEvent;
290     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
291
292     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
293   }
294
295   // Up event, no time diff, no movement
296   {
297     Integration::TouchEvent touchEvent;
298     Integration::HoverEvent hoverEvent;
299     TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f );
300
301     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
302     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
303     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
304     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
305     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
306   }
307   END_TEST;
308 }
309
310 int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void)
311 {
312   TouchEventCombiner combiner;
313   unsigned long time( 0u );
314
315   // Motion event
316   {
317     Integration::TouchEvent touchEvent;
318     Integration::HoverEvent hoverEvent;
319     TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f );
320
321     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
322     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
323     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
324     DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION );
325     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
326   }
327
328   time++;
329
330   // Motion event
331   {
332     Integration::TouchEvent touchEvent;
333     Integration::HoverEvent hoverEvent;
334     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
335
336     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
337     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
338     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
339     DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION );
340     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
341   }
342   END_TEST;
343 }
344
345 int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void)
346 {
347   TouchEventCombiner combiner;
348   unsigned long time( 0u );
349
350   // Motion event
351   {
352     Integration::TouchEvent touchEvent;
353     Integration::HoverEvent hoverEvent;
354     TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f );
355
356     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
357     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
358     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
359     DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION );
360     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
361   }
362
363   time++;
364
365   // Motion event
366   {
367     Integration::TouchEvent touchEvent;
368     Integration::HoverEvent hoverEvent;
369     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
370
371     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
372     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
373     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
374     DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION );
375     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
376   }
377
378   time++;
379
380   // Motion event
381   {
382     Integration::TouchEvent touchEvent;
383     Integration::HoverEvent hoverEvent;
384     TouchPoint point( 1, TouchPoint::Motion, 103.0f, 103.0f );
385
386     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
387     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
388     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
389     DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION );
390     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
391   }
392
393   time++;
394
395   // Down event
396   {
397     Integration::TouchEvent touchEvent;
398     Integration::HoverEvent hoverEvent;
399     TouchPoint point( 1, TouchPoint::Down, 103.0f, 103.0f );
400
401     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
402     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
403     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
404     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
405     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
406     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
407     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
408     DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Finished, TEST_LOCATION );
409     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
410   }
411   END_TEST;
412 }
413
414 int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void)
415 {
416   TouchEventCombiner combiner;
417   unsigned long time( 0u );
418
419   // Down event
420   {
421     Integration::TouchEvent touchEvent;
422     Integration::HoverEvent hoverEvent;
423     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
424
425     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
426     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
427     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
428     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
429     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
430   }
431
432   time++;
433
434   // Another down with the same ID
435   {
436     Integration::TouchEvent touchEvent;
437     Integration::HoverEvent hoverEvent;
438     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
439
440     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
441   }
442   END_TEST;
443 }
444
445 int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void)
446 {
447   TouchEventCombiner combiner;
448   unsigned long time( 0u );
449
450   // Up event
451   {
452     Integration::TouchEvent touchEvent;
453     Integration::HoverEvent hoverEvent;
454     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
455
456     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
457   }
458
459   time++;
460
461   // Up event
462   {
463     Integration::TouchEvent touchEvent;
464     Integration::HoverEvent hoverEvent;
465     TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f );
466
467     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
468   }
469   END_TEST;
470 }
471
472 int UtcDaliTouchEventCombinerSingleTouchTwoUps(void)
473 {
474   TouchEventCombiner combiner;
475   unsigned long time( 0u );
476
477   // Down event
478   {
479     Integration::TouchEvent touchEvent;
480     Integration::HoverEvent hoverEvent;
481     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
482
483     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
484     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
485     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
486     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
487     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
488   }
489
490   time++;
491
492   // Up event
493   {
494     Integration::TouchEvent touchEvent;
495     Integration::HoverEvent hoverEvent;
496     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
497
498     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
499     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
500     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
501     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
502     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
503   }
504
505   time++;
506
507   // Another up event
508   {
509     Integration::TouchEvent touchEvent;
510     Integration::HoverEvent hoverEvent;
511     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
512
513     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
514   }
515   END_TEST;
516 }
517
518 int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void)
519 {
520   TouchEventCombiner combiner;
521   unsigned long time( 0u );
522
523   // Down event
524   {
525     Integration::TouchEvent touchEvent;
526     Integration::HoverEvent hoverEvent;
527     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
528
529     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
530     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
531     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
532     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
533     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
534   }
535
536   time++;
537
538   // Up event with different ID
539   {
540     Integration::TouchEvent touchEvent;
541     Integration::HoverEvent hoverEvent;
542     TouchPoint point( 2, TouchPoint::Up, 100.0f, 100.0f );
543
544     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
545   }
546
547   time++;
548
549   // Up event
550   {
551     Integration::TouchEvent touchEvent;
552     Integration::HoverEvent hoverEvent;
553     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
554
555     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
556     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
557     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
558     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
559     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
560   }
561   END_TEST;
562 }
563
564 int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void)
565 {
566   TouchEventCombiner combiner;
567   unsigned long time( 0u );
568
569   // Down event
570   {
571     Integration::TouchEvent touchEvent;
572     Integration::HoverEvent hoverEvent;
573     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
574
575     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
576     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
577     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
578     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
579     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
580   }
581
582   time++;
583
584   // Motion event with different ID
585   {
586     Integration::TouchEvent touchEvent;
587     Integration::HoverEvent hoverEvent;
588     TouchPoint point( 2, TouchPoint::Motion, 100.0f, 100.0f );
589
590     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchHover, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
591     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
592     DALI_TEST_EQUALS( hoverEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
593     DALI_TEST_EQUALS( hoverEvent.points[0].state, TouchPoint::Started, TEST_LOCATION );
594     DALI_TEST_EQUALS( hoverEvent.points[0].screen, point.screen, TEST_LOCATION );
595   }
596
597   time++;
598
599   // Motion event
600   {
601     Integration::TouchEvent touchEvent;
602     Integration::HoverEvent hoverEvent;
603     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
604
605     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
606     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
607     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
608     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
609     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
610   }
611   END_TEST;
612 }
613
614 int UtcDaliTouchEventCombinerMultiTouchNormal(void)
615 {
616   TouchEventCombiner combiner;
617   unsigned long time( 0u );
618
619   // 1st point down
620   {
621     Integration::TouchEvent touchEvent;
622     Integration::HoverEvent hoverEvent;
623     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
624
625     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
626     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
627     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
628     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
629     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
630   }
631
632   time++;
633
634   // 2nd point down
635   {
636     Integration::TouchEvent touchEvent;
637     Integration::HoverEvent hoverEvent;
638     TouchPoint point( 2, TouchPoint::Down, 200.0f, 200.0f );
639
640     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
641     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
642     DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION );
643     DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION );
644     DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION );
645     DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION );
646   }
647
648   time++;
649
650   // 1st point motion
651   {
652     Integration::TouchEvent touchEvent;
653     Integration::HoverEvent hoverEvent;
654     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f );
655
656     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
657     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
658     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
659     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
660     DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION );
661     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
662   }
663
664   // 2nd point motion, no time diff
665   {
666     Integration::TouchEvent touchEvent;
667     Integration::HoverEvent hoverEvent;
668     TouchPoint point( 2, TouchPoint::Motion, 200.0f, 200.0f );
669
670     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
671   }
672
673   time++;
674
675   // 2nd point motion
676   {
677     Integration::TouchEvent touchEvent;
678     Integration::HoverEvent hoverEvent;
679     TouchPoint point( 2, TouchPoint::Motion, 201.0f, 201.0f );
680
681     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
682     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
683     DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION );
684     DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION );
685     DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION );
686     DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION );
687   }
688
689   time++;
690
691   // 1st point up
692   {
693     Integration::TouchEvent touchEvent;
694     Integration::HoverEvent hoverEvent;
695     TouchPoint point( 1, TouchPoint::Up, 101.0f, 100.0f );
696
697     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
698     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
699     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
700     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
701     DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION );
702     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
703   }
704
705   time++;
706
707   // 2nd point motion
708   {
709     Integration::TouchEvent touchEvent;
710     Integration::HoverEvent hoverEvent;
711     TouchPoint point( 2, TouchPoint::Motion, 202.0f, 202.0f );
712
713     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
714     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
715     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
716     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
717     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
718   }
719
720   time++;
721
722   // 2nd point up
723   {
724     Integration::TouchEvent touchEvent;
725     Integration::HoverEvent hoverEvent;
726     TouchPoint point( 2, TouchPoint::Up, 202.0f, 202.0f );
727
728     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
729     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
730     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
731     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
732     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
733   }
734   END_TEST;
735 }
736
737 int UtcDaliTouchEventCombinerSeveralPoints(void)
738 {
739   TouchEventCombiner combiner;
740   unsigned long time( 0u );
741   unsigned int const maximum( 200u );
742
743   // Several downs
744   for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
745   {
746     Integration::TouchEvent touchEvent;
747     Integration::HoverEvent hoverEvent;
748     TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f );
749
750     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION );
751     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
752   }
753
754   // Several Ups
755   for ( unsigned int pointCount = maximum - 1; pointCount > 0; --pointCount )
756   {
757     Integration::TouchEvent touchEvent;
758     Integration::HoverEvent hoverEvent;
759     TouchPoint point( pointCount, TouchPoint::Up, 100.0f, 100.0f );
760
761     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION );
762     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
763   }
764   END_TEST;
765 }
766
767 int UtcDaliTouchEventCombinerReset(void)
768 {
769   TouchEventCombiner combiner;
770   unsigned long time( 0u );
771
772   // Down event
773   {
774     Integration::TouchEvent touchEvent;
775     Integration::HoverEvent hoverEvent;
776     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
777
778     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
779     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
780     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
781     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
782     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
783   }
784
785   time++;
786
787   // Reset combiner, no more events should be sent to core.
788   combiner.Reset();
789
790   // Up event
791   {
792     Integration::TouchEvent touchEvent;
793     Integration::HoverEvent hoverEvent;
794     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
795
796     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
797   }
798   END_TEST;
799 }
800
801 int UtcDaliTouchEventCombinerSingleTouchInterrupted(void)
802 {
803   TouchEventCombiner combiner;
804   unsigned long time( 0u );
805
806   // Down event
807   {
808     Integration::TouchEvent touchEvent;
809     Integration::HoverEvent hoverEvent;
810     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
811
812     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
813     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
814     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
815     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
816     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
817   }
818
819   time++;
820
821   // Interrupted event
822   {
823     Integration::TouchEvent touchEvent;
824     Integration::HoverEvent hoverEvent;
825     TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f );
826
827     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
828     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
829     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
830     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
831     DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION );
832   }
833
834   // Send up, should not be able to send as combiner has been reset.
835   // Up event
836   {
837     Integration::TouchEvent touchEvent;
838     Integration::HoverEvent hoverEvent;
839     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
840
841     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
842   }
843   END_TEST;
844 }
845
846 int UtcDaliTouchEventCombinerMultiTouchInterrupted(void)
847 {
848   TouchEventCombiner combiner;
849   unsigned long time( 0u );
850   unsigned int const maximum( 200u );
851
852   // Several downs
853   for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
854   {
855     Integration::TouchEvent touchEvent;
856     Integration::HoverEvent hoverEvent;
857     TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f );
858
859     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchTouch, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
860     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
861   }
862
863   // Interrupted event
864   {
865     Integration::TouchEvent touchEvent;
866     Integration::HoverEvent hoverEvent;
867     TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f );
868
869     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchBoth, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
870     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
871     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
872     DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
873     DALI_TEST_EQUALS( hoverEvent.points[0].state, point.state, TEST_LOCATION );
874   }
875
876   // Send up, should not be able to send as combiner has been reset.
877   // Up event
878   {
879     Integration::TouchEvent touchEvent;
880     Integration::HoverEvent hoverEvent;
881     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
882
883     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
884   }
885   END_TEST;
886 }
887
888 int UtcDaliTouchEventCombinerInvalidState(void)
889 {
890   TouchEventCombiner combiner;
891   unsigned long time( 0u );
892
893   // Stationary event
894   {
895     Integration::TouchEvent touchEvent;
896     Integration::HoverEvent hoverEvent;
897     TouchPoint point( 1, TouchPoint::Stationary, 100.0f, 100.0f );
898
899     DALI_TEST_EQUALS( Integration::TouchEventCombiner::DispatchNone, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
900   }
901   END_TEST;
902 }