Refactoring Gestures Class
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-LongPressGestureDetector.cpp
index 2f9773e..4f58ba8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@
 #include <dali/integration-api/render-task-list-integ.h>
 #include <dali/devel-api/events/long-press-gesture-detector-devel.h>
 #include <dali-test-suite-utils.h>
-#include <test-touch-utils.h>
+#include <test-touch-event-utils.h>
 
 using namespace Dali;
 
@@ -48,7 +48,7 @@ struct SignalData
   SignalData()
   : functorCalled( false ),
     voidFunctorCalled( false ),
-    receivedGesture( Gesture::Clear ),
+    receivedGesture(),
     pressedActor()
   {}
 
@@ -57,9 +57,7 @@ struct SignalData
     functorCalled = false;
     voidFunctorCalled = false;
 
-    receivedGesture.numberOfTouches = 0u;
-    receivedGesture.screenPoint = Vector2(0.0f, 0.0f);
-    receivedGesture.localPoint = Vector2(0.0f, 0.0f);
+    receivedGesture.Reset();
 
     pressedActor.Reset();
   }
@@ -93,9 +91,10 @@ struct GestureReceivedFunctor
 // Functor that removes the gestured actor from stage
 struct UnstageActorFunctor : public GestureReceivedFunctor
 {
-  UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage )
+  UnstageActorFunctor( SignalData& data, Gesture::State& stateToUnstage, Integration::Scene scene )
   : GestureReceivedFunctor( data ),
-    stateToUnstage( stateToUnstage )
+    stateToUnstage( stateToUnstage ),
+    scene( scene )
   {
   }
 
@@ -103,26 +102,26 @@ struct UnstageActorFunctor : public GestureReceivedFunctor
   {
     GestureReceivedFunctor::operator()( actor, longPress );
 
-    if ( longPress.state == stateToUnstage )
+    if ( longPress.GetState() == stateToUnstage )
     {
-      Stage::GetCurrent().Remove( actor );
+      scene.Remove( actor );
     }
   }
 
   Gesture::State& stateToUnstage;
+  Integration::Scene scene;
 };
 
 // Functor for receiving a touch event
 struct TouchEventFunctor
 {
-  bool operator()(Actor actor, const TouchEvent& touch)
+  bool operator()(Actor actor, Dali::TouchEvent touch)
   {
     //For line coverage
     unsigned int points = touch.GetPointCount();
     if( points > 0)
     {
-      const TouchPoint& touchPoint = touch.GetPoint(0);
-      tet_printf("Touch Point state = %d\n", touchPoint.state);
+      tet_printf("Touch Point state = %d\n", touch.GetState(0));
     }
     return false;
   }
@@ -196,9 +195,9 @@ int UtcDaliLongPressGestureDetectorNew(void)
 
   // Attach an actor and emit a touch event on the actor to ensure complete line coverage
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -207,7 +206,7 @@ int UtcDaliLongPressGestureDetectorNew(void)
   detector.Attach(actor);
 
   TouchEventFunctor touchFunctor;
-  actor.TouchedSignal().Connect(&application, touchFunctor);
+  actor.TouchSignal().Connect(&application, touchFunctor);
 
   Integration::TouchEvent touchEvent(1);
   Integration::Point point;
@@ -221,8 +220,6 @@ int UtcDaliLongPressGestureDetectorNew(void)
   application.SendNotification();
   application.Render();
 
-  // For line coverage, Initialise default constructor
-  TouchEvent touchEvent2;
   END_TEST;
 }
 
