Merge "DALi Version 1.0.48" into devel/master
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-GestureDetector.cpp
index e79824e..12a41c4 100644 (file)
@@ -35,7 +35,7 @@ void utc_dali_gesture_detector_cleanup(void)
 }
 
 
-int UtcDaliGestureDetectorConstructorNegative(void)
+int UtcDaliGestureDetectorConstructorN(void)
 {
   TestApplication application;
 
@@ -48,17 +48,14 @@ int UtcDaliGestureDetectorConstructorNegative(void)
     detector.Attach(actor);
     tet_result(TET_FAIL);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
-    if ( exception.mCondition.find("detector") != std::string::npos )
-    {
-      tet_result(TET_PASS);
-    }
+    DALI_TEST_ASSERT( e, "detector", TEST_LOCATION );
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorConstructorPositive(void)
+int UtcDaliGestureDetectorConstructorP(void)
 {
   TestApplication application;
 
@@ -72,14 +69,40 @@ int UtcDaliGestureDetectorConstructorPositive(void)
     detector.Attach(actor);
     tet_result(TET_PASS);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    tet_result(TET_FAIL);
+  }
+  END_TEST;
+}
+
+int UtcDaliGestureDetectorAssignP(void)
+{
+  TestApplication application;
+
+  // Use pan gesture as GestureDetector cannot be created.
+  GestureDetector detector = PanGestureDetector::New();
+  GestureDetector detector2;
+
+  detector2 = detector;
+
+  Actor actor = Actor::New();
+
+  try
+  {
+    detector2.Attach(actor);
+    tet_result(TET_PASS);
+  }
+  catch (DaliException& e)
   {
+    DALI_TEST_PRINT_ASSERT( e );
     tet_result(TET_FAIL);
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDownCast(void)
+int UtcDaliGestureDetectorDownCastP(void)
 {
   TestApplication application;
   tet_infoline("Testing Dali::GestureDetector::DownCast()");
@@ -103,7 +126,7 @@ int UtcDaliGestureDetectorDownCast(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorAttachPositive(void)
+int UtcDaliGestureDetectorAttachP(void)
 {
   TestApplication application;
 
@@ -114,13 +137,17 @@ int UtcDaliGestureDetectorAttachPositive(void)
 
   detector.Attach(actor);
 
-  std::vector<Actor> actors = detector.GetAttachedActors();
-
-  if (find(actors.begin(), actors.end(), actor) != actors.end())
+  bool found = false;
+  for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
   {
-    tet_result(TET_PASS);
+    if( detector.GetAttachedActor(i) == actor )
+    {
+      tet_result(TET_PASS);
+      found = true;
+    }
   }
-  else
+
+  if(!found)
   {
     tet_result(TET_FAIL);
   }
@@ -136,7 +163,7 @@ int UtcDaliGestureDetectorAttachPositive(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorAttachNegative(void)
+int UtcDaliGestureDetectorAttachN(void)
 {
   TestApplication application;
 
@@ -151,17 +178,14 @@ int UtcDaliGestureDetectorAttachNegative(void)
     detector.Attach(actor);
     tet_result(TET_FAIL);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
-    if ( exception.mCondition.find("actor") != std::string::npos )
-    {
-      tet_result(TET_PASS);
-    }
+    DALI_TEST_ASSERT( e, "actor", TEST_LOCATION );
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachPositive(void)
+int UtcDaliGestureDetectorDetachP(void)
 {
   TestApplication application;
 
@@ -170,13 +194,18 @@ int UtcDaliGestureDetectorDetachPositive(void)
 
   Actor actor = Actor::New();
   detector.Attach(actor);
-  std::vector<Actor> actors = detector.GetAttachedActors();
 
-  if (find(actors.begin(), actors.end(), actor) != actors.end())
+  bool found = false;
+  for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
   {
-    tet_result(TET_PASS);
+    if( detector.GetAttachedActor(i) == actor )
+    {
+      tet_result(TET_PASS);
+      found = true;
+    }
   }
-  else
+
+  if(!found)
   {
     tet_result(TET_FAIL);
   }
@@ -184,19 +213,28 @@ int UtcDaliGestureDetectorDetachPositive(void)
   // Detach and retrieve attached actors again, the vector should be empty.
   detector.Detach(actor);
 
-  actors = detector.GetAttachedActors();
-  if (actors.empty())
+  found = false;
+  for(size_t i = 0; i < detector.GetAttachedActorCount(); i++)
   {
-    tet_result(TET_PASS);
+    if( detector.GetAttachedActor(i) == actor )
+    {
+      found = true;
+    }
   }
-  else
+
+  if(found)
   {
     tet_result(TET_FAIL);
   }
+  else
+  {
+    tet_result(TET_PASS);
+  }
+
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative01(void)
+int UtcDaliGestureDetectorDetachN01(void)
 {
   TestApplication application;
 
@@ -211,17 +249,14 @@ int UtcDaliGestureDetectorDetachNegative01(void)
     detector.Detach(actor);
     tet_result(TET_FAIL);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
-    if ( exception.mCondition.find("actor") != std::string::npos )
-    {
-      tet_result(TET_PASS);
-    }
+    DALI_TEST_ASSERT( e, "actor", TEST_LOCATION );
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative02(void)
+int UtcDaliGestureDetectorDetachN02(void)
 {
   TestApplication application;
 
@@ -238,14 +273,15 @@ int UtcDaliGestureDetectorDetachNegative02(void)
     detector.Detach(actor2);
     tet_result(TET_PASS);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
+    DALI_TEST_PRINT_ASSERT( e );
     tet_result(TET_FAIL);
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative03(void)
+int UtcDaliGestureDetectorDetachN03(void)
 {
   TestApplication application;
   TestGestureManager& gestureManager = application.GetGestureManager();
@@ -266,14 +302,15 @@ int UtcDaliGestureDetectorDetachNegative03(void)
     detector.Detach(actor);
     DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
+    DALI_TEST_PRINT_ASSERT( e );
     tet_result(TET_FAIL);
   }
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachAll(void)
+int UtcDaliGestureDetectorDetachAllP(void)
 {
   TestApplication application;
 
@@ -290,18 +327,16 @@ int UtcDaliGestureDetectorDetachAll(void)
     detector.Attach(actor);
   }
 
-  std::vector<Actor> attachedActors = detector.GetAttachedActors();
-  DALI_TEST_EQUALS(actorsToAdd, attachedActors.size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(actorsToAdd, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach and retrieve attached actors again, the vector should be empty.
   detector.DetachAll();
 
-  attachedActors = detector.GetAttachedActors();
-  DALI_TEST_EQUALS(true, attachedActors.empty(), TEST_LOCATION);
+  DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachAllNegative(void)
+int UtcDaliGestureDetectorDetachAllN(void)
 {
   TestApplication application;
   TestGestureManager& gestureManager = application.GetGestureManager();
@@ -319,14 +354,12 @@ int UtcDaliGestureDetectorDetachAllNegative(void)
     detector.Attach(actor);
   }
 
-  std::vector<Actor> attachedActors = detector.GetAttachedActors();
-  DALI_TEST_EQUALS(actorsToAdd, attachedActors.size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(actorsToAdd, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach and retrieve attached actors again, the vector should be empty.
   detector.DetachAll();
 
-  attachedActors = detector.GetAttachedActors();
-  DALI_TEST_EQUALS(true, attachedActors.empty(), TEST_LOCATION);
+  DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
   DALI_TEST_EQUALS(true, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
 
   // Call DetachAll again, there should not be any exception
@@ -336,8 +369,9 @@ int UtcDaliGestureDetectorDetachAllNegative(void)
     detector.DetachAll();
     DALI_TEST_EQUALS(false, gestureManager.WasCalled(TestGestureManager::UnregisterType), TEST_LOCATION);
   }
-  catch (DaliException& exception)
+  catch (DaliException& e)
   {
+    DALI_TEST_PRINT_ASSERT( e );
     tet_result(TET_FAIL);
   }
   END_TEST;
@@ -351,17 +385,17 @@ int UtcDaliGestureDetectorGetAttachedActors(void)
   GestureDetector detector = PanGestureDetector::New();
 
   // Initially there should not be any actors.
-  DALI_TEST_EQUALS(0u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Attach one actor
   Actor actor1 = Actor::New();
   detector.Attach(actor1);
-  DALI_TEST_EQUALS(1u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(1u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Attach another actor
   Actor actor2 = Actor::New();
   detector.Attach(actor2);
-  DALI_TEST_EQUALS(2u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(2u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Attach another five actors
   std::vector<Actor> myActors;
@@ -371,35 +405,35 @@ int UtcDaliGestureDetectorGetAttachedActors(void)
     myActors.push_back(actor);
     detector.Attach(actor);
   }
-  DALI_TEST_EQUALS(7u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(7u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach actor2
   detector.Detach(actor2);
-  DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Attach actor1 again, count should not increase.
   detector.Attach(actor1);
-  DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach actor2 again, count should not decrease.
   detector.Detach(actor2);
-  DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach actor1.
   detector.Detach(actor1);
-  DALI_TEST_EQUALS(5u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(5u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Create scoped actor, actor should be automatically removed from the detector when it goes out
   // of scope.
   {
     Actor scopedActor = Actor::New();
     detector.Attach(scopedActor);
-    DALI_TEST_EQUALS(6u, detector.GetAttachedActors().size(), TEST_LOCATION);
+    DALI_TEST_EQUALS(6u, detector.GetAttachedActorCount(), TEST_LOCATION);
   }
-  DALI_TEST_EQUALS(5u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(5u, detector.GetAttachedActorCount(), TEST_LOCATION);
 
   // Detach all so nothing remains.
   detector.DetachAll();
-  DALI_TEST_EQUALS(0u, detector.GetAttachedActors().size(), TEST_LOCATION);
+  DALI_TEST_EQUALS(0u, detector.GetAttachedActorCount(), TEST_LOCATION);
   END_TEST;
 }