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