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/devel-api/events/touch-event-devel.h>
25 #include <dali-test-suite-utils.h>
29 void utc_dali_touch_data_processing_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_touch_data_processing_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
46 PointState::Type state;
51 Vector2 ellipseRadius;
54 DevelDevice::Class::Type deviceClass;
55 DevelDevice::Subclass::Type deviceSubclass;
58 : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
61 static const TestPoint ZERO;
64 const TestPoint TestPoint::ZERO;
67 // Stores data that is populated in the callback and will be read by the TET cases
71 : functorCalled( false ),
80 std::vector<TestPoint> points;
82 const TestPoint& GetPoint(size_t i)
84 if( i < points.size() )
88 return TestPoint::ZERO;
90 size_t GetPointCount()
98 functorCalled = false;
101 touchData.points.clear();
103 touchedActor.Reset();
107 TestTouchData touchData;
111 // Functor that sets the data when called
112 struct TouchDataFunctor
116 * @param[in] data Reference to the data to store callback information.
117 * @param[in] returnValue What the functor should return.
119 TouchDataFunctor( SignalData& data, bool returnValue = true )
120 : signalData( data ),
121 returnValue( returnValue )
125 bool operator()( Actor actor, const TouchData& touchData )
127 signalData.functorCalled = true;
128 signalData.touchedActor = actor;
130 signalData.touchData.time = touchData.GetTime();
131 signalData.touchData.points.clear();
133 for( size_t i=0; i<touchData.GetPointCount(); ++i )
136 p.deviceId = touchData.GetDeviceId(i);
137 p.state = touchData.GetState(i);
138 p.hitActor = touchData.GetHitActor(i);
139 p.local = touchData.GetLocalPosition(i);
140 p.screen = touchData.GetScreenPosition(i);
141 p.radius = touchData.GetRadius(i);
142 p.ellipseRadius = touchData.GetEllipseRadius(i);
143 p.pressure = touchData.GetPressure(i);
144 p.angle = touchData.GetAngle(i);
145 p.deviceClass = DevelTouchData::GetDeviceClass(touchData, i);
146 p.deviceSubclass = DevelTouchData::GetDeviceSubclass(touchData, i);
147 signalData.touchData.points.push_back(p);
153 SignalData& signalData;
163 : signalReceived(false)
168 struct TouchDataHandleFunctor
172 * @param[in] data Reference to the data to store callback information.
173 * @param[in] returnValue What the functor should return.
175 TouchDataHandleFunctor( HandleData& handleData, bool returnValue = true )
176 : handleData(handleData),
177 returnValue( returnValue )
181 bool operator()( Actor actor, const TouchData& someTouchData )
183 handleData.signalReceived = true;
184 TouchData handle(someTouchData);
185 handleData.touchData = handle;
189 HandleData& handleData;
194 // Functor that removes the actor when called.
195 struct RemoveActorFunctor : public TouchDataFunctor
199 * @param[in] data Reference to the data to store callback information.
200 * @param[in] returnValue What the functor should return.
202 RemoveActorFunctor( SignalData& data, bool returnValue = true )
203 : TouchDataFunctor( data, returnValue )
207 bool operator()( Actor actor, const TouchData& touchData )
209 Actor parent( actor.GetParent() );
212 parent.Remove( actor );
215 return TouchDataFunctor::operator()( actor, touchData );
219 struct OutOfBoundsData
225 :functorCalled(false)
230 // Functor that reads out of bounds data when called
231 struct OutOfBoundsFunctor
235 * @param[in] data Reference to the data to store callback information.
236 * @param[in] returnValue What the functor should return.
238 OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
239 : outOfBoundsData ( data ),
240 returnValue( returnValue )
244 bool operator()( Actor actor, const TouchData& touchData )
246 outOfBoundsData.functorCalled = true;
247 size_t count = touchData.GetPointCount();
249 // Read out of bounds data
250 outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
251 outOfBoundsData.point.state = touchData.GetState(count+1);
252 outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
253 outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
254 outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
259 OutOfBoundsData& outOfBoundsData;
263 struct TouchEventFunctor
267 * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called.
269 TouchEventFunctor( bool& functorCalled )
270 : functorCalled( functorCalled )
274 bool operator()( Actor actor, const TouchEvent& touch )
276 functorCalled = true;
283 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
285 Integration::TouchEvent touchEvent;
286 Integration::Point point;
287 point.SetState( state );
288 point.SetScreenPosition( screenPosition );
289 point.SetDeviceClass( DevelDevice::Class::TOUCH );
290 point.SetDeviceSubclass( DevelDevice::Subclass::NONE );
291 touchEvent.points.push_back( point );
297 ///////////////////////////////////////////////////////////////////////////////
299 int UtcDaliTouchDataNormalProcessing01(void)
301 TestApplication application;
303 Actor actor = Actor::New();
304 actor.SetSize(100.0f, 100.0f);
305 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
306 Stage::GetCurrent().Add(actor);
309 application.SendNotification();
310 application.Render();
312 // Connect to actor's touched signal
314 TouchDataFunctor functor( data );
315 actor.TouchSignal().Connect( &application, functor );
317 Vector2 screenCoordinates( 10.0f, 10.0f );
318 Vector2 localCoordinates;
319 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
321 // Emit a down signal
322 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
323 const TestPoint *point1 = &data.touchData.GetPoint(0);
324 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
325 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
326 DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
327 DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
328 DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
331 // Emit a motion signal
332 screenCoordinates.x = screenCoordinates.y = 11.0f;
333 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
334 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
335 const TestPoint *point2 = &data.touchData.GetPoint(0);
336 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
337 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
338 DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
339 DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
340 DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
344 screenCoordinates.x = screenCoordinates.y = 12.0f;
345 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
346 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
347 const TestPoint *point3 = &data.touchData.GetPoint(0);
348 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
349 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
350 DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
351 DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
352 DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
355 // Emit a down signal where the actor is not present
356 screenCoordinates.x = screenCoordinates.y = 200.0f;
357 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
358 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
363 int UtcDaliTouchDataNormalProcessing02(void)
365 TestApplication application;
367 Actor actor = Actor::New();
368 actor.SetSize(100.0f, 100.0f);
369 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
370 Stage::GetCurrent().Add(actor);
373 application.SendNotification();
374 application.Render();
376 // Connect to actor's touched signal
377 HandleData handleData;
378 TouchDataHandleFunctor functor( handleData );
379 actor.TouchSignal().Connect( &application, functor );
381 Vector2 screenCoordinates( 10.0f, 10.0f );
382 Vector2 localCoordinates;
383 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
385 // Emit a down signal
386 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
387 DALI_TEST_EQUALS( true, handleData.signalReceived, TEST_LOCATION );
388 DALI_TEST_EQUALS( 1u, handleData.touchData.GetPointCount(), TEST_LOCATION );
389 DALI_TEST_EQUALS( PointState::DOWN, handleData.touchData.GetState(0), TEST_LOCATION );
390 DALI_TEST_EQUALS( screenCoordinates, handleData.touchData.GetScreenPosition(0), TEST_LOCATION );
391 DALI_TEST_EQUALS( localCoordinates, handleData.touchData.GetLocalPosition(0), 0.1f, TEST_LOCATION );
397 int UtcDaliTouchDataAPINegative(void)
399 TestApplication application;
401 Actor actor = Actor::New();
402 actor.SetSize(100.0f, 100.0f);
403 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
404 Stage::GetCurrent().Add(actor);
407 application.SendNotification();
408 application.Render();
410 // Connect to actor's touched signal
411 OutOfBoundsData data;
412 OutOfBoundsFunctor functor( data, true );
413 actor.TouchSignal().Connect( &application, functor );
415 Vector2 screenCoordinates( 10.0f, 10.0f );
416 Vector2 localCoordinates;
417 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
419 // Emit a down signal
420 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
422 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
423 DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
424 DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
425 DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
426 DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
427 DALI_TEST_CHECK( ! data.point.hitActor );
433 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
435 TestApplication application;
437 Stage stage = Stage::GetCurrent();
438 Vector2 stageSize = stage.GetSize();
440 Actor actor = Actor::New();
441 actor.SetSize(100.0f, 100.0f);
442 actor.SetAnchorPoint(AnchorPoint::CENTER);
443 actor.SetParentOrigin(ParentOrigin::CENTER);
447 application.SendNotification();
448 application.Render();
450 // Get the camera's near and far planes
451 RenderTaskList taskList = stage.GetRenderTaskList();
452 Dali::RenderTask task = taskList.GetTask(0);
453 CameraActor camera = task.GetCameraActor();
454 float nearPlane = camera.GetNearClippingPlane();
455 float farPlane = camera.GetFarClippingPlane();
457 // Calculate the current distance of the actor from the camera
458 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
459 float distance = (stageSize.y * 0.5f) / tanHalfFov;
461 // Connect to actor's touched signal
463 TouchDataFunctor functor( data );
464 actor.TouchSignal().Connect( &application, functor );
466 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
468 // Emit a down signal
469 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
470 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
473 // Emit a down signal where actor is just at the camera's near plane
474 actor.SetZ(distance - nearPlane);
477 application.SendNotification();
478 application.Render();
480 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
481 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
484 // Emit a down signal where actor is closer than the camera's near plane
485 actor.SetZ((distance - nearPlane) + 1.0f);
488 application.SendNotification();
489 application.Render();
491 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
492 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
495 // Emit a down signal where actor is just at the camera's far plane
496 actor.SetZ(distance - farPlane);
499 application.SendNotification();
500 application.Render();
502 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
503 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
506 // Emit a down signal where actor is further than the camera's far plane
507 actor.SetZ((distance - farPlane) - 1.0f);
510 application.SendNotification();
511 application.Render();
513 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
514 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
519 int UtcDaliTouchDataEmitEmpty(void)
521 TestApplication application;
525 // Emit an empty TouchEvent
526 Integration::TouchEvent event;
527 application.ProcessEvent( event );
528 tet_result( TET_FAIL );
530 catch ( Dali::DaliException& e )
532 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
537 int UtcDaliTouchDataInterrupted(void)
539 TestApplication application;
541 Actor actor = Actor::New();
542 actor.SetSize(100.0f, 100.0f);
543 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
544 Stage::GetCurrent().Add(actor);
547 application.SendNotification();
548 application.Render();
550 // Connect to actor's touched signal
552 TouchDataFunctor functor( data );
553 actor.TouchSignal().Connect( &application, functor );
555 // Emit a down signal
556 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
557 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
558 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
561 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
562 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
563 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
564 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
567 // Emit another interrupted signal, our signal handler should not be called.
568 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
569 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
573 int UtcDaliTouchDataParentConsumer(void)
575 TestApplication application;
576 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
578 Actor actor = Actor::New();
579 actor.SetSize(100.0f, 100.0f);
580 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
581 Stage::GetCurrent().Add(actor);
584 application.SendNotification();
585 application.Render();
587 // Connect to actor's touched signal
589 TouchDataFunctor functor( data, false );
590 actor.TouchSignal().Connect( &application, functor );
592 // Connect to root actor's touched signal
594 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
595 rootActor.TouchSignal().Connect( &application, rootFunctor );
597 Vector2 screenCoordinates( 10.0f, 10.0f );
598 Vector2 actorCoordinates, rootCoordinates;
599 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
600 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
602 // Emit a down signal
603 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
604 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
605 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
606 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
607 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
608 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
609 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
610 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
611 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
612 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
613 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
614 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
615 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
619 // Emit a motion signal
620 screenCoordinates.x = screenCoordinates.y = 11.0f;
621 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
622 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
623 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
624 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
625 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
626 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
627 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
628 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
629 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
630 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
631 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
632 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
633 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
634 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
635 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
640 screenCoordinates.x = screenCoordinates.y = 12.0f;
641 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
642 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
643 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
644 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
645 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
646 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
647 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
648 DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
649 DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
650 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
651 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
652 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
653 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
654 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
655 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
659 // Emit a down signal where the actor is not present, will hit the root actor though
660 screenCoordinates.x = screenCoordinates.y = 200.0f;
661 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
662 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
663 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
664 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
665 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
666 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
667 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
668 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
669 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
673 int UtcDaliTouchDataInterruptedParentConsumer(void)
675 TestApplication application;
676 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
678 Actor actor = Actor::New();
679 actor.SetSize(100.0f, 100.0f);
680 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
681 Stage::GetCurrent().Add(actor);
684 application.SendNotification();
685 application.Render();
687 // Connect to actor's touched signal
689 TouchDataFunctor functor( data, false );
690 actor.TouchSignal().Connect( &application, functor );
692 // Connect to root actor's touched signal
694 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
695 rootActor.TouchSignal().Connect( &application, rootFunctor );
697 // Emit a down signal
698 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
699 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
700 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
701 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
702 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
703 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
704 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
708 // Emit an interrupted signal
709 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
710 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
711 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
712 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
713 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
714 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
715 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
719 // Emit another down signal
720 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
721 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
722 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
723 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
724 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
728 // Remove actor from Stage
729 Stage::GetCurrent().Remove( actor );
734 application.SendNotification();
735 application.Render();
737 // Emit an interrupted signal, only root actor's signal should be called.
738 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
739 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
740 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
741 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
742 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
746 // Emit another interrupted state, none of the signal's should be called.
747 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
748 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
749 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
753 int UtcDaliTouchDataLeave(void)
755 TestApplication application;
757 Actor actor = Actor::New();
758 actor.SetSize(100.0f, 100.0f);
759 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
760 Stage::GetCurrent().Add(actor);
763 application.SendNotification();
764 application.Render();
766 // Connect to actor's touched signal
768 TouchDataFunctor functor( data );
769 actor.TouchSignal().Connect( &application, functor );
771 // Set actor to require leave events
772 actor.SetLeaveRequired( true );
774 // Emit a down signal
775 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
776 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
777 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
780 // Emit a motion signal outside of actor, should be signalled with a Leave
781 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
782 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
783 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
786 // Another motion outside of actor, no signalling
787 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
788 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
791 // Another motion event inside actor, signalled with motion
792 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
793 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
794 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
797 // We do not want to listen to leave events anymore
798 actor.SetLeaveRequired( false );
800 // Another motion event outside of actor, no signalling
801 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
802 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
807 int UtcDaliTouchDataLeaveParentConsumer(void)
809 TestApplication application;
810 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
812 Actor actor = Actor::New();
813 actor.SetSize(100.0f, 100.0f);
814 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
815 Stage::GetCurrent().Add(actor);
818 application.SendNotification();
819 application.Render();
821 // Connect to actor's touched signal
823 TouchDataFunctor functor( data, false );
824 actor.TouchSignal().Connect( &application, functor );
826 // Connect to root actor's touched signal
828 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
829 rootActor.TouchSignal().Connect( &application, rootFunctor );
831 // Set actor to require leave events
832 actor.SetLeaveRequired( true );
833 rootActor.SetLeaveRequired( true );
835 // Emit a down signal
836 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
837 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
838 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
839 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
840 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
841 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
842 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
846 // Emit a motion signal outside of actor, should be signalled with a Leave
847 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
848 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
849 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
850 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
851 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
852 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
853 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
857 // Another motion outside of actor, only rootActor signalled
858 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
859 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
860 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
861 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
862 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
866 // Another motion event inside actor, signalled with motion
867 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
868 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
869 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
870 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
871 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
872 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
873 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
877 // We do not want to listen to leave events of actor anymore
878 actor.SetLeaveRequired( false );
880 // Another motion event outside of root actor, only root signalled
881 Vector2 stageSize( Stage::GetCurrent().GetSize() );
882 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
883 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
884 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
885 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
889 int UtcDaliTouchDataActorBecomesInsensitive(void)
891 TestApplication application;
893 Actor actor = Actor::New();
894 actor.SetSize(100.0f, 100.0f);
895 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
896 Stage::GetCurrent().Add(actor);
899 application.SendNotification();
900 application.Render();
902 // Connect to actor's touched signal
904 TouchDataFunctor functor( data );
905 actor.TouchSignal().Connect( &application, functor );
907 // Emit a down signal
908 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
909 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
910 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
913 // Change actor to insensitive
914 actor.SetSensitive( false );
916 // Emit a motion signal, signalled with an interrupted
917 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
918 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
919 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
924 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
926 TestApplication application;
927 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
929 Actor actor = Actor::New();
930 actor.SetSize(100.0f, 100.0f);
931 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
932 Stage::GetCurrent().Add(actor);
935 application.SendNotification();
936 application.Render();
938 // Connect to actor's touched signal
940 TouchDataFunctor functor( data, false );
941 actor.TouchSignal().Connect( &application, functor );
943 // Connect to root actor's touched signal
945 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
946 rootActor.TouchSignal().Connect( &application, rootFunctor );
948 // Emit a down signal
949 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
950 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
951 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
952 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
953 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
954 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
955 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
960 application.SendNotification();
961 application.Render();
963 // Make root actor insensitive
964 rootActor.SetSensitive( false );
966 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
967 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
968 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
969 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
970 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
971 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
975 int UtcDaliTouchDataMultipleLayers(void)
977 TestApplication application;
978 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
980 // Connect to actor's touched signal
982 TouchDataFunctor functor( data );
984 Layer layer1 ( Layer::New() );
985 layer1.SetSize(100.0f, 100.0f);
986 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
987 Stage::GetCurrent().Add( layer1 );
989 Actor actor1 ( Actor::New() );
990 actor1.SetSize( 100.0f, 100.0f );
991 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
992 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
993 layer1.Add( actor1 );
996 application.SendNotification();
997 application.Render();
999 // Connect to layer1 and actor1
1000 layer1.TouchSignal().Connect( &application, functor );
1001 actor1.TouchSignal().Connect( &application, functor );
1003 // Hit in hittable area, actor1 should be hit
1004 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1005 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1006 DALI_TEST_CHECK( data.touchedActor == actor1 );
1009 // Make layer1 insensitive, nothing should be hit
1010 layer1.SetSensitive( false );
1011 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1012 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1015 // Make layer1 sensitive again, again actor1 will be hit
1016 layer1.SetSensitive( true );
1017 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1018 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1019 DALI_TEST_CHECK( data.touchedActor == actor1 );
1022 // Make rootActor insensitive, nothing should be hit
1023 rootActor.SetSensitive( false );
1024 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1025 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1028 // Make rootActor sensitive
1029 rootActor.SetSensitive( true );
1031 // Add another layer
1032 Layer layer2 ( Layer::New() );
1033 layer2.SetSize(100.0f, 100.0f );
1034 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1035 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
1036 Stage::GetCurrent().Add( layer2 );
1038 Actor actor2 ( Actor::New() );
1039 actor2.SetSize(100.0f, 100.0f);
1040 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1041 layer2.Add( actor2 );
1043 // Render and notify
1044 application.SendNotification();
1045 application.Render();
1047 // Connect to layer2 and actor2
1048 layer2.TouchSignal().Connect( &application, functor );
1049 actor2.TouchSignal().Connect( &application, functor );
1051 // Emit an event, should hit layer2
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 == layer2 ); // TODO: Uncomment this after removing renderable hack!
1057 // Make layer2 insensitive, should hit actor1
1058 layer2.SetSensitive( false );
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 == actor1 );
1064 // Make layer2 sensitive again, should hit layer2
1065 layer2.SetSensitive( true );
1066 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1067 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1068 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
1071 // Make layer2 invisible, render and notify
1072 layer2.SetVisible( false );
1073 application.SendNotification();
1074 application.Render();
1076 // Should hit actor1
1077 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1078 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1079 DALI_TEST_CHECK( data.touchedActor == actor1 );
1082 // Make rootActor invisible, render and notify
1083 rootActor.SetVisible( false );
1084 application.SendNotification();
1085 application.Render();
1087 // Should not hit anything
1088 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1089 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1094 int UtcDaliTouchDataMultipleRenderTasks(void)
1096 TestApplication application;
1097 Stage stage ( Stage::GetCurrent() );
1098 Vector2 stageSize ( stage.GetSize() );
1100 Actor actor = Actor::New();
1101 actor.SetSize(100.0f, 100.0f);
1102 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1105 // Create render task
1106 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1107 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1108 renderTask.SetViewport( viewport );
1109 renderTask.SetInputEnabled( true );
1111 // Render and notify
1112 application.SendNotification();
1113 application.Render();
1115 // Connect to actor's touched signal
1117 TouchDataFunctor functor( data );
1118 actor.TouchSignal().Connect( &application, functor );
1120 // Emit a down signal
1121 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1122 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1125 // Ensure renderTask actor can be hit too.
1126 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1127 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1130 // Disable input on renderTask, should not be hittable
1131 renderTask.SetInputEnabled( false );
1132 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1133 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1138 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1140 TestApplication application;
1141 Stage stage ( Stage::GetCurrent() );
1142 Vector2 stageSize ( stage.GetSize() );
1144 Actor actor = Actor::New();
1145 actor.SetSize(100.0f, 100.0f);
1146 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1149 Layer layer = Layer::New();
1150 layer.SetSize(100.0f, 100.0f);
1151 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1154 // Create render task
1155 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1156 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1157 renderTask.SetViewport( viewport );
1158 renderTask.SetInputEnabled( true );
1159 renderTask.SetSourceActor( actor );
1161 // Render and notify
1162 application.SendNotification();
1163 application.Render();
1165 // Connect to layer's touched signal
1167 TouchDataFunctor functor( data );
1168 actor.TouchSignal().Connect( &application, functor );
1169 layer.TouchSignal().Connect( &application, functor );
1171 // Emit a down signal
1172 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1173 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1176 // Ensure renderTask actor can be hit too.
1177 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1178 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1181 // Disable input on renderTask, should not be hittable
1182 renderTask.SetInputEnabled( false );
1183 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1184 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1189 int UtcDaliTouchDataOffscreenRenderTasks(void)
1191 TestApplication application;
1192 Stage stage ( Stage::GetCurrent() );
1193 Vector2 stageSize ( stage.GetSize() );
1195 // FrameBufferImage for offscreen RenderTask
1196 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
1198 // Create a renderable actor to display the FrameBufferImage
1199 Actor renderableActor = CreateRenderableActor( frameBufferImage );
1200 renderableActor.SetParentOrigin(ParentOrigin::CENTER);
1201 renderableActor.SetSize( stageSize.x, stageSize.y );
1202 renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1203 stage.Add( renderableActor );
1205 Actor actor = Actor::New();
1206 actor.SetSize(100.0f, 100.0f);
1207 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1209 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1211 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1213 // Create a RenderTask
1214 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
1215 renderTask.SetSourceActor( actor );
1216 renderTask.SetTargetFrameBuffer( frameBufferImage );
1217 renderTask.SetInputEnabled( true );
1219 // Create another RenderTask
1220 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1221 renderTask2.SetInputEnabled( true );
1223 // Render and notify
1224 application.SendNotification();
1225 application.Render();
1227 // Connect to actor's touched signal
1229 TouchDataFunctor functor( data );
1230 actor.TouchSignal().Connect( &application, functor );
1232 // Emit a down signal
1233 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1234 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1239 int UtcDaliTouchDataMultipleRenderableActors(void)
1241 TestApplication application;
1242 Stage stage ( Stage::GetCurrent() );
1243 Vector2 stageSize ( stage.GetSize() );
1245 Actor parent = CreateRenderableActor();
1246 parent.SetSize(100.0f, 100.0f);
1247 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1250 Actor actor = CreateRenderableActor();
1251 actor.SetSize(100.0f, 100.0f);
1252 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Connect to layer's touched signal
1261 TouchDataFunctor functor( data );
1262 parent.TouchSignal().Connect( &application, functor );
1263 actor.TouchSignal().Connect( &application, functor );
1265 // Emit a down signal
1266 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1267 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1268 DALI_TEST_CHECK( actor == data.touchedActor );
1272 int UtcDaliTouchDataActorRemovedInSignal(void)
1274 TestApplication application;
1276 Actor actor = Actor::New();
1277 actor.SetSize(100.0f, 100.0f);
1278 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1279 Stage::GetCurrent().Add(actor);
1281 // Render and notify
1282 application.SendNotification();
1283 application.Render();
1285 // Connect to actor's touched signal
1287 RemoveActorFunctor functor( data );
1288 actor.TouchSignal().Connect( &application, functor );
1290 // Register for leave events
1291 actor.SetLeaveRequired( true );
1293 // Emit a down signal
1294 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1295 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1298 // Re-add, render and notify
1299 Stage::GetCurrent().Add(actor);
1300 application.SendNotification();
1301 application.Render();
1303 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1304 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1305 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1308 // Emit a down signal
1309 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1310 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1313 // Render and notify
1314 application.SendNotification();
1315 application.Render();
1317 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1318 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1319 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1322 // Re-add actor back to stage, render and notify
1323 Stage::GetCurrent().Add(actor);
1324 application.SendNotification();
1325 application.Render();
1327 // Emit another down event
1328 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1329 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1332 // Completely delete the actor
1335 // Emit event, should not crash and should not receive an event.
1336 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1337 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1341 int UtcDaliTouchDataActorSignalNotConsumed(void)
1343 TestApplication application;
1345 Actor actor = Actor::New();
1346 actor.SetSize(100.0f, 100.0f);
1347 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1348 Stage::GetCurrent().Add(actor);
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Connect to actor's touched signal
1356 TouchDataFunctor functor( data, false );
1357 actor.TouchSignal().Connect( &application, functor );
1359 // Emit a down signal
1360 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1361 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1365 int UtcDaliTouchDataActorUnStaged(void)
1367 TestApplication application;
1369 Actor actor = Actor::New();
1370 actor.SetSize(100.0f, 100.0f);
1371 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1372 Stage::GetCurrent().Add(actor);
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Connect to actor's touched signal
1380 TouchDataFunctor functor( data );
1381 actor.TouchSignal().Connect( &application, functor );
1383 // Emit a down signal
1384 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1385 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1388 // Remove actor from stage
1389 Stage::GetCurrent().Remove( actor );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // Emit a move at the same point, we should not be signalled.
1397 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1398 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1403 int UtcDaliTouchDataSystemOverlayActor(void)
1405 TestApplication application;
1406 Dali::Integration::Core& core( application.GetCore() );
1407 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1408 systemOverlay.GetOverlayRenderTasks().CreateTask();
1410 // Create an actor and add it to the system overlay.
1411 Actor systemActor = Actor::New();
1412 systemActor.SetSize(100.0f, 100.0f);
1413 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1414 systemOverlay.Add( systemActor );
1416 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1417 Actor actor = Actor::New();
1418 actor.SetSize(100.0f, 100.0f);
1419 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1420 Stage::GetCurrent().Add(actor);
1422 // Connect to the touch signals.
1424 TouchDataFunctor functor( data );
1425 systemActor.TouchSignal().Connect( &application, functor );
1426 actor.TouchSignal().Connect( &application, functor );
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1433 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1434 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1435 DALI_TEST_CHECK( systemActor == data.touchedActor );
1439 int UtcDaliTouchDataLayerConsumesTouch(void)
1441 TestApplication application;
1443 Actor actor = Actor::New();
1444 actor.SetSize(100.0f, 100.0f);
1445 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1446 Stage::GetCurrent().Add(actor);
1448 // Render and notify
1449 application.SendNotification();
1450 application.Render();
1452 // Connect to actor's touched signal
1454 TouchDataFunctor functor( data );
1455 actor.TouchSignal().Connect( &application, functor );
1457 // Add a layer to overlap the actor
1458 Layer layer = Layer::New();
1459 layer.SetSize(100.0f, 100.0f);
1460 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1461 Stage::GetCurrent().Add( layer );
1464 // Render and notify
1465 application.SendNotification();
1466 application.Render();
1468 // Emit a few touch signals
1469 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1470 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1471 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1474 // Set layer to consume all touch
1475 layer.SetTouchConsumed( true );
1477 // Render and notify
1478 application.SendNotification();
1479 application.Render();
1481 // Emit the same signals again, should not receive
1482 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1483 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1484 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1490 int UtcDaliTouchDataLeaveActorReadded(void)
1492 TestApplication application;
1493 Stage stage = Stage::GetCurrent();
1495 Actor actor = Actor::New();
1496 actor.SetSize(100.0f, 100.0f);
1497 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1500 // Set actor to receive touch-events
1501 actor.SetLeaveRequired( true );
1503 // Render and notify
1504 application.SendNotification();
1505 application.Render();
1507 // Connect to actor's touched signal
1509 TouchDataFunctor functor( data );
1510 actor.TouchSignal().Connect( &application, functor );
1512 // Emit a down and motion
1513 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1514 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1515 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1518 // Remove actor from stage and add again
1519 stage.Remove( actor );
1522 // Emit a motion within the actor's bounds
1523 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1524 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1527 // Emit a motion outside the actor's bounds
1528 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1529 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1530 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1536 int UtcDaliTouchDataClippedActor(void)
1538 TestApplication application;
1539 Stage stage = Stage::GetCurrent();
1541 Actor actor = Actor::New();
1542 actor.SetSize( 100.0f, 100.0f );
1543 actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1546 Actor clippingActor = Actor::New();
1547 clippingActor.SetSize( 50.0f, 50.0f );
1548 clippingActor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1549 clippingActor.SetProperty( Actor::Property::CLIPPING_MODE, ClippingMode::CLIP_CHILDREN );
1550 stage.Add( clippingActor );
1552 // Add a child to the clipped region.
1553 Actor clippingChild = Actor::New();
1554 clippingChild.SetSize( 50.0f, 50.0f );
1555 clippingChild.SetPosition( 25.0f, 25.0f );
1556 clippingChild.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1557 clippingActor.Add( clippingChild );
1559 // Render and notify.
1560 application.SendNotification();
1561 application.Render();
1563 // Connect to actor's touch signal.
1565 TouchDataFunctor functor( data );
1566 actor.TouchSignal().Connect( &application, functor );
1568 // Emit an event within clipped area - no hit.
1569 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1570 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1573 // Emit an event outside the clipped area but within the actor area, we should have a hit.
1574 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1575 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1578 clippingChild.TouchSignal().Connect( &application, functor );
1580 // Emit an event inside part of the child which is within the clipped area, we should have a hit.
1581 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 30.0f, 30.0f ) ) );
1582 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1588 int UtcDaliTouchDataActorUnstaged(void)
1590 TestApplication application;
1592 Actor actor = Actor::New();
1593 actor.SetSize(100.0f, 100.0f);
1594 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1595 Stage::GetCurrent().Add(actor);
1597 // Render and notify
1598 application.SendNotification();
1599 application.Render();
1601 // Connect to actor's touched signal
1603 TouchDataFunctor functor( data );
1604 actor.TouchSignal().Connect( &application, functor );
1606 // Emit a down signal
1607 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1608 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1609 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1610 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1613 // Render and notify
1614 application.SendNotification();
1615 application.Render();
1617 // Unparent the actor
1620 // Should receive an interrupted event
1621 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1622 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1626 int UtcDaliTouchDataParentUnstaged(void)
1628 TestApplication application;
1630 Actor parent = Actor::New();
1631 parent.SetSize(100.0f, 100.0f);
1632 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1633 Stage::GetCurrent().Add(parent);
1635 Actor actor = Actor::New();
1636 actor.SetSize(100.0f, 100.0f);
1637 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 // Connect to actor's touched signal
1646 TouchDataFunctor functor( data );
1647 actor.TouchSignal().Connect( &application, functor );
1649 // Emit a down signal
1650 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1651 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1652 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1653 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 // Unparent the parent of the touchable actor
1663 // Should receive an interrupted event
1664 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1665 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1669 int UtcDaliTouchDataActorUnstagedDifferentConsumer(void)
1671 TestApplication application;
1673 Actor parent = Actor::New();
1674 parent.SetSize(100.0f, 100.0f);
1675 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1676 Stage::GetCurrent().Add(parent);
1678 Actor actor = Actor::New();
1679 actor.SetSize(100.0f, 100.0f);
1680 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // Connect to actor's touched signal
1689 TouchDataFunctor functor( data, false /* Do not consume */ );
1690 actor.TouchSignal().Connect( &application, functor );
1692 // Connect to parent's touched signal
1693 SignalData parentData;
1694 TouchDataFunctor parentFunctor( parentData );
1695 parent.TouchSignal().Connect( &application, parentFunctor );
1697 // Emit a down signal
1698 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1699 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1700 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1701 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1702 DALI_TEST_CHECK( actor == data.touchedActor );
1703 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1704 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1705 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1706 DALI_TEST_CHECK( parent == parentData.touchedActor );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 // Unparent the actor
1717 // Should receive an interrupted event for both actor & parent
1718 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1719 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1720 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1721 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1725 // Readd actor to parent
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Emit a motion signal
1733 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1734 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1735 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1739 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1740 SignalData secondData;
1741 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1742 actor.TouchSignal().Connect( &application, secondFunctor );
1744 // Unparent the actor
1747 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1748 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1749 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1750 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1751 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1752 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1753 DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1761 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1763 TestApplication application;
1764 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1766 Actor parent = Actor::New();
1767 parent.SetSize(100.0f, 100.0f);
1768 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1769 Stage::GetCurrent().Add(parent);
1771 Actor actor = Actor::New();
1772 actor.SetSize(100.0f, 100.0f);
1773 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // Connect to actor's touched signal
1782 TouchDataFunctor functor( data, false /* Do not consume */ );
1783 actor.TouchSignal().Connect( &application, functor );
1785 // Connect to parent's touched signal
1786 SignalData parentData;
1787 TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1788 parent.TouchSignal().Connect( &application, parentFunctor );
1790 // Connect to root's touched signal and consume
1791 SignalData rootData;
1792 TouchDataFunctor rootFunctor( rootData );
1793 rootActor.TouchSignal().Connect( &application, rootFunctor );
1795 // Emit a down signal
1796 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1797 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1798 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1799 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1800 DALI_TEST_CHECK( actor == data.touchedActor );
1801 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1802 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1803 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1804 DALI_TEST_CHECK( parent == parentData.touchedActor );
1805 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1806 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1807 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1808 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1813 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1814 SignalData secondData;
1815 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1816 parent.TouchSignal().Connect( &application, secondFunctor );
1818 // Emit an interrupted signal, all three should STILL be called
1819 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1820 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1821 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1822 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1823 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1824 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1825 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1833 int UtcDaliTouchDataGetRadius(void)
1835 TestApplication application;
1837 Actor actor = Actor::New();
1838 actor.SetSize(100.0f, 100.0f);
1839 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1840 Stage::GetCurrent().Add(actor);
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Connect to actor's touched signal
1848 TouchDataFunctor functor( data );
1849 actor.TouchSignal().Connect( &application, functor );
1851 // Emit a down signal with an angle
1852 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1853 touchEvent.points[ 0 ].SetRadius( 100.0f );
1854 application.ProcessEvent( touchEvent );
1855 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1856 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1857 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1858 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1859 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1864 int UtcDaliTouchDataGetEllipseRadius(void)
1866 TestApplication application;
1868 Actor actor = Actor::New();
1869 actor.SetSize(100.0f, 100.0f);
1870 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1871 Stage::GetCurrent().Add(actor);
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Connect to actor's touched signal
1879 TouchDataFunctor functor( data );
1880 actor.TouchSignal().Connect( &application, functor );
1882 // Emit a down signal with an angle
1883 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1884 touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1885 application.ProcessEvent( touchEvent );
1886 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1887 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1888 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1889 DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1890 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1895 int UtcDaliTouchDataGetAngle(void)
1897 TestApplication application;
1899 Actor actor = Actor::New();
1900 actor.SetSize(100.0f, 100.0f);
1901 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1902 Stage::GetCurrent().Add(actor);
1904 // Render and notify
1905 application.SendNotification();
1906 application.Render();
1908 // Connect to actor's touched signal
1910 TouchDataFunctor functor( data );
1911 actor.TouchSignal().Connect( &application, functor );
1913 // Emit a down signal with an angle
1914 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1915 touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1916 application.ProcessEvent( touchEvent );
1917 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1918 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1919 DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1924 int UtcDaliTouchDataGetPressure(void)
1926 TestApplication application;
1928 Actor actor = Actor::New();
1929 actor.SetSize(100.0f, 100.0f);
1930 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1931 Stage::GetCurrent().Add(actor);
1933 // Render and notify
1934 application.SendNotification();
1935 application.Render();
1937 // Connect to actor's touched signal
1939 TouchDataFunctor functor( data );
1940 actor.TouchSignal().Connect( &application, functor );
1942 // Emit a down signal with an angle
1943 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1944 touchEvent.points[ 0 ].SetPressure( 10.0f );
1945 application.ProcessEvent( touchEvent );
1946 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1947 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1948 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1953 int UtcDaliTouchDataAndEventUsage(void)
1955 TestApplication application;
1957 Actor actor = Actor::New();
1958 actor.SetSize(100.0f, 100.0f);
1959 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1960 Stage::GetCurrent().Add(actor);
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1966 // Connect to actor's touched signal
1968 TouchDataFunctor functor( data );
1969 actor.TouchSignal().Connect( &application, functor );
1971 // Connect to actor's touched signal (OLD)
1972 bool touchEventFunctorCalled = false;
1973 TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1974 actor.TouchedSignal().Connect( &application, eventFunctor );
1976 // Emit a down signal with an angle
1977 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1978 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1979 DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );
1984 int UtcDaliTouchDataGetDeviceAPINegative(void)
1986 TestApplication application;
1988 Actor actor = Actor::New();
1989 actor.SetSize(100.0f, 100.0f);
1990 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1991 Stage::GetCurrent().Add(actor);
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 // Connect to actor's touched signal
1998 HandleData handleData;
1999 TouchDataHandleFunctor functor( handleData );
2000 actor.TouchSignal().Connect( &application, functor );
2002 Vector2 screenCoordinates( 10.0f, 10.0f );
2003 Vector2 localCoordinates;
2004 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
2006 // Emit a down signal
2007 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
2009 TouchData data = handleData.touchData;
2010 DALI_TEST_EQUALS( DevelTouchData::GetDeviceClass( data, -1 ), DevelDevice::Class::NONE, TEST_LOCATION );
2011 DALI_TEST_EQUALS( DevelTouchData::GetDeviceSubclass( data, -1 ), DevelDevice::Subclass::NONE, TEST_LOCATION );