@@ -277,9 +274,9 @@ int UtcDaliLongPressGestureSignalReceptionNegative(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -305,9 +302,9 @@ int UtcDaliLongPressGestureSignalReceptionPositive(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -323,8 +320,8 @@ int UtcDaliLongPressGestureSignalReceptionPositive(void)
   // Do a long press inside actor's area
   TestGenerateLongPress( application, 50.0f, 50.0f );
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
   TestEndLongPress( application, 50.0f, 50.0f);
   END_TEST;
 }
@@ -334,9 +331,9 @@ int UtcDaliLongPressGestureSignalReceptionDetach(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -352,16 +349,16 @@ int UtcDaliLongPressGestureSignalReceptionDetach(void)
   // Start long press within the actor's area
   TestGenerateLongPress( application, 20.0f, 20.0f );
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Vector2(20.0f, 20.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
   TestEndLongPress( application, 20.0f, 20.0f);
 
   // repeat the long press within the actor's area - we should still receive the signal
   data.Reset();
   TestGenerateLongPress( application, 50.0f, 50.0f );
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.localPoint, 0.1, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Vector2(50.0f, 50.0f), data.receivedGesture.GetLocalPoint(), 0.1, TEST_LOCATION);
   TestEndLongPress( application, 50.0f, 50.0f);
 
   // Detach actor
@@ -389,9 +386,9 @@ int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void)
   // Actor lifetime is scoped
   {
     Actor actor = Actor::New();
-    actor.SetSize(100.0f, 100.0f);
-    actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-    Stage::GetCurrent().Add(actor);
+    actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+    actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+    application.GetScene().Add(actor);
 
     // Render and notify
     application.SendNotification();
@@ -404,7 +401,7 @@ int UtcDaliLongPressGestureSignalReceptionActorDestroyedDuringLongPress(void)
     DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
 
     // Remove the actor from stage and reset the data
-    Stage::GetCurrent().Remove(actor);
+    application.GetScene().Remove(actor);
 
     // Render and notify
     application.SendNotification();
@@ -424,9 +421,9 @@ int UtcDaliLongPressGestureSignalReceptionRotatedActor(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ORIENTATION, Quaternion( Dali::Degree(90.0f), Vector3::ZAXIS ) );
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -443,11 +440,11 @@ int UtcDaliLongPressGestureSignalReceptionRotatedActor(void)
   TestGenerateLongPress( application, 5.0f, 5.0f );
   TestEndLongPress( application, 5.0f, 5.0f);
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION);
 
   // Rotate actor again and render
-  actor.SetOrientation(Dali::Degree(180.0f), Vector3::ZAXIS);
+  actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(180.0f), Vector3::ZAXIS) );
   application.SendNotification();
   application.Render();
 
@@ -456,11 +453,11 @@ int UtcDaliLongPressGestureSignalReceptionRotatedActor(void)
   TestGenerateLongPress( application, 5.0f, 5.0f );
   TestEndLongPress( application, 5.0f, 5.0f);
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(1u, data.receivedGesture.numberOfTouches, TEST_LOCATION);
-  DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.screenPoint, 0.1, TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, data.receivedGesture.GetNumberOfTouches(), TEST_LOCATION);
+  DALI_TEST_EQUALS( Vector2(5.0f, 5.0f), data.receivedGesture.GetScreenPoint(), 0.1, TEST_LOCATION);
 
   // Rotate actor again and render
-  actor.SetOrientation(Dali::Degree(90.0f), Vector3::YAXIS);
+  actor.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::YAXIS) );
   application.SendNotification();
   application.Render();
 
@@ -477,23 +474,20 @@ int UtcDaliLongPressGestureSignalReceptionChildHit(void)
   TestApplication application;
 
   Actor parent = Actor::New();
-  parent.SetSize(100.0f, 100.0f);
-  parent.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(parent);
+  parent.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  parent.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(parent);
 
   // Set child to completely cover parent.
   // Change rotation of child to be different from parent so that we can check if our local coordinate
   // conversion of the parent actor is correct.
   Actor child = Actor::New();
-  child.SetSize(100.0f, 100.0f);
-  child.SetAnchorPoint(AnchorPoint::CENTER);
-  child.SetParentOrigin(ParentOrigin::CENTER);
-  child.SetOrientation(Dali::Degree(90.0f), Vector3::ZAXIS);
+  child.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  child.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER);
+  child.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
+  child.SetProperty( Actor::Property::ORIENTATION, Quaternion(Dali::Degree(90.0f), Vector3::ZAXIS) );
   parent.Add(child);
 
-  TouchEventFunctor touchFunctor;
-  child.TouchedSignal().Connect(&application, touchFunctor);
-
   // Render and notify
   application.SendNotification();
   application.Render();
@@ -510,7 +504,7 @@ int UtcDaliLongPressGestureSignalReceptionChildHit(void)
   TestEndLongPress( application, 50.0f, 50.0f);
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(true, parent == data.pressedActor, TEST_LOCATION);
-  DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(50.0f, 50.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION);
 
   // Attach child and generate same touch points
   // (Also proves that you can detach and then re-attach another actor)
