License conversion from Flora to Apache 2.0
[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/dali.h>
22 #include <dali/integration-api/events/touch-event-combiner.h>
23 #include <dali/integration-api/events/touch-event-integ.h>
24 #include <dali-test-suite-utils.h>
25
26 using namespace Dali;
27 using namespace Dali::Integration;
28
29 void utc_dali_touch_event_combiner_startup(void)
30 {
31   test_return_value = TET_UNDEF;
32 }
33
34 void utc_dali_touch_event_combiner_cleanup(void)
35 {
36   test_return_value = TET_PASS;
37 }
38
39
40 int UtcDaliTouchEventCombinerConstructors(void)
41 {
42   TouchEventCombiner combiner1;
43   DALI_TEST_EQUALS( combiner1.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(1), TEST_LOCATION );
44   DALI_TEST_EQUALS( combiner1.GetMinimumMotionDistanceThreshold(), Vector2( 1.0f, 1.0f ), TEST_LOCATION );
45
46   TouchEventCombiner combiner2( 10, 20.0f, 31.0f );
47   DALI_TEST_EQUALS( combiner2.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
48   DALI_TEST_EQUALS( combiner2.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
49
50   TouchEventCombiner combiner3( 10, Vector2( 20.0f, 31.0f ) );
51   DALI_TEST_EQUALS( combiner3.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
52   DALI_TEST_EQUALS( combiner3.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
53
54   // Boundary Checks
55
56   TouchEventCombiner combiner4( 10, 0.0f, 0.0f );
57   DALI_TEST_EQUALS( combiner4.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
58
59   TouchEventCombiner combiner5( 10, Vector2( 0.0f, 0.0f ) );
60   DALI_TEST_EQUALS( combiner5.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
61   END_TEST;
62 }
63
64 int UtcDaliTouchEventCombinerConstructorsNegative(void)
65 {
66   try
67   {
68     TouchEventCombiner combiner( 10, -20.0f, 31.0f );
69     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
70     tet_result( TET_FAIL );
71   }
72   catch ( Dali::DaliException& e )
73   {
74     tet_result( TET_PASS );
75   }
76
77   try
78   {
79     TouchEventCombiner combiner( 10, 20.0f, -31.0f );
80     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
81     tet_result( TET_FAIL );
82   }
83   catch ( Dali::DaliException& e )
84   {
85     tet_result( TET_PASS );
86   }
87
88   try
89   {
90     TouchEventCombiner combiner( 10, Vector2( -20.0f, 31.0f ) );
91     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
92     tet_result( TET_FAIL );
93   }
94   catch ( Dali::DaliException& e )
95   {
96     tet_result( TET_PASS );
97   }
98
99   try
100   {
101     TouchEventCombiner combiner( 10, Vector2( 20.0f, -31.0f ) );
102     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
103     tet_result( TET_FAIL );
104   }
105   catch ( Dali::DaliException& e )
106   {
107     tet_result( TET_PASS );
108   }
109   END_TEST;
110 }
111
112 int UtcDaliTouchEventCombinerSettersAndGetters(void)
113 {
114   TouchEventCombiner combiner;
115   unsigned long time( 10u );
116   Vector2 distance( 40.0f, 30.0f );
117
118   DALI_TEST_CHECK( combiner.GetMinimumMotionTimeThreshold() != time );
119   DALI_TEST_CHECK( combiner.GetMinimumMotionDistanceThreshold() != distance );
120
121   combiner.SetMinimumMotionTimeThreshold( time );
122   DALI_TEST_EQUALS( combiner.GetMinimumMotionTimeThreshold(), time, TEST_LOCATION );
123
124   combiner.SetMinimumMotionDistanceThreshold( distance.x );
125   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2( distance.x, distance.x ), TEST_LOCATION );
126
127   distance.x = 20.0f;
128   distance.y = 50.0f;
129   combiner.SetMinimumMotionDistanceThreshold( distance.x, distance.y );
130   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
131
132   distance.x = 100.0f;
133   distance.y = 20.0f;
134   combiner.SetMinimumMotionDistanceThreshold( distance );
135   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
136
137   // Boundary Checks
138
139   combiner.SetMinimumMotionDistanceThreshold( 0.0f );
140   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
141
142   combiner.SetMinimumMotionDistanceThreshold( 0.0f, 0.0f );
143   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
144
145   combiner.SetMinimumMotionDistanceThreshold( Vector2::ZERO );
146   DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
147   END_TEST;
148 }
149
150 int UtcDaliTouchEventCombinerSettersNegative(void)
151 {
152   TouchEventCombiner combiner;
153
154   try
155   {
156     combiner.SetMinimumMotionDistanceThreshold( -100.0f );
157     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
158     tet_result( TET_FAIL );
159   }
160   catch ( Dali::DaliException& e )
161   {
162     tet_result( TET_PASS );
163   }
164
165   try
166   {
167     combiner.SetMinimumMotionDistanceThreshold( -100.0f, 20.0f );
168     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
169     tet_result( TET_FAIL );
170   }
171   catch ( Dali::DaliException& e )
172   {
173     tet_result( TET_PASS );
174   }
175
176   try
177   {
178     combiner.SetMinimumMotionDistanceThreshold( 100.0f, -20.0f );
179     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
180     tet_result( TET_FAIL );
181   }
182   catch ( Dali::DaliException& e )
183   {
184     tet_result( TET_PASS );
185   }
186
187   try
188   {
189     combiner.SetMinimumMotionDistanceThreshold( Vector2( -100.0f, 20.0f ) );
190     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
191     tet_result( TET_FAIL );
192   }
193   catch ( Dali::DaliException& e )
194   {
195     tet_result( TET_PASS );
196   }
197
198   try
199   {
200     combiner.SetMinimumMotionDistanceThreshold( Vector2( 100.0f, -20.0f ) );
201     tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
202     tet_result( TET_FAIL );
203   }
204   catch ( Dali::DaliException& e )
205   {
206     tet_result( TET_PASS );
207   }
208   END_TEST;
209 }
210
211 int UtcDaliTouchEventCombinerSingleTouchNormal(void)
212 {
213   TouchEventCombiner combiner;
214   unsigned long time( 0u );
215
216   // Down event
217   {
218     Integration::TouchEvent touchEvent;
219     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
220
221     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
222     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
223     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
224     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
225     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
226   }
227
228   time++;
229
230   // Motion in X direction
231   {
232     Integration::TouchEvent touchEvent;
233     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f );
234
235     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
236     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
237     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
238     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
239     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
240   }
241
242   time++;
243
244   // Motion in Y direction
245   {
246     Integration::TouchEvent touchEvent;
247     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 101.0f );
248
249     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
250     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
251     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
252     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
253     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
254   }
255
256   // Motion event, but same time
257   {
258     Integration::TouchEvent touchEvent;
259     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
260
261     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
262   }
263
264   time++;
265
266   // Motion event, both X and Y movement
267   {
268     Integration::TouchEvent touchEvent;
269     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
270
271     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
272     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
273     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
274     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
275     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
276   }
277
278   time++;
279
280   // Motion event, no movement
281   {
282     Integration::TouchEvent touchEvent;
283     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
284
285     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
286   }
287
288   // Up event, no time diff, no movement
289   {
290     Integration::TouchEvent touchEvent;
291     TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f );
292
293     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
294     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
295     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
296     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
297     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
298   }
299   END_TEST;
300 }
301
302 int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void)
303 {
304   TouchEventCombiner combiner;
305   unsigned long time( 0u );
306
307   // Motion event
308   {
309     Integration::TouchEvent touchEvent;
310     TouchPoint point( 1, TouchPoint::Motion, 100.0f, 100.0f );
311
312     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
313   }
314
315   time++;
316
317   // Motion event
318   {
319     Integration::TouchEvent touchEvent;
320     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
321
322     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
323   }
324   END_TEST;
325 }
326
327 int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void)
328 {
329   TouchEventCombiner combiner;
330   unsigned long time( 0u );
331
332   // Down event
333   {
334     Integration::TouchEvent touchEvent;
335     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
336
337     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
338     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
339     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
340     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
341     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
342   }
343
344   time++;
345
346   // Another down with the same ID
347   {
348     Integration::TouchEvent touchEvent;
349     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
350
351     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
352   }
353   END_TEST;
354 }
355
356 int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void)
357 {
358   TouchEventCombiner combiner;
359   unsigned long time( 0u );
360
361   // Up event
362   {
363     Integration::TouchEvent touchEvent;
364     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
365
366     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
367   }
368
369   time++;
370
371   // Up event
372   {
373     Integration::TouchEvent touchEvent;
374     TouchPoint point( 1, TouchPoint::Up, 102.0f, 102.0f );
375
376     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
377   }
378   END_TEST;
379 }
380
381 int UtcDaliTouchEventCombinerSingleTouchTwoUps(void)
382 {
383   TouchEventCombiner combiner;
384   unsigned long time( 0u );
385
386   // Down event
387   {
388     Integration::TouchEvent touchEvent;
389     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
390
391     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
392     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
393     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
394     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
395     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
396   }
397
398   time++;
399
400   // Up event
401   {
402     Integration::TouchEvent touchEvent;
403     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
404
405     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
406     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
407     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
408     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
409     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
410   }
411
412   time++;
413
414   // Another up event
415   {
416     Integration::TouchEvent touchEvent;
417     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
418
419     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
420   }
421   END_TEST;
422 }
423
424 int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void)
425 {
426   TouchEventCombiner combiner;
427   unsigned long time( 0u );
428
429   // Down event
430   {
431     Integration::TouchEvent touchEvent;
432     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
433
434     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
435     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
436     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
437     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
438     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
439   }
440
441   time++;
442
443   // Up event with different ID
444   {
445     Integration::TouchEvent touchEvent;
446     TouchPoint point( 2, TouchPoint::Up, 100.0f, 100.0f );
447
448     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
449   }
450
451   time++;
452
453   // Up event
454   {
455     Integration::TouchEvent touchEvent;
456     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
457
458     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
459     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
460     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
461     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
462     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
463   }
464   END_TEST;
465 }
466
467 int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void)
468 {
469   TouchEventCombiner combiner;
470   unsigned long time( 0u );
471
472   // Down event
473   {
474     Integration::TouchEvent touchEvent;
475     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
476
477     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
478     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
479     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
480     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
481     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
482   }
483
484   time++;
485
486   // Motion event with different ID
487   {
488     Integration::TouchEvent touchEvent;
489     TouchPoint point( 2, TouchPoint::Motion, 100.0f, 100.0f );
490
491     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
492   }
493
494   time++;
495
496   // Motion event
497   {
498     Integration::TouchEvent touchEvent;
499     TouchPoint point( 1, TouchPoint::Motion, 102.0f, 102.0f );
500
501     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
502     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
503     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
504     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
505     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
506   }
507   END_TEST;
508 }
509
510 int UtcDaliTouchEventCombinerMultiTouchNormal(void)
511 {
512   TouchEventCombiner combiner;
513   unsigned long time( 0u );
514
515   // 1st point down
516   {
517     Integration::TouchEvent touchEvent;
518     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
519
520     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
521     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
522     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
523     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
524     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
525   }
526
527   time++;
528
529   // 2nd point down
530   {
531     Integration::TouchEvent touchEvent;
532     TouchPoint point( 2, TouchPoint::Down, 200.0f, 200.0f );
533
534     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
535     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
536     DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION );
537     DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION );
538     DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION );
539     DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION );
540   }
541
542   time++;
543
544   // 1st point motion
545   {
546     Integration::TouchEvent touchEvent;
547     TouchPoint point( 1, TouchPoint::Motion, 101.0f, 100.0f );
548
549     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
550     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
551     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
552     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
553     DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION );
554     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
555   }
556
557   // 2nd point motion, no time diff
558   {
559     Integration::TouchEvent touchEvent;
560     TouchPoint point( 2, TouchPoint::Motion, 200.0f, 200.0f );
561
562     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
563   }
564
565   time++;
566
567   // 2nd point motion
568   {
569     Integration::TouchEvent touchEvent;
570     TouchPoint point( 2, TouchPoint::Motion, 201.0f, 201.0f );
571
572     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
573     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
574     DALI_TEST_EQUALS( touchEvent.points[1].deviceId, point.deviceId, TEST_LOCATION );
575     DALI_TEST_EQUALS( touchEvent.points[0].state, TouchPoint::Stationary, TEST_LOCATION );
576     DALI_TEST_EQUALS( touchEvent.points[1].state, point.state, TEST_LOCATION );
577     DALI_TEST_EQUALS( touchEvent.points[1].screen, point.screen, TEST_LOCATION );
578   }
579
580   time++;
581
582   // 1st point up
583   {
584     Integration::TouchEvent touchEvent;
585     TouchPoint point( 1, TouchPoint::Up, 101.0f, 100.0f );
586
587     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
588     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
589     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
590     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
591     DALI_TEST_EQUALS( touchEvent.points[1].state, TouchPoint::Stationary, TEST_LOCATION );
592     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
593   }
594
595   time++;
596
597   // 2nd point motion
598   {
599     Integration::TouchEvent touchEvent;
600     TouchPoint point( 2, TouchPoint::Motion, 202.0f, 202.0f );
601
602     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
603     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
604     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
605     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
606     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
607   }
608
609   time++;
610
611   // 2nd point up
612   {
613     Integration::TouchEvent touchEvent;
614     TouchPoint point( 2, TouchPoint::Up, 202.0f, 202.0f );
615
616     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
617     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
618     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
619     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
620     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
621   }
622   END_TEST;
623 }
624
625 int UtcDaliTouchEventCombinerSeveralPoints(void)
626 {
627   TouchEventCombiner combiner;
628   unsigned long time( 0u );
629   unsigned int const maximum( 200u );
630
631   // Several downs
632   for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
633   {
634     Integration::TouchEvent touchEvent;
635     TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f );
636
637     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION );
638     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
639   }
640
641   // Several Ups
642   for ( unsigned int pointCount = maximum - 1; pointCount > 0; --pointCount )
643   {
644     Integration::TouchEvent touchEvent;
645     TouchPoint point( pointCount, TouchPoint::Up, 100.0f, 100.0f );
646
647     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION );
648     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
649   }
650   END_TEST;
651 }
652
653 int UtcDaliTouchEventCombinerReset(void)
654 {
655   TouchEventCombiner combiner;
656   unsigned long time( 0u );
657
658   // Down event
659   {
660     Integration::TouchEvent touchEvent;
661     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
662
663     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
664     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
665     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
666     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
667     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
668   }
669
670   time++;
671
672   // Reset combiner, no more events should be sent to core.
673   combiner.Reset();
674
675   // Up event
676   {
677     Integration::TouchEvent touchEvent;
678     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
679
680     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
681   }
682   END_TEST;
683 }
684
685 int UtcDaliTouchEventCombinerSingleTouchInterrupted(void)
686 {
687   TouchEventCombiner combiner;
688   unsigned long time( 0u );
689
690   // Down event
691   {
692     Integration::TouchEvent touchEvent;
693     TouchPoint point( 1, TouchPoint::Down, 100.0f, 100.0f );
694
695     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
696     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
697     DALI_TEST_EQUALS( touchEvent.points[0].deviceId, point.deviceId, TEST_LOCATION );
698     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
699     DALI_TEST_EQUALS( touchEvent.points[0].screen, point.screen, TEST_LOCATION );
700   }
701
702   time++;
703
704   // Interrupted event
705   {
706     Integration::TouchEvent touchEvent;
707     TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f );
708
709     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
710     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
711     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
712   }
713
714   // Send up, should not be able to send as combiner has been reset.
715   // Up event
716   {
717     Integration::TouchEvent touchEvent;
718     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
719
720     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
721   }
722   END_TEST;
723 }
724
725 int UtcDaliTouchEventCombinerMultiTouchInterrupted(void)
726 {
727   TouchEventCombiner combiner;
728   unsigned long time( 0u );
729   unsigned int const maximum( 200u );
730
731   // Several downs
732   for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
733   {
734     Integration::TouchEvent touchEvent;
735     TouchPoint point( pointCount, TouchPoint::Down, 100.0f, 100.0f );
736
737     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time++, touchEvent ), TEST_LOCATION );
738     DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
739   }
740
741   // Interrupted event
742   {
743     Integration::TouchEvent touchEvent;
744     TouchPoint point( 1, TouchPoint::Interrupted, 100.0f, 100.0f );
745
746     DALI_TEST_EQUALS( true, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
747     DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
748     DALI_TEST_EQUALS( touchEvent.points[0].state, point.state, TEST_LOCATION );
749   }
750
751   // Send up, should not be able to send as combiner has been reset.
752   // Up event
753   {
754     Integration::TouchEvent touchEvent;
755     TouchPoint point( 1, TouchPoint::Up, 100.0f, 100.0f );
756
757     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
758   }
759   END_TEST;
760 }
761
762 int UtcDaliTouchEventCombinerInvalidState(void)
763 {
764   TouchEventCombiner combiner;
765   unsigned long time( 0u );
766
767   // Stationary event
768   {
769     Integration::TouchEvent touchEvent;
770     TouchPoint point( 1, TouchPoint::Stationary, 100.0f, 100.0f );
771
772     DALI_TEST_EQUALS( false, combiner.GetNextTouchEvent( point, time, touchEvent ), TEST_LOCATION );
773   }
774   END_TEST;
775 }