2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/dali-core.h>
22 #include <dali/integration-api/events/touch-event-integ.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali-test-suite-utils.h>
28 void utc_dali_touch_processing_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_touch_processing_cleanup(void)
35 test_return_value = TET_PASS;
38 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled( false ),
55 functorCalled = false;
58 touchEvent.points.clear();
64 TouchEvent touchEvent;
68 // Functor that sets the data when called
69 struct TouchEventFunctor
73 * @param[in] data Reference to the data to store callback information.
74 * @param[in] returnValue What the functor should return.
76 TouchEventFunctor( SignalData& data, bool returnValue = true )
78 returnValue( returnValue )
82 bool operator()( Actor actor, const TouchEvent& touchEvent )
84 signalData.functorCalled = true;
85 signalData.touchedActor = actor;
86 signalData.touchEvent = touchEvent;
91 SignalData& signalData;
95 // Functor that removes the actor when called.
96 struct RemoveActorFunctor : public TouchEventFunctor
100 * @param[in] data Reference to the data to store callback information.
101 * @param[in] returnValue What the functor should return.
103 RemoveActorFunctor( SignalData& data, bool returnValue = true )
104 : TouchEventFunctor( data, returnValue )
108 bool operator()( Actor actor, const TouchEvent& touchEvent )
110 Actor parent( actor.GetParent() );
113 parent.Remove( actor );
116 return TouchEventFunctor::operator()( actor, touchEvent );
120 Integration::TouchEvent GenerateSingleTouch( TouchPoint::State state, Vector2 screenPosition )
122 Integration::TouchEvent touchEvent;
123 touchEvent.points.push_back( TouchPoint ( 0, state, screenPosition.x, screenPosition.y ) );
129 ///////////////////////////////////////////////////////////////////////////////
131 int UtcDaliTouchNormalProcessing(void)
133 TestApplication application;
135 Actor actor = Actor::New();
136 actor.SetSize(100.0f, 100.0f);
137 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
138 Stage::GetCurrent().Add(actor);
141 application.SendNotification();
142 application.Render();
144 // Connect to actor's touched signal
146 TouchEventFunctor functor( data );
147 actor.TouchedSignal().Connect( &application, functor );
149 Vector2 screenCoordinates( 10.0f, 10.0f );
150 Vector2 localCoordinates;
151 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
153 // Emit a down signal
154 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
155 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
156 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
157 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
158 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
159 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
162 // Emit a motion signal
163 screenCoordinates.x = screenCoordinates.y = 11.0f;
164 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
165 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
166 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
167 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
168 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
169 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
170 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
174 screenCoordinates.x = screenCoordinates.y = 12.0f;
175 actor.ScreenToLocal( localCoordinates.x, localCoordinates.y, screenCoordinates.x, screenCoordinates.y );
176 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
177 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
178 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
179 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
180 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
181 DALI_TEST_EQUALS( localCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
184 // Emit a down signal where the actor is not present
185 screenCoordinates.x = screenCoordinates.y = 200.0f;
186 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
187 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
191 int UtcDaliTouchOutsideCameraNearFarPlanes(void)
193 TestApplication application;
195 Stage stage = Stage::GetCurrent();
196 Vector2 stageSize = stage.GetSize();
198 Actor actor = Actor::New();
199 actor.SetSize(100.0f, 100.0f);
200 actor.SetAnchorPoint(AnchorPoint::CENTER);
201 actor.SetParentOrigin(ParentOrigin::CENTER);
205 application.SendNotification();
206 application.Render();
208 // Get the camera's near and far planes
209 RenderTaskList taskList = stage.GetRenderTaskList();
210 Dali::RenderTask task = taskList.GetTask(0);
211 CameraActor camera = task.GetCameraActor();
212 float nearPlane = camera.GetNearClippingPlane();
213 float farPlane = camera.GetFarClippingPlane();
215 // Calculate the current distance of the actor from the camera
216 float tanHalfFov = tanf(camera.GetFieldOfView() * 0.5f);
217 float distance = (stageSize.y * 0.5f) / tanHalfFov;
219 // Connect to actor's touched signal
221 TouchEventFunctor functor( data );
222 actor.TouchedSignal().Connect( &application, functor );
224 Vector2 screenCoordinates( stageSize.x * 0.5f, stageSize.y * 0.5f );
226 // Emit a down signal
227 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
228 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
231 // Emit a down signal where actor is just at the camera's near plane
232 actor.SetZ(distance - nearPlane);
235 application.SendNotification();
236 application.Render();
238 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
239 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
242 // Emit a down signal where actor is closer than the camera's near plane
243 actor.SetZ((distance - nearPlane) + 1.0f);
246 application.SendNotification();
247 application.Render();
249 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
250 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
253 // Emit a down signal where actor is just at the camera's far plane
254 actor.SetZ(distance - farPlane);
257 application.SendNotification();
258 application.Render();
260 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
261 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
264 // Emit a down signal where actor is further than the camera's far plane
265 actor.SetZ((distance - farPlane) - 1.0f);
268 application.SendNotification();
269 application.Render();
271 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
272 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
277 int UtcDaliTouchEmitEmpty(void)
279 TestApplication application;
283 // Emit an empty TouchEvent
284 Integration::TouchEvent event;
285 application.ProcessEvent( event );
286 tet_result( TET_FAIL );
288 catch ( Dali::DaliException& e )
290 DALI_TEST_ASSERT( e, "!event.points.empty()", TEST_LOCATION );
295 int UtcDaliTouchInterrupted(void)
297 TestApplication application;
299 Actor actor = Actor::New();
300 actor.SetSize(100.0f, 100.0f);
301 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
302 Stage::GetCurrent().Add(actor);
305 application.SendNotification();
306 application.Render();
308 // Connect to actor's touched signal
310 TouchEventFunctor functor( data );
311 actor.TouchedSignal().Connect( &application, functor );
313 // Emit a down signal
314 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
315 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
316 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
319 // Emit an interrupted signal, we should be signalled regardless of whether there is a hit or not.
320 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
321 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
322 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
325 // Emit another interrupted signal, our signal handler should not be called.
326 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
327 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
331 int UtcDaliTouchParentConsumer(void)
333 TestApplication application;
334 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
336 Actor actor = Actor::New();
337 actor.SetSize(100.0f, 100.0f);
338 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
339 Stage::GetCurrent().Add(actor);
342 application.SendNotification();
343 application.Render();
345 // Connect to actor's touched signal
347 TouchEventFunctor functor( data, false );
348 actor.TouchedSignal().Connect( &application, functor );
350 // Connect to root actor's touched signal
352 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
353 rootActor.TouchedSignal().Connect( &application, rootFunctor );
355 Vector2 screenCoordinates( 10.0f, 10.0f );
356 Vector2 actorCoordinates, rootCoordinates;
357 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
358 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
360 // Emit a down signal
361 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
362 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
363 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
364 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
365 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
366 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
367 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
368 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
369 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
370 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
371 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
372 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
373 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
377 // Emit a motion signal
378 screenCoordinates.x = screenCoordinates.y = 11.0f;
379 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
380 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
381 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, screenCoordinates ) );
382 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
383 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
384 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
385 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
386 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
387 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
388 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
389 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
390 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
391 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
392 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
393 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
398 screenCoordinates.x = screenCoordinates.y = 12.0f;
399 actor.ScreenToLocal( actorCoordinates.x, actorCoordinates.y, screenCoordinates.x, screenCoordinates.y );
400 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
401 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, screenCoordinates ) );
402 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
403 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
404 DALI_TEST_EQUALS( 1u, data.touchEvent.GetPointCount(), TEST_LOCATION );
405 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
406 DALI_TEST_EQUALS( TouchPoint::Up, data.touchEvent.points[0].state, TEST_LOCATION );
407 DALI_TEST_EQUALS( TouchPoint::Up, rootData.touchEvent.points[0].state, TEST_LOCATION );
408 DALI_TEST_EQUALS( screenCoordinates, data.touchEvent.points[0].screen, TEST_LOCATION );
409 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
410 DALI_TEST_EQUALS( actorCoordinates, data.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
411 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
412 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
413 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
417 // Emit a down signal where the actor is not present, will hit the root actor though
418 screenCoordinates.x = screenCoordinates.y = 200.0f;
419 rootActor.ScreenToLocal( rootCoordinates.x, rootCoordinates.y, screenCoordinates.x, screenCoordinates.y );
420 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, screenCoordinates ) );
421 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
422 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
423 DALI_TEST_EQUALS( 1u, rootData.touchEvent.GetPointCount(), TEST_LOCATION );
424 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
425 DALI_TEST_EQUALS( screenCoordinates, rootData.touchEvent.points[0].screen, TEST_LOCATION );
426 DALI_TEST_EQUALS( rootCoordinates, rootData.touchEvent.points[0].local, 0.1f, TEST_LOCATION );
427 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
431 int UtcDaliTouchInterruptedParentConsumer(void)
433 TestApplication application;
434 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
436 Actor actor = Actor::New();
437 actor.SetSize(100.0f, 100.0f);
438 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
439 Stage::GetCurrent().Add(actor);
442 application.SendNotification();
443 application.Render();
445 // Connect to actor's touched signal
447 TouchEventFunctor functor( data, false );
448 actor.TouchedSignal().Connect( &application, functor );
450 // Connect to root actor's touched signal
452 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
453 rootActor.TouchedSignal().Connect( &application, rootFunctor );
455 // Emit a down signal
456 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
457 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
458 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
459 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
460 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
461 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
462 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
466 // Emit an interrupted signal
467 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
468 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
469 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
470 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
471 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
472 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
473 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
477 // Emit another down signal
478 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
479 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
480 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
481 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
482 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
486 // Remove actor from Stage
487 Stage::GetCurrent().Remove( actor );
492 application.SendNotification();
493 application.Render();
495 // Emit an interrupted signal, only root actor's signal should be called.
496 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f /* Outside actor */ ) ) );
497 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
498 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
499 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
500 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
504 // Emit another interrupted state, none of the signal's should be called.
505 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 200.0f, 200.0f ) ) );
506 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
507 DALI_TEST_EQUALS( false, rootData.functorCalled, TEST_LOCATION );
511 int UtcDaliTouchLeave(void)
513 TestApplication application;
515 Actor actor = Actor::New();
516 actor.SetSize(100.0f, 100.0f);
517 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
518 Stage::GetCurrent().Add(actor);
521 application.SendNotification();
522 application.Render();
524 // Connect to actor's touched signal
526 TouchEventFunctor functor( data );
527 actor.TouchedSignal().Connect( &application, functor );
529 // Set actor to require leave events
530 actor.SetLeaveRequired( true );
532 // Emit a down signal
533 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
534 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
535 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
538 // Emit a motion signal outside of actor, should be signalled with a Leave
539 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
540 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
541 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
544 // Another motion outside of actor, no signalling
545 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
546 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
549 // Another motion event inside actor, signalled with motion
550 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
551 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
552 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
555 // We do not want to listen to leave events anymore
556 actor.SetLeaveRequired( false );
558 // Another motion event outside of actor, no signalling
559 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
560 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
565 int UtcDaliTouchLeaveParentConsumer(void)
567 TestApplication application;
568 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
570 Actor actor = Actor::New();
571 actor.SetSize(100.0f, 100.0f);
572 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
573 Stage::GetCurrent().Add(actor);
576 application.SendNotification();
577 application.Render();
579 // Connect to actor's touched signal
581 TouchEventFunctor functor( data, false );
582 actor.TouchedSignal().Connect( &application, functor );
584 // Connect to root actor's touched signal
586 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
587 rootActor.TouchedSignal().Connect( &application, rootFunctor );
589 // Set actor to require leave events
590 actor.SetLeaveRequired( true );
591 rootActor.SetLeaveRequired( true );
593 // Emit a down signal
594 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
595 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
596 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
597 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
598 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
599 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
600 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
604 // Emit a motion signal outside of actor, should be signalled with a Leave
605 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
606 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
607 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
608 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
609 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
610 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
611 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
615 // Another motion outside of actor, only rootActor signalled
616 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 201.0f, 201.0f )) );
617 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
618 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
619 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
620 DALI_TEST_CHECK( rootActor == rootData.touchEvent.points[0].hitActor );
624 // Another motion event inside actor, signalled with motion
625 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 10.0f, 10.0f )) );
626 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
627 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
628 DALI_TEST_EQUALS( TouchPoint::Motion, data.touchEvent.points[0].state, TEST_LOCATION );
629 DALI_TEST_EQUALS( TouchPoint::Motion, rootData.touchEvent.points[0].state, TEST_LOCATION );
630 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
631 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
635 // We do not want to listen to leave events of actor anymore
636 actor.SetLeaveRequired( false );
638 // Another motion event outside of root actor, only root signalled
639 Vector2 stageSize( Stage::GetCurrent().GetSize() );
640 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( stageSize.width + 10.0f, stageSize.height + 10.0f )) );
641 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
642 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
643 DALI_TEST_EQUALS( TouchPoint::Leave, rootData.touchEvent.points[0].state, TEST_LOCATION );
647 int UtcDaliTouchActorBecomesInsensitive(void)
649 TestApplication application;
651 Actor actor = Actor::New();
652 actor.SetSize(100.0f, 100.0f);
653 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
654 Stage::GetCurrent().Add(actor);
657 application.SendNotification();
658 application.Render();
660 // Connect to actor's touched signal
662 TouchEventFunctor functor( data );
663 actor.TouchedSignal().Connect( &application, functor );
665 // Emit a down signal
666 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
667 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
668 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
671 // Change actor to insensitive
672 actor.SetSensitive( false );
674 // Emit a motion signal, signalled with an interrupted
675 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
676 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
677 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
682 int UtcDaliTouchActorBecomesInsensitiveParentConsumer(void)
684 TestApplication application;
685 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
687 Actor actor = Actor::New();
688 actor.SetSize(100.0f, 100.0f);
689 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
690 Stage::GetCurrent().Add(actor);
693 application.SendNotification();
694 application.Render();
696 // Connect to actor's touched signal
698 TouchEventFunctor functor( data, false );
699 actor.TouchedSignal().Connect( &application, functor );
701 // Connect to root actor's touched signal
703 TouchEventFunctor rootFunctor( rootData ); // Consumes signal
704 rootActor.TouchedSignal().Connect( &application, rootFunctor );
706 // Emit a down signal
707 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
708 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
709 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
710 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
711 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
712 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
713 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
718 application.SendNotification();
719 application.Render();
721 // Make root actor insensitive
722 rootActor.SetSensitive( false );
724 // Emit a motion signal, signalled with an interrupted (should get interrupted even if within root actor)
725 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2 ( 200.0f, 200.0f )) );
726 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
727 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
728 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
729 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );
733 int UtcDaliTouchMultipleLayers(void)
735 TestApplication application;
736 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
738 // Connect to actor's touched signal
740 TouchEventFunctor functor( data );
742 Layer layer1 ( Layer::New() );
743 layer1.SetSize(100.0f, 100.0f);
744 layer1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
745 Stage::GetCurrent().Add( layer1 );
747 Actor actor1 ( Actor::New() );
748 actor1.SetSize( 100.0f, 100.0f );
749 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
750 actor1.SetZ( 1.0f ); // Should hit actor1 in this layer
751 layer1.Add( actor1 );
754 application.SendNotification();
755 application.Render();
757 // Connect to layer1 and actor1
758 layer1.TouchedSignal().Connect( &application, functor );
759 actor1.TouchedSignal().Connect( &application, functor );
761 // Hit in hittable area, actor1 should be hit
762 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
763 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
764 DALI_TEST_CHECK( data.touchedActor == actor1 );
767 // Make layer1 insensitive, nothing should be hit
768 layer1.SetSensitive( false );
769 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
770 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
773 // Make layer1 sensitive again, again actor1 will be hit
774 layer1.SetSensitive( true );
775 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
776 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
777 DALI_TEST_CHECK( data.touchedActor == actor1 );
780 // Make rootActor insensitive, nothing should be hit
781 rootActor.SetSensitive( false );
782 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
783 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
786 // Make rootActor sensitive
787 rootActor.SetSensitive( true );
790 Layer layer2 ( Layer::New() );
791 layer2.SetSize(100.0f, 100.0f );
792 layer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
793 layer2.SetZ( 10.0f ); // Should hit layer2 in this layer rather than actor2
794 Stage::GetCurrent().Add( layer2 );
796 Actor actor2 ( Actor::New() );
797 actor2.SetSize(100.0f, 100.0f);
798 actor2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
799 layer2.Add( actor2 );
802 application.SendNotification();
803 application.Render();
805 // Connect to layer2 and actor2
806 layer2.TouchedSignal().Connect( &application, functor );
807 actor2.TouchedSignal().Connect( &application, functor );
809 // Emit an event, should hit layer2
810 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
811 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
812 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
815 // Make layer2 insensitive, should hit actor1
816 layer2.SetSensitive( false );
817 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
818 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
819 DALI_TEST_CHECK( data.touchedActor == actor1 );
822 // Make layer2 sensitive again, should hit layer2
823 layer2.SetSensitive( true );
824 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
825 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
826 //DALI_TEST_CHECK( data.touchedActor == layer2 ); // TODO: Uncomment this after removing renderable hack!
829 // Make layer2 invisible, render and notify
830 layer2.SetVisible( false );
831 application.SendNotification();
832 application.Render();
835 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
836 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
837 DALI_TEST_CHECK( data.touchedActor == actor1 );
840 // Make rootActor invisible, render and notify
841 rootActor.SetVisible( false );
842 application.SendNotification();
843 application.Render();
845 // Should not hit anything
846 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
847 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
852 int UtcDaliTouchMultipleRenderTasks(void)
854 TestApplication application;
855 Stage stage ( Stage::GetCurrent() );
856 Vector2 stageSize ( stage.GetSize() );
858 Actor actor = Actor::New();
859 actor.SetSize(100.0f, 100.0f);
860 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
863 // Create render task
864 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
865 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
866 renderTask.SetViewport( viewport );
867 renderTask.SetInputEnabled( true );
870 application.SendNotification();
871 application.Render();
873 // Connect to actor's touched signal
875 TouchEventFunctor functor( data );
876 actor.TouchedSignal().Connect( &application, functor );
878 // Emit a down signal
879 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
880 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
883 // Ensure renderTask actor can be hit too.
884 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
885 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
888 // Disable input on renderTask, should not be hittable
889 renderTask.SetInputEnabled( false );
890 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
891 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
896 int UtcDaliTouchMultipleRenderTasksWithChildLayer(void)
898 TestApplication application;
899 Stage stage ( Stage::GetCurrent() );
900 Vector2 stageSize ( stage.GetSize() );
902 Actor actor = Actor::New();
903 actor.SetSize(100.0f, 100.0f);
904 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
907 Layer layer = Layer::New();
908 layer.SetSize(100.0f, 100.0f);
909 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
912 // Create render task
913 Viewport viewport( stageSize.width * 0.5f, stageSize.height * 0.5f, stageSize.width * 0.5f, stageSize.height * 0.5f );
914 RenderTask renderTask ( Stage::GetCurrent().GetRenderTaskList().CreateTask() );
915 renderTask.SetViewport( viewport );
916 renderTask.SetInputEnabled( true );
917 renderTask.SetSourceActor( actor );
920 application.SendNotification();
921 application.Render();
923 // Connect to layer's touched signal
925 TouchEventFunctor functor( data );
926 actor.TouchedSignal().Connect( &application, functor );
927 layer.TouchedSignal().Connect( &application, functor );
929 // Emit a down signal
930 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
931 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
934 // Ensure renderTask actor can be hit too.
935 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
936 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
939 // Disable input on renderTask, should not be hittable
940 renderTask.SetInputEnabled( false );
941 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( viewport.x + 5.0f, viewport.y + 5.0f ) ) );
942 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
947 int UtcDaliTouchOffscreenRenderTasks(void)
949 TestApplication application;
950 Stage stage ( Stage::GetCurrent() );
951 Vector2 stageSize ( stage.GetSize() );
953 // FrameBufferImage for offscreen RenderTask
954 FrameBufferImage frameBufferImage( FrameBufferImage::New( stageSize.width, stageSize.height, Pixel::RGBA8888 ) );
956 // Create an image actor to display the FrameBufferImage
957 ImageActor imageActor ( ImageActor::New( frameBufferImage ) );
958 imageActor.SetParentOrigin(ParentOrigin::CENTER);
959 imageActor.SetSize( stageSize.x, stageSize.y );
960 imageActor.ScaleBy( Vector3(1.0f, -1.0f, 1.0f) ); // FIXME
961 stage.Add( imageActor );
963 Actor actor = Actor::New();
964 actor.SetSize(100.0f, 100.0f);
965 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
967 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE ); // Ensure framebuffer connects
969 stage.GetRenderTaskList().GetTask( 0u ).SetScreenToFrameBufferFunction( RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION );
971 // Create a RenderTask
972 RenderTask renderTask = stage.GetRenderTaskList().CreateTask();
973 renderTask.SetSourceActor( actor );
974 renderTask.SetTargetFrameBuffer( frameBufferImage );
975 renderTask.SetInputEnabled( true );
977 // Create another RenderTask
978 RenderTask renderTask2( stage.GetRenderTaskList().CreateTask() );
979 renderTask2.SetInputEnabled( true );
982 application.SendNotification();
983 application.Render();
985 // Connect to actor's touched signal
987 TouchEventFunctor functor( data );
988 actor.TouchedSignal().Connect( &application, functor );
990 // Emit a down signal
991 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
992 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
997 int UtcDaliTouchMultipleRenderableActors(void)
999 TestApplication application;
1000 Stage stage ( Stage::GetCurrent() );
1001 Vector2 stageSize ( stage.GetSize() );
1003 Actor parent = ImageActor::New();
1004 parent.SetSize(100.0f, 100.0f);
1005 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1008 Actor actor = ImageActor::New();
1009 actor.SetSize(100.0f, 100.0f);
1010 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1013 // Render and notify
1014 application.SendNotification();
1015 application.Render();
1017 // Connect to layer's touched signal
1019 TouchEventFunctor functor( data );
1020 parent.TouchedSignal().Connect( &application, functor );
1021 actor.TouchedSignal().Connect( &application, functor );
1023 // Emit a down signal
1024 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1025 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1026 DALI_TEST_CHECK( actor == data.touchedActor );
1030 int UtcDaliTouchActorRemovedInSignal(void)
1032 TestApplication application;
1034 Actor actor = Actor::New();
1035 actor.SetSize(100.0f, 100.0f);
1036 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1037 Stage::GetCurrent().Add(actor);
1039 // Render and notify
1040 application.SendNotification();
1041 application.Render();
1043 // Connect to actor's touched signal
1045 RemoveActorFunctor functor( data );
1046 actor.TouchedSignal().Connect( &application, functor );
1048 // Register for leave events
1049 actor.SetLeaveRequired( true );
1051 // Emit a down signal
1052 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1053 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1056 // Re-add, render and notify
1057 Stage::GetCurrent().Add(actor);
1058 application.SendNotification();
1059 application.Render();
1061 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1062 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1063 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1066 // Emit a down signal
1067 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1068 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1071 // Render and notify
1072 application.SendNotification();
1073 application.Render();
1075 // Emit another signal outside of actor's area, should not get anything as the scene has changed.
1076 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1077 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1080 // Re-add actor back to stage, render and notify
1081 Stage::GetCurrent().Add(actor);
1082 application.SendNotification();
1083 application.Render();
1085 // Emit another down event
1086 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1087 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1090 // Completely delete the actor
1093 // Emit event, should not crash and should not receive an event.
1094 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 210.0f, 210.0f ) ) );
1095 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1099 int UtcDaliTouchActorSignalNotConsumed(void)
1101 TestApplication application;
1103 Actor actor = Actor::New();
1104 actor.SetSize(100.0f, 100.0f);
1105 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1106 Stage::GetCurrent().Add(actor);
1108 // Render and notify
1109 application.SendNotification();
1110 application.Render();
1112 // Connect to actor's touched signal
1114 TouchEventFunctor functor( data, false );
1115 actor.TouchedSignal().Connect( &application, functor );
1117 // Emit a down signal
1118 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1119 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1123 int UtcDaliTouchActorUnStaged(void)
1125 TestApplication application;
1127 Actor actor = Actor::New();
1128 actor.SetSize(100.0f, 100.0f);
1129 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1130 Stage::GetCurrent().Add(actor);
1132 // Render and notify
1133 application.SendNotification();
1134 application.Render();
1136 // Connect to actor's touched signal
1138 TouchEventFunctor functor( data );
1139 actor.TouchedSignal().Connect( &application, functor );
1141 // Emit a down signal
1142 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1143 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1146 // Remove actor from stage
1147 Stage::GetCurrent().Remove( actor );
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Emit a move at the same point, we should not be signalled.
1155 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1156 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1161 int UtcDaliTouchSystemOverlayActor(void)
1163 TestApplication application;
1164 Dali::Integration::Core& core( application.GetCore() );
1165 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1166 systemOverlay.GetOverlayRenderTasks().CreateTask();
1168 // Create an actor and add it to the system overlay.
1169 Actor systemActor = Actor::New();
1170 systemActor.SetSize(100.0f, 100.0f);
1171 systemActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1172 systemOverlay.Add( systemActor );
1174 // Create an actor and add it to the stage as per normal, same position and size as systemActor
1175 Actor actor = Actor::New();
1176 actor.SetSize(100.0f, 100.0f);
1177 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1178 Stage::GetCurrent().Add(actor);
1180 // Connect to the touch signals.
1182 TouchEventFunctor functor( data );
1183 systemActor.TouchedSignal().Connect( &application, functor );
1184 actor.TouchedSignal().Connect( &application, functor );
1186 // Render and notify
1187 application.SendNotification();
1188 application.Render();
1190 // Emit a down signal, the system overlay is drawn last so is at the top, should hit the systemActor.
1191 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1192 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1193 DALI_TEST_CHECK( systemActor == data.touchedActor );
1197 int UtcDaliTouchLayerConsumesTouch(void)
1199 TestApplication application;
1201 Actor actor = Actor::New();
1202 actor.SetSize(100.0f, 100.0f);
1203 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1204 Stage::GetCurrent().Add(actor);
1206 // Render and notify
1207 application.SendNotification();
1208 application.Render();
1210 // Connect to actor's touched signal
1212 TouchEventFunctor functor( data );
1213 actor.TouchedSignal().Connect( &application, functor );
1215 // Add a layer to overlap the actor
1216 Layer layer = Layer::New();
1217 layer.SetSize(100.0f, 100.0f);
1218 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1219 Stage::GetCurrent().Add( layer );
1222 // Render and notify
1223 application.SendNotification();
1224 application.Render();
1226 // Emit a few touch signals
1227 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1228 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1229 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1232 // Set layer to consume all touch
1233 layer.SetTouchConsumed( true );
1235 // Render and notify
1236 application.SendNotification();
1237 application.Render();
1239 // Emit the same signals again, should not receive
1240 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1241 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Up, Vector2( 10.0f, 10.0f ) ) );
1242 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1248 int UtcDaliTouchLeaveActorReadded(void)
1250 TestApplication application;
1251 Stage stage = Stage::GetCurrent();
1253 Actor actor = Actor::New();
1254 actor.SetSize(100.0f, 100.0f);
1255 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1258 // Set actor to receive touch-events
1259 actor.SetLeaveRequired( true );
1261 // Render and notify
1262 application.SendNotification();
1263 application.Render();
1265 // Connect to actor's touched signal
1267 TouchEventFunctor functor( data );
1268 actor.TouchedSignal().Connect( &application, functor );
1270 // Emit a down and motion
1271 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1272 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 11.0f, 10.0f ) ) );
1273 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1276 // Remove actor from stage and add again
1277 stage.Remove( actor );
1280 // Emit a motion within the actor's bounds
1281 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 12.0f, 10.0f ) ) );
1282 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1285 // Emit a motion outside the actor's bounds
1286 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 200.0f, 200.0f ) ) );
1287 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1288 DALI_TEST_EQUALS( TouchPoint::Leave, data.touchEvent.points[0].state, TEST_LOCATION );
1294 int UtcDaliTouchStencil(void)
1296 TestApplication application;
1297 Stage stage = Stage::GetCurrent();
1299 ImageActor actor = ImageActor::New();
1300 actor.SetSize(100.0f, 100.0f);
1301 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1304 Actor stencil = Actor::New();
1305 stencil.SetSize(50.0f, 50.0f);
1306 stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1307 stencil.SetDrawMode( DrawMode::STENCIL );
1310 // Render and notify
1311 application.SendNotification();
1312 application.Render();
1314 // Connect to actor's touched signal
1316 TouchEventFunctor functor( data );
1317 actor.TouchedSignal().Connect( &application, functor );
1319 // Emit an event within stencil area
1320 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1321 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1324 // Emit an event outside the stencil area but within the actor area
1325 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
1326 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1332 int UtcDaliTouchStencilInActorHierarchy(void)
1334 TestApplication application;
1335 Stage stage = Stage::GetCurrent();
1337 ImageActor parent = ImageActor::New();
1338 parent.SetSize(100.0f, 100.0f);
1339 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1342 ImageActor child = ImageActor::New();
1343 child.SetSize(25.0f, 25.0f);
1344 child.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1347 Actor stencil = Actor::New();
1348 stencil.SetSize(50.0f, 50.0f);
1349 stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1350 stencil.SetDrawMode( DrawMode::STENCIL );
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // Connect to touch signals
1358 SignalData parentData;
1359 parent.TouchedSignal().Connect( &application, TouchEventFunctor(parentData) );
1360 SignalData childData;
1361 child.TouchedSignal().Connect( &application, TouchEventFunctor(childData) );
1363 // Emit an event within stencil area
1364 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1365 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1366 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1370 // Emit an event outside child area and within stencil area
1371 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 40.0f, 40.0f ) ) );
1372 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1373 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1377 // Emit an event outside stencil are but within parent area
1378 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 60.0f, 60.0f ) ) );
1379 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1380 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1384 // Readd actor (so that stencil is the first child)
1385 stage.Remove(parent);
1386 application.SendNotification();
1387 application.Render();
1389 application.SendNotification();
1390 application.Render();
1392 // Redo hit in same area...
1394 // Emit an event within stencil area
1395 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1396 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1397 DALI_TEST_EQUALS( true, childData.functorCalled, TEST_LOCATION );
1401 // Emit an event outside child area and within stencil area
1402 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 40.0f, 40.0f ) ) );
1403 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1404 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1408 // Emit an event outside stencil are but within parent area
1409 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 60.0f, 60.0f ) ) );
1410 DALI_TEST_EQUALS( false, parentData.functorCalled, TEST_LOCATION );
1411 DALI_TEST_EQUALS( false, childData.functorCalled, TEST_LOCATION );
1418 int UtcDaliTouchMultipleStencils(void)
1420 TestApplication application;
1421 Stage stage = Stage::GetCurrent();
1423 ImageActor actor = ImageActor::New();
1424 actor.SetSize(100.0f, 100.0f);
1425 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1428 Actor stencil = Actor::New();
1429 stencil.SetSize(50.0f, 50.0f);
1430 stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1431 stencil.SetDrawMode( DrawMode::STENCIL );
1434 Actor stencil2 = Actor::New();
1435 stencil2.SetSize(50.0f, 50.0f);
1436 stencil2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1437 stencil2.SetDrawMode( DrawMode::STENCIL );
1438 stencil2.SetPosition(50.0f, 50.0f);
1439 stage.Add(stencil2);
1441 // Render and notify
1442 application.SendNotification();
1443 application.Render();
1445 // Connect to actor's touched signal
1447 TouchEventFunctor functor( data );
1448 actor.TouchedSignal().Connect( &application, functor );
1450 // Emit an event within stencil area
1451 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1452 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1455 // Emit an event inside the second stencil area
1456 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
1457 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1460 // Emit an event outside both stencil areas but within the actor area
1461 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 60.0f ) ) );
1462 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1468 int UtcDaliTouchStencilNonRenderableActor(void)
1470 TestApplication application;
1471 Stage stage = Stage::GetCurrent();
1473 Actor actor = Actor::New();
1474 actor.SetSize(100.0f, 100.0f);
1475 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1478 Actor stencil = Actor::New();
1479 stencil.SetSize(50.0f, 50.0f);
1480 stencil.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1481 stencil.SetDrawMode( DrawMode::STENCIL );
1484 // Render and notify
1485 application.SendNotification();
1486 application.Render();
1488 // Connect to actor's touched signal
1490 TouchEventFunctor functor( data );
1491 actor.TouchedSignal().Connect( &application, functor );
1493 // Emit an event within stencil area
1494 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1495 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1498 // Emit an event outside the stencil area but within the actor area, we should have a hit!
1499 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 60.0f, 60.0f ) ) );
1500 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1506 int UtcDaliTouchActorUnstaged(void)
1508 TestApplication application;
1510 Actor actor = Actor::New();
1511 actor.SetSize(100.0f, 100.0f);
1512 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1513 Stage::GetCurrent().Add(actor);
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 // Connect to actor's touched signal
1521 TouchEventFunctor functor( data );
1522 actor.TouchedSignal().Connect( &application, functor );
1524 // Emit a down signal
1525 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1526 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1527 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1528 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Unparent the actor
1538 // Should receive an interrupted event
1539 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1540 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1544 int UtcDaliTouchParentUnstaged(void)
1546 TestApplication application;
1548 Actor parent = Actor::New();
1549 parent.SetSize(100.0f, 100.0f);
1550 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1551 Stage::GetCurrent().Add(parent);
1553 Actor actor = Actor::New();
1554 actor.SetSize(100.0f, 100.0f);
1555 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Connect to actor's touched signal
1564 TouchEventFunctor functor( data );
1565 actor.TouchedSignal().Connect( &application, functor );
1567 // Emit a down signal
1568 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1569 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1570 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1571 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Unparent the parent of the touchable actor
1581 // Should receive an interrupted event
1582 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1583 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1587 int UtcDaliTouchActorUnstagedDifferentConsumer(void)
1589 TestApplication application;
1591 Actor parent = Actor::New();
1592 parent.SetSize(100.0f, 100.0f);
1593 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1594 Stage::GetCurrent().Add(parent);
1596 Actor actor = Actor::New();
1597 actor.SetSize(100.0f, 100.0f);
1598 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Connect to actor's touched signal
1607 TouchEventFunctor functor( data, false /* Do not consume */ );
1608 actor.TouchedSignal().Connect( &application, functor );
1610 // Connect to parent's touched signal
1611 SignalData parentData;
1612 TouchEventFunctor parentFunctor( parentData );
1613 parent.TouchedSignal().Connect( &application, parentFunctor );
1615 // Emit a down signal
1616 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1617 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1618 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1619 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1620 DALI_TEST_CHECK( actor == data.touchedActor );
1621 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1622 DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1623 DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1624 DALI_TEST_CHECK( parent == parentData.touchedActor );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Unparent the actor
1635 // Should receive an interrupted event for both actor & parent
1636 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1637 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1638 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1639 DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1643 // Readd actor to parent
1646 // Render and notify
1647 application.SendNotification();
1648 application.Render();
1650 // Emit a motion signal
1651 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Motion, Vector2( 10.0f, 10.0f ) ) );
1652 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1653 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1657 // Parent is now consumer, connect again to the touched signal of the actor so that it becomes the consumer
1658 SignalData secondData;
1659 TouchEventFunctor secondFunctor( secondData /* Consume */ );
1660 actor.TouchedSignal().Connect( &application, secondFunctor );
1662 // Unparent the actor
1665 // Should receive an interrupted event for both actor functors & the parent as well as it was last consumer
1666 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1667 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1668 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1669 DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1670 DALI_TEST_EQUALS( true, secondData.functorCalled, TEST_LOCATION );
1671 DALI_TEST_EQUALS( TouchPoint::Interrupted, secondData.touchEvent.points[0].state, TEST_LOCATION );
1679 int UtcDaliTouchInterruptedDifferentConsumer(void)
1681 TestApplication application;
1682 Actor rootActor( Stage::GetCurrent().GetRootLayer() );
1684 Actor parent = Actor::New();
1685 parent.SetSize(100.0f, 100.0f);
1686 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1687 Stage::GetCurrent().Add(parent);
1689 Actor actor = Actor::New();
1690 actor.SetSize(100.0f, 100.0f);
1691 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 // Connect to actor's touched signal
1700 TouchEventFunctor functor( data, false /* Do not consume */ );
1701 actor.TouchedSignal().Connect( &application, functor );
1703 // Connect to parent's touched signal
1704 SignalData parentData;
1705 TouchEventFunctor parentFunctor( parentData, false /* Do not consume */ );
1706 parent.TouchedSignal().Connect( &application, parentFunctor );
1708 // Connect to root's touched signal and consume
1709 SignalData rootData;
1710 TouchEventFunctor rootFunctor( rootData );
1711 rootActor.TouchedSignal().Connect( &application, rootFunctor );
1713 // Emit a down signal
1714 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Down, Vector2( 10.0f, 10.0f ) ) );
1715 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1716 DALI_TEST_EQUALS( TouchPoint::Down, data.touchEvent.points[0].state, TEST_LOCATION );
1717 DALI_TEST_CHECK( actor == data.touchEvent.points[0].hitActor );
1718 DALI_TEST_CHECK( actor == data.touchedActor );
1719 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1720 DALI_TEST_EQUALS( TouchPoint::Down, parentData.touchEvent.points[0].state, TEST_LOCATION );
1721 DALI_TEST_CHECK( actor == parentData.touchEvent.points[0].hitActor );
1722 DALI_TEST_CHECK( parent == parentData.touchedActor );
1723 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1724 DALI_TEST_EQUALS( TouchPoint::Down, rootData.touchEvent.points[0].state, TEST_LOCATION );
1725 DALI_TEST_CHECK( actor == rootData.touchEvent.points[0].hitActor );
1726 DALI_TEST_CHECK( rootActor == rootData.touchedActor );
1731 // Root is now consumer, connect to the touched signal of the parent so that it becomes the consumer
1732 SignalData secondData;
1733 TouchEventFunctor secondFunctor( secondData /* Consume */ );
1734 parent.TouchedSignal().Connect( &application, secondFunctor );
1736 // Emit an interrupted signal, all three should STILL be called
1737 application.ProcessEvent( GenerateSingleTouch( TouchPoint::Interrupted, Vector2( 10.0f, 10.0f ) ) );
1738 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1739 DALI_TEST_EQUALS( TouchPoint::Interrupted, data.touchEvent.points[0].state, TEST_LOCATION );
1740 DALI_TEST_EQUALS( true, parentData.functorCalled, TEST_LOCATION );
1741 DALI_TEST_EQUALS( TouchPoint::Interrupted, parentData.touchEvent.points[0].state, TEST_LOCATION );
1742 DALI_TEST_EQUALS( true, rootData.functorCalled, TEST_LOCATION );
1743 DALI_TEST_EQUALS( TouchPoint::Interrupted, rootData.touchEvent.points[0].state, TEST_LOCATION );