Moving CullFace mode and Blending modes to Pipeline
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-ObjectRegistry.cpp
index b65703d..9b77c8b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 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.
  *
  */
 
-#include <iostream>
-
-#include <stdlib.h>
 #include <dali-test-suite-utils.h>
 #include <dali/public-api/dali-core.h>
+#include <stdlib.h>
+
+#include <iostream>
 
 using namespace Dali;
 
 namespace
 {
-
 // Functors to test whether Object created/destroyed signal is emitted for different types of Objects
 
 struct TestObjectDestroyedCallback
@@ -46,7 +45,7 @@ struct TestObjectDestroyedCallback
     }
   }
 
-  bool& mSignalVerified;
+  bool&             mSignalVerified;
   Dali::RefObject*& mObjectPointer;
 };
 
@@ -131,9 +130,9 @@ int UtcDaliObjectRegistryGet(void)
   TestApplication application;
 
   ObjectRegistry registry; //  like this for ctor code coverage
-  registry= application.GetCore().GetObjectRegistry();
+  registry = application.GetCore().GetObjectRegistry();
 
-  DALI_TEST_CHECK( registry );
+  DALI_TEST_CHECK(registry);
   END_TEST;
 }
 
@@ -142,9 +141,46 @@ int UtcDaliObjectRegistryCopyConstructor(void)
   TestApplication application;
 
   ObjectRegistry myRegistry;
