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-event-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, const 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, Integration::Scene scene )
96 : GestureReceivedFunctor( data ),
97 stateToUnstage( stateToUnstage ),
102 void operator()( Actor actor, const PinchGesture& pinch )
104 GestureReceivedFunctor::operator()( actor, pinch );
106 if ( pinch.state == stateToUnstage )
108 scene.Remove( actor );
112 Gesture::State& stateToUnstage;
113 Integration::Scene scene;
118 ///////////////////////////////////////////////////////////////////////////////
120 int UtcDaliPinchGestureDetectorConstructor(void)
122 TestApplication application;
124 PinchGestureDetector detector;
125 DALI_TEST_CHECK(!detector);
129 int UtcDaliPinchGestureDetectorCopyConstructorP(void)
131 TestApplication application;
133 PinchGestureDetector detector = PinchGestureDetector::New();;
135 PinchGestureDetector copy( detector );
136 DALI_TEST_CHECK( detector );
140 int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
142 TestApplication application;
144 PinchGestureDetector detector = PinchGestureDetector::New();;
146 PinchGestureDetector assign;
148 DALI_TEST_CHECK( detector );
150 DALI_TEST_CHECK( detector == assign );
154 int UtcDaliPinchGestureDetectorNew(void)
156 TestApplication application;
158 PinchGestureDetector detector = PinchGestureDetector::New();
160 DALI_TEST_CHECK(detector);
162 // Attach an actor and emit a touch event on the actor to ensure complete line coverage
163 Actor actor = Actor::New();
164 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
165 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
166 application.GetScene().Add(actor);
169 application.SendNotification();
170 application.Render();
172 detector.Attach(actor);
174 Integration::TouchEvent touchEvent(1);
175 Integration::Point point;
176 point.SetDeviceId( 1 );
177 point.SetState( PointState::DOWN );
178 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
179 touchEvent.AddPoint(point);
180 application.ProcessEvent(touchEvent);
182 Integration::Point point2;
183 point.SetDeviceId( 1 );
184 point.SetState( PointState::DOWN );
185 point.SetScreenPosition( Vector2( 20.0f, 20.0f ) );
186 touchEvent.AddPoint(point2);
187 application.ProcessEvent(touchEvent);
191 int UtcDaliPinchGestureDetectorDownCast(void)
193 TestApplication application;
194 tet_infoline("Testing Dali::PinchGestureDetector::DownCast()");
196 PinchGestureDetector detector = PinchGestureDetector::New();
198 BaseHandle object(detector);
200 PinchGestureDetector detector2 = PinchGestureDetector::DownCast(object);
201 DALI_TEST_CHECK(detector2);
203 PinchGestureDetector detector3 = DownCast< PinchGestureDetector >(object);
204 DALI_TEST_CHECK(detector3);
206 BaseHandle unInitializedObject;
207 PinchGestureDetector detector4 = PinchGestureDetector::DownCast(unInitializedObject);
208 DALI_TEST_CHECK(!detector4);
210 PinchGestureDetector detector5 = DownCast< PinchGestureDetector >(unInitializedObject);
211 DALI_TEST_CHECK(!detector5);
213 GestureDetector detector6 = PinchGestureDetector::New();
214 PinchGestureDetector detector7 = PinchGestureDetector::DownCast(detector6);
215 DALI_TEST_CHECK(detector7);
219 // Negative test case for a method
220 int UtcDaliPinchGestureSignalReceptionNegative(void)
222 TestApplication application;
224 Actor actor = Actor::New();
225 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
226 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
227 application.GetScene().Add(actor);
230 application.SendNotification();
231 application.Render();
234 GestureReceivedFunctor functor(data);
236 PinchGestureDetector detector = PinchGestureDetector::New();
237 detector.Attach(actor);
238 detector.DetectedSignal().Connect(&application, functor);
240 // Do a pinch outside actor's area
241 TestStartPinch( application, Vector2( 112.0f, 62.0f ), Vector2( 112.0f, 162.0f ),
242 Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ), 100 );
244 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
246 // Continue pinch into actor's area - we should still not receive the signal
248 TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
249 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
251 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
253 // Stop pinching - we should still not receive the signal
255 TestEndPinch( application, Vector2( 6.0f, 6.0f ), Vector2( 18.0f, 18.0f ),
256 Vector2( 10.0f, 8.0f ), Vector2( 14.0f, 16.0f ), 300 );
258 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
262 int UtcDaliPinchGestureSignalReceptionDownMotionLeave(void)
264 TestApplication application;
266 Actor actor = Actor::New();
267 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
268 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
269 application.GetScene().Add(actor);
272 application.SendNotification();
273 application.Render();
276 GestureReceivedFunctor functor(data);
278 PinchGestureDetector detector = PinchGestureDetector::New();
279 detector.Attach(actor);
280 detector.DetectedSignal().Connect(&application, functor);
282 // Start pan within the actor's area
283 TestStartPinch( application, Vector2( 5.0f, 20.0f ), Vector2( 35.0f, 20.0f ),
284 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
285 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
286 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
287 DALI_TEST_EQUALS(0.666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
288 DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
289 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
291 // Continue the pan within the actor's area - we should still receive the signal
293 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
294 Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 400 );
295 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
296 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
297 DALI_TEST_EQUALS(0.2666f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
298 DALI_TEST_EQUALS(80.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
299 DALI_TEST_EQUALS(Vector2(21.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
301 // Pan Gesture leaves actor's area - we should still receive the signal
303 TestContinuePinch( application, Vector2( 17.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
304 Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ), 1000 );
305 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
306 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
307 DALI_TEST_EQUALS(1.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
308 DALI_TEST_EQUALS(213.333f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
309 DALI_TEST_EQUALS(Vector2(320.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
311 // Gesture ends - we would receive a finished state
313 TestEndPinch( application, Vector2( 300.0f, 10.0f ), Vector2( 340.0f, 10.0f ),
314 Vector2( 305.0f, 10.0f ), Vector2( 315.0f, 10.0f ), 1500);
315 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
316 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
317 DALI_TEST_EQUALS(0.333f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
318 DALI_TEST_EQUALS(600.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
319 DALI_TEST_EQUALS(Vector2(310.0f, 10.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
323 int UtcDaliPinchGestureSignalReceptionDownMotionUp(void)
325 TestApplication application;
327 Actor actor = Actor::New();
328 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
329 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
330 application.GetScene().Add(actor);
333 application.SendNotification();
334 application.Render();
337 GestureReceivedFunctor functor(data);
339 PinchGestureDetector detector = PinchGestureDetector::New();
340 detector.Attach(actor);
341 detector.DetectedSignal().Connect(&application, functor);
343 // Start pinch within the actor's area
344 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
345 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
346 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
347 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
348 DALI_TEST_EQUALS(0.555f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
349 DALI_TEST_EQUALS(106.667f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
350 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
352 // Continue the pinch within the actor's area - we should still receive the signal
354 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
355 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
356 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
357 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
358 DALI_TEST_EQUALS(0.277f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
359 DALI_TEST_EQUALS(66.666f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
360 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
362 // Gesture ends within actor's area - we would receive a finished state
364 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
365 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
366 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
367 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
368 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
369 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
370 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
374 int UtcDaliPinchGestureSignalReceptionDetach(void)
376 TestApplication application;
378 Actor actor = Actor::New();
379 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
380 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
381 application.GetScene().Add(actor);
384 application.SendNotification();
385 application.Render();
388 GestureReceivedFunctor functor(data);
390 PinchGestureDetector detector = PinchGestureDetector::New();
391 detector.Attach(actor);
392 detector.DetectedSignal().Connect(&application, functor);
394 // Start pinch within the actor's area
395 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
396 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
397 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
398 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
401 // Continue the pinch within the actor's area - we should still receive the signal
403 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
404 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
405 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
406 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
408 // Gesture ends within actor's area
410 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
411 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
412 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
413 DALI_TEST_EQUALS(Gesture::Finished, data.receivedGesture.state, TEST_LOCATION);
416 detector.DetachAll();
418 // Ensure we are no longer signalled
420 TestGeneratePinch( application );
421 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
425 int UtcDaliPinchGestureSignalReceptionDetachWhilePinching(void)
427 TestApplication application;
429 Actor actor = Actor::New();
430 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
431 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
432 application.GetScene().Add(actor);
435 application.SendNotification();
436 application.Render();
439 GestureReceivedFunctor functor(data);
441 PinchGestureDetector detector = PinchGestureDetector::New();
442 detector.Attach(actor);
443 detector.DetectedSignal().Connect(&application, functor);
445 // Start pinch within the actor's area
446 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
447 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
448 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
449 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
451 // Continue the pinch within the actor's area - we should still receive the signal
453 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
454 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
455 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
456 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
458 // Detach actor during the pinch, we should not receive the next event
459 detector.DetachAll();
461 // Gesture ends within actor's area
463 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
464 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
465 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
469 int UtcDaliPinchGestureSignalReceptionActorDestroyedWhilePinching(void)
471 TestApplication application;
474 GestureReceivedFunctor functor(data);
476 PinchGestureDetector detector = PinchGestureDetector::New();
477 detector.DetectedSignal().Connect(&application, functor);
479 // Attach a temporary actor to stop detector being removed from PinchGestureProcessor when main actor
481 Actor tempActor = Actor::New();
482 tempActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
483 tempActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
484 application.GetScene().Add(tempActor);
485 detector.Attach(tempActor);
487 // Actor lifetime is scoped
489 Actor actor = Actor::New();
490 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
491 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
492 application.GetScene().Add(actor);
495 application.SendNotification();
496 application.Render();
498 detector.Attach(actor);
500 // Start pinch within the actor's area
501 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
502 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
503 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
504 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
506 // Continue the pinch within the actor's area - we should still receive the signal
508 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
509 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
510 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
511 DALI_TEST_EQUALS(Gesture::Continuing, data.receivedGesture.state, TEST_LOCATION);
513 // Remove the actor from stage and reset the data
514 application.GetScene().Remove(actor);
517 application.SendNotification();
518 application.Render();
521 // Actor should now have been destroyed
523 // Gesture ends within the area where the actor used to be
525 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
526 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
527 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
531 int UtcDaliPinchGestureSignalReceptionRotatedActor(void)
533 TestApplication application;
535 Actor actor = Actor::New();
536 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
537 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
538 application.GetScene().Add(actor);
540 // Render and notify a couple of times
541 application.SendNotification();
542 application.Render();
545 GestureReceivedFunctor functor(data);
547 PinchGestureDetector detector = PinchGestureDetector::New();
548 detector.Attach(actor);
549 detector.DetectedSignal().Connect(&application, functor);
551 // Do an entire pinch, only check finished value
552 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
553 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
555 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
556 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
557 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
558 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
559 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
560 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
562 // Rotate actor again and render and notify
563 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
564 application.SendNotification();
565 application.Render();
567 // Do an entire pinch, only check finished value
568 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
569 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
571 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
572 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
573 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
574 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
575 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
576 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
578 // Rotate actor again and render and notify
579 actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(270.0f), Vector3::ZAXIS) );
580 application.SendNotification();
581 application.Render();
583 // Do an entire pinch, only check finished value
584 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
585 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 4100 );
587 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
588 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 5000);
589 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
590 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
591 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
592 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
596 int UtcDaliPinchGestureSignalReceptionChildHit(void)
598 TestApplication application;
600 Actor parent = Actor::New();
601 parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
602 parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
603 application.GetScene().Add(parent);
605 // Set child to completely cover parent.
606 // Change rotation of child to be different from parent so that we can check if our local coordinate
607 // conversion of the parent actor is correct.
608 Actor child = Actor::New();
609 child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
610 child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
611 child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
612 child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
616 application.SendNotification();
617 application.Render();
620 GestureReceivedFunctor functor(data);
622 PinchGestureDetector detector = PinchGestureDetector::New();
623 detector.Attach(parent);
624 detector.DetectedSignal().Connect(&application, functor);
626 // Do an entire pan, only check finished value - hits child area but parent should still receive it
627 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
628 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
630 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
631 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
632 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
633 DALI_TEST_EQUALS(true, parent == data.pinchedActor, TEST_LOCATION);
634 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
635 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
636 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
638 // Attach child and generate same touch points to yield same results
639 // (Also proves that you can detach and then re-attach another actor)
640 detector.Attach(child);
641 detector.Detach(parent);
643 // Do an entire pan, only check finished value
644 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
645 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 2100 );
647 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
648 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
649 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
650 DALI_TEST_EQUALS(true, child == data.pinchedActor, TEST_LOCATION);
651 DALI_TEST_EQUALS(0.055f, data.receivedGesture.scale, 0.01f, TEST_LOCATION);
652 DALI_TEST_EQUALS(160.0f, data.receivedGesture.speed, 0.01f, TEST_LOCATION);
653 DALI_TEST_EQUALS(Vector2(20.0f, 20.0f), data.receivedGesture.screenCenterPoint, 0.01f, TEST_LOCATION);
657 int UtcDaliPinchGestureSignalReceptionAttachDetachMany(void)
659 TestApplication application;
661 Actor first = Actor::New();
662 first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
663 first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
664 application.GetScene().Add(first);
666 Actor second = Actor::New();
667 second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
668 second.SetProperty( Actor::Property::POSITION_X, 100.0f);
669 second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
670 application.GetScene().Add(second);
673 application.SendNotification();
674 application.Render();
677 GestureReceivedFunctor functor(data);
679 PinchGestureDetector detector = PinchGestureDetector::New();
680 detector.Attach(first);
681 detector.Attach(second);
682 detector.DetectedSignal().Connect(&application, functor);
684 // Start pinch within second actor's area
685 TestStartPinch( application, Vector2( 102.0f, 20.0f ), Vector2( 138.0f, 20.0f ),
686 Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ), 100 );
687 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
688 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
690 // Pinch moves into first actor's area - second actor should receive the pinch
692 TestContinuePinch( application, Vector2( 110.0f, 20.0f ), Vector2( 130.0f, 20.0f ),
693 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
694 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
695 DALI_TEST_EQUALS(true, second == data.pinchedActor, TEST_LOCATION);
697 // Detach the second actor during the pinch, we should not receive the next event
698 detector.Detach(second);
700 // Gesture ends within actor's area
702 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
703 Vector2( 119.0f, 20.0f ), Vector2( 121.0f, 20.0f ), 3000);
704 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
708 int UtcDaliPinchGestureSignalReceptionActorBecomesUntouchable(void)
710 TestApplication application;
712 Actor actor = Actor::New();
713 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
714 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
715 application.GetScene().Add(actor);
718 application.SendNotification();
719 application.Render();
722 GestureReceivedFunctor functor(data);
724 PinchGestureDetector detector = PinchGestureDetector::New();
725 detector.Attach(actor);
726 detector.DetectedSignal().Connect(&application, functor);
728 // Start pinch in actor's area
729 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
730 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
731 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
733 // Pan continues within actor's area
735 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
736 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
737 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
739 // Actor become invisible - actor should not receive the next pinch
740 actor.SetProperty( Actor::Property::VISIBLE,false);
743 application.SendNotification();
744 application.Render();
746 // Gesture ends within actor's area
748 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
749 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
750 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
754 int UtcDaliPinchGestureSignalReceptionMultipleDetectorsOnActor(void)
756 TestApplication application;
758 Actor actor = Actor::New();
759 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
760 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
761 application.GetScene().Add(actor);
763 Actor actor2 = Actor::New();
764 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
765 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
766 application.GetScene().Add(actor2);
769 application.SendNotification();
770 application.Render();
772 // Attach actor to one detector
773 SignalData firstData;
774 GestureReceivedFunctor firstFunctor(firstData);
775 PinchGestureDetector firstDetector = PinchGestureDetector::New();
776 firstDetector.Attach(actor);
777 firstDetector.DetectedSignal().Connect(&application, firstFunctor);
779 // Attach actor to another detector
780 SignalData secondData;
781 GestureReceivedFunctor secondFunctor(secondData);
782 PinchGestureDetector secondDetector = PinchGestureDetector::New();
783 secondDetector.Attach(actor);
784 secondDetector.DetectedSignal().Connect(&application, secondFunctor);
786 // Add second actor to second detector, when we remove the actor, this will make sure that this
787 // gesture detector is not removed from the GestureDetectorProcessor. In this scenario, the
788 // functor should still not be called (which is what we're also testing).
789 secondDetector.Attach(actor2);
791 // Pinch in actor's area - both detector's functors should be called
792 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
793 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
794 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
795 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
797 // Pinch continues in actor's area - both detector's functors should be called
800 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
801 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
802 DALI_TEST_EQUALS(true, firstData.functorCalled, TEST_LOCATION);
803 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
805 // Detach actor from firstDetector and emit pinch on actor, only secondDetector's functor should be called.
806 firstDetector.Detach(actor);
809 TestEndPinch( application, Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ),
810 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
811 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
812 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
814 // New pinch on actor, only secondDetector has actor attached
817 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
818 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
819 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
820 DALI_TEST_EQUALS(true, secondData.functorCalled, TEST_LOCATION);
822 // Detach actor from secondDetector
823 secondDetector.Detach(actor);
826 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
827 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
828 DALI_TEST_EQUALS(false, firstData.functorCalled, TEST_LOCATION);
829 DALI_TEST_EQUALS(false, secondData.functorCalled, TEST_LOCATION);
833 int UtcDaliPinchGestureSignalReceptionEnsureCorrectSignalling(void)
835 TestApplication application;
837 Actor actor1 = Actor::New();
838 actor1.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
839 actor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
840 application.GetScene().Add(actor1);
842 GestureReceivedFunctor functor1(data1);
843 PinchGestureDetector detector1 = PinchGestureDetector::New();
844 detector1.Attach(actor1);
845 detector1.DetectedSignal().Connect(&application, functor1);
847 Actor actor2 = Actor::New();
848 actor2.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
849 actor2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::BOTTOM_RIGHT);
850 actor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::BOTTOM_RIGHT);
851 application.GetScene().Add(actor2);
853 GestureReceivedFunctor functor2(data2);
854 PinchGestureDetector detector2 = PinchGestureDetector::New();
855 detector2.Attach(actor2);
856 detector2.DetectedSignal().Connect(&application, functor2);
859 application.SendNotification();
860 application.Render();
862 // Start pan in actor1's area, only data1 should be set
863 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
864 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
865 DALI_TEST_EQUALS(true, data1.functorCalled, TEST_LOCATION);
866 DALI_TEST_EQUALS(false, data2.functorCalled, TEST_LOCATION);
870 int UtcDaliPinchGestureActorUnstaged(void)
872 TestApplication application;
874 Actor actor = Actor::New();
875 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
876 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
877 application.GetScene().Add(actor);
880 application.SendNotification();
881 application.Render();
883 // State to remove actor in.
884 Gesture::State stateToUnstage( Gesture::Started );
886 // Attach actor to detector
888 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
889 PinchGestureDetector detector = PinchGestureDetector::New();
890 detector.Attach(actor);
891 detector.DetectedSignal().Connect( &application, functor );
894 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
895 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
896 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
898 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
899 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
900 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
904 application.SendNotification();
905 application.Render();
907 // Re-add actor to stage
908 application.GetScene().Add(actor);
911 application.SendNotification();
912 application.Render();
914 // Change state to Gesture::Continuing to remove
915 stateToUnstage = Gesture::Continuing;
918 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
919 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
920 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
922 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
923 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
924 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
926 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
927 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
928 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
932 application.SendNotification();
933 application.Render();
935 // Re-add actor to stage
936 application.GetScene().Add(actor);
939 application.SendNotification();
940 application.Render();
942 // Change state to Gesture::Continuing to remove
943 stateToUnstage = Gesture::Finished;
946 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
947 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
948 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
950 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
951 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
952 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
954 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
955 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
956 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
957 tet_result( TET_PASS ); // If we get here then we have handled actor stage removal gracefully.
961 int UtcDaliPinchGestureActorStagedAndDestroyed(void)
963 TestApplication application;
965 Actor actor = Actor::New();
966 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
967 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
968 application.GetScene().Add(actor);
970 // Create and add a second actor so that GestureDetector destruction does not come into play.
971 Actor dummyActor( Actor::New() );
972 dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
973 dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
974 dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
975 application.GetScene().Add(dummyActor);
978 application.SendNotification();
979 application.Render();
981 // State to remove actor in.
982 Gesture::State stateToUnstage( Gesture::Started );
984 // Attach actor to detector
986 UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
987 PinchGestureDetector detector = PinchGestureDetector::New();
988 detector.Attach(actor);
989 detector.Attach(dummyActor);
990 detector.DetectedSignal().Connect( &application, functor );
992 // Here we are testing a Started actor which is removed in the Started callback, but then added back
993 // before we get a continuing state. As we were removed from the stage, even if we're at the same
994 // position, we should still not be signalled.
997 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
998 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
999 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Re add to the stage, we should not be signalled
1007 application.GetScene().Add(actor);
1009 // Render and notify
1010 application.SendNotification();
1011 application.Render();
1013 // Continue signal emission
1014 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1015 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 500 );
1016 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1018 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1019 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1020 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1023 // Here we delete an actor in started, we should not receive any subsequent signalling.
1026 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1027 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1028 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1031 // Render and notify
1032 application.SendNotification();
1033 application.Render();
1035 // Delete actor as well
1038 // Render and notify
1039 application.SendNotification();
1040 application.Render();
1042 // Continue signal emission
1043 TestContinuePinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1044 Vector2( 15.0f, 20.0f ), Vector2( 25.0f, 20.0f ), 2000 );
1045 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1047 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1048 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 3000);
1049 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1053 int UtcDaliPinchGestureLayerConsumesTouch(void)
1055 TestApplication application;
1057 Actor actor = Actor::New();
1058 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1059 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1060 application.GetScene().Add(actor);
1064 GestureReceivedFunctor functor(data);
1065 PinchGestureDetector detector = PinchGestureDetector::New();
1066 detector.Attach(actor);
1067 detector.DetectedSignal().Connect( &application, functor );
1069 // Add a layer to overlap the actor
1070 Layer layer = Layer::New();
1071 layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1072 layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1073 application.GetScene().Add( layer );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Emit signals, should receive
1081 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1082 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1083 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1084 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1085 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1088 // Set layer to consume all touch
1089 layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
1091 // Render and notify
1092 application.SendNotification();
1093 application.Render();
1095 // Emit the same signals again, should not receive
1096 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1097 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 1500 );
1098 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1099 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 2000);
1100 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1106 int UtcDaliPinchGestureInterruptedWhenTouchConsumed(void)
1108 TestApplication application;
1110 Actor actor = Actor::New();
1111 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1112 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1113 application.GetScene().Add(actor);
1115 bool consume = false;
1116 TouchEventFunctorConsumeSetter touchFunctor(consume);
1117 actor.TouchSignal().Connect(&application,touchFunctor);
1119 // Render and notify
1120 application.SendNotification();
1121 application.Render();
1124 GestureReceivedFunctor functor(data);
1126 PinchGestureDetector detector = PinchGestureDetector::New();
1127 detector.Attach(actor);
1128 detector.DetectedSignal().Connect(&application, functor);
1130 // Start gesture within the actor's area, we should receive the pinch as the touch is NOT being consumed
1131 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1132 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1134 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1135 DALI_TEST_EQUALS(Gesture::Started, data.receivedGesture.state, TEST_LOCATION);
1138 // Continue the gesture within the actor's area, but now the touch consumes thus cancelling the gesture
1141 TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1142 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1144 DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
1145 DALI_TEST_EQUALS(Gesture::Cancelled, data.receivedGesture.state, TEST_LOCATION);
1148 // Start another pinch, we should not even get the callback this time
1149 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1150 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1151 DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
1157 int UtcDaliPinchGestureDisableDetectionDuringPinchN(void)
1159 // Crash sometimes occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
1161 TestApplication application;
1163 Actor actor = Actor::New();
1164 actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
1165 actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
1166 application.GetScene().Add(actor);
1169 PinchGestureDetector detector = PinchGestureDetector::New();
1170 bool functorCalled = false;
1171 detector.Attach( actor );
1172 detector.DetectedSignal().Connect(
1174 [&detector, &functorCalled](Actor actor, const PinchGesture& gesture)
1176 if( gesture.state == Gesture::Finished )
1178 detector.Detach(actor);
1179 functorCalled = true;
1183 // Render and notify
1184 application.SendNotification();
1185 application.Render();
1187 // Try the gesture, should not crash
1190 TestStartPinch( application, Vector2( 2.0f, 20.0f ), Vector2( 38.0f, 20.0f ),
1191 Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ), 100 );
1192 TestContinuePinch( application, Vector2( 112.0f, 100.0f ), Vector2( 112.0f, 124.0f ),
1193 Vector2( 5.0f, 5.0f ), Vector2( 35.0f, 35.0f ), 200 );
1194 TestEndPinch( application, Vector2( 10.0f, 20.0f ), Vector2( 30.0f, 20.0f ),
1195 Vector2( 19.0f, 20.0f ), Vector2( 21.0f, 20.0f ), 1000);
1197 DALI_TEST_CHECK( true ); // No crash, test has passed
1198 DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
1202 DALI_TEST_CHECK( false ); // If we crash, the test has failed