@@ -523,7 +517,7 @@ int UtcDaliLongPressGestureSignalReceptionChildHit(void)
   TestEndLongPress( application, 51.0f, 51.0f);
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(true, child == data.pressedActor, TEST_LOCATION);
-  DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.screenPoint, 0.01f, TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(51.0f, 51.0f), data.receivedGesture.GetScreenPoint(), 0.01f, TEST_LOCATION);
   END_TEST;
 }
 
@@ -532,15 +526,15 @@ int UtcDaliLongPressGestureSignalReceptionAttachDetachMany(void)
   TestApplication application;
 
   Actor first = Actor::New();
-  first.SetSize(100.0f, 100.0f);
-  first.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(first);
+  first.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  first.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(first);
 
   Actor second = Actor::New();
-  second.SetSize(100.0f, 100.0f);
-  second.SetX(100.0f);
-  second.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(second);
+  second.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  second.SetProperty( Actor::Property::POSITION_X, 100.0f);
+  second.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(second);
 
   // Render and notify
   application.SendNotification();
@@ -589,9 +583,9 @@ int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -610,7 +604,7 @@ int UtcDaliLongPressGestureSignalReceptionActorBecomesUntouchable(void)
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
 
   // Actor becomes invisible - actor should not receive the next long press
-  actor.SetVisible(false);
+  actor.SetProperty( Actor::Property::VISIBLE,false);
 
   // Render and notify
   application.SendNotification();
@@ -629,9 +623,9 @@ int UtcDaliLongPressGestureSignalReceptionMultipleDetectorsOnActor(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -663,9 +657,9 @@ int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -683,7 +677,7 @@ int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void)
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
 
   // Move actor somewhere else
-  actor.SetPosition( 100.0f, 100.0f );
+  actor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
 
   // Render and notify
   application.SendNotification();
@@ -699,7 +693,7 @@ int UtcDaliLongPressGestureSignalReceptionDifferentPossible(void)
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
 
   // Move actor in to the long press position.
-  actor.SetPosition( 0.0f, 0.0f );
+  actor.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, 0.0f ));
 
   // Render and notify
   application.SendNotification();