-  ObjectRegistry anotherRegistry( myRegistry );
+  ObjectRegistry anotherRegistry(myRegistry);
+
+  DALI_TEST_EQUALS(myRegistry, anotherRegistry, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliObjectRegistryMoveConstructor(void)
+{
+  TestApplication application;
+
+  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+  DALI_TEST_CHECK(registry);
+  DALI_TEST_EQUALS(2, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+
+  ObjectRegistry move = std::move(registry);
+  DALI_TEST_CHECK(move);
+
+  // Check that object is moved (not copied, so ref count keeps the same)
+  DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+  DALI_TEST_CHECK(!registry);
+
+  END_TEST;
+}
+
+int UtcDaliObjectRegistryMoveAssignment(void)
+{
+  TestApplication application;
+
+  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+  DALI_TEST_CHECK(registry);
+  DALI_TEST_EQUALS(2, registry.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+
+  ObjectRegistry move;
+  move = std::move(registry);
+  DALI_TEST_CHECK(move);
+
+  // Check that object is moved (not copied, so ref count keeps the same)
+  DALI_TEST_EQUALS(2, move.GetBaseObject().ReferenceCount(), TEST_LOCATION);
+  DALI_TEST_CHECK(!registry);
 
-  DALI_TEST_EQUALS( myRegistry, anotherRegistry, TEST_LOCATION );
   END_TEST;
 }
 
@@ -152,13 +188,13 @@ int UtcDaliObjectRegistrySignalActorCreated(void)
 {
   tet_infoline("Testing GetObjectRegistry()");
   TestApplication application;
-  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
-  DALI_TEST_CHECK( registry );
+  ObjectRegistry  registry = application.GetCore().GetObjectRegistry();
+  DALI_TEST_CHECK(registry);
 
-  bool verified = false;
+  bool              verified = false;
   TestActorCallback test(verified);
 
-  Dali::RefObject* objectPointer = NULL;
+  Dali::RefObject*            objectPointer = NULL;
   TestObjectDestroyedCallback test2(verified, objectPointer);
 
   registry.ObjectCreatedSignal().Connect(&application, test);
@@ -166,12 +202,12 @@ int UtcDaliObjectRegistrySignalActorCreated(void)
 
   {
     Actor actor = Actor::New();
-    DALI_TEST_CHECK( test.mSignalVerified );
+    DALI_TEST_CHECK(test.mSignalVerified);
 
-    verified = false;
+    verified      = false;
     objectPointer = actor.GetObjectPtr();
   }
-  DALI_TEST_CHECK( test.mSignalVerified );
+  DALI_TEST_CHECK(test.mSignalVerified);
   END_TEST;
 }
 
@@ -181,10 +217,10 @@ int UtcDaliObjectRegistrySignalCameraCreated(void)
 
   ObjectRegistry registry = application.GetCore().GetObjectRegistry();
 
-  bool verified = false;
+  bool                    verified = false;
   TestCameraActorCallback test(verified);
 
-  Dali::RefObject* objectPointer = NULL;
+  Dali::RefObject*            objectPointer = NULL;
   TestObjectDestroyedCallback test2(verified, objectPointer);
 
   registry.ObjectCreatedSignal().Connect(&application, test);
@@ -192,24 +228,24 @@ int UtcDaliObjectRegistrySignalCameraCreated(void)
 
   {
     CameraActor actor = CameraActor::New();
-    DALI_TEST_CHECK( test.mSignalVerified );
+    DALI_TEST_CHECK(test.mSignalVerified);
 
-    verified = false;
+    verified      = false;
     objectPointer = actor.GetObjectPtr();
   }
-  DALI_TEST_CHECK( test.mSignalVerified );
+  DALI_TEST_CHECK(test.mSignalVerified);
   END_TEST;
 }
 
 int UtcDaliObjectRegistrySignalLayerCreated(void)
 {
   TestApplication application;
-  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+  ObjectRegistry  registry = application.GetCore().GetObjectRegistry();
 
-  bool verified = false;
+  bool              verified = false;
   TestLayerCallback test(verified);
 
-  Dali::RefObject* objectPointer = NULL;
+  Dali::RefObject*            objectPointer = NULL;
   TestObjectDestroyedCallback test2(verified, objectPointer);
 
   registry.ObjectCreatedSignal().Connect(&application, test);
@@ -217,24 +253,24 @@ int UtcDaliObjectRegistrySignalLayerCreated(void)
 
   {
     Layer actor = Layer::New();
-    DALI_TEST_CHECK( test.mSignalVerified );
+    DALI_TEST_CHECK(test.mSignalVerified);
 
-    verified = false;
+    verified      = false;
     objectPointer = actor.GetObjectPtr();
   }
-  DALI_TEST_CHECK( test.mSignalVerified );
+  DALI_TEST_CHECK(test.mSignalVerified);
   END_TEST;
 }
 
 int UtcDaliObjectRegistrySignalAnimationCreated(void)
 {
   TestApplication application;
-  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
+  ObjectRegistry  registry = application.GetCore().GetObjectRegistry();
 
-  bool verified = false;
+  bool                  verified = false;
   TestAnimationCallback test(verified);
 
-  Dali::RefObject* objectPointer = NULL;
+  Dali::RefObject*            objectPointer = NULL;
   TestObjectDestroyedCallback test2(verified, objectPointer);
 
   registry.ObjectCreatedSignal().Connect(&application, test);
@@ -242,11 +278,43 @@ int UtcDaliObjectRegistrySignalAnimationCreated(void)
 
   {
     Animation animation = Animation::New(1.0f);
-    DALI_TEST_CHECK( test.mSignalVerified );
+    DALI_TEST_CHECK(test.mSignalVerified);
 
-    verified = false;
+    verified      = false;
     objectPointer = animation.GetObjectPtr();
   }
-  DALI_TEST_CHECK( test.mSignalVerified );
+  DALI_TEST_CHECK(test.mSignalVerified);
+  END_TEST;
+}
+
+int UtcDaliObjectRegistryObjectCreatedSignalNegative(void)
+{
+  TestApplication      application;
+  Dali::ObjectRegistry instance;
+  try
+  {
+    instance.ObjectCreatedSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliObjectRegistryObjectDestroyedSignalNegative(void)
+{
+  TestApplication      application;
+  Dali::ObjectRegistry instance;
+  try
+  {
+    instance.ObjectDestroyedSignal();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
   END_TEST;
 }