Move TouchPoint to Devel API
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-DragAndDropDetector.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 8e574b4..9f41ad8
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 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,6 @@
 
 #include <dali-toolkit/devel-api/drag-drop-detector/drag-and-drop-detector.h>
 #include <dali/integration-api/events/touch-event-integ.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
 
 using namespace Dali;
 using namespace Dali::Toolkit;
@@ -82,7 +81,7 @@ namespace
     bool returnValue;
     };
 
-  Integration::TouchEvent GenerateSingleTouch(TouchPoint::State state, const Vector2& screenPosition)
+  Integration::TouchEvent GenerateSingleTouch(PointState::Type state, const Vector2& screenPosition)
   {
     Integration::TouchEvent touchEvent;
     Integration::Point point;
@@ -91,25 +90,6 @@ namespace
     touchEvent.points.push_back(point);
     return touchEvent;
   }
-
-  Integration::PanGestureEvent GeneratePan(
-    Gesture::State state,
-    Vector2 previousPosition,
-    Vector2 currentPosition,
-    unsigned long timeDelta,
-    unsigned int numberOfTouches = 1,
-    unsigned int time = 1u)
-  {
-    Integration::PanGestureEvent pan(state);
-    pan.previousPosition = previousPosition;
-    pan.currentPosition = currentPosition;
-    pan.timeDelta = timeDelta;
-    pan.numberOfTouches = numberOfTouches;
-    pan.time = time;
-
-    return pan;
-  }
-
 }
 
 int UtcDaliDragAndDropDetectorConstructorN(void)
@@ -286,13 +266,13 @@ int UtcDaliDragAndDropDetectorGetAttachedControlP(void)
 
 int UtcDaliDragAndDropDetectorStartSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control = Control::New();
-  control.SetSize(100.0f, 100.0f);
-  control.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  Stage::GetCurrent().Add(control);
+  control.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  application.GetScene().Add(control);
   detector.Attach(control);
 
   application.SendNotification();
@@ -305,12 +285,11 @@ int UtcDaliDragAndDropDetectorStartSignal(void)
   DragSignalFunctor functor(data);
   detector.StartedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control, data.control, TEST_LOCATION);
-  DALI_TEST_EQUALS(Vector2(10.0f, 10.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION);
+  DALI_TEST_EQUALS(Vector2(20.0f, 40.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION);
   data.Reset();
 
   END_TEST;
@@ -318,22 +297,22 @@ int UtcDaliDragAndDropDetectorStartSignal(void)
 
 int UtcDaliDragAndDropDetectorEnteredSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
-
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f,100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
+
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   detector.Attach(control1);
   detector.Attach(control2);
@@ -345,12 +324,10 @@ int UtcDaliDragAndDropDetectorEnteredSignal(void)
   DragSignalFunctor functor(data);
   detector.EnteredSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  Vector2 screenCoordinates(10.0f, 110.0f);
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control2, data.control, TEST_LOCATION);
@@ -363,22 +340,22 @@ int UtcDaliDragAndDropDetectorEnteredSignal(void)
 
 int UtcDaliDragAndDropDetectorMovedSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
-
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f,100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
+
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   detector.Attach(control1);
   detector.Attach(control2);
@@ -390,16 +367,14 @@ int UtcDaliDragAndDropDetectorMovedSignal(void)
   DragSignalFunctor functor(data);
   detector.MovedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  Vector2 screenCoordinates(10.0f, 110.0f);
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   screenCoordinates.y = 120.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(Vector2(10.0f, 120.0f), data.detector.GetCurrentScreenPosition(), TEST_LOCATION);
@@ -412,25 +387,25 @@ int UtcDaliDragAndDropDetectorMovedSignal(void)
 
 int UtcDaliDragAndDropDetectorExitedSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f,100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
 
-  control1.SetLeaveRequired(true);
-  control2.SetLeaveRequired(true);
+  control1.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
+  control2.SetProperty( Actor::Property::LEAVE_REQUIRED,true);
 
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   detector.Attach(control1);
   detector.Attach(control2);
@@ -442,16 +417,14 @@ int UtcDaliDragAndDropDetectorExitedSignal(void)
   DragSignalFunctor functor(data);
   detector.ExitedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  Vector2 screenCoordinates(10.0f, 110.0f);
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   screenCoordinates.x = 20.0f;
   screenCoordinates.y = 20.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control2, data.control, TEST_LOCATION);
 
