2 * Copyright (c) 2020 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/render-task-list-integ.h>
24 #include <dali-test-suite-utils.h>
25 #include <test-touch-utils.h>
26 #include <test-touch-data-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, Integration::Scene scene )
97 : GestureReceivedFunctor( data ),
98 stateToUnstage( stateToUnstage ),
103 void operator()( Actor actor, const PinchGesture& pinch )
105 GestureReceivedFunctor::operator()( actor, pinch );
107 if ( pinch.state == stateToUnstage )
109 scene.Remove( actor );
113 Gesture::State& stateToUnstage;
114 Integration::Scene scene;
117 // Functor for receiving a touch event
118 struct TouchEventFunctor
120 bool operator()(Actor actor, const TouchEvent& touch)
128 ///////////////////////////////////////////////////////////////////////////////
130 int UtcDaliPinchGestureDetectorConstructor(void)
132 TestApplication application;
134 PinchGestureDetector detector;
135 DALI_TEST_CHECK(!detector);
139 int UtcDaliPinchGestureDetectorCopyConstructorP(void)
141 TestApplication application;
143 PinchGestureDetector detector = PinchGestureDetector::New();;
145 PinchGestureDetector copy( detector );
146 DALI_TEST_CHECK( detector );
150 int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
152 TestApplication application;
154 PinchGestureDetector detector = PinchGestureDetector::New();;
156 PinchGestureDetector assign;
158 DALI_TEST_CHECK( detector );
160 DALI_TEST_CHECK( detector == assign );
164 int UtcDaliPinchGestureDetectorNew(void)
166 TestApplication application;
168 PinchGestureDetector detector = PinchGestureDetector::New();
170 DALI_TEST_CHECK(detector);
172 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
173 Actor actor = Actor::New();
174 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
175 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
176 application.GetScene().Add(actor);
179 application.SendNotification();
180 application.Render();
182 detector.Attach(actor);
184 Integration::TouchEvent touchEvent(1);
185 Integration::Point point;
186 point.SetDeviceId( 1 );
187 point.SetState( PointState::DOWN );
188 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
189 touchEvent.AddPoint(point);
190 application.ProcessEvent(touchEvent);
192 Integration::Point point2;
193 point.SetDeviceId( 1 );
194 point.SetState( PointState::DOWN );
195 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
196 touchEvent.AddPoint(point2);
197 application.ProcessEvent(touchEvent);
201 int UtcDaliPinchGestureDetectorDownCast(void)
203 TestApplication application;
204 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
206 PinchGestureDetector detector = PinchGestureDetector::New();
208 BaseHandle object(detector);
210 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
211 DALI_TEST_CHECK(detector2);
213 PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object);
214 DALI_TEST_CHECK(detector3);
216 BaseHandle unInitializedObject;
217 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
218 DALI_TEST_CHECK(!detector4);
220 PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject);
221 DALI_TEST_CHECK(!detector5);
223 GestureDetector detector6 = PinchGestureDetector::New();
224 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
225 DALI_TEST_CHECK(detector7);
229 // Negative test case for a method
230 int UtcDaliPinchGestureSignalReceptionNegative(void)
232 TestApplication application;
234 Actor actor = Actor::New();
235 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
236 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
237 application.GetScene().Add(actor);
240 application.SendNotification();
241 application.Render();
244 GestureReceivedFunctor functor(data);
246 PinchGestureDetector detector = PinchGestureDetector::New();
247 detector.Attach(actor);
248 detector.DetectedSignal().Connect(&application, functor);
250 // Do a pinch outside actor's area
251 TestStartPinch( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
252 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
254 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
256 // Continue pinch into actor's area - we should still not receive the signal
258 TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
259 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
261 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
263 // Stop pinching - we should still not receive the signal
265 TestEndPinch( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
266 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
268 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
272 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
274 TestApplication application;
276 Actor actor = Actor::New();
277 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
278 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
279 application.GetScene().Add(actor);
282 application.SendNotification();
283 application.Render();
286 GestureReceivedFunctor functor(data);
288 PinchGestureDetector detector = PinchGestureDetector::New();
289 detector.Attach(actor);
290 detector.DetectedSignal().Connect(&application, functor);
292 // Start pan within the actor's area
293 TestStartPinch( application, Vector2( 5.0f, 20.0f ), Vector2( 35.0f, 20.0f ),
294 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
295 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
296 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
297 DALI_TEST_EQUALS(0.666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
298 DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
299 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
301 // Continue the pan within the actor's area - we should still receive the signal
303 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
304 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
305 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
306 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
307 DALI_TEST_EQUALS(0.2666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
308 DALI_TEST_EQUALS(80.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
309 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
311 // Pan Gesture leaves actor's area - we should still receive the signal
313 TestContinuePinch( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
314 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
315 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
316 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
317 DALI_TEST_EQUALS(1.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
318 DALI_TEST_EQUALS(213.333f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
319 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
321 // Gesture ends - we would receive a finished state
323 TestEndPinch( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
324 Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
325 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
326 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
327 DALI_TEST_EQUALS(0.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
328 DALI_TEST_EQUALS(600.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
329 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
333 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
335 TestApplication application;
337 Actor actor = Actor::New();
338 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
339 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
340 application.GetScene().Add(actor);
343 application.SendNotification();
344 application.Render();
347 GestureReceivedFunctor functor(data);
349 PinchGestureDetector detector = PinchGestureDetector::New();
350 detector.Attach(actor);
351 detector.DetectedSignal().Connect(&application, functor);
353 // Start pinch within the actor's area
354 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
355 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
356 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
357 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
358 DALI_TEST_EQUALS(0.555f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
359 DALI_TEST_EQUALS(106.667f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
360 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
362 // Continue the pinch within the actor's area - we should still receive the signal
364 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
365 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
366 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
367 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
368 DALI_TEST_EQUALS(0.277f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
369 DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
370 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
372 // Gesture ends within actor's area - we would receive a finished state
374 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
375 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
376 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
377 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
378 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
379 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
380 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
384 int UtcDaliPinchGestureSignalReceptionDetach(void)
386 TestApplication application;
388 Actor actor = Actor::New();
389 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
390 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
391 application.GetScene().Add(actor);
394 application.SendNotification();
395 application.Render();
398 GestureReceivedFunctor functor(data);
400 PinchGestureDetector detector = PinchGestureDetector::New();
401 detector.Attach(actor);
402 detector.DetectedSignal().Connect(&application, functor);
404 // Start pinch within the actor's area
405 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
406 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
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 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
414 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
415 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
416 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
418 // Gesture ends within actor's area
420 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
421 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
422 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
423 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
426 detector.DetachAll();
428 // Ensure we are no longer signalled
430 TestGeneratePinch( application );
431 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
435 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
437 TestApplication application;
439 Actor actor = Actor::New();
440 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
441 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
442 application.GetScene().Add(actor);
445 application.SendNotification();
446 application.Render();
449 GestureReceivedFunctor functor(data);
451 PinchGestureDetector detector = PinchGestureDetector::New();
452 detector.Attach(actor);
453 detector.DetectedSignal().Connect(&application, functor);
455 // Start pinch within the actor's area
456 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
457 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
458 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
459 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
461 // Continue the pinch within the actor's area - we should still receive the signal
463 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
464 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
465 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
466 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
468 // Detach actor during the pinch, we should not receive the next event
469 detector.DetachAll();
471 // Gesture ends within actor's area
473 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
474 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
475 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
479 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
481 TestApplication application;
484 GestureReceivedFunctor functor(data);
486 PinchGestureDetector detector = PinchGestureDetector::New();
487 detector.DetectedSignal().Connect(&application, functor);
489 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
491 Actor tempActor = Actor::New();
492 tempActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
493 tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
494 application.GetScene().Add(tempActor);
495 detector.Attach(tempActor);
497 // Actor lifetime is scoped
499 Actor actor = Actor::New();
500 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
501 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
502 application.GetScene().Add(actor);
505 application.SendNotification();
506 application.Render();
508 detector.Attach(actor);
510 // Start pinch within the actor's area
511 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
512 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
513 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
514 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
516 // Continue the pinch within the actor's area - we should still receive the signal
518 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
519 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
520 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
521 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
523 // Remove the actor from stage and reset the data
524 application.GetScene().Remove(actor);
527 application.SendNotification();
528 application.Render();
531 // Actor should now have been destroyed
533 // Gesture ends within the area where the actor used to be
535 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
536 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
537 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
541 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
543 TestApplication application;
545 Actor actor = Actor::New();
546 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
547 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
548 application.GetScene().Add(actor);
550 // Render and notify a couple of times
551 application.SendNotification();
552 application.Render();
555 GestureReceivedFunctor functor(data);
557 PinchGestureDetector detector = PinchGestureDetector::New();
558 detector.Attach(actor);
559 detector.DetectedSignal().Connect(&application, functor);
561 // Do an entire pinch, only check finished value
562 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
563 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
565 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
566 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
567 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
568 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
569 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
570 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
572 // Rotate actor again and render and notify
573 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
574 application.SendNotification();
575 application.Render();
577 // Do an entire pinch, only check finished value
578 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
579 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
581 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
582 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
583 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
584 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
585 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
586 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
588 // Rotate actor again and render and notify
589 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) );
590 application.SendNotification();
591 application.Render();
593 // Do an entire pinch, only check finished value
594 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
595 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
597 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
598 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 5000);
599 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
600 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
601 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
602 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
606 int UtcDaliPinchGestureSignalReceptionChildHit(void)
608 TestApplication application;
610 Actor parent = Actor::New();
611 parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
612 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
613 application.GetScene().Add(parent);
615 // Set child to completely cover parent.
616 // Change rotation of child to be different from parent so that we can check if our local coordinate
617 // conversion of the parent actor is correct.
618 Actor child = Actor::New();
619 child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
620 child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
621 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
622 child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
625 TouchEventFunctor touchFunctor;
626 child.TouchedSignal().Connect(&application, touchFunctor);
629 application.SendNotification();
630 application.Render();
633 GestureReceivedFunctor functor(data);
635 PinchGestureDetector detector = PinchGestureDetector::New();
636 detector.Attach(parent);
637 detector.DetectedSignal().Connect(&application, functor);
639 // Do an entire pan, only check finished value - hits child area but parent should still receive it
640 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
641 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
643 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
644 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
645 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
646 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
647 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
648 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
649 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
651 // Attach child and generate same touch points to yield same results
652 // (Also proves that you can detach and then re-attach another actor)
653 detector.Attach(child);
654 detector.Detach(parent);
656 // Do an entire pan, only check finished value
657 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
658 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
660 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
661 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
662 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
663 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
664 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
665 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
666 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
670 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
672 TestApplication application;
674 Actor first = Actor::New();
675 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
676 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
677 application.GetScene().Add(first);
679 Actor second = Actor::New();
680 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
681 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
682 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
683 application.GetScene().Add(second);
686 application.SendNotification();
687 application.Render();
690 GestureReceivedFunctor functor(data);
692 PinchGestureDetector detector = PinchGestureDetector::New();
693 detector.Attach(first);
694 detector.Attach(second);
695 detector.DetectedSignal().Connect(&application, functor);
697 // Start pinch within second actor's area
698 TestStartPinch( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
699 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
700 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
701 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
703 // Pinch moves into first actor's area - second actor should receive the pinch
705 TestContinuePinch( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
706 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
707 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
708 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
710 // Detach the second actor during the pinch, we should not receive the next event
711 detector.Detach(second);
713 // Gesture ends within actor's area
715 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
716 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
717 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
721 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
723 TestApplication application;
725 Actor actor = Actor::New();
726 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
727 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
728 application.GetScene().Add(actor);
731 application.SendNotification();
732 application.Render();
735 GestureReceivedFunctor functor(data);
737 PinchGestureDetector detector = PinchGestureDetector::New();
738 detector.Attach(actor);
739 detector.DetectedSignal().Connect(&application, functor);
741 // Start pinch in actor's area
742 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
743 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
744 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
746 // Pan continues within actor's area
748 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
749 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
750 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
752 // Actor become invisible - actor should not receive the next pinch
753 actor.SetProperty( Actor::Property::VISIBLE,false);
756 application.SendNotification();
757 application.Render();
759 // Gesture ends within actor's area
761 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
762 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
763 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
767 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
769 TestApplication application;
771 Actor actor = Actor::New();
772 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
773 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
774 application.GetScene().Add(actor);
776 Actor actor2 = Actor::New();
777 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
778 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
779 application.GetScene().Add(actor2);
782 application.SendNotification();
783 application.Render();
785 // Attach actor to one detector
786 SignalData firstData;
787 GestureReceivedFunctor firstFunctor(firstData);
788 PinchGestureDetector firstDetector = PinchGestureDetector::New();
789 firstDetector.Attach(actor);
790 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
792 // Attach actor to another detector
793 SignalData secondData;
794 GestureReceivedFunctor secondFunctor(secondData);
795 PinchGestureDetector secondDetector = PinchGestureDetector::New();
796 secondDetector.Attach(actor);
797 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
799 // Add second actor to second detector, when we remove the actor, this will make sure that this
800 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
801 // functor should still not be called (which is what we're also testing).
802 secondDetector.Attach(actor2);
804 // Pinch in actor's area - both detector's functors should be called
805 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
806 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
807 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
808 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
810 // Pinch continues in actor's area - both detector's functors should be called
813 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
814 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
815 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
816 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
818 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
819 firstDetector.Detach(actor);
822 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
823 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
824 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
825 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
827 // New pinch on actor, only secondDetector has actor attached
830 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
831 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
832 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
833 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
835 // Detach actor from secondDetector
836 secondDetector.Detach(actor);
839 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
840 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
841 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
842 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
846 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
848 TestApplication application;
850 Actor actor1 = Actor::New();
851 actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
852 actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
853 application.GetScene().Add(actor1);
855 GestureReceivedFunctor functor1(data1);
856 PinchGestureDetector detector1 = PinchGestureDetector::New();
857 detector1.Attach(actor1);
858 detector1.DetectedSignal().Connect(&application, functor1);
860 Actor actor2 = Actor::New();
861 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
862 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
863 actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
864 application.GetScene().Add(actor2);
866 GestureReceivedFunctor functor2(data2);
867 PinchGestureDetector detector2 = PinchGestureDetector::New();
868 detector2.Attach(actor2);
869 detector2.DetectedSignal().Connect(&application, functor2);
872 application.SendNotification();
873 application.Render();
875 // Start pan in actor1's area, only data1 should be set
876 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
877 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
878 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
879 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
883 int UtcDaliPinchGestureActorUnstaged(void)
885 TestApplication application;
887 Actor actor = Actor::New();
888 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
889 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
890 application.GetScene().Add(actor);
893 application.SendNotification();
894 application.Render();
896 // State to remove actor in.
897 Gesture::State stateToUnstage( Gesture::Started );
899 // Attach actor to detector
901 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
902 PinchGestureDetector detector = PinchGestureDetector::New();
903 detector.Attach(actor);
904 detector.DetectedSignal().Connect( &application, functor );
907 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
908 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
909 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
911 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
912 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
913 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
917 application.SendNotification();
918 application.Render();
920 // Re-add actor to stage
921 application.GetScene().Add(actor);
924 application.SendNotification();
925 application.Render();
927 // Change state to Gesture::Continuing to remove
928 stateToUnstage = Gesture::Continuing;
931 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
932 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
933 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
935 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
936 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
937 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
939 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
940 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
941 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
945 application.SendNotification();
946 application.Render();
948 // Re-add actor to stage
949 application.GetScene().Add(actor);
952 application.SendNotification();
953 application.Render();
955 // Change state to Gesture::Continuing to remove
956 stateToUnstage = Gesture::Finished;
959 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
960 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
961 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
963 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
964 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
965 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
967 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
968 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
969 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
970 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
974 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
976 TestApplication application;
978 Actor actor = Actor::New();
979 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
980 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
981 application.GetScene().Add(actor);
983 // Create and add a second actor so that GestureDetector destruction does not come into play.
984 Actor dummyActor( Actor::New() );
985 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
986 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
987 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
988 application.GetScene().Add(dummyActor);
991 application.SendNotification();
992 application.Render();
994 // State to remove actor in.
995 Gesture::State stateToUnstage( Gesture::Started );
997 // Attach actor to detector
999 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
1000 PinchGestureDetector detector = PinchGestureDetector::New();
1001 detector.Attach(actor);
1002 detector.Attach(dummyActor);
1003 detector.DetectedSignal().Connect( &application, functor );
1005 // Here we are testing a Started actor which is removed in the Started callback, but then added back
1006 // before we get a continuing state. As we were removed from the stage, even if we're at the same
1007 // position, we should still not be signalled.
1010 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1011 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1012 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1015 // Render and notify
1016 application.SendNotification();
1017 application.Render();
1019 // Re add to the stage, we should not be signalled
1020 application.GetScene().Add(actor);
1022 // Render and notify
1023 application.SendNotification();
1024 application.Render();
1026 // Continue signal emission
1027 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1028 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1029 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1031 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1032 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1033 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1036 // Here we delete an actor in started, we should not receive any subsequent signalling.
1039 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1040 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1041 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1044 // Render and notify
1045 application.SendNotification();
1046 application.Render();
1048 // Delete actor as well
1051 // Render and notify
1052 application.SendNotification();
1053 application.Render();
1055 // Continue signal emission
1056 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1057 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1058 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1060 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1061 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1062 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1066 int UtcDaliPinchGestureLayerConsumesTouch(void)
1068 TestApplication application;
1070 Actor actor = Actor::New();
1071 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1072 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1073 application.GetScene().Add(actor);
1077 GestureReceivedFunctor functor(data);
1078 PinchGestureDetector detector = PinchGestureDetector::New();
1079 detector.Attach(actor);
1080 detector.DetectedSignal().Connect( &application, functor );
1082 // Add a layer to overlap the actor
1083 Layer layer = Layer::New();
1084 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1085 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1086 application.GetScene().Add( layer );
1089 // Render and notify
1090 application.SendNotification();
1091 application.Render();
1093 // Emit signals, should receive
1094 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1095 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1096 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1097 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1098 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1101 // Set layer to consume all touch
1102 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1104 // Render and notify
1105 application.SendNotification();
1106 application.Render();
1108 // Emit the same signals again, should not receive
1109 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1110 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1111 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1112 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1113 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1119 int UtcDaliPinchGestureInterruptedWhenTouchConsumed(void)
1121 TestApplication application;
1123 Actor actor = Actor::New();
1124 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1125 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1126 application.GetScene().Add(actor);
1128 bool consume = false;
1129 TouchDataFunctorConsumeSetter touchFunctor(consume);
1130 actor.TouchSignal().Connect(&application,touchFunctor);
1132 // Render and notify
1133 application.SendNotification();
1134 application.Render();
1137 GestureReceivedFunctor functor(data);
1139 PinchGestureDetector detector = PinchGestureDetector::New();
1140 detector.Attach(actor);
1141 detector.DetectedSignal().Connect(&application, functor);
1143 // Start gesture within the actor's area, we should receive the pinch as the touch is NOT being consumed
1144 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1145 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1147 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1148 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
1151 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1154 TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1155 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1157 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1158 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
1161 // Start another pinch, we should not even get the callback this time
1162 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1163 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1164 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);