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/events/pinch-gesture-event.h>
24 #include <dali/integration-api/system-overlay.h>
25 #include <dali-test-suite-utils.h>
26 #include <test-touch-utils.h>
30 void utc_dali_pinch_gesture_detector_startup(void)
32 test_return_value = TET_UNDEF;
35 void utc_dali_pinch_gesture_detector_cleanup(void)
37 test_return_value = TET_PASS;
40 ///////////////////////////////////////////////////////////////////////////////
44 // Stores data that is populated in the callback and will be read by the TET cases
48 : functorCalled(false),
49 voidFunctorCalled(false),
50 receivedGesture(Gesture::Started)
55 functorCalled = false;
56 voidFunctorCalled = false;
58 receivedGesture.state = Gesture::Started;
59 receivedGesture.scale = 0.0f;
60 receivedGesture.speed = 0.0f;
61 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
62 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
68 bool voidFunctorCalled;
69 PinchGesture receivedGesture;
73 // Functor that sets the data when called
74 struct GestureReceivedFunctor
76 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
78 void operator()(Actor actor, const PinchGesture& pinch)
80 signalData.functorCalled = true;
81 signalData.receivedGesture = pinch;
82 signalData.pinchedActor = actor;
87 signalData.voidFunctorCalled = true;
90 SignalData& signalData;
93 // Functor that removes the gestured actor from stage
94 struct UnstageActorFunctor : public GestureReceivedFunctor
96 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
97 : GestureReceivedFunctor( data ),
98 stateToUnstage( stateToUnstage )
102 void operator()( Actor actor, const PinchGesture& pinch )
104 GestureReceivedFunctor::operator()( actor, pinch );
106 if ( pinch.state == stateToUnstage )
108 Stage::GetCurrent().Remove( actor );
112 Gesture::State& stateToUnstage;
115 // Functor for receiving a touch event
116 struct TouchEventFunctor
118 bool operator()(Actor actor, const TouchEvent& touch)
124 // Generate a PinchGestureEvent to send to Core
125 Integration::PinchGestureEvent GeneratePinch(
126 Gesture::State state,
131 Integration::PinchGestureEvent pinch(state);
135 pinch.centerPoint = centerpoint;
142 ///////////////////////////////////////////////////////////////////////////////
144 int UtcDaliPinchGestureDetectorConstructor(void)
146 TestApplication application;
148 PinchGestureDetector detector;
149 DALI_TEST_CHECK(!detector);
153 int UtcDaliPinchGestureDetectorCopyConstructorP(void)
155 TestApplication application;
157 PinchGestureDetector detector = PinchGestureDetector::New();;
159 PinchGestureDetector copy( detector );
160 DALI_TEST_CHECK( detector );
164 int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
166 TestApplication application;
168 PinchGestureDetector detector = PinchGestureDetector::New();;
170 PinchGestureDetector assign;
172 DALI_TEST_CHECK( detector );
174 DALI_TEST_CHECK( detector == assign );
178 int UtcDaliPinchGestureDetectorNew(void)
180 TestApplication application;
182 PinchGestureDetector detector = PinchGestureDetector::New();
184 DALI_TEST_CHECK(detector);
186 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
187 Actor actor = Actor::New();
188 actor.SetSize(100.0f, 100.0f);
189 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
190 Stage::GetCurrent().Add(actor);
193 application.SendNotification();
194 application.Render();
196 detector.Attach(actor);
198 Integration::TouchEvent touchEvent(1);
199 Integration::Point point;
200 point.SetDeviceId( 1 );
201 point.SetState( PointState::DOWN );
202 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
203 touchEvent.AddPoint(point);
204 application.ProcessEvent(touchEvent);
206 Integration::Point point2;
207 point.SetDeviceId( 1 );
208 point.SetState( PointState::DOWN );
209 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
210 touchEvent.AddPoint(point2);
211 application.ProcessEvent(touchEvent);
215 int UtcDaliPinchGestureDetectorDownCast(void)
217 TestApplication application;
218 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
220 PinchGestureDetector detector = PinchGestureDetector::New();
222 BaseHandle object(detector);
224 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
225 DALI_TEST_CHECK(detector2);
227 PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object);
228 DALI_TEST_CHECK(detector3);
230 BaseHandle unInitializedObject;
231 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
232 DALI_TEST_CHECK(!detector4);
234 PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject);
235 DALI_TEST_CHECK(!detector5);
237 GestureDetector detector6 = PinchGestureDetector::New();
238 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
239 DALI_TEST_CHECK(detector7);
243 // Negative test case for a method
244 int UtcDaliPinchGestureSignalReceptionNegative(void)
246 TestApplication application;
248 Actor actor = Actor::New();
249 actor.SetSize(100.0f, 100.0f);
250 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
251 Stage::GetCurrent().Add(actor);
254 application.SendNotification();
255 application.Render();
258 GestureReceivedFunctor functor(data);
260 PinchGestureDetector detector = PinchGestureDetector::New();
261 detector.Attach(actor);
262 detector.DetectedSignal().Connect(&application, functor);
264 // Do a pinch outside actor's area
265 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f)));
266 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
268 // Continue pinch into actor's area - we should still not receive the signal
270 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f)));
271 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
273 // Stop pinching - we should still not receive the signal
275 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f)));
276 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
280 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
282 TestApplication application;
284 Actor actor = Actor::New();
285 actor.SetSize(100.0f, 100.0f);
286 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
287 Stage::GetCurrent().Add(actor);
290 application.SendNotification();
291 application.Render();
294 GestureReceivedFunctor functor(data);
296 PinchGestureDetector detector = PinchGestureDetector::New();
297 detector.Attach(actor);
298 detector.DetectedSignal().Connect(&application, functor);
300 // Start pan within the actor's area
301 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
302 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
303 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
304 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
305 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
306 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
308 // Continue the pan within the actor's area - we should still receive the signal
310 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f)));
311 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
312 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
313 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
314 DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
315 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
317 // Pan Gesture leaves actor's area - we should still receive the signal
319 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f)));
320 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
321 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
322 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
323 DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
324 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
326 // Gesture ends - we would receive a finished state
328 application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f)));
329 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
330 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
331 DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
332 DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
333 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
337 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
339 TestApplication application;
341 Actor actor = Actor::New();
342 actor.SetSize(100.0f, 100.0f);
343 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
344 Stage::GetCurrent().Add(actor);
347 application.SendNotification();
348 application.Render();
351 GestureReceivedFunctor functor(data);
353 PinchGestureDetector detector = PinchGestureDetector::New();
354 detector.Attach(actor);
355 detector.DetectedSignal().Connect(&application, functor);
357 // Start pinch within the actor's area
358 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
359 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
360 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
361 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
362 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
363 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
365 // Continue the pinch within the actor's area - we should still receive the signal
367 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
368 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
369 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
370 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
371 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
372 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
374 // Gesture ends within actor's area - we would receive a finished state
376 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
377 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
378 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
379 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
380 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
381 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
385 int UtcDaliPinchGestureSignalReceptionCancelled(void)
387 TestApplication application;
389 Actor actor = Actor::New();
390 actor.SetSize(100.0f, 100.0f);
391 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
392 Stage::GetCurrent().Add(actor);
395 application.SendNotification();
396 application.Render();
399 GestureReceivedFunctor functor(data);
401 PinchGestureDetector detector = PinchGestureDetector::New();
402 detector.Attach(actor);
403 detector.DetectedSignal().Connect(&application, functor);
405 // Start pinch within the actor's area
406 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
407 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
408 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
411 // Continue the pinch within the actor's area - we should still receive the signal
413 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
414 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
415 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
417 // The gesture is cancelled
419 application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
420 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
421 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
425 int UtcDaliPinchGestureSignalReceptionDetach(void)
427 TestApplication application;
429 Actor actor = Actor::New();
430 actor.SetSize(100.0f, 100.0f);
431 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
432 Stage::GetCurrent().Add(actor);
435 application.SendNotification();
436 application.Render();
439 GestureReceivedFunctor functor(data);
441 PinchGestureDetector detector = PinchGestureDetector::New();
442 detector.Attach(actor);
443 detector.DetectedSignal().Connect(&application, functor);
445 // Start pinch within the actor's area
446 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
447 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
448 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
451 // Continue the pinch within the actor's area - we should still receive the signal
453 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
454 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
455 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
457 // Gesture ends within actor's area
459 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
460 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
461 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
464 detector.DetachAll();
466 // Ensure we are no longer signalled
468 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
469 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
470 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
471 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
475 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
477 TestApplication application;
479 Actor actor = Actor::New();
480 actor.SetSize(100.0f, 100.0f);
481 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
482 Stage::GetCurrent().Add(actor);
485 application.SendNotification();
486 application.Render();
489 GestureReceivedFunctor functor(data);
491 PinchGestureDetector detector = PinchGestureDetector::New();
492 detector.Attach(actor);
493 detector.DetectedSignal().Connect(&application, functor);
495 // Start pinch within the actor's area
496 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
497 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
498 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
500 // Continue the pinch within the actor's area - we should still receive the signal
502 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
503 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
504 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
506 // Detach actor during the pinch, we should not receive the next event
507 detector.DetachAll();
509 // Gesture ends within actor's area
511 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
512 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
516 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
518 TestApplication application;
521 GestureReceivedFunctor functor(data);
523 PinchGestureDetector detector = PinchGestureDetector::New();
524 detector.DetectedSignal().Connect(&application, functor);
526 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
528 Actor tempActor = Actor::New();
529 tempActor.SetSize(100.0f, 100.0f);
530 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
531 Stage::GetCurrent().Add(tempActor);
532 detector.Attach(tempActor);
534 // Actor lifetime is scoped
536 Actor actor = Actor::New();
537 actor.SetSize(100.0f, 100.0f);
538 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
539 Stage::GetCurrent().Add(actor);
542 application.SendNotification();
543 application.Render();
545 detector.Attach(actor);
547 // Start pinch within the actor's area
548 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
549 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
550 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
552 // Continue the pinch within the actor's area - we should still receive the signal
554 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
555 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
556 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
558 // Remove the actor from stage and reset the data
559 Stage::GetCurrent().Remove(actor);
562 application.SendNotification();
563 application.Render();
566 // Actor should now have been destroyed
568 // Gesture ends within the area where the actor used to be
570 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
571 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
575 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
577 TestApplication application;
579 Actor actor = Actor::New();
580 actor.SetSize(100.0f, 100.0f);
581 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
582 Stage::GetCurrent().Add(actor);
584 // Render and notify a couple of times
585 application.SendNotification();
586 application.Render();
589 GestureReceivedFunctor functor(data);
591 PinchGestureDetector detector = PinchGestureDetector::New();
592 detector.Attach(actor);
593 detector.DetectedSignal().Connect(&application, functor);
595 // Do an entire pinch, only check finished value
596 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
598 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
599 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
600 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
601 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
602 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
604 // Rotate actor again and render and notify
605 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
606 application.SendNotification();
607 application.Render();
609 // Do an entire pinch, only check finished value
610 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
612 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
613 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
614 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
615 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
616 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
618 // Rotate actor again and render and notify
619 actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS);
620 application.SendNotification();
621 application.Render();
623 // Do an entire pinch, only check finished value
624 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
626 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
627 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
628 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
629 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
630 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
634 int UtcDaliPinchGestureSignalReceptionChildHit(void)
636 TestApplication application;
638 Actor parent = Actor::New();
639 parent.SetSize(100.0f, 100.0f);
640 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
641 Stage::GetCurrent().Add(parent);
643 // Set child to completely cover parent.
644 // Change rotation of child to be different from parent so that we can check if our local coordinate
645 // conversion of the parent actor is correct.
646 Actor child = Actor::New();
647 child.SetSize(100.0f, 100.0f);
648 child.SetAnchorPoint(AnchorPoint::CENTER);
649 child.SetParentOrigin(ParentOrigin::CENTER);
650 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
653 TouchEventFunctor touchFunctor;
654 child.TouchedSignal().Connect(&application, touchFunctor);
657 application.SendNotification();
658 application.Render();
661 GestureReceivedFunctor functor(data);
663 PinchGestureDetector detector = PinchGestureDetector::New();
664 detector.Attach(parent);
665 detector.DetectedSignal().Connect(&application, functor);
667 // Do an entire pan, only check finished value - hits child area but parent should still receive it
668 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
670 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
671 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
672 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
673 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
674 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
675 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
677 // Attach child and generate same touch points to yield same results
678 // (Also proves that you can detach and then re-attach another actor)
679 detector.Attach(child);
680 detector.Detach(parent);
682 // Do an entire pan, only check finished value
683 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
685 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
686 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
687 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
688 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
689 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
690 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
694 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
696 TestApplication application;
698 Actor first = Actor::New();
699 first.SetSize(100.0f, 100.0f);
700 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
701 Stage::GetCurrent().Add(first);
703 Actor second = Actor::New();
704 second.SetSize(100.0f, 100.0f);
706 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
707 Stage::GetCurrent().Add(second);
710 application.SendNotification();
711 application.Render();
714 GestureReceivedFunctor functor(data);
716 PinchGestureDetector detector = PinchGestureDetector::New();
717 detector.Attach(first);
718 detector.Attach(second);
719 detector.DetectedSignal().Connect(&application, functor);
721 // Start pinch within second actor's area
722 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
723 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
724 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
726 // Pinch moves into first actor's area - second actor should receive the pinch
728 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
729 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
730 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
732 // Detach the second actor during the pinch, we should not receive the next event
733 detector.Detach(second);
735 // Gesture ends within actor's area
737 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
738 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
742 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
744 TestApplication application;
746 Actor actor = Actor::New();
747 actor.SetSize(100.0f, 100.0f);
748 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
749 Stage::GetCurrent().Add(actor);
752 application.SendNotification();
753 application.Render();
756 GestureReceivedFunctor functor(data);
758 PinchGestureDetector detector = PinchGestureDetector::New();
759 detector.Attach(actor);
760 detector.DetectedSignal().Connect(&application, functor);
762 // Start pinch in actor's area
763 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
764 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
766 // Pan continues within actor's area
768 application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
769 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
771 // Actor become invisible - actor should not receive the next pinch
772 actor.SetVisible(false);
775 application.SendNotification();
776 application.Render();
778 // Gesture ends within actor's area
780 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
781 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
785 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
787 TestApplication application;
789 Actor actor = Actor::New();
790 actor.SetSize(100.0f, 100.0f);
791 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
792 Stage::GetCurrent().Add(actor);
794 Actor actor2 = Actor::New();
795 actor2.SetSize(100.0f, 100.0f);
796 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
797 Stage::GetCurrent().Add(actor2);
800 application.SendNotification();
801 application.Render();
803 // Attach actor to one detector
804 SignalData firstData;
805 GestureReceivedFunctor firstFunctor(firstData);
806 PinchGestureDetector firstDetector = PinchGestureDetector::New();
807 firstDetector.Attach(actor);
808 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
810 // Attach actor to another detector
811 SignalData secondData;
812 GestureReceivedFunctor secondFunctor(secondData);
813 PinchGestureDetector secondDetector = PinchGestureDetector::New();
814 secondDetector.Attach(actor);
815 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
817 // Add second actor to second detector, when we remove the actor, this will make sure that this
818 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
819 // functor should still not be called (which is what we're also testing).
820 secondDetector.Attach(actor2);
822 // Pinch in actor's area - both detector's functors should be called
823 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
824 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
825 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
827 // Pinch continues in actor's area - both detector's functors should be called
830 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
831 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
832 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
834 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
835 firstDetector.Detach(actor);
838 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
839 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
840 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
842 // New pinch on actor, only secondDetector has actor attached
845 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
846 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
847 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
849 // Detach actor from secondDetector
850 secondDetector.Detach(actor);
853 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
854 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
855 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
859 int UtcDaliPinchGestureSignalReceptionMultipleStarted(void)
861 // Should handle two started events gracefully.
863 TestApplication application;
865 Actor actor = Actor::New();
866 actor.SetSize(100.0f, 100.0f);
867 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
868 Stage::GetCurrent().Add(actor);
871 GestureReceivedFunctor functor(data);
873 PinchGestureDetector detector = PinchGestureDetector::New();
874 detector.Attach(actor);
875 detector.DetectedSignal().Connect(&application, functor);
878 application.SendNotification();
879 application.Render();
881 // Start pan in actor's area
882 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
883 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
885 // Send another start in actor's area
887 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
888 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
890 // Add a child actor to overlap actor and send another start in actor's area
891 Actor child = Actor::New();
892 child.SetSize(100.0f, 100.0f);
893 child.SetAnchorPoint(AnchorPoint::CENTER);
894 child.SetParentOrigin(ParentOrigin::CENTER);
897 TouchEventFunctor touchFunctor;
898 child.TouchedSignal().Connect(&application, touchFunctor);
901 application.SendNotification();
902 application.Render();
904 // Send another start in actor's area
906 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
907 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
909 // Send another start in actor's area
911 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
912 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
916 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
918 TestApplication application;
920 Actor actor1 = Actor::New();
921 actor1.SetSize(100.0f, 100.0f);
922 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
923 Stage::GetCurrent().Add(actor1);
925 GestureReceivedFunctor functor1(data1);
926 PinchGestureDetector detector1 = PinchGestureDetector::New();
927 detector1.Attach(actor1);
928 detector1.DetectedSignal().Connect(&application, functor1);
930 Actor actor2 = Actor::New();
931 actor2.SetSize(100.0f, 100.0f);
932 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
933 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
934 Stage::GetCurrent().Add(actor2);
936 GestureReceivedFunctor functor2(data2);
937 PinchGestureDetector detector2 = PinchGestureDetector::New();
938 detector2.Attach(actor2);
939 detector2.DetectedSignal().Connect(&application, functor2);
942 application.SendNotification();
943 application.Render();
945 // Start pan in actor1's area, only data1 should be set
946 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
947 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
948 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
952 int UtcDaliPinchGestureEmitIncorrectStateClear(void)
954 TestApplication application;
956 Actor actor = Actor::New();
957 actor.SetSize(100.0f, 100.0f);
958 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
959 Stage::GetCurrent().Add(actor);
962 application.SendNotification();
963 application.Render();
965 // Attach actor to detector
967 GestureReceivedFunctor functor( data );
968 PinchGestureDetector detector = PinchGestureDetector::New();
969 detector.Attach(actor);
970 detector.DetectedSignal().Connect( &application, functor );
975 application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
976 tet_result(TET_FAIL);
978 catch ( Dali::DaliException& e )
980 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
985 int UtcDaliPinchGestureEmitIncorrectStatePossible(void)
987 TestApplication application;
989 Actor actor = Actor::New();
990 actor.SetSize(100.0f, 100.0f);
991 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
992 Stage::GetCurrent().Add(actor);
995 application.SendNotification();
996 application.Render();
998 // Attach actor to detector
1000 GestureReceivedFunctor functor( data );
1001 PinchGestureDetector detector = PinchGestureDetector::New();
1002 detector.Attach(actor);
1003 detector.DetectedSignal().Connect( &application, functor );
1005 // Try a Possible state
1008 application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1009 tet_result(TET_FAIL);
1011 catch ( Dali::DaliException& e )
1013 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
1018 int UtcDaliPinchGestureActorUnstaged(void)
1020 TestApplication application;
1022 Actor actor = Actor::New();
1023 actor.SetSize(100.0f, 100.0f);
1024 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1025 Stage::GetCurrent().Add(actor);
1027 // Render and notify
1028 application.SendNotification();
1029 application.Render();
1031 // State to remove actor in.
1032 Gesture::State stateToUnstage( Gesture::Started );
1034 // Attach actor to detector
1036 UnstageActorFunctor functor( data, stateToUnstage );
1037 PinchGestureDetector detector = PinchGestureDetector::New();
1038 detector.Attach(actor);
1039 detector.DetectedSignal().Connect( &application, functor );
1042 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1043 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1045 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1046 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Re-add actor to stage
1054 Stage::GetCurrent().Add(actor);
1056 // Render and notify
1057 application.SendNotification();
1058 application.Render();
1060 // Change state to Gesture::Continuing to remove
1061 stateToUnstage = Gesture::Continuing;
1064 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1065 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1067 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1068 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1070 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1071 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1074 // Render and notify
1075 application.SendNotification();
1076 application.Render();
1078 // Re-add actor to stage
1079 Stage::GetCurrent().Add(actor);
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Change state to Gesture::Continuing to remove
1086 stateToUnstage = Gesture::Finished;
1089 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1090 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1092 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1093 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1095 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1096 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1097 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1101 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
1103 TestApplication application;
1105 Actor actor = Actor::New();
1106 actor.SetSize(100.0f, 100.0f);
1107 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1108 Stage::GetCurrent().Add(actor);
1110 // Create and add a second actor so that GestureDetector destruction does not come into play.
1111 Actor dummyActor( Actor::New() );
1112 dummyActor.SetSize( 100.0f, 100.0f );
1113 dummyActor.SetPosition( 100.0f, 100.0f );
1114 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1115 Stage::GetCurrent().Add(dummyActor);
1117 // Render and notify
1118 application.SendNotification();
1119 application.Render();
1121 // State to remove actor in.
1122 Gesture::State stateToUnstage( Gesture::Started );
1124 // Attach actor to detector
1126 UnstageActorFunctor functor( data, stateToUnstage );
1127 PinchGestureDetector detector = PinchGestureDetector::New();
1128 detector.Attach(actor);
1129 detector.Attach(dummyActor);
1130 detector.DetectedSignal().Connect( &application, functor );
1132 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1133 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1134 // position, we should still not be signalled.
1137 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1138 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1141 // Render and notify
1142 application.SendNotification();
1143 application.Render();
1145 // Re add to the stage, we should not be signalled
1146 Stage::GetCurrent().Add(actor);
1148 // Render and notify
1149 application.SendNotification();
1150 application.Render();
1152 // Continue signal emission
1153 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1154 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1156 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1157 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1160 // Here we delete an actor in started, we should not receive any subsequent signalling.
1163 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1164 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1167 // Render and notify
1168 application.SendNotification();
1169 application.Render();
1171 // Delete actor as well
1174 // Render and notify
1175 application.SendNotification();
1176 application.Render();
1178 // Continue signal emission
1179 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1180 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1182 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1183 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1187 int UtcDaliPinchGestureSystemOverlay(void)
1189 TestApplication application;
1190 Dali::Integration::Core& core = application.GetCore();
1191 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1192 systemOverlay.GetOverlayRenderTasks().CreateTask();
1194 Actor actor = Actor::New();
1195 actor.SetSize(100.0f, 100.0f);
1196 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1197 systemOverlay.Add(actor);
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1204 GestureReceivedFunctor functor(data);
1206 PinchGestureDetector detector = PinchGestureDetector::New();
1207 detector.Attach(actor);
1208 detector.DetectedSignal().Connect(&application, functor);
1210 Vector2 screenCoords( 50.0f, 50.0f );
1211 float scale ( 10.0f );
1212 float speed ( 50.0f );
1214 // Start pan within the actor's area
1215 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1216 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1220 int UtcDaliPinchGestureBehindTouchableSystemOverlay(void)
1222 TestApplication application;
1223 Dali::Integration::Core& core = application.GetCore();
1224 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1225 systemOverlay.GetOverlayRenderTasks().CreateTask();
1227 // SystemOverlay actor
1228 Actor systemOverlayActor = Actor::New();
1229 systemOverlayActor.SetSize(100.0f, 100.0f);
1230 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1231 systemOverlay.Add(systemOverlayActor);
1234 Actor stageActor = Actor::New();
1235 stageActor.SetSize(100.0f, 100.0f);
1236 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1237 Stage::GetCurrent().Add(stageActor);
1239 // Render and notify
1240 application.SendNotification();
1241 application.Render();
1243 // Set system-overlay actor to touchable
1244 TouchEventData touchData;
1245 TouchEventDataFunctor touchFunctor( touchData );
1246 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1248 // Set stage actor to receive the gesture
1250 GestureReceivedFunctor functor(data);
1252 PinchGestureDetector detector = PinchGestureDetector::New();
1253 detector.Attach(stageActor);
1254 detector.DetectedSignal().Connect(&application, functor);
1256 Vector2 screenCoords( 50.0f, 50.0f );
1257 float scale ( 10.0f );
1258 float speed ( 50.0f );
1260 // Start pinch within the two actors' area
1261 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1262 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1263 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1264 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1269 // Do touch in the same area
1270 application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) );
1271 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1272 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1277 int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void)
1279 TestApplication application;
1280 Dali::Integration::Core& core = application.GetCore();
1281 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1282 systemOverlay.GetOverlayRenderTasks().CreateTask();
1284 // SystemOverlay actor
1285 Actor systemOverlayActor = Actor::New();
1286 systemOverlayActor.SetSize(100.0f, 100.0f);
1287 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1288 systemOverlay.Add(systemOverlayActor);
1291 Actor stageActor = Actor::New();
1292 stageActor.SetSize(100.0f, 100.0f);
1293 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1294 Stage::GetCurrent().Add(stageActor);
1296 // Render and notify
1297 application.SendNotification();
1298 application.Render();
1300 // Set stage actor to touchable
1301 TouchEventData touchData;
1302 TouchEventDataFunctor touchFunctor( touchData );
1303 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1305 // Set system-overlay actor to have the gesture
1307 GestureReceivedFunctor functor(data);
1309 PinchGestureDetector detector = PinchGestureDetector::New();
1310 detector.Attach(systemOverlayActor);
1311 detector.DetectedSignal().Connect(&application, functor);
1313 Vector2 screenCoords( 50.0f, 50.0f );
1314 float scale ( 10.0f );
1315 float speed ( 50.0f );
1317 // Start pinch within the two actors' area
1318 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1319 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1320 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1321 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1326 // Do touch in the same area
1327 application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) );
1328 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1329 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1334 int UtcDaliPinchGestureLayerConsumesTouch(void)
1336 TestApplication application;
1338 Actor actor = Actor::New();
1339 actor.SetSize(100.0f, 100.0f);
1340 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1341 Stage::GetCurrent().Add(actor);
1345 GestureReceivedFunctor functor(data);
1346 PinchGestureDetector detector = PinchGestureDetector::New();
1347 detector.Attach(actor);
1348 detector.DetectedSignal().Connect( &application, functor );
1350 // Add a layer to overlap the actor
1351 Layer layer = Layer::New();
1352 layer.SetSize(100.0f, 100.0f);
1353 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1354 Stage::GetCurrent().Add( layer );
1357 // Render and notify
1358 application.SendNotification();
1359 application.Render();
1361 Vector2 screenCoords( 50.0f, 50.0f );
1362 float scale ( 10.0f );
1363 float speed ( 50.0f );
1365 // Emit signals, should receive
1366 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1367 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1368 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1371 // Set layer to consume all touch
1372 layer.SetTouchConsumed( true );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Emit the same signals again, should not receive
1379 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1380 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1381 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);