2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
20 #include <dali/dali.h>
21 #include <dali/integration-api/events/touch-event-integ.h>
22 #include <dali/integration-api/events/pinch-gesture-event.h>
23 #include <dali/integration-api/system-overlay.h>
24 #include <dali-test-suite-utils.h>
25 #include <test-touch-utils.h>
29 void utc_dali_pinch_gesture_detector_startup(void)
31 test_return_value = TET_UNDEF;
34 void utc_dali_pinch_gesture_detector_cleanup(void)
36 test_return_value = TET_PASS;
39 ///////////////////////////////////////////////////////////////////////////////
43 // Stores data that is populated in the callback and will be read by the TET cases
47 : functorCalled(false),
48 voidFunctorCalled(false),
49 receivedGesture(Gesture::Started)
54 functorCalled = false;
55 voidFunctorCalled = false;
57 receivedGesture.state = Gesture::Started;
58 receivedGesture.scale = 0.0f;
59 receivedGesture.speed = 0.0f;
60 receivedGesture.screenCenterPoint = Vector2(0.0f, 0.0f);
61 receivedGesture.localCenterPoint = Vector2(0.0f, 0.0f);
67 bool voidFunctorCalled;
68 PinchGesture receivedGesture;
72 // Functor that sets the data when called
73 struct GestureReceivedFunctor
75 GestureReceivedFunctor(SignalData& data) : signalData(data) { }
77 void operator()(Actor actor, PinchGesture pinch)
79 signalData.functorCalled = true;
80 signalData.receivedGesture = pinch;
81 signalData.pinchedActor = actor;
86 signalData.voidFunctorCalled = true;
89 SignalData& signalData;
92 // Functor that removes the gestured actor from stage
93 struct UnstageActorFunctor : public GestureReceivedFunctor
95 UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
96 : GestureReceivedFunctor( data ),
97 stateToUnstage( stateToUnstage )
101 void operator()( Actor actor, PinchGesture pinch )
103 GestureReceivedFunctor::operator()( actor, pinch );
105 if ( pinch.state == stateToUnstage )
107 Stage::GetCurrent().Remove( actor );
111 Gesture::State& stateToUnstage;
114 // Functor for receiving a touch event
115 struct TouchEventFunctor
117 bool operator()(Actor actor, const TouchEvent& touch)
123 // Generate a PinchGestureEvent to send to Core
124 Integration::PinchGestureEvent GeneratePinch(
125 Gesture::State state,
130 Integration::PinchGestureEvent pinch(state);
134 pinch.centerPoint = centerpoint;
141 ///////////////////////////////////////////////////////////////////////////////
143 int UtcDaliPinchGestureDetectorConstructor(void)
145 TestApplication application;
147 PinchGestureDetector detector;
148 DALI_TEST_CHECK(!detector);
152 int UtcDaliPinchGestureDetectorNew(void)
154 TestApplication application;
156 PinchGestureDetector detector = PinchGestureDetector::New();
158 DALI_TEST_CHECK(detector);
160 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
161 Actor actor = Actor::New();
162 actor.SetSize(100.0f, 100.0f);
163 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
164 Stage::GetCurrent().Add(actor);
167 application.SendNotification();
168 application.Render();
170 detector.Attach(actor);
172 Integration::TouchEvent touchEvent(1);
173 TouchPoint point(1, TouchPoint::Down, 20.0f, 20.0f);
174 touchEvent.AddPoint(point);
175 application.ProcessEvent(touchEvent);
177 TouchPoint point2(1, TouchPoint::Down, 20.0f, 20.0f, 20.0f, 20.0f);
178 touchEvent.AddPoint(point2);
179 application.ProcessEvent(touchEvent);
183 int UtcDaliPinchGestureDetectorDownCast(void)
185 TestApplication application;
186 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
188 PinchGestureDetector detector = PinchGestureDetector::New();
190 BaseHandle object(detector);
192 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
193 DALI_TEST_CHECK(detector2);
195 PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object);
196 DALI_TEST_CHECK(detector3);
198 BaseHandle unInitializedObject;
199 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
200 DALI_TEST_CHECK(!detector4);
202 PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject);
203 DALI_TEST_CHECK(!detector5);
205 GestureDetector detector6 = PinchGestureDetector::New();
206 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
207 DALI_TEST_CHECK(detector7);
211 // Negative test case for a method
212 int UtcDaliPinchGestureSignalReceptionNegative(void)
214 TestApplication application;
216 Actor actor = Actor::New();
217 actor.SetSize(100.0f, 100.0f);
218 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
219 Stage::GetCurrent().Add(actor);
222 application.SendNotification();
223 application.Render();
226 GestureReceivedFunctor functor(data);
228 PinchGestureDetector detector = PinchGestureDetector::New();
229 detector.Attach(actor);
230 detector.DetectedSignal().Connect(&application, functor);
232 // Do a pinch outside actor's area
233 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 45.0f, Vector2(112.0f, 112.0f)));
234 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
236 // Continue pinch into actor's area - we should still not receive the signal
238 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 4.5f, 95.0f, Vector2(20.0f, 20.0f)));
239 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
241 // Stop pinching - we should still not receive the signal
243 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(12.0f, 12.0f)));
244 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
248 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
250 TestApplication application;
252 Actor actor = Actor::New();
253 actor.SetSize(100.0f, 100.0f);
254 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
255 Stage::GetCurrent().Add(actor);
258 application.SendNotification();
259 application.Render();
262 GestureReceivedFunctor functor(data);
264 PinchGestureDetector detector = PinchGestureDetector::New();
265 detector.Attach(actor);
266 detector.DetectedSignal().Connect(&application, functor);
268 // Start pan within the actor's area
269 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
270 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
271 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
272 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
273 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
274 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
276 // Continue the pan within the actor's area - we should still receive the signal
278 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 90.0f, Vector2(21.0f, 20.0f)));
279 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
280 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
281 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
282 DALI_TEST_EQUALS(90.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
283 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
285 // Pan Gesture leaves actor's area - we should still receive the signal
287 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 15.5f, Vector2(320.0f, 10.0f)));
288 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
289 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
290 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
291 DALI_TEST_EQUALS(15.5f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
292 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
294 // Gesture ends - we would receive a finished state
296 application.ProcessEvent(GeneratePinch(Gesture::Finished, 15.2f, 12.1f, Vector2(310.0f, 10.0f)));
297 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
298 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
299 DALI_TEST_EQUALS(15.2f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
300 DALI_TEST_EQUALS(12.1f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
301 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
305 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
307 TestApplication application;
309 Actor actor = Actor::New();
310 actor.SetSize(100.0f, 100.0f);
311 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
312 Stage::GetCurrent().Add(actor);
315 application.SendNotification();
316 application.Render();
319 GestureReceivedFunctor functor(data);
321 PinchGestureDetector detector = PinchGestureDetector::New();
322 detector.Attach(actor);
323 detector.DetectedSignal().Connect(&application, functor);
325 // Start pinch within the actor's area
326 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
327 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
328 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
329 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
330 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
331 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
333 // Continue the pinch within the actor's area - we should still receive the signal
335 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
336 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
337 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
338 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
339 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
340 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
342 // Gesture ends within actor's area - we would receive a finished state
344 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
345 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
346 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
347 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
348 DALI_TEST_EQUALS(25.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
349 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
353 int UtcDaliPinchGestureSignalReceptionCancelled(void)
355 TestApplication application;
357 Actor actor = Actor::New();
358 actor.SetSize(100.0f, 100.0f);
359 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
360 Stage::GetCurrent().Add(actor);
363 application.SendNotification();
364 application.Render();
367 GestureReceivedFunctor functor(data);
369 PinchGestureDetector detector = PinchGestureDetector::New();
370 detector.Attach(actor);
371 detector.DetectedSignal().Connect(&application, functor);
373 // Start pinch within the actor's area
374 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
375 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
376 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
379 // Continue the pinch within the actor's area - we should still receive the signal
381 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
382 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
383 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
385 // The gesture is cancelled
387 application.ProcessEvent(GeneratePinch(Gesture::Cancelled, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
388 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
389 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
393 int UtcDaliPinchGestureSignalReceptionDetach(void)
395 TestApplication application;
397 Actor actor = Actor::New();
398 actor.SetSize(100.0f, 100.0f);
399 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
400 Stage::GetCurrent().Add(actor);
403 application.SendNotification();
404 application.Render();
407 GestureReceivedFunctor functor(data);
409 PinchGestureDetector detector = PinchGestureDetector::New();
410 detector.Attach(actor);
411 detector.DetectedSignal().Connect(&application, functor);
413 // Start pinch within the actor's area
414 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
415 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
416 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
419 // Continue the pinch within the actor's area - we should still receive the signal
421 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
422 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
423 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
425 // Gesture ends within actor's area
427 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
428 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
429 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
432 detector.DetachAll();
434 // Ensure we are no longer signalled
436 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 20.0f)));
437 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
438 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
439 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
443 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
445 TestApplication application;
447 Actor actor = Actor::New();
448 actor.SetSize(100.0f, 100.0f);
449 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
450 Stage::GetCurrent().Add(actor);
453 application.SendNotification();
454 application.Render();
457 GestureReceivedFunctor functor(data);
459 PinchGestureDetector detector = PinchGestureDetector::New();
460 detector.Attach(actor);
461 detector.DetectedSignal().Connect(&application, functor);
463 // Start pinch within the actor's area
464 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
465 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
466 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
468 // Continue the pinch within the actor's area - we should still receive the signal
470 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
471 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
472 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
474 // Detach actor during the pinch, we should not receive the next event
475 detector.DetachAll();
477 // Gesture ends within actor's area
479 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
480 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
484 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
486 TestApplication application;
489 GestureReceivedFunctor functor(data);
491 PinchGestureDetector detector = PinchGestureDetector::New();
492 detector.DetectedSignal().Connect(&application, functor);
494 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
496 Actor tempActor = Actor::New();
497 tempActor.SetSize(100.0f, 100.0f);
498 tempActor.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
499 Stage::GetCurrent().Add(tempActor);
500 detector.Attach(tempActor);
502 // Actor lifetime is scoped
504 Actor actor = Actor::New();
505 actor.SetSize(100.0f, 100.0f);
506 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
507 Stage::GetCurrent().Add(actor);
510 application.SendNotification();
511 application.Render();
513 detector.Attach(actor);
515 // Start pinch within the actor's area
516 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
517 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
518 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
520 // Continue the pinch within the actor's area - we should still receive the signal
522 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
523 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
524 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
526 // Remove the actor from stage and reset the data
527 Stage::GetCurrent().Remove(actor);
530 application.SendNotification();
531 application.Render();
534 // Actor should now have been destroyed
536 // Gesture ends within the area where the actor used to be
538 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 25.0f, Vector2(20.0f, 20.0f)));
539 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
543 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
545 TestApplication application;
547 Actor actor = Actor::New();
548 actor.SetSize(100.0f, 100.0f);
549 actor.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
550 Stage::GetCurrent().Add(actor);
552 // Render and notify a couple of times
553 application.SendNotification();
554 application.Render();
557 GestureReceivedFunctor functor(data);
559 PinchGestureDetector detector = PinchGestureDetector::New();
560 detector.Attach(actor);
561 detector.DetectedSignal().Connect(&application, functor);
563 // Do an entire pinch, only check finished value
564 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
566 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
567 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
568 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
569 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
570 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
572 // Rotate actor again and render and notify
573 actor.SetRotation(Dali::Degree(180.0f), Vector3::ZAXIS);
574 application.SendNotification();
575 application.Render();
577 // Do an entire pinch, only check finished value
578 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
580 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
581 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
582 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
583 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
584 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
586 // Rotate actor again and render and notify
587 actor.SetRotation(Dali::Degree(270.0f), Vector3::ZAXIS);
588 application.SendNotification();
589 application.Render();
591 // Do an entire pinch, only check finished value
592 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
594 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
595 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
596 DALI_TEST_EQUALS(10.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
597 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
598 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
602 int UtcDaliPinchGestureSignalReceptionChildHit(void)
604 TestApplication application;
606 Actor parent = Actor::New();
607 parent.SetSize(100.0f, 100.0f);
608 parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
609 Stage::GetCurrent().Add(parent);
611 // Set child to completely cover parent.
612 // Change rotation of child to be different from parent so that we can check if our local coordinate
613 // conversion of the parent actor is correct.
614 Actor child = Actor::New();
615 child.SetSize(100.0f, 100.0f);
616 child.SetAnchorPoint(AnchorPoint::CENTER);
617 child.SetParentOrigin(ParentOrigin::CENTER);
618 child.SetRotation(Dali::Degree(90.0f), Vector3::ZAXIS);
621 TouchEventFunctor touchFunctor;
622 child.TouchedSignal().Connect(&application, touchFunctor);
625 application.SendNotification();
626 application.Render();
629 GestureReceivedFunctor functor(data);
631 PinchGestureDetector detector = PinchGestureDetector::New();
632 detector.Attach(parent);
633 detector.DetectedSignal().Connect(&application, functor);
635 // Do an entire pan, only check finished value - hits child area but parent should still receive it
636 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
638 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
639 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
640 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
641 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
642 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
643 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
645 // Attach child and generate same touch points to yield same results
646 // (Also proves that you can detach and then re-attach another actor)
647 detector.Attach(child);
648 detector.Detach(parent);
650 // Do an entire pan, only check finished value
651 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
653 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
654 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
655 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
656 DALI_TEST_EQUALS(5.0f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
657 DALI_TEST_EQUALS(50.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
658 DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
662 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
664 TestApplication application;
666 Actor first = Actor::New();
667 first.SetSize(100.0f, 100.0f);
668 first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
669 Stage::GetCurrent().Add(first);
671 Actor second = Actor::New();
672 second.SetSize(100.0f, 100.0f);
674 second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
675 Stage::GetCurrent().Add(second);
678 application.SendNotification();
679 application.Render();
682 GestureReceivedFunctor functor(data);
684 PinchGestureDetector detector = PinchGestureDetector::New();
685 detector.Attach(first);
686 detector.Attach(second);
687 detector.DetectedSignal().Connect(&application, functor);
689 // Start pinch within second actor's area
690 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
691 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
692 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
694 // Pinch moves into first actor's area - second actor should receive the pinch
696 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(10.0f, 10.0f)));
697 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
698 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
700 // Detach the second actor during the pinch, we should not receive the next event
701 detector.Detach(second);
703 // Gesture ends within actor's area
705 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(120.0f, 10.0f)));
706 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
710 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
712 TestApplication application;
714 Actor actor = Actor::New();
715 actor.SetSize(100.0f, 100.0f);
716 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
717 Stage::GetCurrent().Add(actor);
720 application.SendNotification();
721 application.Render();
724 GestureReceivedFunctor functor(data);
726 PinchGestureDetector detector = PinchGestureDetector::New();
727 detector.Attach(actor);
728 detector.DetectedSignal().Connect(&application, functor);
730 // Start pinch in actor's area
731 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
732 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
734 // Pan continues within actor's area
736 application.ProcessEvent(GeneratePinch(Gesture::Started, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
737 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
739 // Actor become invisible - actor should not receive the next pinch
740 actor.SetVisible(false);
743 application.SendNotification();
744 application.Render();
746 // Gesture ends within actor's area
748 application.ProcessEvent(GeneratePinch(Gesture::Finished, 5.0f, 50.0f, Vector2(10.0f, 10.0f)));
749 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
753 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
755 TestApplication application;
757 Actor actor = Actor::New();
758 actor.SetSize(100.0f, 100.0f);
759 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
760 Stage::GetCurrent().Add(actor);
762 Actor actor2 = Actor::New();
763 actor2.SetSize(100.0f, 100.0f);
764 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
765 Stage::GetCurrent().Add(actor2);
768 application.SendNotification();
769 application.Render();
771 // Attach actor to one detector
772 SignalData firstData;
773 GestureReceivedFunctor firstFunctor(firstData);
774 PinchGestureDetector firstDetector = PinchGestureDetector::New();
775 firstDetector.Attach(actor);
776 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
778 // Attach actor to another detector
779 SignalData secondData;
780 GestureReceivedFunctor secondFunctor(secondData);
781 PinchGestureDetector secondDetector = PinchGestureDetector::New();
782 secondDetector.Attach(actor);
783 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
785 // Add second actor to second detector, when we remove the actor, this will make sure that this
786 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
787 // functor should still not be called (which is what we're also testing).
788 secondDetector.Attach(actor2);
790 // Pinch in actor's area - both detector's functors should be called
791 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
792 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
793 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
795 // Pinch continues in actor's area - both detector's functors should be called
798 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
799 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
800 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
802 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
803 firstDetector.Detach(actor);
806 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
807 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
808 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
810 // New pinch on actor, only secondDetector has actor attached
813 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
814 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
815 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
817 // Detach actor from secondDetector
818 secondDetector.Detach(actor);
821 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
822 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
823 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
827 int UtcDaliPinchGestureSignalReceptionMultipleStarted(void)
829 // Should handle two started events gracefully.
831 TestApplication application;
833 Actor actor = Actor::New();
834 actor.SetSize(100.0f, 100.0f);
835 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
836 Stage::GetCurrent().Add(actor);
839 GestureReceivedFunctor functor(data);
841 PinchGestureDetector detector = PinchGestureDetector::New();
842 detector.Attach(actor);
843 detector.DetectedSignal().Connect(&application, functor);
846 application.SendNotification();
847 application.Render();
849 // Start pan in actor's area
850 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
851 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
853 // Send another start in actor's area
855 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
856 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
858 // Add a child actor to overlap actor and send another start in actor's area
859 Actor child = Actor::New();
860 child.SetSize(100.0f, 100.0f);
861 child.SetAnchorPoint(AnchorPoint::CENTER);
862 child.SetParentOrigin(ParentOrigin::CENTER);
865 TouchEventFunctor touchFunctor;
866 child.TouchedSignal().Connect(&application, touchFunctor);
869 application.SendNotification();
870 application.Render();
872 // Send another start in actor's area
874 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
875 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
877 // Send another start in actor's area
879 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
880 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
884 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
886 TestApplication application;
888 Actor actor1 = Actor::New();
889 actor1.SetSize(100.0f, 100.0f);
890 actor1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
891 Stage::GetCurrent().Add(actor1);
893 GestureReceivedFunctor functor1(data1);
894 PinchGestureDetector detector1 = PinchGestureDetector::New();
895 detector1.Attach(actor1);
896 detector1.DetectedSignal().Connect(&application, functor1);
898 Actor actor2 = Actor::New();
899 actor2.SetSize(100.0f, 100.0f);
900 actor2.SetAnchorPoint(AnchorPoint::BOTTOM_RIGHT);
901 actor2.SetParentOrigin(ParentOrigin::BOTTOM_RIGHT);
902 Stage::GetCurrent().Add(actor2);
904 GestureReceivedFunctor functor2(data2);
905 PinchGestureDetector detector2 = PinchGestureDetector::New();
906 detector2.Attach(actor2);
907 detector2.DetectedSignal().Connect(&application, functor2);
910 application.SendNotification();
911 application.Render();
913 // Start pan in actor1's area, only data1 should be set
914 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
915 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
916 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
920 int UtcDaliPinchGestureEmitIncorrectStateClear(void)
922 TestApplication application;
924 Actor actor = Actor::New();
925 actor.SetSize(100.0f, 100.0f);
926 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
927 Stage::GetCurrent().Add(actor);
930 application.SendNotification();
931 application.Render();
933 // Attach actor to detector
935 GestureReceivedFunctor functor( data );
936 PinchGestureDetector detector = PinchGestureDetector::New();
937 detector.Attach(actor);
938 detector.DetectedSignal().Connect( &application, functor );
943 application.ProcessEvent(GeneratePinch(Gesture::Clear, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
944 tet_result(TET_FAIL);
946 catch ( Dali::DaliException& e )
948 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
953 int UtcDaliPinchGestureEmitIncorrectStatePossible(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 );
973 // Try a Possible state
976 application.ProcessEvent(GeneratePinch(Gesture::Possible, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
977 tet_result(TET_FAIL);
979 catch ( Dali::DaliException& e )
981 DALI_TEST_ASSERT( e, "false", TEST_LOCATION );
986 int UtcDaliPinchGestureActorUnstaged(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 // State to remove actor in.
1000 Gesture::State stateToUnstage( Gesture::Started );
1002 // Attach actor to detector
1004 UnstageActorFunctor functor( data, stateToUnstage );
1005 PinchGestureDetector detector = PinchGestureDetector::New();
1006 detector.Attach(actor);
1007 detector.DetectedSignal().Connect( &application, functor );
1010 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1011 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1013 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1014 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1017 // Render and notify
1018 application.SendNotification();
1019 application.Render();
1021 // Re-add actor to stage
1022 Stage::GetCurrent().Add(actor);
1024 // Render and notify
1025 application.SendNotification();
1026 application.Render();
1028 // Change state to Gesture::Continuing to remove
1029 stateToUnstage = Gesture::Continuing;
1032 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1033 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1035 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1036 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1038 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1039 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1042 // Render and notify
1043 application.SendNotification();
1044 application.Render();
1046 // Re-add actor to stage
1047 Stage::GetCurrent().Add(actor);
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Change state to Gesture::Continuing to remove
1054 stateToUnstage = Gesture::Finished;
1057 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1058 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1060 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1061 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1063 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1064 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1065 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
1069 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
1071 TestApplication application;
1073 Actor actor = Actor::New();
1074 actor.SetSize(100.0f, 100.0f);
1075 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1076 Stage::GetCurrent().Add(actor);
1078 // Create and add a second actor so that GestureDetector destruction does not come into play.
1079 Actor dummyActor( Actor::New() );
1080 dummyActor.SetSize( 100.0f, 100.0f );
1081 dummyActor.SetPosition( 100.0f, 100.0f );
1082 dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1083 Stage::GetCurrent().Add(dummyActor);
1085 // Render and notify
1086 application.SendNotification();
1087 application.Render();
1089 // State to remove actor in.
1090 Gesture::State stateToUnstage( Gesture::Started );
1092 // Attach actor to detector
1094 UnstageActorFunctor functor( data, stateToUnstage );
1095 PinchGestureDetector detector = PinchGestureDetector::New();
1096 detector.Attach(actor);
1097 detector.Attach(dummyActor);
1098 detector.DetectedSignal().Connect( &application, functor );
1100 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1101 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1102 // position, we should still not be signalled.
1105 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1106 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1113 // Re add to the stage, we should not be signalled
1114 Stage::GetCurrent().Add(actor);
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Continue signal emission
1121 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1122 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1124 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1125 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1128 // Here we delete an actor in started, we should not receive any subsequent signalling.
1131 application.ProcessEvent(GeneratePinch(Gesture::Started, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1132 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Delete actor as well
1142 // Render and notify
1143 application.SendNotification();
1144 application.Render();
1146 // Continue signal emission
1147 application.ProcessEvent(GeneratePinch(Gesture::Continuing, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1148 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1150 application.ProcessEvent(GeneratePinch(Gesture::Finished, 10.0f, 50.0f, Vector2(20.0f, 10.0f)));
1151 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1155 int UtcDaliPinchGestureSystemOverlay(void)
1157 TestApplication application;
1158 Dali::Integration::Core& core = application.GetCore();
1159 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1160 systemOverlay.GetOverlayRenderTasks().CreateTask();
1162 Actor actor = Actor::New();
1163 actor.SetSize(100.0f, 100.0f);
1164 actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1165 systemOverlay.Add(actor);
1167 // Render and notify
1168 application.SendNotification();
1169 application.Render();
1172 GestureReceivedFunctor functor(data);
1174 PinchGestureDetector detector = PinchGestureDetector::New();
1175 detector.Attach(actor);
1176 detector.DetectedSignal().Connect(&application, functor);
1178 Vector2 screenCoords( 50.0f, 50.0f );
1179 float scale ( 10.0f );
1180 float speed ( 50.0f );
1182 // Start pan within the actor's area
1183 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1184 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1188 int UtcDaliPinchGestureBehindTouchableSystemOverlay(void)
1190 TestApplication application;
1191 Dali::Integration::Core& core = application.GetCore();
1192 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1193 systemOverlay.GetOverlayRenderTasks().CreateTask();
1195 // SystemOverlay actor
1196 Actor systemOverlayActor = Actor::New();
1197 systemOverlayActor.SetSize(100.0f, 100.0f);
1198 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1199 systemOverlay.Add(systemOverlayActor);
1202 Actor stageActor = Actor::New();
1203 stageActor.SetSize(100.0f, 100.0f);
1204 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1205 Stage::GetCurrent().Add(stageActor);
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Set system-overlay actor to touchable
1212 TouchEventData touchData;
1213 TouchEventDataFunctor touchFunctor( touchData );
1214 systemOverlayActor.TouchedSignal().Connect(&application, touchFunctor);
1216 // Set stage actor to receive the gesture
1218 GestureReceivedFunctor functor(data);
1220 PinchGestureDetector detector = PinchGestureDetector::New();
1221 detector.Attach(stageActor);
1222 detector.DetectedSignal().Connect(&application, functor);
1224 Vector2 screenCoords( 50.0f, 50.0f );
1225 float scale ( 10.0f );
1226 float speed ( 50.0f );
1228 // Start pinch within the two actors' area
1229 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1230 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1231 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1232 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1237 // Do touch in the same area
1238 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1239 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1240 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );
1245 int UtcDaliPinchGestureTouchBehindGesturedSystemOverlay(void)
1247 TestApplication application;
1248 Dali::Integration::Core& core = application.GetCore();
1249 Dali::Integration::SystemOverlay& systemOverlay( core.GetSystemOverlay() );
1250 systemOverlay.GetOverlayRenderTasks().CreateTask();
1252 // SystemOverlay actor
1253 Actor systemOverlayActor = Actor::New();
1254 systemOverlayActor.SetSize(100.0f, 100.0f);
1255 systemOverlayActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1256 systemOverlay.Add(systemOverlayActor);
1259 Actor stageActor = Actor::New();
1260 stageActor.SetSize(100.0f, 100.0f);
1261 stageActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
1262 Stage::GetCurrent().Add(stageActor);
1264 // Render and notify
1265 application.SendNotification();
1266 application.Render();
1268 // Set stage actor to touchable
1269 TouchEventData touchData;
1270 TouchEventDataFunctor touchFunctor( touchData );
1271 stageActor.TouchedSignal().Connect(&application, touchFunctor);
1273 // Set system-overlay actor to have the gesture
1275 GestureReceivedFunctor functor(data);
1277 PinchGestureDetector detector = PinchGestureDetector::New();
1278 detector.Attach(systemOverlayActor);
1279 detector.DetectedSignal().Connect(&application, functor);
1281 Vector2 screenCoords( 50.0f, 50.0f );
1282 float scale ( 10.0f );
1283 float speed ( 50.0f );
1285 // Start pinch within the two actors' area
1286 application.ProcessEvent( GeneratePinch( Gesture::Started, scale, speed, screenCoords ) );
1287 application.ProcessEvent( GeneratePinch( Gesture::Finished, scale, speed, screenCoords ) );
1288 DALI_TEST_EQUALS( true, data.functorCalled, TEST_LOCATION );
1289 DALI_TEST_EQUALS( false, touchData.functorCalled, TEST_LOCATION );
1294 // Do touch in the same area
1295 application.ProcessEvent( touchFunctor.GenerateSingleTouch( TouchPoint::Down, screenCoords ) );
1296 DALI_TEST_EQUALS( false, data.functorCalled, TEST_LOCATION );
1297 DALI_TEST_EQUALS( true, touchData.functorCalled, TEST_LOCATION );