@@ -462,22 +435,22 @@ int UtcDaliDragAndDropDetectorExitedSignal(void)
 
 int UtcDaliDragAndDropDetectorDroppedSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
-
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f,100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
+
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   detector.Attach(control1);
   detector.Attach(control2);
@@ -489,16 +462,14 @@ int UtcDaliDragAndDropDetectorDroppedSignal(void)
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  Vector2 screenCoordinates(10.0f, 110.0f);
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   screenCoordinates.y = 112.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Up, screenCoordinates));
+  application.ProcessEvent(GenerateSingleTouch(PointState::UP, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control2, data.control, TEST_LOCATION);
@@ -512,22 +483,22 @@ int UtcDaliDragAndDropDetectorDroppedSignal(void)
 
 int UtcDaliDragAndDropDetectorEndedSignal(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
-
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f,100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
+
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   application.SendNotification();
   application.Render(RENDER_FRAME_INTERVAL);
@@ -539,13 +510,9 @@ int UtcDaliDragAndDropDetectorEndedSignal(void)
   DragSignalFunctor functor(data);
   detector.EndedSignal().Connect(&application, functor);
 
-  application.ProcessEvent(GeneratePan(Gesture::Possible, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
-  application.ProcessEvent(GeneratePan(Gesture::Started, Vector2(10.0f, 10.0f), Vector2(12.0f, 12.0f), 10));
-
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, Vector2(10.0f, 10.0f)));
+  TestGenerateMiniPan(application);
 
-  application.ProcessEvent(GeneratePan(Gesture::Continuing, Vector2(10.0f, 10.0f), Vector2(120.0f, 12.0f), 10));
-  application.ProcessEvent(GeneratePan(Gesture::Finished, Vector2(120.0f, 12.0f), Vector2(120.0f, 20.0f), 10));
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control1, data.control, TEST_LOCATION);
@@ -556,24 +523,24 @@ int UtcDaliDragAndDropDetectorEndedSignal(void)
 
 int UtcDaliDragAndDropDetectorGetContent(void)
 {
-  TestApplication application;
+  ToolkitTestApplication application;
 
   Dali::Toolkit::DragAndDropDetector detector = Dali::Toolkit::DragAndDropDetector::New();
   Control control1 = Control::New();
   Control control2 = Control::New();
-  control1.SetName("control1");
-  control2.SetName("control2");
-  control1.SetSize(100.0f,100.0f);
-  control2.SetSize(100.0f, 100.0f);
-  control1.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-  control1.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control2.SetParentOrigin(ParentOrigin::TOP_LEFT);
-  control1.SetPosition(0.0f, 0.0f);
-  control2.SetPosition(0.0f, 100.0f);
-
-  Stage::GetCurrent().Add(control1);
-  Stage::GetCurrent().Add(control2);
+  control1.SetProperty( Dali::Actor::Property::NAME,"control1");
+  control2.SetProperty( Dali::Actor::Property::NAME,"control2");
+  control1.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control2.SetProperty( Actor::Property::SIZE, Vector2(100.0f, 100.0f) );
+  control1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control2.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT);
+  control1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::TOP_LEFT);
+  control1.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 0.0f));
+  control2.SetProperty( Actor::Property::POSITION, Vector2(0.0f, 100.0f));
+
+  application.GetScene().Add(control1);
+  application.GetScene().Add(control2);
 
   detector.Attach(control1);
   detector.Attach(control2);
@@ -585,16 +552,14 @@ int UtcDaliDragAndDropDetectorGetContent(void)
   DragSignalFunctor functor(data);
   detector.DroppedSignal().Connect(&application, functor);
 
-  Vector2 screenCoordinates(10.0f, 10.0f);
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Down, screenCoordinates));
+  TestGenerateMiniPan(application);
 
-  screenCoordinates.x = 10.0f;
-  screenCoordinates.y = 110.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Motion, screenCoordinates));
+  Vector2 screenCoordinates(10.0f, 110.0f);
+  application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, screenCoordinates));
 
   screenCoordinates.x = 10.0f;
   screenCoordinates.y = 112.0f;
-  application.ProcessEvent(GenerateSingleTouch(TouchPoint::Up, screenCoordinates));
+  application.ProcessEvent(GenerateSingleTouch(PointState::UP, screenCoordinates));
 
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(control2, data.control, TEST_LOCATION);