[dali_1.4.20] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ControlImpl.cpp
index 6150385..31f3094 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/wheel-event-integ.h>
-#include <dali/integration-api/events/long-press-gesture-event.h>
-#include <dali/integration-api/events/pinch-gesture-event.h>
-#include <dali/integration-api/events/pan-gesture-event.h>
-#include <dali/integration-api/events/tap-gesture-event.h>
 #include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/events/hover-event-integ.h>
 
@@ -236,107 +232,32 @@ int UtcDaliControlImplOnGestureMethods(void)
     dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
 
     DALI_TEST_CHECK( dummyImpl.pinchCalled == false );
-    Integration::PinchGestureEvent pinch(Gesture::Started);
-    pinch.scale = 10.0f;
-    pinch.speed = 50.0f;
-    pinch.centerPoint = Vector2(20.0f, 20.0f);
-    application.ProcessEvent(pinch);
+
+    TestGeneratePinch(application);
+
     DALI_TEST_CHECK( dummyImpl.pinchCalled == true );
 
     DALI_TEST_CHECK( dummyImpl.panCalled == false );
-    Integration::PanGestureEvent pan(Gesture::Possible);
-    pan.previousPosition = Vector2(10.0f, 20.0f);
-    pan.currentPosition = Vector2(20.0f, 20.0f);
-    pan.timeDelta = 10;
-    pan.numberOfTouches = 1u;
-    application.ProcessEvent(pan);
-    pan.state = Gesture::Started;
-    application.ProcessEvent(pan);
-    DALI_TEST_CHECK( dummyImpl.panCalled == true );
 
-    DALI_TEST_CHECK( dummyImpl.tapCalled == false );
-    Integration::TapGestureEvent tap(Gesture::Possible);
-    tap.numberOfTaps = 1u;
-    tap.numberOfTouches = 1u;
-    tap.point = Vector2(50.0f, 50.0f);
-    application.ProcessEvent(tap);
-    tap.state = Gesture::Started;
-    application.ProcessEvent(tap);
-    DALI_TEST_CHECK( dummyImpl.tapCalled == true );
+    TestGenerateMiniPan(application);
 
-    DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
-    Integration::LongPressGestureEvent longPress(Gesture::Possible);
-    longPress.numberOfTouches = 1u;
-    longPress.point = Vector2(50.0f, 50.0f);
-    application.ProcessEvent(longPress);
-    longPress.state = Gesture::Started;
-    application.ProcessEvent(longPress);
-    DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
-    longPress.state = Gesture::Finished;
-    application.ProcessEvent(longPress);
-
-    Stage::GetCurrent().Remove(dummy);
-  }
+    DALI_TEST_CHECK( dummyImpl.panCalled == true );
 
-  // Ensure full code coverage
-  {
-    DummyControl dummy = DummyControl::New();
-    dummy.SetSize( Vector2( 100.0f, 100.0f ) );
+    DALI_TEST_CHECK( dummyImpl.tapCalled == false );
 
-    dummy.SetAnchorPoint(AnchorPoint::TOP_LEFT);
-    Stage::GetCurrent().Add(dummy);
+    TestGenerateTap(application);
 
-    // Render and notify a couple of times
-    application.SendNotification();
-    application.Render();
-    application.SendNotification();
-    application.Render();
+    DALI_TEST_CHECK( dummyImpl.tapCalled == true );
 
-    DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(dummy.GetImplementation());
-    dummyImpl.EnableGestureDetection( Gesture::Type(Gesture::Pinch | Gesture::Pan | Gesture::Tap | Gesture::LongPress) );
+    DALI_TEST_CHECK( dummyImpl.longPressCalled == false );
 
-    DALI_TEST_CHECK( dummy.GetCurrentScale().x != 10.0f );
-    Integration::PinchGestureEvent pinch(Gesture::Started);
-    pinch.scale = 10.0f;
-    pinch.speed = 50.0f;
-    pinch.centerPoint = Vector2(20.0f, 20.0f);
-    application.ProcessEvent(pinch);
+    TestGenerateLongPress(application);
 
-    // Render and notify a couple of times
-    application.SendNotification();
-    application.Render();
-    application.SendNotification();
-    application.Render();
-    DALI_TEST_CHECK( dummy.GetCurrentScale().x == 10.0f );
-
-    Integration::PanGestureEvent pan(Gesture::Possible);
-    pan.previousPosition = Vector2(10.0f, 20.0f);
-    pan.currentPosition = Vector2(20.0f, 20.0f);
-    pan.timeDelta = 10;
-    pan.numberOfTouches = 1u;
-    application.ProcessEvent(pan);
-    pan.state = Gesture::Started;
-    application.ProcessEvent(pan);
-
-    Integration::TapGestureEvent tap(Gesture::Possible);
-    tap.numberOfTaps = 1u;
-    tap.numberOfTouches = 1u;
-    tap.point = Vector2(50.0f, 50.0f);
-    application.ProcessEvent(tap);
-    tap.state = Gesture::Started;
-    application.ProcessEvent(tap);
-
-    Integration::LongPressGestureEvent longPress(Gesture::Possible);
-    longPress.numberOfTouches = 1u;
-    longPress.point = Vector2(50.0f, 50.0f);
-    application.ProcessEvent(longPress);
-    longPress.state = Gesture::Started;
-    application.ProcessEvent(longPress);
-    longPress.state = Gesture::Finished;
-    application.ProcessEvent(longPress);
+    DALI_TEST_CHECK( dummyImpl.longPressCalled == true );
 
     Stage::GetCurrent().Remove(dummy);
   }
+
   END_TEST;
 }