@@ -722,9 +716,9 @@ int UtcDaliLongPressGesturePossibleCancelled(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -750,9 +744,9 @@ int UtcDaliLongPressGestureDetachAfterStarted(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -784,9 +778,9 @@ int UtcDaliLongPressGestureActorUnstaged(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -797,7 +791,7 @@ int UtcDaliLongPressGestureActorUnstaged(void)
 
   // Attach actor to detector
   SignalData data;
-  UnstageActorFunctor functor( data, stateToUnstage );
+  UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
   LongPressGestureDetector detector = LongPressGestureDetector::New();
   detector.Attach(actor);
   detector.DetectedSignal().Connect( &application, functor );
@@ -814,7 +808,7 @@ int UtcDaliLongPressGestureActorUnstaged(void)
   application.Render();
 
   // Re-add actor to stage
-  Stage::GetCurrent().Add(actor);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -838,16 +832,16 @@ int UtcDaliLongPressGestureActorStagedAndDestroyed(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Create and add a second actor so that GestureDetector destruction does not come into play.
   Actor dummyActor( Actor::New() );
-  dummyActor.SetSize( 100.0f, 100.0f );
-  dummyActor.SetPosition( 100.0f, 100.0f );
-  dummyActor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(dummyActor);
+  dummyActor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  dummyActor.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
+  dummyActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(dummyActor);
 
   // Render and notify
   application.SendNotification();
@@ -858,7 +852,7 @@ int UtcDaliLongPressGestureActorStagedAndDestroyed(void)
 
   // Attach actor to detector
   SignalData data;
-  UnstageActorFunctor functor( data, stateToUnstage );
+  UnstageActorFunctor functor( data, stateToUnstage, application.GetScene() );
   LongPressGestureDetector detector = LongPressGestureDetector::New();
   detector.Attach(actor);
   detector.Attach(dummyActor);
@@ -878,7 +872,7 @@ int UtcDaliLongPressGestureActorStagedAndDestroyed(void)
   application.Render();
 
   // Re add to the stage, we should not be signalled
-  Stage::GetCurrent().Add(actor);
+  application.GetScene().Add(actor);
 
   // Render and notify
   application.SendNotification();
@@ -918,9 +912,9 @@ int UtcDaliLongPressGestureLayerConsumesTouch(void)
   TestApplication application;
 
   Actor actor = Actor::New();
-  actor.SetSize(100.0f, 100.0f);
-  actor.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(actor);
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
 
   // Add a detector
   SignalData data;
@@ -931,9 +925,9 @@ int UtcDaliLongPressGestureLayerConsumesTouch(void)
 
   // Add a layer to overlap the actor
   Layer layer = Layer::New();
-  layer.SetSize(100.0f, 100.0f);
-  layer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add( layer );
+  layer.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  layer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add( layer );
   layer.RaiseToTop();
 
   // Render and notify
@@ -947,7 +941,7 @@ int UtcDaliLongPressGestureLayerConsumesTouch(void)
   data.Reset();
 
   // Set layer to consume all touch
-  layer.SetTouchConsumed( true );
+  layer.SetProperty( Layer::Property::CONSUMES_TOUCH, true );
 
   // Render and notify
   application.SendNotification();
@@ -972,9 +966,9 @@ int UtcDaliLongPressGestureSetMinimumHoldingTime(void)
   Integration::SetLongPressMinimumHoldingTime( kMinumumHolding1 );
 
   Actor actor = Actor::New();
-  actor.SetSize( 100.0f, 100.0f );
-  actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
-  Stage::GetCurrent().Add( actor );
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+  application.GetScene().Add( actor );
 
   // Render and notify
   application.SendNotification();
@@ -994,3 +988,95 @@ int UtcDaliLongPressGestureSetMinimumHoldingTime(void)
 
   END_TEST;
 }
+
+int UtcDaliLongPressGestureInterruptedWhenTouchConsumed(void)
+{
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
+
+  bool consume = false;
+  TouchEventFunctorConsumeSetter touchFunctor(consume);
+  actor.TouchSignal().Connect(&application,touchFunctor);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  SignalData data;
+  GestureReceivedFunctor functor(data);
+
+  LongPressGestureDetector detector = LongPressGestureDetector::New();
+  detector.Attach(actor);
+  detector.DetectedSignal().Connect(&application, functor);
+
+  // Start gesture within the actor's area, we should receive the gesture as the touch is NOT being consumed
+  TestGenerateLongPress( application, 50.0f, 50.0f );
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  data.Reset();
+  TestEndLongPress(application, 50.0f,50.0f);
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  data.Reset();
+
+  // Another gesture in the same location, this time we will not receive it as touch is being consumed
+  consume = true;
+  TestGenerateLongPress( application, 50.0f, 50.0f );
+  DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+  data.Reset();
+  TestEndLongPress(application, 50.0f,50.0f);
+  DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliLongPressGestureDisableDetectionDuringLongPressN(void)
+{
+  // Crash occurred when gesture-recognizer was deleted internally during a signal when the attached actor was detached
+
+  TestApplication application;
+
+  Actor actor = Actor::New();
+  actor.SetProperty( Actor::Property::SIZE, Vector2( 100.0f, 100.0f ) );
+  actor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(actor);
+
+  // Add a detector
+  LongPressGestureDetector detector = LongPressGestureDetector::New();
+  bool functorCalled = false;
+  detector.Attach( actor );
+  detector.DetectedSignal().Connect(
+      &application,
+      [&detector, &functorCalled](Actor actor, const LongPressGesture& gesture)
+      {
+        if( gesture.GetState() == Gesture::Finished )
+        {
+          detector.Detach(actor);
+          functorCalled = true;
+        }
+      });
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  // Try the gesture, should not crash
+  try
+  {
+    TestGenerateLongPress( application, 50.0f, 10.0f );
+    TestEndLongPress( application, 50.0f, 10.0f );
+
+    DALI_TEST_CHECK( true ); // No crash, test has passed
+    DALI_TEST_EQUALS(functorCalled, true, TEST_LOCATION);
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK( false ); // If we crash, the test has failed
+  }
+
+  END_TEST;
+}
+
+