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/integration-api/render-task-list-integ.h>
26 #include <dali-test-suite-utils.h>
27 #include <test-touch-utils.h>
31 void utc_dali_pinch_gesture_detector_startup(void)
33 test_return_value = TET_UNDEF;
36 void utc_dali_pinch_gesture_detector_cleanup(void)
38 test_return_value = TET_PASS;
41 ///////////////////////////////////////////////////////////////////////////////
45 // Stores data that is populated in the callback and will be read by the TET cases
49 : functorCalled(false),
50 voidFunctorCalled(false),
51 receivedGesture(Gesture::Started)
56 functorCalled = false;
57 voidFunctorCalled = false;
59 receivedGesture.state = Gesture::Started;
60 receivedGesture.scale = 0.0f;
61 receivedGesture.speed = 0.0f;
62 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
63 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
69 bool voidFunctorCalled;
70 PinchGesture receivedGesture;
74 // Functor that sets the data when called
75 struct GestureReceivedFunctor
77 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
79 void operator()(Actor actor, const PinchGesture& pinch)
81 signalData.functorCalled = true;
82 signalData.receivedGesture = pinch;
83 signalData.pinchedActor = actor;
88 signalData.voidFunctorCalled = true;
91 SignalData& signalData;
94 // Functor that removes the gestured actor from stage
95 struct UnstageActorFunctor : public GestureReceivedFunctor
97 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
98 : GestureReceivedFunctor( data ),
99 stateToUnstage( stateToUnstage )
103 void operator()( Actor actor, const PinchGesture& pinch )
105 GestureReceivedFunctor::operator()( actor, pinch );
107 if ( pinch.state == stateToUnstage )
109 Stage::GetCurrent().Remove( actor );
113 Gesture::State& stateToUnstage;
116 // Functor for receiving a touch event
117 struct TouchEventFunctor
119 bool operator()(Actor actor, const TouchEvent& touch)
125 // Generate a PinchGestureEvent to send to Core
126 Integration::PinchGestureEvent GeneratePinch(
127 Gesture::State state,
132 Integration::PinchGestureEvent pinch(state);
136 pinch.centerPoint = centerpoint;
143 ///////////////////////////////////////////////////////////////////////////////
145 int UtcDaliPinchGestureDetectorConstructor(void)
147 TestApplication application;
149 PinchGestureDetector detector;
150 DALI_TEST_CHECK(!detector);
154 int UtcDaliPinchGestureDetectorCopyConstructorP(void)
156 TestApplication application;
158 PinchGestureDetector detector = PinchGestureDetector::New();;
160 PinchGestureDetector copy( detector );
161 DALI_TEST_CHECK( detector );
165 int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
167 TestApplication application;
169 PinchGestureDetector detector = PinchGestureDetector::New();;
171 PinchGestureDetector assign;
173 DALI_TEST_CHECK( detector );
175 DALI_TEST_CHECK( detector == assign );
179 int UtcDaliPinchGestureDetectorNew(void)
181 TestApplication application;
183 PinchGestureDetector detector = PinchGestureDetector::New();
185 DALI_TEST_CHECK(detector);
187 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
188 Actor actor = Actor::New();
189 actor.SetSize(100.0f, 100.0f);
190 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
191 Stage::GetCurrent().Add(actor);
194 application.SendNotification();
195 application.Render();
197 detector.Attach(actor);
199 Integration::TouchEvent touchEvent(1);
200 Integration::Point point;
201 point.SetDeviceId( 1 );
202 point.SetState( PointState::DOWN );
203 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
204 touchEvent.AddPoint(point);
205 application.ProcessEvent(touchEvent);
207 Integration::Point point2;
208 point.SetDeviceId( 1 );
209 point.SetState( PointState::DOWN );
210 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
211 touchEvent.AddPoint(point2);
212 application.ProcessEvent(touchEvent);
216 int UtcDaliPinchGestureDetectorDownCast(void)
218 TestApplication application;
219 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
221 PinchGestureDetector detector = PinchGestureDetector::New();
223 BaseHandle object(detector);
225 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
226 DALI_TEST_CHECK(detector2);
228 PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object);
229 DALI_TEST_CHECK(detector3);
231 BaseHandle unInitializedObject;
232 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
233 DALI_TEST_CHECK(!detector4);
235 PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject);
236 DALI_TEST_CHECK(!detector5);
238 GestureDetector detector6 = PinchGestureDetector::New();
239 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
240 DALI_TEST_CHECK(detector7);
244 // Negative test case for a method
245 int UtcDaliPinchGestureSignalReceptionNegative(void)
247 TestApplication application;
249 Actor actor = Actor::New();
250 actor.SetSize(100.0f, 100.0f);
251 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
252 Stage::GetCurrent().Add(actor);
255 application.SendNotification();
256 application.Render();
259 GestureReceivedFunctor functor(data);
261 PinchGestureDetector detector = PinchGestureDetector::New();
262 detector.Attach(actor);
263 detector.DetectedSignal().Connect(&application, functor);
265 // Do a pinch outside actor's area
266 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f)));
267 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
269 // Continue pinch into actor's area - we should still not receive the signal
271 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f)));
272 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
274 // Stop pinching - we should still not receive the signal
276 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f)));
277 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
281 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
283 TestApplication application;
285 Actor actor = Actor::New();
286 actor.SetSize(100.0f, 100.0f);
287 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
288 Stage::GetCurrent().Add(actor);
291 application.SendNotification();
292 application.Render();
295 GestureReceivedFunctor functor(data);
297 PinchGestureDetector detector = PinchGestureDetector::New();
298 detector.Attach(actor);
299 detector.DetectedSignal().Connect(&application, functor);
301 // Start pan within the actor's area
302 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
303 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
304 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
305 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
306 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
307 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
309 // Continue the pan within the actor's area - we should still receive the signal
311 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f)));
312 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
313 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
314 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
315 DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
316 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
318 // Pan Gesture leaves actor's area - we should still receive the signal
320 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f)));
321 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
322 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
323 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
324 DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
325 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
327 // Gesture ends - we would receive a finished state
329 application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f)));
330 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
331 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
332 DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
333 DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
334 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
338 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
340 TestApplication application;
342 Actor actor = Actor::New();
343 actor.SetSize(100.0f, 100.0f);
344 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
345 Stage::GetCurrent().Add(actor);
348 application.SendNotification();
349 application.Render();
352 GestureReceivedFunctor functor(data);
354 PinchGestureDetector detector = PinchGestureDetector::New();
355 detector.Attach(actor);
356 detector.DetectedSignal().Connect(&application, functor);
358 // Start pinch within the actor's area
359 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
360 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
361 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
362 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
363 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
364 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
366 // Continue the pinch within the actor's area - we should still receive the signal
368 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
369 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
370 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
371 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
372 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
373 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
375 // Gesture ends within actor's area - we would receive a finished state
377 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
378 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
379 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
380 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
381 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
382 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
386 int UtcDaliPinchGestureSignalReceptionCancelled(void)
388 TestApplication application;
390 Actor actor = Actor::New();
391 actor.SetSize(100.0f, 100.0f);
392 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
393 Stage::GetCurrent().Add(actor);
396 application.SendNotification();
397 application.Render();
400 GestureReceivedFunctor functor(data);
402 PinchGestureDetector detector = PinchGestureDetector::New();
403 detector.Attach(actor);
404 detector.DetectedSignal().Connect(&application, functor);
406 // Start pinch within the actor's area
407 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
408 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
409 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
412 // Continue the pinch within the actor's area - we should still receive the signal
414 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
415 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
416 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
418 // The gesture is cancelled
420 application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
421 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
422 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
426 int UtcDaliPinchGestureSignalReceptionDetach(void)
428 TestApplication application;
430 Actor actor = Actor::New();
431 actor.SetSize(100.0f, 100.0f);
432 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
433 Stage::GetCurrent().Add(actor);
436 application.SendNotification();
437 application.Render();
440 GestureReceivedFunctor functor(data);
442 PinchGestureDetector detector = PinchGestureDetector::New();
443 detector.Attach(actor);
444 detector.DetectedSignal().Connect(&application, functor);
446 // Start pinch within the actor's area
447 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
448 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
449 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
452 // Continue the pinch within the actor's area - we should still receive the signal
454 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
455 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
456 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
458 // Gesture ends within actor's area
460 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
461 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
462 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
465 detector.DetachAll();
467 // Ensure we are no longer signalled
469 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
470 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
471 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
472 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
476 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
478 TestApplication application;
480 Actor actor = Actor::New();
481 actor.SetSize(100.0f, 100.0f);
482 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
483 Stage::GetCurrent().Add(actor);
486 application.SendNotification();
487 application.Render();
490 GestureReceivedFunctor functor(data);
492 PinchGestureDetector detector = PinchGestureDetector::New();
493 detector.Attach(actor);
494 detector.DetectedSignal().Connect(&application, functor);
496 // Start pinch within the actor's area
497 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
498 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
499 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
501 // Continue the pinch within the actor's area - we should still receive the signal
503 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
504 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
505 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
507 // Detach actor during the pinch, we should not receive the next event
508 detector.DetachAll();
510 // Gesture ends within actor's area
512 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
513 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
517 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
519 TestApplication application;
522 GestureReceivedFunctor functor(data);
524 PinchGestureDetector detector = PinchGestureDetector::New();
525 detector.DetectedSignal().Connect(&application, functor);
527 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
529 Actor tempActor = Actor::New();
530 tempActor.SetSize(100.0f, 100.0f);
531 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
532 Stage::GetCurrent().Add(tempActor);
533 detector.Attach(tempActor);
535 // Actor lifetime is scoped
537 Actor actor = Actor::New();
538 actor.SetSize(100.0f, 100.0f);
539 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
540 Stage::GetCurrent().Add(actor);
543 application.SendNotification();
544 application.Render();
546 detector.Attach(actor);
548 // Start pinch within the actor's area
549 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
550 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
551 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
553 // Continue the pinch within the actor's area - we should still receive the signal
555 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
556 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
557 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
559 // Remove the actor from stage and reset the data
560 Stage::GetCurrent().Remove(actor);
563 application.SendNotification();
564 application.Render();
567 // Actor should now have been destroyed
569 // Gesture ends within the area where the actor used to be
571 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
572 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
576 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
578 TestApplication application;
580 Actor actor = Actor::New();
581 actor.SetSize(100.0f, 100.0f);
582 actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
583 Stage::GetCurrent().Add(actor);
585 // Render and notify a couple of times
586 application.SendNotification();
587 application.Render();
590 GestureReceivedFunctor functor(data);
592 PinchGestureDetector detector = PinchGestureDetector::New();
593 detector.Attach(actor);
594 detector.DetectedSignal().Connect(&application, functor);
596 // Do an entire pinch, only check finished value
597 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
599 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
600 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
601 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
602 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
603 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
605 // Rotate actor again and render and notify
606 actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
607 application.SendNotification();
608 application.Render();
610 // Do an entire pinch, only check finished value
611 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
613 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
614 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
615 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
616 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
617 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
619 // Rotate actor again and render and notify
620 actor.SetOrientation(Dali::Degree(270.0f), Vector3::ZAXIS);
621 application.SendNotification();
622 application.Render();
624 // Do an entire pinch, only check finished value
625 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
627 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
628 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
629 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
630 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
631 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
635 int UtcDaliPinchGestureSignalReceptionChildHit(void)
637 TestApplication application;
639 Actor parent = Actor::New();
640 parent.SetSize(100.0f, 100.0f);
641 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
642 Stage::GetCurrent().Add(parent);
644 // Set child to completely cover parent.
645 // Change rotation of child to be different from parent so that we can check if our local coordinate
646 // conversion of the parent actor is correct.
647 Actor child = Actor::New();
648 child.SetSize(100.0f, 100.0f);
649 child.SetAnchorPoint(AnchorPoint::CENTER);
650 child.SetParentOrigin(ParentOrigin::CENTER);
651 child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
654 TouchEventFunctor touchFunctor;
655 child.TouchedSignal().Connect(&application, touchFunctor);
658 application.SendNotification();
659 application.Render();
662 GestureReceivedFunctor functor(data);
664 PinchGestureDetector detector = PinchGestureDetector::New();
665 detector.Attach(parent);
666 detector.DetectedSignal().Connect(&application, functor);
668 // Do an entire pan, only check finished value - hits child area but parent should still receive it
669 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
671 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
672 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
673 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
674 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
675 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
676 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
678 // Attach child and generate same touch points to yield same results
679 // (Also proves that you can detach and then re-attach another actor)
680 detector.Attach(child);
681 detector.Detach(parent);
683 // Do an entire pan, only check finished value
684 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
686 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
687 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
688 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
689 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
690 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
691 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
695 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
697 TestApplication application;
699 Actor first = Actor::New();
700 first.SetSize(100.0f, 100.0f);
701 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
702 Stage::GetCurrent().Add(first);
704 Actor second = Actor::New();
705 second.SetSize(100.0f, 100.0f);
707 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
708 Stage::GetCurrent().Add(second);
711 application.SendNotification();
712 application.Render();
715 GestureReceivedFunctor functor(data);
717 PinchGestureDetector detector = PinchGestureDetector::New();
718 detector.Attach(first);
719 detector.Attach(second);
720 detector.DetectedSignal().Connect(&application, functor);
722 // Start pinch within second actor's area
723 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
724 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
725 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
727 // Pinch moves into first actor's area - second actor should receive the pinch
729 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
730 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
731 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
733 // Detach the second actor during the pinch, we should not receive the next event
734 detector.Detach(second);
736 // Gesture ends within actor's area
738 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
739 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
743 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
745 TestApplication application;
747 Actor actor = Actor::New();
748 actor.SetSize(100.0f, 100.0f);
749 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
750 Stage::GetCurrent().Add(actor);
753 application.SendNotification();
754 application.Render();
757 GestureReceivedFunctor functor(data);
759 PinchGestureDetector detector = PinchGestureDetector::New();
760 detector.Attach(actor);
761 detector.DetectedSignal().Connect(&application, functor);
763 // Start pinch in actor's area
764 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
765 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
767 // Pan continues within actor's area
769 application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
770 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
772 // Actor become invisible - actor should not receive the next pinch
773 actor.SetVisible(false);
776 application.SendNotification();
777 application.Render();
779 // Gesture ends within actor's area
781 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
782 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
786 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
788 TestApplication application;
790 Actor actor = Actor::New();
791 actor.SetSize(100.0f, 100.0f);
792 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
793 Stage::GetCurrent().Add(actor);
795 Actor actor2 = Actor::New();
796 actor2.SetSize(100.0f, 100.0f);
797 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
798 Stage::GetCurrent().Add(actor2);
801 application.SendNotification();
802 application.Render();
804 // Attach actor to one detector
805 SignalData firstData;
806 GestureReceivedFunctor firstFunctor(firstData);
807 PinchGestureDetector firstDetector = PinchGestureDetector::New();
808 firstDetector.Attach(actor);
809 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
811 // Attach actor to another detector
812 SignalData secondData;
813 GestureReceivedFunctor secondFunctor(secondData);
814 PinchGestureDetector secondDetector = PinchGestureDetector::New();
815 secondDetector.Attach(actor);
816 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
818 // Add second actor to second detector, when we remove the actor, this will make sure that this
819 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
820 // functor should still not be called (which is what we're also testing).
821 secondDetector.Attach(actor2);
823 // Pinch in actor's area - both detector's functors should be called
824 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
825 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
826 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
828 // Pinch continues in actor's area - both detector's functors should be called
831 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
832 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
833 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
835 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
836 firstDetector.Detach(actor);
839 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
840 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
841 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
843 // New pinch on actor, only secondDetector has actor attached
846 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
847 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
848 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
850 // Detach actor from secondDetector
851 secondDetector.Detach(actor);
854 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
855 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
856 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
860 int UtcDaliPinchGestureSignalReceptionMultipleStarted(void)
862 // Should handle two started events gracefully.
864 TestApplication application;
866 Actor actor = Actor::New();
867 actor.SetSize(100.0f, 100.0f);
868 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
869 Stage::GetCurrent().Add(actor);
872 GestureReceivedFunctor functor(data);
874 PinchGestureDetector detector = PinchGestureDetector::New();
875 detector.Attach(actor);
876 detector.DetectedSignal().Connect(&application, functor);
879 application.SendNotification();
880 application.Render();
882 // Start pan in actor's area
883 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
884 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
886 // Send another start in actor's area
888 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
889 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
891 // Add a child actor to overlap actor and send another start in actor's area
892 Actor child = Actor::New();
893 child.SetSize(100.0f, 100.0f);
894 child.SetAnchorPoint(AnchorPoint::CENTER);
895 child.SetParentOrigin(ParentOrigin::CENTER);
898 TouchEventFunctor touchFunctor;
899 child.TouchedSignal().Connect(&application, touchFunctor);
902 application.SendNotification();
903 application.Render();
905 // Send another start in actor's area
907 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
908 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
910 // Send another start in actor's area
912 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
913 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
917 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
919 TestApplication application;
921 Actor actor1 = Actor::New();
922 actor1.SetSize(100.0f, 100.0f);
923 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
924 Stage::GetCurrent().Add(actor1);
926 GestureReceivedFunctor functor1(data1);
927 PinchGestureDetector detector1 = PinchGestureDetector::New();
928 detector1.Attach(actor1);
929 detector1.DetectedSignal().Connect(&application, functor1);
931 Actor actor2 = Actor::New();
932 actor2.SetSize(100.0f, 100.0f);
933 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
934 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
935 Stage::GetCurrent().Add(actor2);
937 GestureReceivedFunctor functor2(data2);
938 PinchGestureDetector detector2 = PinchGestureDetector::New();
939 detector2.Attach(actor2);
940 detector2.DetectedSignal().Connect(&application, functor2);
943 application.SendNotification();
944 application.Render();
946 // Start pan in actor1's area, only data1 should be set
947 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
948 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
949 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
953 int UtcDaliPinchGestureEmitIncorrectStateClear(void)
955 TestApplication application;
957 Actor actor = Actor::New();
958 actor.SetSize(100.0f, 100.0f);
959 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
960 Stage::GetCurrent().Add(actor);
963 application.SendNotification();
964 application.Render();
966 // Attach actor to detector
968 GestureReceivedFunctor functor( data );
969 PinchGestureDetector detector = PinchGestureDetector::New();
970 detector.Attach(actor);
971 detector.DetectedSignal().Connect( &application, functor );
976 application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
977 tet_result(TET_FAIL);
979 catch ( Dali::DaliException& e )
981 DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
986 int UtcDaliPinchGestureEmitIncorrectStatePossible(void)
988 TestApplication application;
990 Actor actor = Actor::New();
991 actor.SetSize(100.0f, 100.0f);
992 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
993 Stage::GetCurrent().Add(actor);
996 application.SendNotification();
997 application.Render();
999 // Attach actor to detector
1001 GestureReceivedFunctor functor( data );
1002 PinchGestureDetector detector = PinchGestureDetector::New();
1003 detector.Attach(actor);
1004 detector.DetectedSignal().Connect( &application, functor );
1006 // Try a Possible state
1009 application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1010 tet_result(TET_FAIL);
1012 catch ( Dali::DaliException& e )
1014 DALI_TEST_ASSERT( e, "Incorrect state", TEST_LOCATION );
1019 int UtcDaliPinchGestureActorUnstaged(void)
1021 TestApplication application;
1023 Actor actor = Actor::New();
1024 actor.SetSize(100.0f, 100.0f);
1025 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1026 Stage::GetCurrent().Add(actor);
1028 // Render and notify
1029 application.SendNotification();
1030 application.Render();
1032 // State to remove actor in.
1033 Gesture::State stateToUnstage( Gesture::Started );
1035 // Attach actor to detector
1037 UnstageActorFunctor functor( data, stateToUnstage );
1038 PinchGestureDetector detector = PinchGestureDetector::New();
1039 detector.Attach(actor);
1040 detector.DetectedSignal().Connect( &application, functor );
1043 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1044 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1046 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1047 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1050 // Render and notify
1051 application.SendNotification();
1052 application.Render();
1054 // Re-add actor to stage
1055 Stage::GetCurrent().Add(actor);
1057 // Render and notify
1058 application.SendNotification();
1059 application.Render();
1061 // Change state to Gesture::Continuing to remove
1062 stateToUnstage = Gesture::Continuing;
1065 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1066 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1068 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1069 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1071 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1072 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1075 // Render and notify
1076 application.SendNotification();
1077 application.Render();
1079 // Re-add actor to stage
1080 Stage::GetCurrent().Add(actor);
1082 // Render and notify
1083 application.SendNotification();
1084 application.Render();
1086 // Change state to Gesture::Continuing to remove
1087 stateToUnstage = Gesture::Finished;
1090 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1091 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1093 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1094 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1096 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1097 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1098 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1102 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
1104 TestApplication application;
1106 Actor actor = Actor::New();
1107 actor.SetSize(100.0f, 100.0f);
1108 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1109 Stage::GetCurrent().Add(actor);
1111 // Create and add a second actor so that GestureDetector destruction does not come into play.
1112 Actor dummyActor( Actor::New() );
1113 dummyActor.SetSize( 100.0f, 100.0f );
1114 dummyActor.SetPosition( 100.0f, 100.0f );
1115 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1116 Stage::GetCurrent().Add(dummyActor);
1118 // Render and notify
1119 application.SendNotification();
1120 application.Render();
1122 // State to remove actor in.
1123 Gesture::State stateToUnstage( Gesture::Started );
1125 // Attach actor to detector
1127 UnstageActorFunctor functor( data, stateToUnstage );
1128 PinchGestureDetector detector = PinchGestureDetector::New();
1129 detector.Attach(actor);
1130 detector.Attach(dummyActor);
1131 detector.DetectedSignal().Connect( &application, functor );
1133 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1134 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1135 // position, we should still not be signalled.
1138 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1139 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1142 // Render and notify
1143 application.SendNotification();
1144 application.Render();
1146 // Re add to the stage, we should not be signalled
1147 Stage::GetCurrent().Add(actor);
1149 // Render and notify
1150 application.SendNotification();
1151 application.Render();
1153 // Continue signal emission
1154 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1155 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1157 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1158 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1161 // Here we delete an actor in started, we should not receive any subsequent signalling.
1164 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1165 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1168 // Render and notify
1169 application.SendNotification();
1170 application.Render();
1172 // Delete actor as well
1175 // Render and notify
1176 application.SendNotification();
1177 application.Render();
1179 // Continue signal emission
1180 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1181 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1183 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1184 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1188 int UtcDaliPinchGestureSystemOverlay(void)
1190 TestApplication application;
1191 Dali::Integration::Core& core = application.GetCore();
1192 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1194 Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
1195 Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor();
1196 Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor();
1197 Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
1198 systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList );
1200 Actor actor = Actor::New();
1201 actor.SetSize(100.0f, 100.0f);
1202 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1203 systemOverlay.Add(actor);
1205 // Render and notify
1206 application.SendNotification();
1207 application.Render();
1210 GestureReceivedFunctor functor(data);
1212 PinchGestureDetector detector = PinchGestureDetector::New();
1213 detector.Attach(actor);
1214 detector.DetectedSignal().Connect(&application, functor);
1216 Vector2 screenCoords( 50.0f, 50.0f );
1217 float scale ( 10.0f );
1218 float speed ( 50.0f );
1220 // Start pan within the actor's area
1221 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1222 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1226 int UtcDaliPinchGestureBehindTouchableSystemOverlay(void)
1228 TestApplication application;
1229 Dali::Integration::Core& core = application.GetCore();
1230 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1232 Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
1233 Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor();
1234 Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor();
1235 Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
1236 systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList );
1238 // SystemOverlay actor
1239 Actor systemOverlayActor = Actor::New();
1240 systemOverlayActor.SetSize(100.0f, 100.0f);
1241 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1242 systemOverlay.Add(systemOverlayActor);
1245 Actor stageActor = Actor::New();
1246 stageActor.SetSize(100.0f, 100.0f);
1247 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1248 Stage::GetCurrent().Add(stageActor);
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Set system-overlay actor to touchable
1255 TouchEventData touchData;
1256 TouchEventDataFunctor touchFunctor( touchData );
1257 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1259 // Set stage actor to receive the gesture
1261 GestureReceivedFunctor functor(data);
1263 PinchGestureDetector detector = PinchGestureDetector::New();
1264 detector.Attach(stageActor);
1265 detector.DetectedSignal().Connect(&application, functor);
1267 Vector2 screenCoords( 50.0f, 50.0f );
1268 float scale ( 10.0f );
1269 float speed ( 50.0f );
1271 // Start pinch within the two actors' area
1272 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1273 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1274 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1275 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1280 // Do touch in the same area
1281 application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) );
1282 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1283 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1288 int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void)
1290 TestApplication application;
1291 Dali::Integration::Core& core = application.GetCore();
1292 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1294 Dali::RenderTaskList overlayRenderTaskList = Integration::RenderTaskList::New();
1295 Dali::Actor overlayRootActor = systemOverlay.GetDefaultRootActor();
1296 Dali::CameraActor overlayCameraActor = systemOverlay.GetDefaultCameraActor();
1297 Integration::RenderTaskList::CreateTask( overlayRenderTaskList, overlayRootActor, overlayCameraActor );
1298 systemOverlay.SetOverlayRenderTasks( overlayRenderTaskList );
1300 // SystemOverlay actor
1301 Actor systemOverlayActor = Actor::New();
1302 systemOverlayActor.SetSize(100.0f, 100.0f);
1303 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1304 systemOverlay.Add(systemOverlayActor);
1307 Actor stageActor = Actor::New();
1308 stageActor.SetSize(100.0f, 100.0f);
1309 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1310 Stage::GetCurrent().Add(stageActor);
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Set stage actor to touchable
1317 TouchEventData touchData;
1318 TouchEventDataFunctor touchFunctor( touchData );
1319 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1321 // Set system-overlay actor to have the gesture
1323 GestureReceivedFunctor functor(data);
1325 PinchGestureDetector detector = PinchGestureDetector::New();
1326 detector.Attach(systemOverlayActor);
1327 detector.DetectedSignal().Connect(&application, functor);
1329 Vector2 screenCoords( 50.0f, 50.0f );
1330 float scale ( 10.0f );
1331 float speed ( 50.0f );
1333 // Start pinch within the two actors' area
1334 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1335 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1336 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1337 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1342 // Do touch in the same area
1343 application.ProcessEvent( touchFunctor.GenerateSingleTouch( PointState::DOWN, screenCoords ) );
1344 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1345 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1350 int UtcDaliPinchGestureLayerConsumesTouch(void)
1352 TestApplication application;
1354 Actor actor = Actor::New();
1355 actor.SetSize(100.0f, 100.0f);
1356 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1357 Stage::GetCurrent().Add(actor);
1361 GestureReceivedFunctor functor(data);
1362 PinchGestureDetector detector = PinchGestureDetector::New();
1363 detector.Attach(actor);
1364 detector.DetectedSignal().Connect( &application, functor );
1366 // Add a layer to overlap the actor
1367 Layer layer = Layer::New();
1368 layer.SetSize(100.0f, 100.0f);
1369 layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1370 Stage::GetCurrent().Add( layer );
1373 // Render and notify
1374 application.SendNotification();
1375 application.Render();
1377 Vector2 screenCoords( 50.0f, 50.0f );
1378 float scale ( 10.0f );
1379 float speed ( 50.0f );
1381 // Emit signals, should receive
1382 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1383 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1384 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1387 // Set layer to consume all touch
1388 layer.SetTouchConsumed( true );
1390 // Render and notify
1391 application.SendNotification();
1392 application.Render();
1394 // Emit the same signals again, should not receive
1395 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1396 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1397 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);