2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali-test-suite-utils.h>
28 void utc_dali_touch_data_processing_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_touch_data_processing_cleanup(void)
35 test_return_value = TET_PASS;
38 ///////////////////////////////////////////////////////////////////////////////
45 PointState::Type state;
50 Vector2 ellipseRadius;
55 : deviceId(-1), state(PointState::FINISHED), radius(0), pressure(0)
58 static const TestPoint ZERO;
61 const TestPoint TestPoint::ZERO;
64 // Stores data that is populated in the callback and will be read by the TET cases
68 : functorCalled( false ),
77 std::vector<TestPoint> points;
79 const TestPoint& GetPoint(size_t i)
81 if( i < points.size() )
85 return TestPoint::ZERO;
87 size_t GetPointCount()
95 functorCalled = false;
98 touchData.points.clear();
100 touchedActor.Reset();
104 TestTouchData touchData;
108 // Functor that sets the data when called
109 struct TouchDataFunctor
113 * @param[in] data Reference to the data to store callback information.
114 * @param[in] returnValue What the functor should return.
116 TouchDataFunctor( SignalData& data, bool returnValue = true )
117 : signalData( data ),
118 returnValue( returnValue )
122 bool operator()( Actor actor, const TouchData& touchData )
124 signalData.functorCalled = true;
125 signalData.touchedActor = actor;
127 signalData.touchData.time = touchData.GetTime();
128 signalData.touchData.points.clear();
130 for( size_t i=0; i<touchData.GetPointCount(); ++i )
133 p.deviceId = touchData.GetDeviceId(i);
134 p.state = touchData.GetState(i);
135 p.hitActor = touchData.GetHitActor(i);
136 p.local = touchData.GetLocalPosition(i);
137 p.screen = touchData.GetScreenPosition(i);
138 p.radius = touchData.GetRadius(i);
139 p.ellipseRadius = touchData.GetEllipseRadius(i);
140 p.pressure = touchData.GetPressure(i);
141 p.angle = touchData.GetAngle(i);
142 signalData.touchData.points.push_back(p);
148 SignalData& signalData;
152 // Functor that removes the actor when called.
153 struct RemoveActorFunctor : public TouchDataFunctor
157 * @param[in] data Reference to the data to store callback information.
158 * @param[in] returnValue What the functor should return.
160 RemoveActorFunctor( SignalData& data, bool returnValue = true )
161 : TouchDataFunctor( data, returnValue )
165 bool operator()( Actor actor, const TouchData& touchData )
167 Actor parent( actor.GetParent() );
170 parent.Remove( actor );
173 return TouchDataFunctor::operator()( actor, touchData );
177 struct OutOfBoundsData
183 :functorCalled(false)
188 // Functor that reads out of bounds data when called
189 struct OutOfBoundsFunctor
193 * @param[in] data Reference to the data to store callback information.
194 * @param[in] returnValue What the functor should return.
196 OutOfBoundsFunctor( OutOfBoundsData& data, bool returnValue = true )
197 : outOfBoundsData ( data ),
198 returnValue( returnValue )
202 bool operator()( Actor actor, const TouchData& touchData )
204 outOfBoundsData.functorCalled = true;
205 size_t count = touchData.GetPointCount();
207 // Read out of bounds data
208 outOfBoundsData.point.deviceId = touchData.GetDeviceId(count+1);
209 outOfBoundsData.point.state = touchData.GetState(count+1);
210 outOfBoundsData.point.hitActor = touchData.GetHitActor(count+1);
211 outOfBoundsData.point.local = touchData.GetLocalPosition(count+1);
212 outOfBoundsData.point.screen = touchData.GetScreenPosition(count+1);
217 OutOfBoundsData& outOfBoundsData;
221 struct TouchEventFunctor
225 * @param[in] functorCalled Reference to a boolean which is set to true if the touch event functor is called.
227 TouchEventFunctor( bool& functorCalled )
228 : functorCalled( functorCalled )
232 bool operator()( Actor actor, const TouchEvent& touch )
234 functorCalled = true;
241 Integration::TouchEvent GenerateSingleTouch( PointState::Type state, const Vector2& screenPosition )
243 Integration::TouchEvent touchEvent;
244 Integration::Point point;
245 point.SetState( state );
246 point.SetScreenPosition( screenPosition );
247 touchEvent.points.push_back( point );
253 ///////////////////////////////////////////////////////////////////////////////
255 int UtcDaliTouchDataNormalProcessing(void)
257 TestApplication application;
259 Actor actor = Actor::New();
260 actor.SetSize(100.0f, 100.0f);
261 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
262 Stage::GetCurrent().Add(actor);
265 application.SendNotification();
266 application.Render();
268 // Connect to actor's touched signal
270 TouchDataFunctor functor( data );
271 actor.TouchSignal().Connect( &application, functor );
273 Vector2 screenCoordinates( 10.0f, 10.0f );
274 Vector2 localCoordinates;
275 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
277 // Emit a down signal
278 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
279 const TestPoint *point1 = &data.touchData.GetPoint(0);
280 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
281 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
282 DALI_TEST_EQUALS( PointState::DOWN, point1->state, TEST_LOCATION );
283 DALI_TEST_EQUALS( screenCoordinates, point1->screen, TEST_LOCATION );
284 DALI_TEST_EQUALS( localCoordinates, point1->local, 0.1f, TEST_LOCATION );
287 // Emit a motion signal
288 screenCoordinates.x = screenCoordinates.y = 11.0f;
289 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
290 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
291 const TestPoint *point2 = &data.touchData.GetPoint(0);
292 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
293 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
294 DALI_TEST_EQUALS( PointState::MOTION, point2->state, TEST_LOCATION );
295 DALI_TEST_EQUALS( screenCoordinates, point2->screen, TEST_LOCATION );
296 DALI_TEST_EQUALS( localCoordinates, point2->local, 0.1f, TEST_LOCATION );
300 screenCoordinates.x = screenCoordinates.y = 12.0f;
301 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
302 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
303 const TestPoint *point3 = &data.touchData.GetPoint(0);
304 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
305 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
306 DALI_TEST_EQUALS( PointState::UP, point3->state, TEST_LOCATION );
307 DALI_TEST_EQUALS( screenCoordinates, point3->screen, TEST_LOCATION );
308 DALI_TEST_EQUALS( localCoordinates, point3->local, 0.1f, TEST_LOCATION );
311 // Emit a down signal where the actor is not present
312 screenCoordinates.x = screenCoordinates.y = 200.0f;
313 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
314 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
319 int UtcDaliTouchDataAPINegative(void)
321 TestApplication application;
323 Actor actor = Actor::New();
324 actor.SetSize(100.0f, 100.0f);
325 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
326 Stage::GetCurrent().Add(actor);
329 application.SendNotification();
330 application.Render();
332 // Connect to actor's touched signal
333 OutOfBoundsData data;
334 OutOfBoundsFunctor functor( data, true );
335 actor.TouchSignal().Connect( &application, functor );
337 Vector2 screenCoordinates( 10.0f, 10.0f );
338 Vector2 localCoordinates;
339 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
341 // Emit a down signal
342 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
344 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
345 DALI_TEST_EQUALS( -1, data.point.deviceId, TEST_LOCATION );
346 DALI_TEST_EQUALS( PointState::FINISHED, data.point.state, TEST_LOCATION );
347 DALI_TEST_EQUALS( Vector2::ZERO, data.point.screen, TEST_LOCATION );
348 DALI_TEST_EQUALS( Vector2::ZERO, data.point.local, 0.1f, TEST_LOCATION );
349 DALI_TEST_CHECK( ! data.point.hitActor );
355 int UtcDaliTouchDataOutsideCameraNearFarPlanes(void)
357 TestApplication application;
359 Stage stage = Stage::GetCurrent();
360 Vector2 stageSize = stage.GetSize();
362 Actor actor = Actor::New();
363 actor.SetSize(100.0f, 100.0f);
364 actor.SetAnchorPoint(AnchorPoint::CENTER);
365 actor.SetParentOrigin(ParentOrigin::CENTER);
369 application.SendNotification();
370 application.Render();
372 // Get the camera's near and far planes
373 RenderTaskList taskList = stage.GetRenderTaskList();
374 Dali::RenderTask task = taskList.GetTask(0);
375 CameraActor camera = task.GetCameraActor();
376 float nearPlane = camera.GetNearClippingPlane();
377 float farPlane = camera.GetFarClippingPlane();
379 // Calculate the current distance of the actor from the camera
380 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
381 float distance = (stageSize.y * 0.5f) / tanHalfFov;
383 // Connect to actor's touched signal
385 TouchDataFunctor functor( data );
386 actor.TouchSignal().Connect( &application, functor );
388 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
390 // Emit a down signal
391 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
392 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
395 // Emit a down signal where actor is just at the camera's near plane
396 actor.SetZ(distance - nearPlane);
399 application.SendNotification();
400 application.Render();
402 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
403 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
406 // Emit a down signal where actor is closer than the camera's near plane
407 actor.SetZ((distance - nearPlane) + 1.0f);
410 application.SendNotification();
411 application.Render();
413 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
414 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
417 // Emit a down signal where actor is just at the camera's far plane
418 actor.SetZ(distance - farPlane);
421 application.SendNotification();
422 application.Render();
424 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
425 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
428 // Emit a down signal where actor is further than the camera's far plane
429 actor.SetZ((distance - farPlane) - 1.0f);
432 application.SendNotification();
433 application.Render();
435 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
436 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
441 int UtcDaliTouchDataEmitEmpty(void)
443 TestApplication application;
447 // Emit an empty TouchEvent
448 Integration::TouchEvent event;
449 application.ProcessEvent( event );
450 tet_result( TET_FAIL );
452 catch ( Dali::DaliException& e )
454 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
459 int UtcDaliTouchDataInterrupted(void)
461 TestApplication application;
463 Actor actor = Actor::New();
464 actor.SetSize(100.0f, 100.0f);
465 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
466 Stage::GetCurrent().Add(actor);
469 application.SendNotification();
470 application.Render();
472 // Connect to actor's touched signal
474 TouchDataFunctor functor( data );
475 actor.TouchSignal().Connect( &application, functor );
477 // Emit a down signal
478 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
479 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
480 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
483 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
484 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
485 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
486 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
489 // Emit another interrupted signal, our signal handler should not be called.
490 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
491 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
495 int UtcDaliTouchDataParentConsumer(void)
497 TestApplication application;
498 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
500 Actor actor = Actor::New();
501 actor.SetSize(100.0f, 100.0f);
502 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
503 Stage::GetCurrent().Add(actor);
506 application.SendNotification();
507 application.Render();
509 // Connect to actor's touched signal
511 TouchDataFunctor functor( data, false );
512 actor.TouchSignal().Connect( &application, functor );
514 // Connect to root actor's touched signal
516 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
517 rootActor.TouchSignal().Connect( &application, rootFunctor );
519 Vector2 screenCoordinates( 10.0f, 10.0f );
520 Vector2 actorCoordinates, rootCoordinates;
521 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
522 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
524 // Emit a down signal
525 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
526 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
527 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
528 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
529 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
530 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
531 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
532 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
533 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
534 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
535 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
536 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
537 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
541 // Emit a motion signal
542 screenCoordinates.x = screenCoordinates.y = 11.0f;
543 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
544 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
545 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, screenCoordinates ) );
546 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
547 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
548 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
549 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
550 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
551 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
552 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
553 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
554 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
555 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
556 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
557 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
562 screenCoordinates.x = screenCoordinates.y = 12.0f;
563 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
564 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
565 application.ProcessEvent( GenerateSingleTouch( PointState::UP, screenCoordinates ) );
566 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
567 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
568 DALI_TEST_EQUALS( 1u, data.touchData.GetPointCount(), TEST_LOCATION );
569 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
570 DALI_TEST_EQUALS( PointState::UP, data.touchData.points[0].state, TEST_LOCATION );
571 DALI_TEST_EQUALS( PointState::UP, rootData.touchData.points[0].state, TEST_LOCATION );
572 DALI_TEST_EQUALS( screenCoordinates, data.touchData.points[0].screen, TEST_LOCATION );
573 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
574 DALI_TEST_EQUALS( actorCoordinates, data.touchData.points[0].local, 0.1f, TEST_LOCATION );
575 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
576 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
577 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
581 // Emit a down signal where the actor is not present, will hit the root actor though
582 screenCoordinates.x = screenCoordinates.y = 200.0f;
583 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
584 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, screenCoordinates ) );
585 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
586 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
587 DALI_TEST_EQUALS( 1u, rootData.touchData.GetPointCount(), TEST_LOCATION );
588 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
589 DALI_TEST_EQUALS( screenCoordinates, rootData.touchData.points[0].screen, TEST_LOCATION );
590 DALI_TEST_EQUALS( rootCoordinates, rootData.touchData.points[0].local, 0.1f, TEST_LOCATION );
591 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
595 int UtcDaliTouchDataInterruptedParentConsumer(void)
597 TestApplication application;
598 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
600 Actor actor = Actor::New();
601 actor.SetSize(100.0f, 100.0f);
602 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
603 Stage::GetCurrent().Add(actor);
606 application.SendNotification();
607 application.Render();
609 // Connect to actor's touched signal
611 TouchDataFunctor functor( data, false );
612 actor.TouchSignal().Connect( &application, functor );
614 // Connect to root actor's touched signal
616 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
617 rootActor.TouchSignal().Connect( &application, rootFunctor );
619 // Emit a down signal
620 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
621 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
622 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
623 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
624 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
625 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
626 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
630 // Emit an interrupted signal
631 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
632 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
633 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
634 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
635 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
636 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
637 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
641 // Emit another down signal
642 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
643 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
644 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
645 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
646 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
650 // Remove actor from Stage
651 Stage::GetCurrent().Remove( actor );
656 application.SendNotification();
657 application.Render();
659 // Emit an interrupted signal, only root actor's signal should be called.
660 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
661 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
662 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
663 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
664 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
668 // Emit another interrupted state, none of the signal's should be called.
669 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 200.0f, 200.0f ) ) );
670 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
671 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
675 int UtcDaliTouchDataLeave(void)
677 TestApplication application;
679 Actor actor = Actor::New();
680 actor.SetSize(100.0f, 100.0f);
681 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
682 Stage::GetCurrent().Add(actor);
685 application.SendNotification();
686 application.Render();
688 // Connect to actor's touched signal
690 TouchDataFunctor functor( data );
691 actor.TouchSignal().Connect( &application, functor );
693 // Set actor to require leave events
694 actor.SetLeaveRequired( true );
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( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
702 // Emit a motion signal outside of actor, should be signalled with a Leave
703 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
704 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
705 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
708 // Another motion outside of actor, no signalling
709 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
710 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
713 // Another motion event inside actor, signalled with motion
714 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
715 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
716 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
719 // We do not want to listen to leave events anymore
720 actor.SetLeaveRequired( false );
722 // Another motion event outside of actor, no signalling
723 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
724 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
729 int UtcDaliTouchDataLeaveParentConsumer(void)
731 TestApplication application;
732 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
734 Actor actor = Actor::New();
735 actor.SetSize(100.0f, 100.0f);
736 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
737 Stage::GetCurrent().Add(actor);
740 application.SendNotification();
741 application.Render();
743 // Connect to actor's touched signal
745 TouchDataFunctor functor( data, false );
746 actor.TouchSignal().Connect( &application, functor );
748 // Connect to root actor's touched signal
750 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
751 rootActor.TouchSignal().Connect( &application, rootFunctor );
753 // Set actor to require leave events
754 actor.SetLeaveRequired( true );
755 rootActor.SetLeaveRequired( true );
757 // Emit a down signal
758 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
759 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
760 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
761 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
762 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
763 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
764 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
768 // Emit a motion signal outside of actor, should be signalled with a Leave
769 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
770 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
771 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
772 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
773 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
774 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
775 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
779 // Another motion outside of actor, only rootActor signalled
780 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 201.0f, 201.0f )) );
781 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
782 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
783 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
784 DALI_TEST_CHECK( rootActor == rootData.touchData.points[0].hitActor );
788 // Another motion event inside actor, signalled with motion
789 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 10.0f, 10.0f )) );
790 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
791 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
792 DALI_TEST_EQUALS( PointState::MOTION, data.touchData.points[0].state, TEST_LOCATION );
793 DALI_TEST_EQUALS( PointState::MOTION, rootData.touchData.points[0].state, TEST_LOCATION );
794 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
795 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
799 // We do not want to listen to leave events of actor anymore
800 actor.SetLeaveRequired( false );
802 // Another motion event outside of root actor, only root signalled
803 Vector2 stageSize( Stage::GetCurrent().GetSize() );
804 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
805 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
806 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
807 DALI_TEST_EQUALS( PointState::LEAVE, rootData.touchData.points[0].state, TEST_LOCATION );
811 int UtcDaliTouchDataActorBecomesInsensitive(void)
813 TestApplication application;
815 Actor actor = Actor::New();
816 actor.SetSize(100.0f, 100.0f);
817 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
818 Stage::GetCurrent().Add(actor);
821 application.SendNotification();
822 application.Render();
824 // Connect to actor's touched signal
826 TouchDataFunctor functor( data );
827 actor.TouchSignal().Connect( &application, functor );
829 // Emit a down signal
830 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
831 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
832 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
835 // Change actor to insensitive
836 actor.SetSensitive( false );
838 // Emit a motion signal, signalled with an interrupted
839 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
840 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
841 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
846 int UtcDaliTouchDataActorBecomesInsensitiveParentConsumer(void)
848 TestApplication application;
849 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
851 Actor actor = Actor::New();
852 actor.SetSize(100.0f, 100.0f);
853 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
854 Stage::GetCurrent().Add(actor);
857 application.SendNotification();
858 application.Render();
860 // Connect to actor's touched signal
862 TouchDataFunctor functor( data, false );
863 actor.TouchSignal().Connect( &application, functor );
865 // Connect to root actor's touched signal
867 TouchDataFunctor rootFunctor( rootData ); // Consumes signal
868 rootActor.TouchSignal().Connect( &application, rootFunctor );
870 // Emit a down signal
871 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
872 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
873 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
874 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
875 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
876 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
877 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
882 application.SendNotification();
883 application.Render();
885 // Make root actor insensitive
886 rootActor.SetSensitive( false );
888 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
889 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2 ( 200.0f, 200.0f )) );
890 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
891 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
892 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
893 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
897 int UtcDaliTouchDataMultipleLayers(void)
899 TestApplication application;
900 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
902 // Connect to actor's touched signal
904 TouchDataFunctor functor( data );
906 Layer layer1 ( Layer::New() );
907 layer1.SetSize(100.0f, 100.0f);
908 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
909 Stage::GetCurrent().Add( layer1 );
911 Actor actor1 ( Actor::New() );
912 actor1.SetSize( 100.0f, 100.0f );
913 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
914 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
915 layer1.Add( actor1 );
918 application.SendNotification();
919 application.Render();
921 // Connect to layer1 and actor1
922 layer1.TouchSignal().Connect( &application, functor );
923 actor1.TouchSignal().Connect( &application, functor );
925 // Hit in hittable area, actor1 should be hit
926 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
927 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
928 DALI_TEST_CHECK( data.touchedActor == actor1 );
931 // Make layer1 insensitive, nothing should be hit
932 layer1.SetSensitive( false );
933 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
934 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
937 // Make layer1 sensitive again, again actor1 will be hit
938 layer1.SetSensitive( true );
939 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
940 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
941 DALI_TEST_CHECK( data.touchedActor == actor1 );
944 // Make rootActor insensitive, nothing should be hit
945 rootActor.SetSensitive( false );
946 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
947 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
950 // Make rootActor sensitive
951 rootActor.SetSensitive( true );
954 Layer layer2 ( Layer::New() );
955 layer2.SetSize(100.0f, 100.0f );
956 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
957 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
958 Stage::GetCurrent().Add( layer2 );
960 Actor actor2 ( Actor::New() );
961 actor2.SetSize(100.0f, 100.0f);
962 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
963 layer2.Add( actor2 );
966 application.SendNotification();
967 application.Render();
969 // Connect to layer2 and actor2
970 layer2.TouchSignal().Connect( &application, functor );
971 actor2.TouchSignal().Connect( &application, functor );
973 // Emit an event, should hit layer2
974 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
975 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
976 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
979 // Make layer2 insensitive, should hit actor1
980 layer2.SetSensitive( false );
981 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
982 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
983 DALI_TEST_CHECK( data.touchedActor == actor1 );
986 // Make layer2 sensitive again, should hit layer2
987 layer2.SetSensitive( true );
988 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
989 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
990 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
993 // Make layer2 invisible, render and notify
994 layer2.SetVisible( false );
995 application.SendNotification();
996 application.Render();
999 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1000 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1001 DALI_TEST_CHECK( data.touchedActor == actor1 );
1004 // Make rootActor invisible, render and notify
1005 rootActor.SetVisible( false );
1006 application.SendNotification();
1007 application.Render();
1009 // Should not hit anything
1010 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1011 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1016 int UtcDaliTouchDataMultipleRenderTasks(void)
1018 TestApplication application;
1019 Stage stage ( Stage::GetCurrent() );
1020 Vector2 stageSize ( stage.GetSize() );
1022 Actor actor = Actor::New();
1023 actor.SetSize(100.0f, 100.0f);
1024 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1027 // Create render task
1028 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1029 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1030 renderTask.SetViewport( viewport );
1031 renderTask.SetInputEnabled( true );
1033 // Render and notify
1034 application.SendNotification();
1035 application.Render();
1037 // Connect to actor's touched signal
1039 TouchDataFunctor functor( data );
1040 actor.TouchSignal().Connect( &application, functor );
1042 // Emit a down signal
1043 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1044 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1047 // Ensure renderTask actor can be hit too.
1048 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1049 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1052 // Disable input on renderTask, should not be hittable
1053 renderTask.SetInputEnabled( false );
1054 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1055 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1060 int UtcDaliTouchDataMultipleRenderTasksWithChildLayer(void)
1062 TestApplication application;
1063 Stage stage ( Stage::GetCurrent() );
1064 Vector2 stageSize ( stage.GetSize() );
1066 Actor actor = Actor::New();
1067 actor.SetSize(100.0f, 100.0f);
1068 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1071 Layer layer = Layer::New();
1072 layer.SetSize(100.0f, 100.0f);
1073 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1076 // Create render task
1077 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
1078 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
1079 renderTask.SetViewport( viewport );
1080 renderTask.SetInputEnabled( true );
1081 renderTask.SetSourceActor( actor );
1083 // Render and notify
1084 application.SendNotification();
1085 application.Render();
1087 // Connect to layer's touched signal
1089 TouchDataFunctor functor( data );
1090 actor.TouchSignal().Connect( &application, functor );
1091 layer.TouchSignal().Connect( &application, functor );
1093 // Emit a down signal
1094 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1095 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1098 // Ensure renderTask actor can be hit too.
1099 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1100 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1103 // Disable input on renderTask, should not be hittable
1104 renderTask.SetInputEnabled( false );
1105 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
1106 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1111 int UtcDaliTouchDataOffscreenRenderTasks(void)
1113 TestApplication application;
1114 Stage stage ( Stage::GetCurrent() );
1115 Vector2 stageSize ( stage.GetSize() );
1117 // FrameBufferImage for offscreen RenderTask
1118 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
1120 // Create a renderable actor to display the FrameBufferImage
1121 Actor renderableActor = CreateRenderableActor( frameBufferImage );
1122 renderableActor.SetParentOrigin(ParentOrigin::CENTER);
1123 renderableActor.SetSize( stageSize.x, stageSize.y );
1124 renderableActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
1125 stage.Add( renderableActor );
1127 Actor actor = Actor::New();
1128 actor.SetSize(100.0f, 100.0f);
1129 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1131 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
1133 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
1135 // Create a RenderTask
1136 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
1137 renderTask.SetSourceActor( actor );
1138 renderTask.SetTargetFrameBuffer( frameBufferImage );
1139 renderTask.SetInputEnabled( true );
1141 // Create another RenderTask
1142 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
1143 renderTask2.SetInputEnabled( true );
1145 // Render and notify
1146 application.SendNotification();
1147 application.Render();
1149 // Connect to actor's touched signal
1151 TouchDataFunctor functor( data );
1152 actor.TouchSignal().Connect( &application, functor );
1154 // Emit a down signal
1155 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1156 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1161 int UtcDaliTouchDataMultipleRenderableActors(void)
1163 TestApplication application;
1164 Stage stage ( Stage::GetCurrent() );
1165 Vector2 stageSize ( stage.GetSize() );
1167 Actor parent = CreateRenderableActor();
1168 parent.SetSize(100.0f, 100.0f);
1169 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1172 Actor actor = CreateRenderableActor();
1173 actor.SetSize(100.0f, 100.0f);
1174 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Connect to layer's touched signal
1183 TouchDataFunctor functor( data );
1184 parent.TouchSignal().Connect( &application, functor );
1185 actor.TouchSignal().Connect( &application, functor );
1187 // Emit a down signal
1188 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1189 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1190 DALI_TEST_CHECK( actor == data.touchedActor );
1194 int UtcDaliTouchDataActorRemovedInSignal(void)
1196 TestApplication application;
1198 Actor actor = Actor::New();
1199 actor.SetSize(100.0f, 100.0f);
1200 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1201 Stage::GetCurrent().Add(actor);
1203 // Render and notify
1204 application.SendNotification();
1205 application.Render();
1207 // Connect to actor's touched signal
1209 RemoveActorFunctor functor( data );
1210 actor.TouchSignal().Connect( &application, functor );
1212 // Register for leave events
1213 actor.SetLeaveRequired( true );
1215 // Emit a down signal
1216 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1217 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1220 // Re-add, render and notify
1221 Stage::GetCurrent().Add(actor);
1222 application.SendNotification();
1223 application.Render();
1225 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1226 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1227 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1230 // Emit a down signal
1231 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1232 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1235 // Render and notify
1236 application.SendNotification();
1237 application.Render();
1239 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1240 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1241 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1244 // Re-add actor back to stage, render and notify
1245 Stage::GetCurrent().Add(actor);
1246 application.SendNotification();
1247 application.Render();
1249 // Emit another down event
1250 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1251 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1254 // Completely delete the actor
1257 // Emit event, should not crash and should not receive an event.
1258 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 210.0f, 210.0f ) ) );
1259 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1263 int UtcDaliTouchDataActorSignalNotConsumed(void)
1265 TestApplication application;
1267 Actor actor = Actor::New();
1268 actor.SetSize(100.0f, 100.0f);
1269 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1270 Stage::GetCurrent().Add(actor);
1272 // Render and notify
1273 application.SendNotification();
1274 application.Render();
1276 // Connect to actor's touched signal
1278 TouchDataFunctor functor( data, false );
1279 actor.TouchSignal().Connect( &application, functor );
1281 // Emit a down signal
1282 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1283 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1287 int UtcDaliTouchDataActorUnStaged(void)
1289 TestApplication application;
1291 Actor actor = Actor::New();
1292 actor.SetSize(100.0f, 100.0f);
1293 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1294 Stage::GetCurrent().Add(actor);
1296 // Render and notify
1297 application.SendNotification();
1298 application.Render();
1300 // Connect to actor's touched signal
1302 TouchDataFunctor functor( data );
1303 actor.TouchSignal().Connect( &application, functor );
1305 // Emit a down signal
1306 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1307 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1310 // Remove actor from stage
1311 Stage::GetCurrent().Remove( actor );
1314 // Render and notify
1315 application.SendNotification();
1316 application.Render();
1318 // Emit a move at the same point, we should not be signalled.
1319 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1320 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1325 int UtcDaliTouchDataSystemOverlayActor(void)
1327 TestApplication application;
1328 Dali::Integration::Core& core( application.GetCore() );
1329 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1330 systemOverlay.GetOverlayRenderTasks().CreateTask();
1332 // Create an actor and add it to the system overlay.
1333 Actor systemActor = Actor::New();
1334 systemActor.SetSize(100.0f, 100.0f);
1335 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1336 systemOverlay.Add( systemActor );
1338 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1339 Actor actor = Actor::New();
1340 actor.SetSize(100.0f, 100.0f);
1341 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1342 Stage::GetCurrent().Add(actor);
1344 // Connect to the touch signals.
1346 TouchDataFunctor functor( data );
1347 systemActor.TouchSignal().Connect( &application, functor );
1348 actor.TouchSignal().Connect( &application, functor );
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1355 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1356 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1357 DALI_TEST_CHECK( systemActor == data.touchedActor );
1361 int UtcDaliTouchDataLayerConsumesTouch(void)
1363 TestApplication application;
1365 Actor actor = Actor::New();
1366 actor.SetSize(100.0f, 100.0f);
1367 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1368 Stage::GetCurrent().Add(actor);
1370 // Render and notify
1371 application.SendNotification();
1372 application.Render();
1374 // Connect to actor's touched signal
1376 TouchDataFunctor functor( data );
1377 actor.TouchSignal().Connect( &application, functor );
1379 // Add a layer to overlap the actor
1380 Layer layer = Layer::New();
1381 layer.SetSize(100.0f, 100.0f);
1382 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1383 Stage::GetCurrent().Add( layer );
1386 // Render and notify
1387 application.SendNotification();
1388 application.Render();
1390 // Emit a few touch signals
1391 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1392 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1393 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1396 // Set layer to consume all touch
1397 layer.SetTouchConsumed( true );
1399 // Render and notify
1400 application.SendNotification();
1401 application.Render();
1403 // Emit the same signals again, should not receive
1404 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1405 application.ProcessEvent( GenerateSingleTouch( PointState::UP, Vector2( 10.0f, 10.0f ) ) );
1406 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1412 int UtcDaliTouchDataLeaveActorReadded(void)
1414 TestApplication application;
1415 Stage stage = Stage::GetCurrent();
1417 Actor actor = Actor::New();
1418 actor.SetSize(100.0f, 100.0f);
1419 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1422 // Set actor to receive touch-events
1423 actor.SetLeaveRequired( true );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Connect to actor's touched signal
1431 TouchDataFunctor functor( data );
1432 actor.TouchSignal().Connect( &application, functor );
1434 // Emit a down and motion
1435 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1436 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 11.0f, 10.0f ) ) );
1437 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1440 // Remove actor from stage and add again
1441 stage.Remove( actor );
1444 // Emit a motion within the actor's bounds
1445 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 12.0f, 10.0f ) ) );
1446 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1449 // Emit a motion outside the actor's bounds
1450 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 200.0f, 200.0f ) ) );
1451 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1452 DALI_TEST_EQUALS( PointState::LEAVE, data.touchData.points[0].state, TEST_LOCATION );
1458 int UtcDaliTouchDataStencilNonRenderableActor(void)
1460 TestApplication application;
1461 Stage stage = Stage::GetCurrent();
1463 Actor actor = Actor::New();
1464 actor.SetSize(100.0f, 100.0f);
1465 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1468 Actor stencil = Actor::New();
1469 stencil.SetSize(50.0f, 50.0f);
1470 stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1471 stencil.SetDrawMode( DrawMode::STENCIL );
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // Connect to actor's touched signal
1480 TouchDataFunctor functor( data );
1481 actor.TouchSignal().Connect( &application, functor );
1483 // Emit an event within stencil area
1484 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1485 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1488 // Emit an event outside the stencil area but within the actor area, we should have a hit!
1489 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 60.0f, 60.0f ) ) );
1490 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1496 int UtcDaliTouchDataActorUnstaged(void)
1498 TestApplication application;
1500 Actor actor = Actor::New();
1501 actor.SetSize(100.0f, 100.0f);
1502 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1503 Stage::GetCurrent().Add(actor);
1505 // Render and notify
1506 application.SendNotification();
1507 application.Render();
1509 // Connect to actor's touched signal
1511 TouchDataFunctor functor( data );
1512 actor.TouchSignal().Connect( &application, functor );
1514 // Emit a down signal
1515 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1516 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1517 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1518 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Unparent the actor
1528 // Should receive an interrupted event
1529 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1530 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1534 int UtcDaliTouchDataParentUnstaged(void)
1536 TestApplication application;
1538 Actor parent = Actor::New();
1539 parent.SetSize(100.0f, 100.0f);
1540 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1541 Stage::GetCurrent().Add(parent);
1543 Actor actor = Actor::New();
1544 actor.SetSize(100.0f, 100.0f);
1545 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Connect to actor's touched signal
1554 TouchDataFunctor functor( data );
1555 actor.TouchSignal().Connect( &application, functor );
1557 // Emit a down signal
1558 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1559 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1560 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1561 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Unparent the parent of the touchable actor
1571 // Should receive an interrupted event
1572 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1573 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1577 int UtcDaliTouchDataActorUnstagedDifferentConsumer(void)
1579 TestApplication application;
1581 Actor parent = Actor::New();
1582 parent.SetSize(100.0f, 100.0f);
1583 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1584 Stage::GetCurrent().Add(parent);
1586 Actor actor = Actor::New();
1587 actor.SetSize(100.0f, 100.0f);
1588 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1591 // Render and notify
1592 application.SendNotification();
1593 application.Render();
1595 // Connect to actor's touched signal
1597 TouchDataFunctor functor( data, false /* Do not consume */ );
1598 actor.TouchSignal().Connect( &application, functor );
1600 // Connect to parent's touched signal
1601 SignalData parentData;
1602 TouchDataFunctor parentFunctor( parentData );
1603 parent.TouchSignal().Connect( &application, parentFunctor );
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 );
1610 DALI_TEST_CHECK( actor == data.touchedActor );
1611 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1612 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1613 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1614 DALI_TEST_CHECK( parent == parentData.touchedActor );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 // Unparent the actor
1625 // Should receive an interrupted event for both actor & parent
1626 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1627 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1628 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1629 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1633 // Readd actor to parent
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Emit a motion signal
1641 application.ProcessEvent( GenerateSingleTouch( PointState::MOTION, Vector2( 10.0f, 10.0f ) ) );
1642 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1643 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1647 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1648 SignalData secondData;
1649 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1650 actor.TouchSignal().Connect( &application, secondFunctor );
1652 // Unparent the actor
1655 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1656 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1657 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1658 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1659 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1660 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1661 DALI_TEST_EQUALS( PointState::INTERRUPTED, secondData.touchData.points[0].state, TEST_LOCATION );
1669 int UtcDaliTouchDataInterruptedDifferentConsumer(void)
1671 TestApplication application;
1672 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1674 Actor parent = Actor::New();
1675 parent.SetSize(100.0f, 100.0f);
1676 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1677 Stage::GetCurrent().Add(parent);
1679 Actor actor = Actor::New();
1680 actor.SetSize(100.0f, 100.0f);
1681 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 // Connect to actor's touched signal
1690 TouchDataFunctor functor( data, false /* Do not consume */ );
1691 actor.TouchSignal().Connect( &application, functor );
1693 // Connect to parent's touched signal
1694 SignalData parentData;
1695 TouchDataFunctor parentFunctor( parentData, false /* Do not consume */ );
1696 parent.TouchSignal().Connect( &application, parentFunctor );
1698 // Connect to root's touched signal and consume
1699 SignalData rootData;
1700 TouchDataFunctor rootFunctor( rootData );
1701 rootActor.TouchSignal().Connect( &application, rootFunctor );
1703 // Emit a down signal
1704 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1705 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1706 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1707 DALI_TEST_CHECK( actor == data.touchData.points[0].hitActor );
1708 DALI_TEST_CHECK( actor == data.touchedActor );
1709 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1710 DALI_TEST_EQUALS( PointState::DOWN, parentData.touchData.points[0].state, TEST_LOCATION );
1711 DALI_TEST_CHECK( actor == parentData.touchData.points[0].hitActor );
1712 DALI_TEST_CHECK( parent == parentData.touchedActor );
1713 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1714 DALI_TEST_EQUALS( PointState::DOWN, rootData.touchData.points[0].state, TEST_LOCATION );
1715 DALI_TEST_CHECK( actor == rootData.touchData.points[0].hitActor );
1716 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1721 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1722 SignalData secondData;
1723 TouchDataFunctor secondFunctor( secondData /* Consume */ );
1724 parent.TouchSignal().Connect( &application, secondFunctor );
1726 // Emit an interrupted signal, all three should STILL be called
1727 application.ProcessEvent( GenerateSingleTouch( PointState::INTERRUPTED, Vector2( 10.0f, 10.0f ) ) );
1728 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1729 DALI_TEST_EQUALS( PointState::INTERRUPTED, data.touchData.points[0].state, TEST_LOCATION );
1730 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1731 DALI_TEST_EQUALS( PointState::INTERRUPTED, parentData.touchData.points[0].state, TEST_LOCATION );
1732 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1733 DALI_TEST_EQUALS( PointState::INTERRUPTED, rootData.touchData.points[0].state, TEST_LOCATION );
1741 int UtcDaliTouchDataGetRadius(void)
1743 TestApplication application;
1745 Actor actor = Actor::New();
1746 actor.SetSize(100.0f, 100.0f);
1747 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1748 Stage::GetCurrent().Add(actor);
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 // Connect to actor's touched signal
1756 TouchDataFunctor functor( data );
1757 actor.TouchSignal().Connect( &application, functor );
1759 // Emit a down signal with an angle
1760 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1761 touchEvent.points[ 0 ].SetRadius( 100.0f );
1762 application.ProcessEvent( touchEvent );
1763 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1764 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1765 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1766 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1767 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1772 int UtcDaliTouchDataGetEllipseRadius(void)
1774 TestApplication application;
1776 Actor actor = Actor::New();
1777 actor.SetSize(100.0f, 100.0f);
1778 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1779 Stage::GetCurrent().Add(actor);
1781 // Render and notify
1782 application.SendNotification();
1783 application.Render();
1785 // Connect to actor's touched signal
1787 TouchDataFunctor functor( data );
1788 actor.TouchSignal().Connect( &application, functor );
1790 // Emit a down signal with an angle
1791 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1792 touchEvent.points[ 0 ].SetRadius( 100.0f, Vector2( 20.0f, 10.0f ) );
1793 application.ProcessEvent( touchEvent );
1794 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1795 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1796 DALI_TEST_EQUALS( 100.0f, data.touchData.points[0].radius, TEST_LOCATION );
1797 DALI_TEST_EQUALS( 20.0f, data.touchData.points[0].ellipseRadius.x, TEST_LOCATION );
1798 DALI_TEST_EQUALS( 10.0f, data.touchData.points[0].ellipseRadius.y, TEST_LOCATION );
1803 int UtcDaliTouchDataGetAngle(void)
1805 TestApplication application;
1807 Actor actor = Actor::New();
1808 actor.SetSize(100.0f, 100.0f);
1809 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1810 Stage::GetCurrent().Add(actor);
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 // Connect to actor's touched signal
1818 TouchDataFunctor functor( data );
1819 actor.TouchSignal().Connect( &application, functor );
1821 // Emit a down signal with an angle
1822 Integration::TouchEvent touchEvent = GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) );
1823 touchEvent.points[ 0 ].SetAngle( Degree( 90.0f ) );
1824 application.ProcessEvent( touchEvent );
1825 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1826 DALI_TEST_EQUALS( PointState::DOWN, data.touchData.points[0].state, TEST_LOCATION );
1827 DALI_TEST_EQUALS( Degree( 90.0f ), data.touchData.points[0].angle, TEST_LOCATION );
1832 int UtcDaliTouchDataGetPressure(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 ].SetPressure( 10.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( 10.0f, data.touchData.points[0].pressure, TEST_LOCATION );
1861 int UtcDaliTouchDataAndEventUsage(void)
1863 TestApplication application;
1865 Actor actor = Actor::New();
1866 actor.SetSize(100.0f, 100.0f);
1867 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1868 Stage::GetCurrent().Add(actor);
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1874 // Connect to actor's touched signal
1876 TouchDataFunctor functor( data );
1877 actor.TouchSignal().Connect( &application, functor );
1879 // Connect to actor's touched signal (OLD)
1880 bool touchEventFunctorCalled = false;
1881 TouchEventFunctor eventFunctor( touchEventFunctorCalled );
1882 actor.TouchedSignal().Connect( &application, eventFunctor );
1884 // Emit a down signal with an angle
1885 application.ProcessEvent( GenerateSingleTouch( PointState::DOWN, Vector2( 10.0f, 10.0f ) ) );
1886 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1887 DALI_TEST_EQUALS( true, touchEventFunctorCalled, TEST_LOCATION );