2 * Copyright (c) 2017 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;
53 Device::Class::Type deviceClass;
54 Device::Subclass::Type deviceSubclass;
57 : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
60 static const TestPoint ZERO;
63 const TestPoint TestPoint::ZERO;
66 // Stores data that is populated in the callback and will be read by the TET cases
70 : functorCalled( false ),
79 std::vector<TestPoint> points;
81 const TestPoint& GetPoint(size_t i)
83 if( i < points.size() )
87 return TestPoint::ZERO;
89 size_t GetPointCount()
97 functorCalled = false;
100 touchData.points.clear();
102 touchedActor.Reset();
106 TestTouchData touchData;
110 // Functor that sets the data when called
111 struct TouchDataFunctor
115 * @param[in] data Reference to the data to store callback information.
116 * @param[in] returnValue What the functor should return.
118 TouchDataFunctor( SignalData& data, bool returnValue = true )
119 : signalData( data ),
120 returnValue( returnValue )
124 bool operator()( Actor actor, const TouchData& touchData )
126 signalData.functorCalled = true;
127 signalData.touchedActor = actor;
129 signalData.touchData.time = touchData.GetTime();
130 signalData.touchData.points.clear();
132 for( size_t i=0; i<touchData.GetPointCount(); ++i )
135 p.deviceId = touchData.GetDeviceId(i);
136 p.state = touchData.GetState(i);
137 p.hitActor = touchData.GetHitActor(i);
138 p.local = touchData.GetLocalPosition(i);
139 p.screen = touchData.GetScreenPosition(i);
140 p.radius = touchData.GetRadius(i);
141 p.ellipseRadius = touchData.GetEllipseRadius(i);
142 p.pressure = touchData.GetPressure(i);
143 p.angle = touchData.GetAngle(i);
144 p.deviceClass = touchData.GetDeviceClass(i);
145 p.deviceSubclass = touchData.GetDeviceSubclass(i);
146 signalData.touchData.points.push_back(p);
152 SignalData& signalData;
162 : signalReceived(false)
167 struct TouchDataHandleFunctor
171 * @param[in] data Reference to the data to store callback information.
172 * @param[in] returnValue What the functor should return.
174 TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
175 : handleData(handleData),
176 returnValue( returnValue )
180 bool operator()( Actor actor, const TouchData& someTouchData )
182 handleData.signalReceived = true;
183 TouchData handle(someTouchData);
184 handleData.touchData = handle;
188 HandleData& handleData;
193 // Functor that removes the actor when called.
194 struct RemoveActorFunctor : public TouchDataFunctor
198 * @param[in] data Reference to the data to store callback information.
199 * @param[in] returnValue What the functor should return.
201 RemoveActorFunctor( SignalData& data, bool returnValue = true )
202 : TouchDataFunctor( data, returnValue )
206 bool operator()( Actor actor, const TouchData& touchData )
208 Actor parent( actor.GetParent() );
211 parent.Remove( actor );
214 return TouchDataFunctor::operator()( actor, touchData );
218 struct OutOfBoundsData
224 :functorCalled(false)
229 // Functor that reads out of bounds data when called
230 struct OutOfBoundsFunctor
234 * @param[in] data Reference to the data to store callback information.
235 * @param[in] returnValue What the functor should return.
237 OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
238 : outOfBoundsData ( data ),
239 returnValue( returnValue )
243 bool operator()( Actor actor, const TouchData& touchData )
245 outOfBoundsData.functorCalled = true;
246 size_t count = touchData.GetPointCount();
248 // Read out of bounds data
249 outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
250 outOfBoundsData.point.state = touchData.GetState(count+1);
251 outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
252 outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
253 outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
258 OutOfBoundsData& outOfBoundsData;
262 struct TouchEventFunctor
266 * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called.
268 TouchEventFunctor( bool& functorCalled )
269 : functorCalled( functorCalled )
273 bool operator()( Actor actor, const TouchEvent& touch )
275 functorCalled = true;
282 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
284 Integration::TouchEvent touchEvent;
285 Integration::Point point;
286 point.SetState( state );
287 point.SetScreenPosition( screenPosition );
288 point.SetDeviceClass( Device::Class::TOUCH );
289 point.SetDeviceSubclass( Device::Subclass::NONE );
290 touchEvent.points.push_back( point );
296 ///////////////////////////////////////////////////////////////////////////////
298 int UtcDaliTouchDataNormalProcessing01(void)
300 TestApplication application;
302 Actor actor = Actor::New();
303 actor.SetSize(100.0f, 100.0f);
304 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
305 Stage::GetCurrent().Add(actor);
308 application.SendNotification();
309 application.Render();
311 // Connect to actor's touched signal
313 TouchDataFunctor functor( data );
314 actor.TouchSignal().Connect( &application, functor );
316 Vector2 screenCoordinates( 10.0f, 10.0f );
317 Vector2 localCoordinates;
318 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
320 // Emit a down signal
321 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
322 const TestPoint *point1 = &data.touchData.GetPoint(0);
323 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
324 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
325 DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
326 DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
327 DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
330 // Emit a motion signal
331 screenCoordinates.x = screenCoordinates.y = 11.0f;
332 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
333 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
334 const TestPoint *point2 = &data.touchData.GetPoint(0);
335 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
336 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
337 DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
338 DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
339 DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
343 screenCoordinates.x = screenCoordinates.y = 12.0f;
344 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
345 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
346 const TestPoint *point3 = &data.touchData.GetPoint(0);
347 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
348 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
349 DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
350 DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
351 DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
354 // Emit a down signal where the actor is not present
355 screenCoordinates.x = screenCoordinates.y = 200.0f;
356 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
357 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
362 int UtcDaliTouchDataNormalProcessing02(void)
364 TestApplication application;
366 Actor actor = Actor::New();
367 actor.SetSize(100.0f, 100.0f);
368 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
369 Stage::GetCurrent().Add(actor);
372 application.SendNotification();
373 application.Render();
375 // Connect to actor's touched signal
376 HandleData handleData;
377 TouchDataHandleFunctor functor( handleData );
378 actor.TouchSignal().Connect( &application, functor );
380 Vector2 screenCoordinates( 10.0f, 10.0f );
381 Vector2 localCoordinates;
382 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
384 // Emit a down signal
385 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
386 DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
387 DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
388 DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
389 DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
390 DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
396 int UtcDaliTouchDataAPINegative(void)
398 TestApplication application;
400 Actor actor = Actor::New();
401 actor.SetSize(100.0f, 100.0f);
402 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
403 Stage::GetCurrent().Add(actor);
406 application.SendNotification();
407 application.Render();
409 // Connect to actor's touched signal
410 OutOfBoundsData data;
411 OutOfBoundsFunctor functor( data, true );
412 actor.TouchSignal().Connect( &application, functor );
414 Vector2 screenCoordinates( 10.0f, 10.0f );
415 Vector2 localCoordinates;
416 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
418 // Emit a down signal
419 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
421 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
422 DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
423 DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
424 DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
425 DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
426 DALI_TEST_CHECK( ! data.point.hitActor );
432 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
434 TestApplication application;
436 Stage stage = Stage::GetCurrent();
437 Vector2 stageSize = stage.GetSize();
439 Actor actor = Actor::New();
440 actor.SetSize(100.0f, 100.0f);
441 actor.SetAnchorPoint(AnchorPoint::CENTER);
442 actor.SetParentOrigin(ParentOrigin::CENTER);
446 application.SendNotification();
447 application.Render();
449 // Get the camera's near and far planes
450 RenderTaskList taskList = stage.GetRenderTaskList();
451 Dali::RenderTask task = taskList.GetTask(0);
452 CameraActor camera = task.GetCameraActor();
453 float nearPlane = camera.GetNearClippingPlane();
454 float farPlane = camera.GetFarClippingPlane();
456 // Calculate the current distance of the actor from the camera
457 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
458 float distance = (stageSize.y * 0.5f) / tanHalfFov;
460 // Connect to actor's touched signal
462 TouchDataFunctor functor( data );
463 actor.TouchSignal().Connect( &application, functor );
465 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
467 // Emit a down signal
468 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
469 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
472 // Emit a down signal where actor is just at the camera's near plane
473 actor.SetZ(distance - nearPlane);
476 application.SendNotification();
477 application.Render();
479 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
480 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
483 // Emit a down signal where actor is closer than the camera's near plane
484 actor.SetZ((distance - nearPlane) + 1.0f);
487 application.SendNotification();
488 application.Render();
490 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
491 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
494 // Emit a down signal where actor is just at the camera's far plane
495 actor.SetZ(distance - farPlane);
498 application.SendNotification();
499 application.Render();
501 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
502 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
505 // Emit a down signal where actor is further than the camera's far plane
506 actor.SetZ((distance - farPlane) - 1.0f);
509 application.SendNotification();
510 application.Render();
512 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
513 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
518 int UtcDaliTouchDataEmitEmpty(void)
520 TestApplication application;
524 // Emit an empty TouchEvent
525 Integration::TouchEvent event;
526 application.ProcessEvent( event );
527 tet_result( TET_FAIL );
529 catch ( Dali::DaliException& e )
531 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
536 int UtcDaliTouchDataInterrupted(void)
538 TestApplication application;
540 Actor actor = Actor::New();
541 actor.SetSize(100.0f, 100.0f);
542 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
543 Stage::GetCurrent().Add(actor);
546 application.SendNotification();
547 application.Render();
549 // Connect to actor's touched signal
551 TouchDataFunctor functor( data );
552 actor.TouchSignal().Connect( &application, functor );
554 // Emit a down signal
555 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
556 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
557 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
560 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
561 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
562 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
563 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
566 // Emit another interrupted signal, our signal handler should not be called.
567 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
568 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
572 int UtcDaliTouchDataParentConsumer(void)
574 TestApplication application;
575 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
577 Actor actor = Actor::New();
578 actor.SetSize(100.0f, 100.0f);
579 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
580 Stage::GetCurrent().Add(actor);
583 application.SendNotification();
584 application.Render();
586 // Connect to actor's touched signal
588 TouchDataFunctor functor( data, false );
589 actor.TouchSignal().Connect( &application, functor );
591 // Connect to root actor's touched signal
593 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
594 rootActor.TouchSignal().Connect( &application, rootFunctor );
596 Vector2 screenCoordinates( 10.0f, 10.0f );
597 Vector2 actorCoordinates, rootCoordinates;
598 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
599 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
601 // Emit a down signal
602 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
603 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
604 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
605 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
606 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
607 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
608 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
609 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
610 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
611 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
612 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
613 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
614 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
618 // Emit a motion signal
619 screenCoordinates.x = screenCoordinates.y = 11.0f;
620 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
621 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
622 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
623 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
624 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
625 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
626 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
627 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
628 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
629 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
630 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
631 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
632 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
633 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
634 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
639 screenCoordinates.x = screenCoordinates.y = 12.0f;
640 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
641 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
642 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
643 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
644 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
645 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
646 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
647 DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
648 DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
649 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
650 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
651 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
652 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
653 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
654 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
658 // Emit a down signal where the actor is not present, will hit the root actor though
659 screenCoordinates.x = screenCoordinates.y = 200.0f;
660 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
661 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
662 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
663 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
664 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
665 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
666 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
667 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
668 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
672 int UtcDaliTouchDataInterruptedParentConsumer(void)
674 TestApplication application;
675 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
677 Actor actor = Actor::New();
678 actor.SetSize(100.0f, 100.0f);
679 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
680 Stage::GetCurrent().Add(actor);
683 application.SendNotification();
684 application.Render();
686 // Connect to actor's touched signal
688 TouchDataFunctor functor( data, false );
689 actor.TouchSignal().Connect( &application, functor );
691 // Connect to root actor's touched signal
693 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
694 rootActor.TouchSignal().Connect( &application, rootFunctor );
696 // Emit a down signal
697 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
698 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
699 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
700 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
701 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
702 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
703 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
707 // Emit an interrupted signal
708 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
709 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
710 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
711 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
712 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
713 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
714 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
718 // Emit another down signal
719 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
720 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
721 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
722 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
723 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
727 // Remove actor from Stage
728 Stage::GetCurrent().Remove( actor );
733 application.SendNotification();
734 application.Render();
736 // Emit an interrupted signal, only root actor's signal should be called.
737 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
738 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
739 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
740 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
741 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
745 // Emit another interrupted state, none of the signal's should be called.
746 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
747 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
748 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
752 int UtcDaliTouchDataLeave(void)
754 TestApplication application;
756 Actor actor = Actor::New();
757 actor.SetSize(100.0f, 100.0f);
758 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
759 Stage::GetCurrent().Add(actor);
762 application.SendNotification();
763 application.Render();
765 // Connect to actor's touched signal
767 TouchDataFunctor functor( data );
768 actor.TouchSignal().Connect( &application, functor );
770 // Set actor to require leave events
771 actor.SetLeaveRequired( true );
773 // Emit a down signal
774 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
775 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
776 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
779 // Emit a motion signal outside of actor, should be signalled with a Leave
780 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
781 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
782 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
785 // Another motion outside of actor, no signalling
786 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
787 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
790 // Another motion event inside actor, signalled with motion
791 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
792 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
793 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
796 // We do not want to listen to leave events anymore
797 actor.SetLeaveRequired( false );
799 // Another motion event outside of actor, no signalling
800 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
801 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
806 int UtcDaliTouchDataLeaveParentConsumer(void)
808 TestApplication application;
809 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
811 Actor actor = Actor::New();
812 actor.SetSize(100.0f, 100.0f);
813 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
814 Stage::GetCurrent().Add(actor);
817 application.SendNotification();
818 application.Render();
820 // Connect to actor's touched signal
822 TouchDataFunctor functor( data, false );
823 actor.TouchSignal().Connect( &application, functor );
825 // Connect to root actor's touched signal
827 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
828 rootActor.TouchSignal().Connect( &application, rootFunctor );
830 // Set actor to require leave events
831 actor.SetLeaveRequired( true );
832 rootActor.SetLeaveRequired( true );
834 // Emit a down signal
835 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
836 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
837 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
838 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
839 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
840 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
841 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
845 // Emit a motion signal outside of actor, should be signalled with a Leave
846 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
847 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
848 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
849 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
850 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
851 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
852 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
856 // Another motion outside of actor, only rootActor signalled
857 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
858 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
859 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
860 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
861 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
865 // Another motion event inside actor, signalled with motion
866 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
867 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
868 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
869 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
870 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
871 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
872 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
876 // We do not want to listen to leave events of actor anymore
877 actor.SetLeaveRequired( false );
879 // Another motion event outside of root actor, only root signalled
880 Vector2 stageSize( Stage::GetCurrent().GetSize() );
881 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
882 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
883 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
884 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
888 int UtcDaliTouchDataActorBecomesInsensitive(void)
890 TestApplication application;
892 Actor actor = Actor::New();
893 actor.SetSize(100.0f, 100.0f);
894 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
895 Stage::GetCurrent().Add(actor);
898 application.SendNotification();
899 application.Render();
901 // Connect to actor's touched signal
903 TouchDataFunctor functor( data );
904 actor.TouchSignal().Connect( &application, functor );
906 // Emit a down signal
907 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
908 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
909 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
912 // Change actor to insensitive
913 actor.SetSensitive( false );
915 // Emit a motion signal, signalled with an interrupted
916 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
917 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
918 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
923 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
925 TestApplication application;
926 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
928 Actor actor = Actor::New();
929 actor.SetSize(100.0f, 100.0f);
930 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
931 Stage::GetCurrent().Add(actor);
934 application.SendNotification();
935 application.Render();
937 // Connect to actor's touched signal
939 TouchDataFunctor functor( data, false );
940 actor.TouchSignal().Connect( &application, functor );
942 // Connect to root actor's touched signal
944 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
945 rootActor.TouchSignal().Connect( &application, rootFunctor );
947 // Emit a down signal
948 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
949 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
950 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
951 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
952 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
953 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
954 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
959 application.SendNotification();
960 application.Render();
962 // Make root actor insensitive
963 rootActor.SetSensitive( false );
965 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
966 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
967 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
968 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
969 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
970 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
974 int UtcDaliTouchDataMultipleLayers(void)
976 TestApplication application;
977 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
979 // Connect to actor's touched signal
981 TouchDataFunctor functor( data );
983 Layer layer1 ( Layer::New() );
984 layer1.SetSize(100.0f, 100.0f);
985 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
986 Stage::GetCurrent().Add( layer1 );
988 Actor actor1 ( Actor::New() );
989 actor1.SetSize( 100.0f, 100.0f );
990 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
991 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
992 layer1.Add( actor1 );
995 application.SendNotification();
996 application.Render();
998 // Connect to layer1 and actor1
999 layer1.TouchSignal().Connect( &application, functor );
1000 actor1.TouchSignal().Connect( &application, functor );
1002 // Hit in hittable area, actor1 should be hit
1003 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1004 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1005 DALI_TEST_CHECK( data.touchedActor == actor1 );
1008 // Make layer1 insensitive, nothing should be hit
1009 layer1.SetSensitive( false );
1010 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1011 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1014 // Make layer1 sensitive again, again actor1 will be hit
1015 layer1.SetSensitive( true );
1016 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1017 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1018 DALI_TEST_CHECK( data.touchedActor == actor1 );
1021 // Make rootActor insensitive, nothing should be hit
1022 rootActor.SetSensitive( false );
1023 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1024 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1027 // Make rootActor sensitive
1028 rootActor.SetSensitive( true );
1030 // Add another layer
1031 Layer layer2 ( Layer::New() );
1032 layer2.SetSize(100.0f, 100.0f );
1033 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1034 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
1035 Stage::GetCurrent().Add( layer2 );
1037 Actor actor2 ( Actor::New() );
1038 actor2.SetSize(100.0f, 100.0f);
1039 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1040 layer2.Add( actor2 );
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Connect to layer2 and actor2
1047 layer2.TouchSignal().Connect( &application, functor );
1048 actor2.TouchSignal().Connect( &application, functor );
1050 // Emit an event, should hit layer2
1051 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1052 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1053 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1056 // Make layer2 insensitive, should hit actor1
1057 layer2.SetSensitive( false );
1058 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1059 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1060 DALI_TEST_CHECK( data.touchedActor == actor1 );
1063 // Make layer2 sensitive again, should hit layer2
1064 layer2.SetSensitive( true );
1065 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1066 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1067 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1070 // Make layer2 invisible, render and notify
1071 layer2.SetVisible( false );
1072 application.SendNotification();
1073 application.Render();
1075 // Should hit actor1
1076 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1077 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1078 DALI_TEST_CHECK( data.touchedActor == actor1 );
1081 // Make rootActor invisible, render and notify
1082 rootActor.SetVisible( false );
1083 application.SendNotification();
1084 application.Render();
1086 // Should not hit anything
1087 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1088 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1093 int UtcDaliTouchDataMultipleRenderTasks(void)
1095 TestApplication application;
1096 Stage stage ( Stage::GetCurrent() );
1097 Vector2 stageSize ( stage.GetSize() );
1099 Actor actor = Actor::New();
1100 actor.SetSize(100.0f, 100.0f);
1101 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1104 // Create render task
1105 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1106 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1107 renderTask.SetViewport( viewport );
1108 renderTask.SetInputEnabled( true );
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Connect to actor's touched signal
1116 TouchDataFunctor functor( data );
1117 actor.TouchSignal().Connect( &application, functor );
1119 // Emit a down signal
1120 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1121 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1124 // Ensure renderTask actor can be hit too.
1125 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1126 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1129 // Disable input on renderTask, should not be hittable
1130 renderTask.SetInputEnabled( false );
1131 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1132 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1137 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1139 TestApplication application;
1140 Stage stage ( Stage::GetCurrent() );
1141 Vector2 stageSize ( stage.GetSize() );
1143 Actor actor = Actor::New();
1144 actor.SetSize(100.0f, 100.0f);
1145 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1148 Layer layer = Layer::New();
1149 layer.SetSize(100.0f, 100.0f);
1150 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1153 // Create render task
1154 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1155 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1156 renderTask.SetViewport( viewport );
1157 renderTask.SetInputEnabled( true );
1158 renderTask.SetSourceActor( actor );
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Connect to layer's touched signal
1166 TouchDataFunctor functor( data );
1167 actor.TouchSignal().Connect( &application, functor );
1168 layer.TouchSignal().Connect( &application, functor );
1170 // Emit a down signal
1171 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1172 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1175 // Ensure renderTask actor can be hit too.
1176 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1177 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1180 // Disable input on renderTask, should not be hittable
1181 renderTask.SetInputEnabled( false );
1182 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1183 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1188 int UtcDaliTouchDataOffscreenRenderTasks(void)
1190 TestApplication application;
1191 Stage stage ( Stage::GetCurrent() );
1192 Vector2 stageSize ( stage.GetSize() );
1194 // FrameBufferImage for offscreen RenderTask
1195 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
1197 // Create a renderable actor to display the FrameBufferImage
1198 Actor renderableActor = CreateRenderableActor( frameBufferImage );
1199 renderableActor.SetParentOrigin(ParentOrigin::CENTER);
1200 renderableActor.SetSize( stageSize.x, stageSize.y );
1201 renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1202 stage.Add( renderableActor );
1204 Actor actor = Actor::New();
1205 actor.SetSize(100.0f, 100.0f);
1206 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1208 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1210 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1212 // Create a RenderTask
1213 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
1214 renderTask.SetSourceActor( actor );
1215 renderTask.SetTargetFrameBuffer( frameBufferImage );
1216 renderTask.SetInputEnabled( true );
1218 // Create another RenderTask
1219 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1220 renderTask2.SetInputEnabled( true );
1222 // Render and notify
1223 application.SendNotification();
1224 application.Render();
1226 // Connect to actor's touched signal
1228 TouchDataFunctor functor( data );
1229 actor.TouchSignal().Connect( &application, functor );
1231 // Emit a down signal
1232 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1233 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1238 int UtcDaliTouchDataMultipleRenderableActors(void)
1240 TestApplication application;
1241 Stage stage ( Stage::GetCurrent() );
1242 Vector2 stageSize ( stage.GetSize() );
1244 Actor parent = CreateRenderableActor();
1245 parent.SetSize(100.0f, 100.0f);
1246 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1249 Actor actor = CreateRenderableActor();
1250 actor.SetSize(100.0f, 100.0f);
1251 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Connect to layer's touched signal
1260 TouchDataFunctor functor( data );
1261 parent.TouchSignal().Connect( &application, functor );
1262 actor.TouchSignal().Connect( &application, functor );
1264 // Emit a down signal
1265 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1266 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1267 DALI_TEST_CHECK( actor == data.touchedActor );
1271 int UtcDaliTouchDataActorRemovedInSignal(void)
1273 TestApplication application;
1275 Actor actor = Actor::New();
1276 actor.SetSize(100.0f, 100.0f);
1277 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1278 Stage::GetCurrent().Add(actor);
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Connect to actor's touched signal
1286 RemoveActorFunctor functor( data );
1287 actor.TouchSignal().Connect( &application, functor );
1289 // Register for leave events
1290 actor.SetLeaveRequired( true );
1292 // Emit a down signal
1293 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1294 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1297 // Re-add, render and notify
1298 Stage::GetCurrent().Add(actor);
1299 application.SendNotification();
1300 application.Render();
1302 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1303 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1304 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1307 // Emit a down signal
1308 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1309 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1317 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1318 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1321 // Re-add actor back to stage, render and notify
1322 Stage::GetCurrent().Add(actor);
1323 application.SendNotification();
1324 application.Render();
1326 // Emit another down event
1327 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1328 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1331 // Completely delete the actor
1334 // Emit event, should not crash and should not receive an event.
1335 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1336 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1340 int UtcDaliTouchDataActorSignalNotConsumed(void)
1342 TestApplication application;
1344 Actor actor = Actor::New();
1345 actor.SetSize(100.0f, 100.0f);
1346 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1347 Stage::GetCurrent().Add(actor);
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 // Connect to actor's touched signal
1355 TouchDataFunctor functor( data, false );
1356 actor.TouchSignal().Connect( &application, functor );
1358 // Emit a down signal
1359 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1360 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1364 int UtcDaliTouchDataActorUnStaged(void)
1366 TestApplication application;
1368 Actor actor = Actor::New();
1369 actor.SetSize(100.0f, 100.0f);
1370 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1371 Stage::GetCurrent().Add(actor);
1373 // Render and notify
1374 application.SendNotification();
1375 application.Render();
1377 // Connect to actor's touched signal
1379 TouchDataFunctor functor( data );
1380 actor.TouchSignal().Connect( &application, functor );
1382 // Emit a down signal
1383 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1384 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1387 // Remove actor from stage
1388 Stage::GetCurrent().Remove( actor );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Emit a move at the same point, we should not be signalled.
1396 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1397 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1402 int UtcDaliTouchDataSystemOverlayActor(void)
1404 TestApplication application;
1405 Dali::Integration::Core& core( application.GetCore() );
1406 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1407 systemOverlay.GetOverlayRenderTasks().CreateTask();
1409 // Create an actor and add it to the system overlay.
1410 Actor systemActor = Actor::New();
1411 systemActor.SetSize(100.0f, 100.0f);
1412 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1413 systemOverlay.Add( systemActor );
1415 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1416 Actor actor = Actor::New();
1417 actor.SetSize(100.0f, 100.0f);
1418 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1419 Stage::GetCurrent().Add(actor);
1421 // Connect to the touch signals.
1423 TouchDataFunctor functor( data );
1424 systemActor.TouchSignal().Connect( &application, functor );
1425 actor.TouchSignal().Connect( &application, functor );
1427 // Render and notify
1428 application.SendNotification();
1429 application.Render();
1431 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1432 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1433 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1434 DALI_TEST_CHECK( systemActor == data.touchedActor );
1438 int UtcDaliTouchDataLayerConsumesTouch(void)
1440 TestApplication application;
1442 Actor actor = Actor::New();
1443 actor.SetSize(100.0f, 100.0f);
1444 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1445 Stage::GetCurrent().Add(actor);
1447 // Render and notify
1448 application.SendNotification();
1449 application.Render();
1451 // Connect to actor's touched signal
1453 TouchDataFunctor functor( data );
1454 actor.TouchSignal().Connect( &application, functor );
1456 // Add a layer to overlap the actor
1457 Layer layer = Layer::New();
1458 layer.SetSize(100.0f, 100.0f);
1459 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1460 Stage::GetCurrent().Add( layer );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 // Emit a few touch signals
1468 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1469 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1470 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1473 // Set layer to consume all touch
1474 layer.SetTouchConsumed( true );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Emit the same signals again, should not receive
1481 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1482 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1483 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1489 int UtcDaliTouchDataLeaveActorReadded(void)
1491 TestApplication application;
1492 Stage stage = Stage::GetCurrent();
1494 Actor actor = Actor::New();
1495 actor.SetSize(100.0f, 100.0f);
1496 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1499 // Set actor to receive touch-events
1500 actor.SetLeaveRequired( true );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 // Connect to actor's touched signal
1508 TouchDataFunctor functor( data );
1509 actor.TouchSignal().Connect( &application, functor );
1511 // Emit a down and motion
1512 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1513 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1514 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1517 // Remove actor from stage and add again
1518 stage.Remove( actor );
1521 // Emit a motion within the actor's bounds
1522 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1523 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1526 // Emit a motion outside the actor's bounds
1527 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1528 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1529 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1535 int UtcDaliTouchDataClippedActor(void)
1537 TestApplication application;
1538 Stage stage = Stage::GetCurrent();
1540 Actor actor = Actor::New();
1541 actor.SetSize( 100.0f, 100.0f );
1542 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1545 Actor clippingActor = Actor::New();
1546 clippingActor.SetSize( 50.0f, 50.0f );
1547 clippingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1548 clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1549 stage.Add( clippingActor );
1551 // Add a child to the clipped region.
1552 Actor clippingChild = Actor::New();
1553 clippingChild.SetSize( 50.0f, 50.0f );
1554 clippingChild.SetPosition( 25.0f, 25.0f );
1555 clippingChild.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1556 clippingActor.Add( clippingChild );
1558 // Render and notify.
1559 application.SendNotification();
1560 application.Render();
1562 // Connect to actor's touch signal.
1564 TouchDataFunctor functor( data );
1565 actor.TouchSignal().Connect( &application, functor );
1567 // Emit an event within clipped area - no hit.
1568 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1569 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1572 // Emit an event outside the clipped area but within the actor area, we should have a hit.
1573 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1574 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1577 clippingChild.TouchSignal().Connect( &application, functor );
1579 // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1580 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 30.0f, 30.0f ) ) );
1581 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1587 int UtcDaliTouchDataActorUnstaged(void)
1589 TestApplication application;
1591 Actor actor = Actor::New();
1592 actor.SetSize(100.0f, 100.0f);
1593 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1594 Stage::GetCurrent().Add(actor);
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 // Connect to actor's touched signal
1602 TouchDataFunctor functor( data );
1603 actor.TouchSignal().Connect( &application, functor );
1605 // Emit a down signal
1606 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1607 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1608 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1609 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1612 // Render and notify
1613 application.SendNotification();
1614 application.Render();
1616 // Unparent the actor
1619 // Should receive an interrupted event
1620 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1621 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1625 int UtcDaliTouchDataParentUnstaged(void)
1627 TestApplication application;
1629 Actor parent = Actor::New();
1630 parent.SetSize(100.0f, 100.0f);
1631 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1632 Stage::GetCurrent().Add(parent);
1634 Actor actor = Actor::New();
1635 actor.SetSize(100.0f, 100.0f);
1636 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Connect to actor's touched signal
1645 TouchDataFunctor functor( data );
1646 actor.TouchSignal().Connect( &application, functor );
1648 // Emit a down signal
1649 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1650 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1651 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1652 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // Unparent the parent of the touchable actor
1662 // Should receive an interrupted event
1663 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1664 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1668 int UtcDaliTouchDataActorUnstagedDifferentConsumer(void)
1670 TestApplication application;
1672 Actor parent = Actor::New();
1673 parent.SetSize(100.0f, 100.0f);
1674 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1675 Stage::GetCurrent().Add(parent);
1677 Actor actor = Actor::New();
1678 actor.SetSize(100.0f, 100.0f);
1679 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1682 // Render and notify
1683 application.SendNotification();
1684 application.Render();
1686 // Connect to actor's touched signal
1688 TouchDataFunctor functor( data, false /* Do not consume */ );
1689 actor.TouchSignal().Connect( &application, functor );
1691 // Connect to parent's touched signal
1692 SignalData parentData;
1693 TouchDataFunctor parentFunctor( parentData );
1694 parent.TouchSignal().Connect( &application, parentFunctor );
1696 // Emit a down signal
1697 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1698 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1699 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1700 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1701 DALI_TEST_CHECK( actor == data.touchedActor );
1702 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1703 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1704 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1705 DALI_TEST_CHECK( parent == parentData.touchedActor );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Unparent the actor
1716 // Should receive an interrupted event for both actor & parent
1717 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1718 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1719 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1720 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1724 // Readd actor to parent
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1731 // Emit a motion signal
1732 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1733 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1734 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1738 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1739 SignalData secondData;
1740 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1741 actor.TouchSignal().Connect( &application, secondFunctor );
1743 // Unparent the actor
1746 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1747 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1748 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1749 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1750 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1751 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1752 DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1760 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1762 TestApplication application;
1763 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1765 Actor parent = Actor::New();
1766 parent.SetSize(100.0f, 100.0f);
1767 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1768 Stage::GetCurrent().Add(parent);
1770 Actor actor = Actor::New();
1771 actor.SetSize(100.0f, 100.0f);
1772 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // Connect to actor's touched signal
1781 TouchDataFunctor functor( data, false /* Do not consume */ );
1782 actor.TouchSignal().Connect( &application, functor );
1784 // Connect to parent's touched signal
1785 SignalData parentData;
1786 TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1787 parent.TouchSignal().Connect( &application, parentFunctor );
1789 // Connect to root's touched signal and consume
1790 SignalData rootData;
1791 TouchDataFunctor rootFunctor( rootData );
1792 rootActor.TouchSignal().Connect( &application, rootFunctor );
1794 // Emit a down signal
1795 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1796 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1797 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1798 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1799 DALI_TEST_CHECK( actor == data.touchedActor );
1800 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1801 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1802 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1803 DALI_TEST_CHECK( parent == parentData.touchedActor );
1804 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1805 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1806 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1807 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1812 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1813 SignalData secondData;
1814 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1815 parent.TouchSignal().Connect( &application, secondFunctor );
1817 // Emit an interrupted signal, all three should STILL be called
1818 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1819 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1820 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1821 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1822 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1823 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1824 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1832 int UtcDaliTouchDataGetRadius(void)
1834 TestApplication application;
1836 Actor actor = Actor::New();
1837 actor.SetSize(100.0f, 100.0f);
1838 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1839 Stage::GetCurrent().Add(actor);
1841 // Render and notify
1842 application.SendNotification();
1843 application.Render();
1845 // Connect to actor's touched signal
1847 TouchDataFunctor functor( data );
1848 actor.TouchSignal().Connect( &application, functor );
1850 // Emit a down signal with an angle
1851 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1852 touchEvent.points[ 0 ].SetRadius( 100.0f );
1853 application.ProcessEvent( touchEvent );
1854 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1855 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1856 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1857 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1858 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1863 int UtcDaliTouchDataGetEllipseRadius(void)
1865 TestApplication application;
1867 Actor actor = Actor::New();
1868 actor.SetSize(100.0f, 100.0f);
1869 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1870 Stage::GetCurrent().Add(actor);
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 // Connect to actor's touched signal
1878 TouchDataFunctor functor( data );
1879 actor.TouchSignal().Connect( &application, functor );
1881 // Emit a down signal with an angle
1882 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1883 touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1884 application.ProcessEvent( touchEvent );
1885 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1886 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1887 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1888 DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1889 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1894 int UtcDaliTouchDataGetAngle(void)
1896 TestApplication application;
1898 Actor actor = Actor::New();
1899 actor.SetSize(100.0f, 100.0f);
1900 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1901 Stage::GetCurrent().Add(actor);
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 // Connect to actor's touched signal
1909 TouchDataFunctor functor( data );
1910 actor.TouchSignal().Connect( &application, functor );
1912 // Emit a down signal with an angle
1913 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1914 touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1915 application.ProcessEvent( touchEvent );
1916 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1917 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1918 DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1923 int UtcDaliTouchDataGetPressure(void)
1925 TestApplication application;
1927 Actor actor = Actor::New();
1928 actor.SetSize(100.0f, 100.0f);
1929 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1930 Stage::GetCurrent().Add(actor);
1932 // Render and notify
1933 application.SendNotification();
1934 application.Render();
1936 // Connect to actor's touched signal
1938 TouchDataFunctor functor( data );
1939 actor.TouchSignal().Connect( &application, functor );
1941 // Emit a down signal with an angle
1942 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1943 touchEvent.points[ 0 ].SetPressure( 10.0f );
1944 application.ProcessEvent( touchEvent );
1945 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1946 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1947 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1952 int UtcDaliTouchDataAndEventUsage(void)
1954 TestApplication application;
1956 Actor actor = Actor::New();
1957 actor.SetSize(100.0f, 100.0f);
1958 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1959 Stage::GetCurrent().Add(actor);
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1965 // Connect to actor's touched signal
1967 TouchDataFunctor functor( data );
1968 actor.TouchSignal().Connect( &application, functor );
1970 // Connect to actor's touched signal (OLD)
1971 bool touchEventFunctorCalled = false;
1972 TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1973 actor.TouchedSignal().Connect( &application, eventFunctor );
1975 // Emit a down signal with an angle
1976 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1977 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1978 DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );
1983 int UtcDaliTouchDataGetDeviceAPINegative(void)
1985 TestApplication application;
1987 Actor actor = Actor::New();
1988 actor.SetSize(100.0f, 100.0f);
1989 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1990 Stage::GetCurrent().Add(actor);
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Connect to actor's touched signal
1997 HandleData handleData;
1998 TouchDataHandleFunctor functor( handleData );
1999 actor.TouchSignal().Connect( &application, functor );
2001 Vector2 screenCoordinates( 10.0f, 10.0f );
2002 Vector2 localCoordinates;
2003 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
2005 // Emit a down signal
2006 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
2008 TouchData data = handleData.touchData;
2009 DALI_TEST_EQUALS( data.GetDeviceClass( -1 ), Device::Class::NONE, TEST_LOCATION );
2010 DALI_TEST_EQUALS( data.GetDeviceSubclass( -1 ), Device::Subclass::NONE, TEST_LOCATION );