2 * Copyright (c) 2016 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-integ.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali-test-suite-utils.h>
28 void utc_dali_touch_data_processing_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_touch_data_processing_cleanup(void)
35 test_return_value = TET_PASS;
38 ///////////////////////////////////////////////////////////////////////////////
45 PointState::Type state;
50 Vector2 ellipseRadius;
55 : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
58 static const TestPoint ZERO;
61 const TestPoint TestPoint::ZERO;
64 // Stores data that is populated in the callback and will be read by the TET cases
68 : functorCalled( false ),
77 std::vector<TestPoint> points;
79 const TestPoint& GetPoint(size_t i)
81 if( i < points.size() )
85 return TestPoint::ZERO;
87 size_t GetPointCount()
95 functorCalled = false;
98 touchData.points.clear();
100 touchedActor.Reset();
104 TestTouchData touchData;
108 // Functor that sets the data when called
109 struct TouchDataFunctor
113 * @param[in] data Reference to the data to store callback information.
114 * @param[in] returnValue What the functor should return.
116 TouchDataFunctor( SignalData& data, bool returnValue = true )
117 : signalData( data ),
118 returnValue( returnValue )
122 bool operator()( Actor actor, const TouchData& touchData )
124 signalData.functorCalled = true;
125 signalData.touchedActor = actor;
127 signalData.touchData.time = touchData.GetTime();
128 signalData.touchData.points.clear();
130 for( size_t i=0; i<touchData.GetPointCount(); ++i )
133 p.deviceId = touchData.GetDeviceId(i);
134 p.state = touchData.GetState(i);
135 p.hitActor = touchData.GetHitActor(i);
136 p.local = touchData.GetLocalPosition(i);
137 p.screen = touchData.GetScreenPosition(i);
138 p.radius = touchData.GetRadius(i);
139 p.ellipseRadius = touchData.GetEllipseRadius(i);
140 p.pressure = touchData.GetPressure(i);
141 p.angle = touchData.GetAngle(i);
142 signalData.touchData.points.push_back(p);
148 SignalData& signalData;
158 : signalReceived(false)
163 struct TouchDataHandleFunctor
167 * @param[in] data Reference to the data to store callback information.
168 * @param[in] returnValue What the functor should return.
170 TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
171 : handleData(handleData),
172 returnValue( returnValue )
176 bool operator()( Actor actor, const TouchData& someTouchData )
178 handleData.signalReceived = true;
179 TouchData handle(someTouchData);
180 handleData.touchData = handle;
184 HandleData& handleData;
189 // Functor that removes the actor when called.
190 struct RemoveActorFunctor : public TouchDataFunctor
194 * @param[in] data Reference to the data to store callback information.
195 * @param[in] returnValue What the functor should return.
197 RemoveActorFunctor( SignalData& data, bool returnValue = true )
198 : TouchDataFunctor( data, returnValue )
202 bool operator()( Actor actor, const TouchData& touchData )
204 Actor parent( actor.GetParent() );
207 parent.Remove( actor );
210 return TouchDataFunctor::operator()( actor, touchData );
214 struct OutOfBoundsData
220 :functorCalled(false)
225 // Functor that reads out of bounds data when called
226 struct OutOfBoundsFunctor
230 * @param[in] data Reference to the data to store callback information.
231 * @param[in] returnValue What the functor should return.
233 OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
234 : outOfBoundsData ( data ),
235 returnValue( returnValue )
239 bool operator()( Actor actor, const TouchData& touchData )
241 outOfBoundsData.functorCalled = true;
242 size_t count = touchData.GetPointCount();
244 // Read out of bounds data
245 outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
246 outOfBoundsData.point.state = touchData.GetState(count+1);
247 outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
248 outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
249 outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
254 OutOfBoundsData& outOfBoundsData;
258 struct TouchEventFunctor
262 * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called.
264 TouchEventFunctor( bool& functorCalled )
265 : functorCalled( functorCalled )
269 bool operator()( Actor actor, const TouchEvent& touch )
271 functorCalled = true;
278 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
280 Integration::TouchEvent touchEvent;
281 Integration::Point point;
282 point.SetState( state );
283 point.SetScreenPosition( screenPosition );
284 touchEvent.points.push_back( point );
290 ///////////////////////////////////////////////////////////////////////////////
292 int UtcDaliTouchDataNormalProcessing01(void)
294 TestApplication application;
296 Actor actor = Actor::New();
297 actor.SetSize(100.0f, 100.0f);
298 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
299 Stage::GetCurrent().Add(actor);
302 application.SendNotification();
303 application.Render();
305 // Connect to actor's touched signal
307 TouchDataFunctor functor( data );
308 actor.TouchSignal().Connect( &application, functor );
310 Vector2 screenCoordinates( 10.0f, 10.0f );
311 Vector2 localCoordinates;
312 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
314 // Emit a down signal
315 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
316 const TestPoint *point1 = &data.touchData.GetPoint(0);
317 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
318 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
319 DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
320 DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
321 DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
324 // Emit a motion signal
325 screenCoordinates.x = screenCoordinates.y = 11.0f;
326 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
327 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
328 const TestPoint *point2 = &data.touchData.GetPoint(0);
329 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
330 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
331 DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
332 DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
333 DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
337 screenCoordinates.x = screenCoordinates.y = 12.0f;
338 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
339 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
340 const TestPoint *point3 = &data.touchData.GetPoint(0);
341 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
342 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
343 DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
344 DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
345 DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
348 // Emit a down signal where the actor is not present
349 screenCoordinates.x = screenCoordinates.y = 200.0f;
350 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
351 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
356 int UtcDaliTouchDataNormalProcessing02(void)
358 TestApplication application;
360 Actor actor = Actor::New();
361 actor.SetSize(100.0f, 100.0f);
362 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
363 Stage::GetCurrent().Add(actor);
366 application.SendNotification();
367 application.Render();
369 // Connect to actor's touched signal
370 HandleData handleData;
371 TouchDataHandleFunctor functor( handleData );
372 actor.TouchSignal().Connect( &application, functor );
374 Vector2 screenCoordinates( 10.0f, 10.0f );
375 Vector2 localCoordinates;
376 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
378 // Emit a down signal
379 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
380 DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
381 DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
382 DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
383 DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
384 DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
390 int UtcDaliTouchDataAPINegative(void)
392 TestApplication application;
394 Actor actor = Actor::New();
395 actor.SetSize(100.0f, 100.0f);
396 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
397 Stage::GetCurrent().Add(actor);
400 application.SendNotification();
401 application.Render();
403 // Connect to actor's touched signal
404 OutOfBoundsData data;
405 OutOfBoundsFunctor functor( data, true );
406 actor.TouchSignal().Connect( &application, functor );
408 Vector2 screenCoordinates( 10.0f, 10.0f );
409 Vector2 localCoordinates;
410 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
412 // Emit a down signal
413 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
415 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
416 DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
417 DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
418 DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
419 DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
420 DALI_TEST_CHECK( ! data.point.hitActor );
426 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
428 TestApplication application;
430 Stage stage = Stage::GetCurrent();
431 Vector2 stageSize = stage.GetSize();
433 Actor actor = Actor::New();
434 actor.SetSize(100.0f, 100.0f);
435 actor.SetAnchorPoint(AnchorPoint::CENTER);
436 actor.SetParentOrigin(ParentOrigin::CENTER);
440 application.SendNotification();
441 application.Render();
443 // Get the camera's near and far planes
444 RenderTaskList taskList = stage.GetRenderTaskList();
445 Dali::RenderTask task = taskList.GetTask(0);
446 CameraActor camera = task.GetCameraActor();
447 float nearPlane = camera.GetNearClippingPlane();
448 float farPlane = camera.GetFarClippingPlane();
450 // Calculate the current distance of the actor from the camera
451 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
452 float distance = (stageSize.y * 0.5f) / tanHalfFov;
454 // Connect to actor's touched signal
456 TouchDataFunctor functor( data );
457 actor.TouchSignal().Connect( &application, functor );
459 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
461 // Emit a down signal
462 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
463 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
466 // Emit a down signal where actor is just at the camera's near plane
467 actor.SetZ(distance - nearPlane);
470 application.SendNotification();
471 application.Render();
473 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
474 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
477 // Emit a down signal where actor is closer than the camera's near plane
478 actor.SetZ((distance - nearPlane) + 1.0f);
481 application.SendNotification();
482 application.Render();
484 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
485 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
488 // Emit a down signal where actor is just at the camera's far plane
489 actor.SetZ(distance - farPlane);
492 application.SendNotification();
493 application.Render();
495 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
496 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
499 // Emit a down signal where actor is further than the camera's far plane
500 actor.SetZ((distance - farPlane) - 1.0f);
503 application.SendNotification();
504 application.Render();
506 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
507 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
512 int UtcDaliTouchDataEmitEmpty(void)
514 TestApplication application;
518 // Emit an empty TouchEvent
519 Integration::TouchEvent event;
520 application.ProcessEvent( event );
521 tet_result( TET_FAIL );
523 catch ( Dali::DaliException& e )
525 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
530 int UtcDaliTouchDataInterrupted(void)
532 TestApplication application;
534 Actor actor = Actor::New();
535 actor.SetSize(100.0f, 100.0f);
536 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
537 Stage::GetCurrent().Add(actor);
540 application.SendNotification();
541 application.Render();
543 // Connect to actor's touched signal
545 TouchDataFunctor functor( data );
546 actor.TouchSignal().Connect( &application, functor );
548 // Emit a down signal
549 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
550 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
551 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
554 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
555 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
556 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
557 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
560 // Emit another interrupted signal, our signal handler should not be called.
561 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
562 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
566 int UtcDaliTouchDataParentConsumer(void)
568 TestApplication application;
569 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
571 Actor actor = Actor::New();
572 actor.SetSize(100.0f, 100.0f);
573 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
574 Stage::GetCurrent().Add(actor);
577 application.SendNotification();
578 application.Render();
580 // Connect to actor's touched signal
582 TouchDataFunctor functor( data, false );
583 actor.TouchSignal().Connect( &application, functor );
585 // Connect to root actor's touched signal
587 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
588 rootActor.TouchSignal().Connect( &application, rootFunctor );
590 Vector2 screenCoordinates( 10.0f, 10.0f );
591 Vector2 actorCoordinates, rootCoordinates;
592 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
593 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
595 // Emit a down signal
596 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
597 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
598 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
599 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
600 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
601 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
602 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
603 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
604 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
605 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
606 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
607 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
608 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
612 // Emit a motion signal
613 screenCoordinates.x = screenCoordinates.y = 11.0f;
614 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
615 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
616 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
617 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
618 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
619 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
620 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
621 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
622 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
623 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
624 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
625 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
626 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
627 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
628 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
633 screenCoordinates.x = screenCoordinates.y = 12.0f;
634 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
635 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
636 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
637 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
638 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
639 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
640 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
641 DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
642 DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
643 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
644 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
645 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
646 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
647 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
648 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
652 // Emit a down signal where the actor is not present, will hit the root actor though
653 screenCoordinates.x = screenCoordinates.y = 200.0f;
654 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
655 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
656 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
657 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
658 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
659 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
660 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
661 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
662 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
666 int UtcDaliTouchDataInterruptedParentConsumer(void)
668 TestApplication application;
669 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
671 Actor actor = Actor::New();
672 actor.SetSize(100.0f, 100.0f);
673 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
674 Stage::GetCurrent().Add(actor);
677 application.SendNotification();
678 application.Render();
680 // Connect to actor's touched signal
682 TouchDataFunctor functor( data, false );
683 actor.TouchSignal().Connect( &application, functor );
685 // Connect to root actor's touched signal
687 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
688 rootActor.TouchSignal().Connect( &application, rootFunctor );
690 // Emit a down signal
691 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
692 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
693 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
694 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
695 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
696 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
697 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
701 // Emit an interrupted signal
702 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
703 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
704 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
705 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
706 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
707 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
708 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
712 // Emit another down signal
713 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
714 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
715 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
716 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
717 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
721 // Remove actor from Stage
722 Stage::GetCurrent().Remove( actor );
727 application.SendNotification();
728 application.Render();
730 // Emit an interrupted signal, only root actor's signal should be called.
731 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
732 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
733 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
734 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
735 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
739 // Emit another interrupted state, none of the signal's should be called.
740 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
741 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
742 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
746 int UtcDaliTouchDataLeave(void)
748 TestApplication application;
750 Actor actor = Actor::New();
751 actor.SetSize(100.0f, 100.0f);
752 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
753 Stage::GetCurrent().Add(actor);
756 application.SendNotification();
757 application.Render();
759 // Connect to actor's touched signal
761 TouchDataFunctor functor( data );
762 actor.TouchSignal().Connect( &application, functor );
764 // Set actor to require leave events
765 actor.SetLeaveRequired( true );
767 // Emit a down signal
768 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
769 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
770 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
773 // Emit a motion signal outside of actor, should be signalled with a Leave
774 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
775 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
776 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
779 // Another motion outside of actor, no signalling
780 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
781 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
784 // Another motion event inside actor, signalled with motion
785 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
786 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
787 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
790 // We do not want to listen to leave events anymore
791 actor.SetLeaveRequired( false );
793 // Another motion event outside of actor, no signalling
794 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
795 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
800 int UtcDaliTouchDataLeaveParentConsumer(void)
802 TestApplication application;
803 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
805 Actor actor = Actor::New();
806 actor.SetSize(100.0f, 100.0f);
807 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
808 Stage::GetCurrent().Add(actor);
811 application.SendNotification();
812 application.Render();
814 // Connect to actor's touched signal
816 TouchDataFunctor functor( data, false );
817 actor.TouchSignal().Connect( &application, functor );
819 // Connect to root actor's touched signal
821 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
822 rootActor.TouchSignal().Connect( &application, rootFunctor );
824 // Set actor to require leave events
825 actor.SetLeaveRequired( true );
826 rootActor.SetLeaveRequired( true );
828 // Emit a down signal
829 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
830 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
831 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
832 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
833 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
834 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
835 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
839 // Emit a motion signal outside of actor, should be signalled with a Leave
840 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
841 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
842 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
843 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
844 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
845 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
846 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
850 // Another motion outside of actor, only rootActor signalled
851 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
852 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
853 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
854 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
855 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
859 // Another motion event inside actor, signalled with motion
860 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
861 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
862 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
863 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
864 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
865 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
866 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
870 // We do not want to listen to leave events of actor anymore
871 actor.SetLeaveRequired( false );
873 // Another motion event outside of root actor, only root signalled
874 Vector2 stageSize( Stage::GetCurrent().GetSize() );
875 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
876 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
877 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
878 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
882 int UtcDaliTouchDataActorBecomesInsensitive(void)
884 TestApplication application;
886 Actor actor = Actor::New();
887 actor.SetSize(100.0f, 100.0f);
888 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
889 Stage::GetCurrent().Add(actor);
892 application.SendNotification();
893 application.Render();
895 // Connect to actor's touched signal
897 TouchDataFunctor functor( data );
898 actor.TouchSignal().Connect( &application, functor );
900 // Emit a down signal
901 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
902 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
903 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
906 // Change actor to insensitive
907 actor.SetSensitive( false );
909 // Emit a motion signal, signalled with an interrupted
910 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
911 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
912 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
917 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
919 TestApplication application;
920 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
922 Actor actor = Actor::New();
923 actor.SetSize(100.0f, 100.0f);
924 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
925 Stage::GetCurrent().Add(actor);
928 application.SendNotification();
929 application.Render();
931 // Connect to actor's touched signal
933 TouchDataFunctor functor( data, false );
934 actor.TouchSignal().Connect( &application, functor );
936 // Connect to root actor's touched signal
938 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
939 rootActor.TouchSignal().Connect( &application, rootFunctor );
941 // Emit a down signal
942 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
943 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
944 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
945 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
946 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
947 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
948 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
953 application.SendNotification();
954 application.Render();
956 // Make root actor insensitive
957 rootActor.SetSensitive( false );
959 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
960 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
961 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
962 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
963 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
964 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
968 int UtcDaliTouchDataMultipleLayers(void)
970 TestApplication application;
971 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
973 // Connect to actor's touched signal
975 TouchDataFunctor functor( data );
977 Layer layer1 ( Layer::New() );
978 layer1.SetSize(100.0f, 100.0f);
979 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
980 Stage::GetCurrent().Add( layer1 );
982 Actor actor1 ( Actor::New() );
983 actor1.SetSize( 100.0f, 100.0f );
984 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
985 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
986 layer1.Add( actor1 );
989 application.SendNotification();
990 application.Render();
992 // Connect to layer1 and actor1
993 layer1.TouchSignal().Connect( &application, functor );
994 actor1.TouchSignal().Connect( &application, functor );
996 // Hit in hittable area, actor1 should be hit
997 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
998 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
999 DALI_TEST_CHECK( data.touchedActor == actor1 );
1002 // Make layer1 insensitive, nothing should be hit
1003 layer1.SetSensitive( false );
1004 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1005 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1008 // Make layer1 sensitive again, again actor1 will be hit
1009 layer1.SetSensitive( true );
1010 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1011 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1012 DALI_TEST_CHECK( data.touchedActor == actor1 );
1015 // Make rootActor insensitive, nothing should be hit
1016 rootActor.SetSensitive( false );
1017 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1018 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1021 // Make rootActor sensitive
1022 rootActor.SetSensitive( true );
1024 // Add another layer
1025 Layer layer2 ( Layer::New() );
1026 layer2.SetSize(100.0f, 100.0f );
1027 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1028 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
1029 Stage::GetCurrent().Add( layer2 );
1031 Actor actor2 ( Actor::New() );
1032 actor2.SetSize(100.0f, 100.0f);
1033 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1034 layer2.Add( actor2 );
1036 // Render and notify
1037 application.SendNotification();
1038 application.Render();
1040 // Connect to layer2 and actor2
1041 layer2.TouchSignal().Connect( &application, functor );
1042 actor2.TouchSignal().Connect( &application, functor );
1044 // Emit an event, should hit layer2
1045 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1046 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1047 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1050 // Make layer2 insensitive, should hit actor1
1051 layer2.SetSensitive( false );
1052 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1053 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1054 DALI_TEST_CHECK( data.touchedActor == actor1 );
1057 // Make layer2 sensitive again, should hit layer2
1058 layer2.SetSensitive( true );
1059 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1060 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1061 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1064 // Make layer2 invisible, render and notify
1065 layer2.SetVisible( false );
1066 application.SendNotification();
1067 application.Render();
1069 // Should hit actor1
1070 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1071 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1072 DALI_TEST_CHECK( data.touchedActor == actor1 );
1075 // Make rootActor invisible, render and notify
1076 rootActor.SetVisible( false );
1077 application.SendNotification();
1078 application.Render();
1080 // Should not hit anything
1081 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1082 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1087 int UtcDaliTouchDataMultipleRenderTasks(void)
1089 TestApplication application;
1090 Stage stage ( Stage::GetCurrent() );
1091 Vector2 stageSize ( stage.GetSize() );
1093 Actor actor = Actor::New();
1094 actor.SetSize(100.0f, 100.0f);
1095 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1098 // Create render task
1099 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1100 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1101 renderTask.SetViewport( viewport );
1102 renderTask.SetInputEnabled( true );
1104 // Render and notify
1105 application.SendNotification();
1106 application.Render();
1108 // Connect to actor's touched signal
1110 TouchDataFunctor functor( data );
1111 actor.TouchSignal().Connect( &application, functor );
1113 // Emit a down signal
1114 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1115 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1118 // Ensure renderTask actor can be hit too.
1119 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1120 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1123 // Disable input on renderTask, should not be hittable
1124 renderTask.SetInputEnabled( false );
1125 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1126 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1131 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1133 TestApplication application;
1134 Stage stage ( Stage::GetCurrent() );
1135 Vector2 stageSize ( stage.GetSize() );
1137 Actor actor = Actor::New();
1138 actor.SetSize(100.0f, 100.0f);
1139 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1142 Layer layer = Layer::New();
1143 layer.SetSize(100.0f, 100.0f);
1144 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1147 // Create render task
1148 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1149 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1150 renderTask.SetViewport( viewport );
1151 renderTask.SetInputEnabled( true );
1152 renderTask.SetSourceActor( actor );
1154 // Render and notify
1155 application.SendNotification();
1156 application.Render();
1158 // Connect to layer's touched signal
1160 TouchDataFunctor functor( data );
1161 actor.TouchSignal().Connect( &application, functor );
1162 layer.TouchSignal().Connect( &application, functor );
1164 // Emit a down signal
1165 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1166 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1169 // Ensure renderTask actor can be hit too.
1170 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1171 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1174 // Disable input on renderTask, should not be hittable
1175 renderTask.SetInputEnabled( false );
1176 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1177 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1182 int UtcDaliTouchDataOffscreenRenderTasks(void)
1184 TestApplication application;
1185 Stage stage ( Stage::GetCurrent() );
1186 Vector2 stageSize ( stage.GetSize() );
1188 // FrameBufferImage for offscreen RenderTask
1189 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
1191 // Create a renderable actor to display the FrameBufferImage
1192 Actor renderableActor = CreateRenderableActor( frameBufferImage );
1193 renderableActor.SetParentOrigin(ParentOrigin::CENTER);
1194 renderableActor.SetSize( stageSize.x, stageSize.y );
1195 renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1196 stage.Add( renderableActor );
1198 Actor actor = Actor::New();
1199 actor.SetSize(100.0f, 100.0f);
1200 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1202 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1204 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1206 // Create a RenderTask
1207 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
1208 renderTask.SetSourceActor( actor );
1209 renderTask.SetTargetFrameBuffer( frameBufferImage );
1210 renderTask.SetInputEnabled( true );
1212 // Create another RenderTask
1213 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1214 renderTask2.SetInputEnabled( true );
1216 // Render and notify
1217 application.SendNotification();
1218 application.Render();
1220 // Connect to actor's touched signal
1222 TouchDataFunctor functor( data );
1223 actor.TouchSignal().Connect( &application, functor );
1225 // Emit a down signal
1226 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1227 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1232 int UtcDaliTouchDataMultipleRenderableActors(void)
1234 TestApplication application;
1235 Stage stage ( Stage::GetCurrent() );
1236 Vector2 stageSize ( stage.GetSize() );
1238 Actor parent = CreateRenderableActor();
1239 parent.SetSize(100.0f, 100.0f);
1240 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1243 Actor actor = CreateRenderableActor();
1244 actor.SetSize(100.0f, 100.0f);
1245 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1248 // Render and notify
1249 application.SendNotification();
1250 application.Render();
1252 // Connect to layer's touched signal
1254 TouchDataFunctor functor( data );
1255 parent.TouchSignal().Connect( &application, functor );
1256 actor.TouchSignal().Connect( &application, functor );
1258 // Emit a down signal
1259 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1260 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1261 DALI_TEST_CHECK( actor == data.touchedActor );
1265 int UtcDaliTouchDataActorRemovedInSignal(void)
1267 TestApplication application;
1269 Actor actor = Actor::New();
1270 actor.SetSize(100.0f, 100.0f);
1271 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1272 Stage::GetCurrent().Add(actor);
1274 // Render and notify
1275 application.SendNotification();
1276 application.Render();
1278 // Connect to actor's touched signal
1280 RemoveActorFunctor functor( data );
1281 actor.TouchSignal().Connect( &application, functor );
1283 // Register for leave events
1284 actor.SetLeaveRequired( true );
1286 // Emit a down signal
1287 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1288 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1291 // Re-add, render and notify
1292 Stage::GetCurrent().Add(actor);
1293 application.SendNotification();
1294 application.Render();
1296 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1297 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1298 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1301 // Emit a down signal
1302 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1303 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1311 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1312 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1315 // Re-add actor back to stage, render and notify
1316 Stage::GetCurrent().Add(actor);
1317 application.SendNotification();
1318 application.Render();
1320 // Emit another down event
1321 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1322 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1325 // Completely delete the actor
1328 // Emit event, should not crash and should not receive an event.
1329 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1330 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1334 int UtcDaliTouchDataActorSignalNotConsumed(void)
1336 TestApplication application;
1338 Actor actor = Actor::New();
1339 actor.SetSize(100.0f, 100.0f);
1340 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1341 Stage::GetCurrent().Add(actor);
1343 // Render and notify
1344 application.SendNotification();
1345 application.Render();
1347 // Connect to actor's touched signal
1349 TouchDataFunctor functor( data, false );
1350 actor.TouchSignal().Connect( &application, functor );
1352 // Emit a down signal
1353 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1354 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1358 int UtcDaliTouchDataActorUnStaged(void)
1360 TestApplication application;
1362 Actor actor = Actor::New();
1363 actor.SetSize(100.0f, 100.0f);
1364 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1365 Stage::GetCurrent().Add(actor);
1367 // Render and notify
1368 application.SendNotification();
1369 application.Render();
1371 // Connect to actor's touched signal
1373 TouchDataFunctor functor( data );
1374 actor.TouchSignal().Connect( &application, functor );
1376 // Emit a down signal
1377 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1378 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1381 // Remove actor from stage
1382 Stage::GetCurrent().Remove( actor );
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Emit a move at the same point, we should not be signalled.
1390 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1391 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1396 int UtcDaliTouchDataSystemOverlayActor(void)
1398 TestApplication application;
1399 Dali::Integration::Core& core( application.GetCore() );
1400 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1401 systemOverlay.GetOverlayRenderTasks().CreateTask();
1403 // Create an actor and add it to the system overlay.
1404 Actor systemActor = Actor::New();
1405 systemActor.SetSize(100.0f, 100.0f);
1406 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1407 systemOverlay.Add( systemActor );
1409 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1410 Actor actor = Actor::New();
1411 actor.SetSize(100.0f, 100.0f);
1412 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1413 Stage::GetCurrent().Add(actor);
1415 // Connect to the touch signals.
1417 TouchDataFunctor functor( data );
1418 systemActor.TouchSignal().Connect( &application, functor );
1419 actor.TouchSignal().Connect( &application, functor );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1426 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1427 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1428 DALI_TEST_CHECK( systemActor == data.touchedActor );
1432 int UtcDaliTouchDataLayerConsumesTouch(void)
1434 TestApplication application;
1436 Actor actor = Actor::New();
1437 actor.SetSize(100.0f, 100.0f);
1438 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1439 Stage::GetCurrent().Add(actor);
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Connect to actor's touched signal
1447 TouchDataFunctor functor( data );
1448 actor.TouchSignal().Connect( &application, functor );
1450 // Add a layer to overlap the actor
1451 Layer layer = Layer::New();
1452 layer.SetSize(100.0f, 100.0f);
1453 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1454 Stage::GetCurrent().Add( layer );
1457 // Render and notify
1458 application.SendNotification();
1459 application.Render();
1461 // Emit a few touch signals
1462 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1463 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1464 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1467 // Set layer to consume all touch
1468 layer.SetTouchConsumed( true );
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
1474 // Emit the same signals again, should not receive
1475 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1476 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1477 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1483 int UtcDaliTouchDataLeaveActorReadded(void)
1485 TestApplication application;
1486 Stage stage = Stage::GetCurrent();
1488 Actor actor = Actor::New();
1489 actor.SetSize(100.0f, 100.0f);
1490 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1493 // Set actor to receive touch-events
1494 actor.SetLeaveRequired( true );
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Connect to actor's touched signal
1502 TouchDataFunctor functor( data );
1503 actor.TouchSignal().Connect( &application, functor );
1505 // Emit a down and motion
1506 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1507 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1508 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1511 // Remove actor from stage and add again
1512 stage.Remove( actor );
1515 // Emit a motion within the actor's bounds
1516 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1517 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1520 // Emit a motion outside the actor's bounds
1521 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1522 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1523 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1529 int UtcDaliTouchDataClippedActor(void)
1531 TestApplication application;
1532 Stage stage = Stage::GetCurrent();
1534 Actor actor = Actor::New();
1535 actor.SetSize( 100.0f, 100.0f );
1536 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1539 Actor clippingActor = Actor::New();
1540 clippingActor.SetSize( 50.0f, 50.0f );
1541 clippingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1542 clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1543 stage.Add( clippingActor );
1545 // Render and notify.
1546 application.SendNotification();
1547 application.Render();
1549 // Connect to actor's touch signal.
1551 TouchDataFunctor functor( data );
1552 actor.TouchSignal().Connect( &application, functor );
1554 // Emit an event within clipped area.
1555 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1556 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1559 // Emit an event outside the clipped area but within the actor area, we should have a hit.
1560 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1561 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1567 int UtcDaliTouchDataActorUnstaged(void)
1569 TestApplication application;
1571 Actor actor = Actor::New();
1572 actor.SetSize(100.0f, 100.0f);
1573 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1574 Stage::GetCurrent().Add(actor);
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Connect to actor's touched signal
1582 TouchDataFunctor functor( data );
1583 actor.TouchSignal().Connect( &application, functor );
1585 // Emit a down signal
1586 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1587 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1588 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1589 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1592 // Render and notify
1593 application.SendNotification();
1594 application.Render();
1596 // Unparent the actor
1599 // Should receive an interrupted event
1600 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1601 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1605 int UtcDaliTouchDataParentUnstaged(void)
1607 TestApplication application;
1609 Actor parent = Actor::New();
1610 parent.SetSize(100.0f, 100.0f);
1611 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1612 Stage::GetCurrent().Add(parent);
1614 Actor actor = Actor::New();
1615 actor.SetSize(100.0f, 100.0f);
1616 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // Connect to actor's touched signal
1625 TouchDataFunctor functor( data );
1626 actor.TouchSignal().Connect( &application, functor );
1628 // Emit a down signal
1629 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1630 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1631 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1632 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 // Unparent the parent of the touchable actor
1642 // Should receive an interrupted event
1643 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1644 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1648 int UtcDaliTouchDataActorUnstagedDifferentConsumer(void)
1650 TestApplication application;
1652 Actor parent = Actor::New();
1653 parent.SetSize(100.0f, 100.0f);
1654 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1655 Stage::GetCurrent().Add(parent);
1657 Actor actor = Actor::New();
1658 actor.SetSize(100.0f, 100.0f);
1659 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // Connect to actor's touched signal
1668 TouchDataFunctor functor( data, false /* Do not consume */ );
1669 actor.TouchSignal().Connect( &application, functor );
1671 // Connect to parent's touched signal
1672 SignalData parentData;
1673 TouchDataFunctor parentFunctor( parentData );
1674 parent.TouchSignal().Connect( &application, parentFunctor );
1676 // Emit a down signal
1677 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1678 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1679 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1680 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1681 DALI_TEST_CHECK( actor == data.touchedActor );
1682 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1683 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1684 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1685 DALI_TEST_CHECK( parent == parentData.touchedActor );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // Unparent the actor
1696 // Should receive an interrupted event for both actor & parent
1697 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1698 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1699 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1700 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1704 // Readd actor to parent
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1711 // Emit a motion signal
1712 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1713 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1714 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1718 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1719 SignalData secondData;
1720 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1721 actor.TouchSignal().Connect( &application, secondFunctor );
1723 // Unparent the actor
1726 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1727 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1728 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1729 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1730 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1731 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1732 DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1740 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1742 TestApplication application;
1743 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1745 Actor parent = Actor::New();
1746 parent.SetSize(100.0f, 100.0f);
1747 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1748 Stage::GetCurrent().Add(parent);
1750 Actor actor = Actor::New();
1751 actor.SetSize(100.0f, 100.0f);
1752 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1755 // Render and notify
1756 application.SendNotification();
1757 application.Render();
1759 // Connect to actor's touched signal
1761 TouchDataFunctor functor( data, false /* Do not consume */ );
1762 actor.TouchSignal().Connect( &application, functor );
1764 // Connect to parent's touched signal
1765 SignalData parentData;
1766 TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1767 parent.TouchSignal().Connect( &application, parentFunctor );
1769 // Connect to root's touched signal and consume
1770 SignalData rootData;
1771 TouchDataFunctor rootFunctor( rootData );
1772 rootActor.TouchSignal().Connect( &application, rootFunctor );
1774 // Emit a down signal
1775 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1776 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1777 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1778 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1779 DALI_TEST_CHECK( actor == data.touchedActor );
1780 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1781 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1782 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1783 DALI_TEST_CHECK( parent == parentData.touchedActor );
1784 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1785 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1786 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1787 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1792 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1793 SignalData secondData;
1794 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1795 parent.TouchSignal().Connect( &application, secondFunctor );
1797 // Emit an interrupted signal, all three should STILL be called
1798 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1799 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1800 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1801 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1802 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1803 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1804 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1812 int UtcDaliTouchDataGetRadius(void)
1814 TestApplication application;
1816 Actor actor = Actor::New();
1817 actor.SetSize(100.0f, 100.0f);
1818 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1819 Stage::GetCurrent().Add(actor);
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // Connect to actor's touched signal
1827 TouchDataFunctor functor( data );
1828 actor.TouchSignal().Connect( &application, functor );
1830 // Emit a down signal with an angle
1831 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1832 touchEvent.points[ 0 ].SetRadius( 100.0f );
1833 application.ProcessEvent( touchEvent );
1834 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1835 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1836 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1837 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1838 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1843 int UtcDaliTouchDataGetEllipseRadius(void)
1845 TestApplication application;
1847 Actor actor = Actor::New();
1848 actor.SetSize(100.0f, 100.0f);
1849 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1850 Stage::GetCurrent().Add(actor);
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Connect to actor's touched signal
1858 TouchDataFunctor functor( data );
1859 actor.TouchSignal().Connect( &application, functor );
1861 // Emit a down signal with an angle
1862 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1863 touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1864 application.ProcessEvent( touchEvent );
1865 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1866 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1867 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1868 DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1869 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1874 int UtcDaliTouchDataGetAngle(void)
1876 TestApplication application;
1878 Actor actor = Actor::New();
1879 actor.SetSize(100.0f, 100.0f);
1880 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1881 Stage::GetCurrent().Add(actor);
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // Connect to actor's touched signal
1889 TouchDataFunctor functor( data );
1890 actor.TouchSignal().Connect( &application, functor );
1892 // Emit a down signal with an angle
1893 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1894 touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1895 application.ProcessEvent( touchEvent );
1896 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1897 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1898 DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1903 int UtcDaliTouchDataGetPressure(void)
1905 TestApplication application;
1907 Actor actor = Actor::New();
1908 actor.SetSize(100.0f, 100.0f);
1909 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1910 Stage::GetCurrent().Add(actor);
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 // Connect to actor's touched signal
1918 TouchDataFunctor functor( data );
1919 actor.TouchSignal().Connect( &application, functor );
1921 // Emit a down signal with an angle
1922 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1923 touchEvent.points[ 0 ].SetPressure( 10.0f );
1924 application.ProcessEvent( touchEvent );
1925 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1926 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1927 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1932 int UtcDaliTouchDataAndEventUsage(void)
1934 TestApplication application;
1936 Actor actor = Actor::New();
1937 actor.SetSize(100.0f, 100.0f);
1938 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1939 Stage::GetCurrent().Add(actor);
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Connect to actor's touched signal
1947 TouchDataFunctor functor( data );
1948 actor.TouchSignal().Connect( &application, functor );
1950 // Connect to actor's touched signal (OLD)
1951 bool touchEventFunctorCalled = false;
1952 TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1953 actor.TouchedSignal().Connect( &application, eventFunctor );
1955 // Emit a down signal with an angle
1956 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1957 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1958 DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );