2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
28 using namespace Dali::Integration;
32 Point GeneratePoint( int deviceId, PointState::Type state, float x, float y )
35 point.SetDeviceId( deviceId );
36 point.SetState( state );
37 point.SetScreenPosition( Vector2( x, y ) );
42 void utc_dali_touch_event_combiner_startup(void)
44 test_return_value = TET_UNDEF;
47 void utc_dali_touch_event_combiner_cleanup(void)
49 test_return_value = TET_PASS;
53 int UtcDaliTouchEventCombinerConstructors(void)
55 TouchEventCombiner combiner1;
56 DALI_TEST_EQUALS( combiner1.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(1), TEST_LOCATION );
57 DALI_TEST_EQUALS( combiner1.GetMinimumMotionDistanceThreshold(), Vector2( 1.0f, 1.0f ), TEST_LOCATION );
59 TouchEventCombiner combiner2( 10, 20.0f, 31.0f );
60 DALI_TEST_EQUALS( combiner2.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
61 DALI_TEST_EQUALS( combiner2.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
63 TouchEventCombiner combiner3( 10, Vector2( 20.0f, 31.0f ) );
64 DALI_TEST_EQUALS( combiner3.GetMinimumMotionTimeThreshold(), static_cast<long unsigned>(10), TEST_LOCATION );
65 DALI_TEST_EQUALS( combiner3.GetMinimumMotionDistanceThreshold(), Vector2( 20.0f, 31.0f ), TEST_LOCATION );
69 TouchEventCombiner combiner4( 10, 0.0f, 0.0f );
70 DALI_TEST_EQUALS( combiner4.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
72 TouchEventCombiner combiner5( 10, Vector2( 0.0f, 0.0f ) );
73 DALI_TEST_EQUALS( combiner5.GetMinimumMotionDistanceThreshold(), Vector2( 0.0f, 0.0f ), TEST_LOCATION );
77 int UtcDaliTouchEventCombinerConstructorsNegative(void)
81 TouchEventCombiner combiner( 10, -20.0f, 31.0f );
82 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
83 tet_result( TET_FAIL );
85 catch ( Dali::DaliException& e )
87 tet_result( TET_PASS );
92 TouchEventCombiner combiner( 10, 20.0f, -31.0f );
93 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
94 tet_result( TET_FAIL );
96 catch ( Dali::DaliException& e )
98 tet_result( TET_PASS );
103 TouchEventCombiner combiner( 10, Vector2( -20.0f, 31.0f ) );
104 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
105 tet_result( TET_FAIL );
107 catch ( Dali::DaliException& e )
109 tet_result( TET_PASS );
114 TouchEventCombiner combiner( 10, Vector2( 20.0f, -31.0f ) );
115 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
116 tet_result( TET_FAIL );
118 catch ( Dali::DaliException& e )
120 tet_result( TET_PASS );
125 int UtcDaliTouchEventCombinerSettersAndGetters(void)
127 TouchEventCombiner combiner;
128 unsigned long time( 10u );
129 Vector2 distance( 40.0f, 30.0f );
131 DALI_TEST_CHECK( combiner.GetMinimumMotionTimeThreshold() != time );
132 DALI_TEST_CHECK( combiner.GetMinimumMotionDistanceThreshold() != distance );
134 combiner.SetMinimumMotionTimeThreshold( time );
135 DALI_TEST_EQUALS( combiner.GetMinimumMotionTimeThreshold(), time, TEST_LOCATION );
137 combiner.SetMinimumMotionDistanceThreshold( distance.x );
138 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2( distance.x, distance.x ), TEST_LOCATION );
142 combiner.SetMinimumMotionDistanceThreshold( distance.x, distance.y );
143 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
147 combiner.SetMinimumMotionDistanceThreshold( distance );
148 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), distance, TEST_LOCATION );
152 combiner.SetMinimumMotionDistanceThreshold( 0.0f );
153 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
155 combiner.SetMinimumMotionDistanceThreshold( 0.0f, 0.0f );
156 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
158 combiner.SetMinimumMotionDistanceThreshold( Vector2::ZERO );
159 DALI_TEST_EQUALS( combiner.GetMinimumMotionDistanceThreshold(), Vector2::ZERO, TEST_LOCATION );
163 int UtcDaliTouchEventCombinerSettersNegative(void)
165 TouchEventCombiner combiner;
169 combiner.SetMinimumMotionDistanceThreshold( -100.0f );
170 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
171 tet_result( TET_FAIL );
173 catch ( Dali::DaliException& e )
175 tet_result( TET_PASS );
180 combiner.SetMinimumMotionDistanceThreshold( -100.0f, 20.0f );
181 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
182 tet_result( TET_FAIL );
184 catch ( Dali::DaliException& e )
186 tet_result( TET_PASS );
191 combiner.SetMinimumMotionDistanceThreshold( 100.0f, -20.0f );
192 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
193 tet_result( TET_FAIL );
195 catch ( Dali::DaliException& e )
197 tet_result( TET_PASS );
202 combiner.SetMinimumMotionDistanceThreshold( Vector2( -100.0f, 20.0f ) );
203 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
204 tet_result( TET_FAIL );
206 catch ( Dali::DaliException& e )
208 tet_result( TET_PASS );
213 combiner.SetMinimumMotionDistanceThreshold( Vector2( 100.0f, -20.0f ) );
214 tet_printf( "%s: Should have asserted\n", TEST_LOCATION );
215 tet_result( TET_FAIL );
217 catch ( Dali::DaliException& e )
219 tet_result( TET_PASS );
224 int UtcDaliTouchEventCombinerSingleTouchNormal(void)
226 TouchEventCombiner combiner;
227 unsigned long time( 0u );
231 Integration::TouchEvent touchEvent;
232 Integration::HoverEvent hoverEvent;
233 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
235 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
236 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
237 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
238 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
239 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
244 // Motion in X direction
246 Integration::TouchEvent touchEvent;
247 Integration::HoverEvent hoverEvent;
248 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 100.0f );
250 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
251 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
252 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
253 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
254 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
259 // Motion in Y direction
261 Integration::TouchEvent touchEvent;
262 Integration::HoverEvent hoverEvent;
263 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 101.0f );
265 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
266 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
267 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
268 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
269 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
272 // Motion event, but same time
274 Integration::TouchEvent touchEvent;
275 Integration::HoverEvent hoverEvent;
276 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
278 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
283 // Motion event, both X and Y movement
285 Integration::TouchEvent touchEvent;
286 Integration::HoverEvent hoverEvent;
287 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
289 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
290 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
291 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
292 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
293 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
298 // Motion event, no movement
300 Integration::TouchEvent touchEvent;
301 Integration::HoverEvent hoverEvent;
302 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
304 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
307 // Up event, no time diff, no movement
309 Integration::TouchEvent touchEvent;
310 Integration::HoverEvent hoverEvent;
311 Integration::Point point = GeneratePoint( 1, PointState::UP, 102.0f, 102.0f );
313 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
314 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
315 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
316 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
317 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
322 int UtcDaliTouchEventCombinerSingleTouchMotionWithoutDown(void)
324 TouchEventCombiner combiner;
325 unsigned long time( 0u );
329 Integration::TouchEvent touchEvent;
330 Integration::HoverEvent hoverEvent;
331 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 100.0f, 100.0f );
333 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
334 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
335 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
336 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION );
337 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
344 Integration::TouchEvent touchEvent;
345 Integration::HoverEvent hoverEvent;
346 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
348 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
349 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
350 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
351 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
352 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
357 int UtcDaliTouchEventCombinerSingleTouchMotionFollowedByDown(void)
359 TouchEventCombiner combiner;
360 unsigned long time( 0u );
364 Integration::TouchEvent touchEvent;
365 Integration::HoverEvent hoverEvent;
366 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 100.0f, 100.0f );
368 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
369 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
370 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
371 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION );
372 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
379 Integration::TouchEvent touchEvent;
380 Integration::HoverEvent hoverEvent;
381 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
383 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
384 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
385 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
386 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
387 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
394 Integration::TouchEvent touchEvent;
395 Integration::HoverEvent hoverEvent;
396 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 103.0f, 103.0f );
398 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
399 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
400 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
401 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
402 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
409 Integration::TouchEvent touchEvent;
410 Integration::HoverEvent hoverEvent;
411 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 103.0f, 103.0f );
413 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
414 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
415 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
416 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
417 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
418 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
419 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
420 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::FINISHED, TEST_LOCATION );
421 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
426 int UtcDaliTouchEventCombinerSingleTouchTwoDowns(void)
428 TouchEventCombiner combiner;
429 unsigned long time( 0u );
433 Integration::TouchEvent touchEvent;
434 Integration::HoverEvent hoverEvent;
435 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
437 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
438 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
439 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
440 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
441 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
446 // Another down with the same ID
448 Integration::TouchEvent touchEvent;
449 Integration::HoverEvent hoverEvent;
450 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
452 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
457 int UtcDaliTouchEventCombinerSingleTouchUpWithoutDown(void)
459 TouchEventCombiner combiner;
460 unsigned long time( 0u );
464 Integration::TouchEvent touchEvent;
465 Integration::HoverEvent hoverEvent;
466 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
468 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
475 Integration::TouchEvent touchEvent;
476 Integration::HoverEvent hoverEvent;
477 Integration::Point point = GeneratePoint( 1, PointState::UP, 102.0f, 102.0f );
479 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
484 int UtcDaliTouchEventCombinerSingleTouchTwoUps(void)
486 TouchEventCombiner combiner;
487 unsigned long time( 0u );
491 Integration::TouchEvent touchEvent;
492 Integration::HoverEvent hoverEvent;
493 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
495 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
496 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
497 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
498 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
499 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
506 Integration::TouchEvent touchEvent;
507 Integration::HoverEvent hoverEvent;
508 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
510 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
511 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
512 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
513 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
514 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
521 Integration::TouchEvent touchEvent;
522 Integration::HoverEvent hoverEvent;
523 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
525 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
530 int UtcDaliTouchEventCombinerSingleTouchUpWithDifferentId(void)
532 TouchEventCombiner combiner;
533 unsigned long time( 0u );
537 Integration::TouchEvent touchEvent;
538 Integration::HoverEvent hoverEvent;
539 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
541 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
542 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
543 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
544 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
545 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
550 // Up event with different ID
552 Integration::TouchEvent touchEvent;
553 Integration::HoverEvent hoverEvent;
554 Integration::Point point = GeneratePoint( 2, PointState::UP, 100.0f, 100.0f );
556 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
563 Integration::TouchEvent touchEvent;
564 Integration::HoverEvent hoverEvent;
565 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
567 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
568 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
569 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
570 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
571 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
576 int UtcDaliTouchEventCombinerSingleTouchMotionWithDifferentId(void)
578 TouchEventCombiner combiner;
579 unsigned long time( 0u );
583 Integration::TouchEvent touchEvent;
584 Integration::HoverEvent hoverEvent;
585 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
587 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
588 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
589 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
590 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
591 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
596 // Motion event with different ID
598 Integration::TouchEvent touchEvent;
599 Integration::HoverEvent hoverEvent;
600 Integration::Point point = GeneratePoint( 2, PointState::MOTION, 100.0f, 100.0f );
602 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_HOVER, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
603 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
604 DALI_TEST_EQUALS( hoverEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
605 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), PointState::STARTED, TEST_LOCATION );
606 DALI_TEST_EQUALS( hoverEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
613 Integration::TouchEvent touchEvent;
614 Integration::HoverEvent hoverEvent;
615 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 102.0f, 102.0f );
617 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
618 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
619 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
620 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
621 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
626 int UtcDaliTouchEventCombinerMultiTouchNormal(void)
628 TouchEventCombiner combiner;
629 unsigned long time( 0u );
633 Integration::TouchEvent touchEvent;
634 Integration::HoverEvent hoverEvent;
635 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
637 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
638 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
639 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
640 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
641 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
648 Integration::TouchEvent touchEvent;
649 Integration::HoverEvent hoverEvent;
650 Integration::Point point = GeneratePoint( 2, PointState::DOWN, 200.0f, 200.0f );
652 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
653 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
654 DALI_TEST_EQUALS( touchEvent.points[1].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
655 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), PointState::STATIONARY, TEST_LOCATION );
656 DALI_TEST_EQUALS( touchEvent.points[1].GetState(), point.GetState(), TEST_LOCATION );
657 DALI_TEST_EQUALS( touchEvent.points[1].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
664 Integration::TouchEvent touchEvent;
665 Integration::HoverEvent hoverEvent;
666 Integration::Point point = GeneratePoint( 1, PointState::MOTION, 101.0f, 100.0f );
668 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
669 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
670 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
671 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
672 DALI_TEST_EQUALS( touchEvent.points[1].GetState(), PointState::STATIONARY, TEST_LOCATION );
673 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
676 // 2nd point motion, no time diff
678 Integration::TouchEvent touchEvent;
679 Integration::HoverEvent hoverEvent;
680 Integration::Point point = GeneratePoint( 2, PointState::MOTION, 200.0f, 200.0f );
682 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
689 Integration::TouchEvent touchEvent;
690 Integration::HoverEvent hoverEvent;
691 Integration::Point point = GeneratePoint( 2, PointState::MOTION, 201.0f, 201.0f );
693 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
694 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
695 DALI_TEST_EQUALS( touchEvent.points[1].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
696 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), PointState::STATIONARY, TEST_LOCATION );
697 DALI_TEST_EQUALS( touchEvent.points[1].GetState(), point.GetState(), TEST_LOCATION );
698 DALI_TEST_EQUALS( touchEvent.points[1].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
705 Integration::TouchEvent touchEvent;
706 Integration::HoverEvent hoverEvent;
707 Integration::Point point = GeneratePoint( 1, PointState::UP, 101.0f, 100.0f );
709 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
710 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 2u, TEST_LOCATION );
711 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
712 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
713 DALI_TEST_EQUALS( touchEvent.points[1].GetState(), PointState::STATIONARY, TEST_LOCATION );
714 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
721 Integration::TouchEvent touchEvent;
722 Integration::HoverEvent hoverEvent;
723 Integration::Point point = GeneratePoint( 2, PointState::MOTION, 202.0f, 202.0f );
725 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
726 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
727 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
728 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
729 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
736 Integration::TouchEvent touchEvent;
737 Integration::HoverEvent hoverEvent;
738 Integration::Point point = GeneratePoint( 2, PointState::UP, 202.0f, 202.0f );
740 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
741 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
742 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
743 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
744 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
749 int UtcDaliTouchEventCombinerSeveralPoints(void)
751 TouchEventCombiner combiner;
752 unsigned long time( 0u );
753 unsigned int const maximum( 200u );
756 for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
758 Integration::TouchEvent touchEvent;
759 Integration::HoverEvent hoverEvent;
760 Integration::Point point = GeneratePoint( pointCount, PointState::DOWN, 100.0f, 100.0f );
762 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION );
763 DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
767 for ( unsigned int pointCount = maximum - 1; pointCount > 0; --pointCount )
769 Integration::TouchEvent touchEvent;
770 Integration::HoverEvent hoverEvent;
771 Integration::Point point = GeneratePoint( pointCount, PointState::UP, 100.0f, 100.0f );
773 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time++, touchEvent, hoverEvent ), TEST_LOCATION );
774 DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
779 int UtcDaliTouchEventCombinerReset(void)
781 TouchEventCombiner combiner;
782 unsigned long time( 0u );
786 Integration::TouchEvent touchEvent;
787 Integration::HoverEvent hoverEvent;
788 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
790 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
791 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
792 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
793 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
794 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
799 // Reset combiner, no more events should be sent to core.
804 Integration::TouchEvent touchEvent;
805 Integration::HoverEvent hoverEvent;
806 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
808 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
813 int UtcDaliTouchEventCombinerSingleTouchInterrupted(void)
815 TouchEventCombiner combiner;
816 unsigned long time( 0u );
820 Integration::TouchEvent touchEvent;
821 Integration::HoverEvent hoverEvent;
822 Integration::Point point = GeneratePoint( 1, PointState::DOWN, 100.0f, 100.0f );
824 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
825 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
826 DALI_TEST_EQUALS( touchEvent.points[0].GetDeviceId(), point.GetDeviceId(), TEST_LOCATION );
827 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
828 DALI_TEST_EQUALS( touchEvent.points[0].GetScreenPosition(), point.GetScreenPosition(), TEST_LOCATION );
835 Integration::TouchEvent touchEvent;
836 Integration::HoverEvent hoverEvent;
837 Integration::Point point = GeneratePoint( 1, PointState::INTERRUPTED, 100.0f, 100.0f );
839 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
840 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
841 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
842 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
843 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
846 // Send up, should not be able to send as combiner has been reset.
849 Integration::TouchEvent touchEvent;
850 Integration::HoverEvent hoverEvent;
851 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
853 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
858 int UtcDaliTouchEventCombinerMultiTouchInterrupted(void)
860 TouchEventCombiner combiner;
861 unsigned long time( 0u );
862 unsigned int const maximum( 200u );
865 for ( unsigned int pointCount = 1u; pointCount < maximum; ++pointCount )
867 Integration::TouchEvent touchEvent;
868 Integration::HoverEvent hoverEvent;
869 Integration::Point point = GeneratePoint( pointCount, PointState::DOWN, 100.0f, 100.0f );
871 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_TOUCH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
872 DALI_TEST_EQUALS( touchEvent.GetPointCount(), pointCount, TEST_LOCATION );
877 Integration::TouchEvent touchEvent;
878 Integration::HoverEvent hoverEvent;
879 Integration::Point point = GeneratePoint( 1, PointState::INTERRUPTED, 100.0f, 100.0f );
881 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_BOTH, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
882 DALI_TEST_EQUALS( touchEvent.GetPointCount(), 1u, TEST_LOCATION );
883 DALI_TEST_EQUALS( touchEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
884 DALI_TEST_EQUALS( hoverEvent.GetPointCount(), 1u, TEST_LOCATION );
885 DALI_TEST_EQUALS( hoverEvent.points[0].GetState(), point.GetState(), TEST_LOCATION );
888 // Send up, should not be able to send as combiner has been reset.
891 Integration::TouchEvent touchEvent;
892 Integration::HoverEvent hoverEvent;
893 Integration::Point point = GeneratePoint( 1, PointState::UP, 100.0f, 100.0f );
895 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );
900 int UtcDaliTouchEventCombinerInvalidState(void)
902 TouchEventCombiner combiner;
903 unsigned long time( 0u );
907 Integration::TouchEvent touchEvent;
908 Integration::HoverEvent hoverEvent;
909 Integration::Point point = GeneratePoint( 1, PointState::STATIONARY, 100.0f, 100.0f );
911 DALI_TEST_EQUALS( Integration::TouchEventCombiner::DISPATCH_NONE, combiner.GetNextTouchEvent( point, time, touchEvent, hoverEvent ), TEST_LOCATION );