Add move semantics to common and base Toolkit classes
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-Control.cpp
index 0af28c3..d10cbec 100644 (file)
@@ -142,7 +142,7 @@ int UtcDaliControlRegister(void)
   ToolkitTestApplication application;
 
   // Ensure the object is registered after creation
-  ObjectRegistry registry = Stage::GetCurrent().GetObjectRegistry();
+  ObjectRegistry registry = application.GetCore().GetObjectRegistry();
   DALI_TEST_CHECK( registry );
 
   gObjectCreatedCallBackCalled = false;
@@ -181,6 +181,43 @@ int UtcDaliControlCopyAndAssignment(void)
   END_TEST;
 }
 
+int UtcDaliControlMoveConstructor(void)
+{
+  ToolkitTestApplication application;
+
+  Control control = Control::New();
+  DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  control.SetProperty( Actor::Property::SENSITIVE, false );
+  DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+  Control moved = std::move( control );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+  DALI_TEST_CHECK( !control );
+
+  END_TEST;
+}
+
+int UtcDaliControlMoveAssignment(void)
+{
+  ToolkitTestApplication application;
+
+  Control control = Control::New();
+  DALI_TEST_EQUALS( 1, control.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  control.SetProperty( Actor::Property::SENSITIVE, false );
+  DALI_TEST_CHECK( false == control.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+
+  Control moved;
+  moved = std::move( control );
+  DALI_TEST_CHECK( moved );
+  DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( false == moved.GetProperty< bool >( Actor::Property::SENSITIVE ) );
+  DALI_TEST_CHECK( !control );
+
+  END_TEST;
+}
+
 int UtcDaliControlDownCast(void)
 {
   ToolkitTestApplication application;
@@ -512,6 +549,18 @@ int UtcDaliControlBackgroundColorRendererCount(void)
   DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
   DALI_TEST_EQUALS( GetControlBackgroundColor( control ), semiTransparent, TEST_LOCATION );
 
+  Renderer renderer = control.GetRendererAt( 0 );
+  DALI_TEST_CHECK( renderer );
+
+  tet_infoline( "Set semi transparent alpha with positive RGB values, renderer should not be changed" );
+  const Vector4 newColor( 1.0f, 1.0f, 0.5f, 0.5f );
+  control.SetBackgroundColor( newColor );
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS( control.GetRendererCount(), 1u, TEST_LOCATION );
+  DALI_TEST_EQUALS( GetControlBackgroundColor( control ), newColor, TEST_LOCATION );
+  DALI_TEST_EQUALS( renderer, control.GetRendererAt( 0 ), TEST_LOCATION );
+
   tet_infoline( "Set transparent, ensure no renderers are created" );
   control.SetBackgroundColor( Color::TRANSPARENT );
   application.SendNotification();