Output stream insert support added to property value 43/37243/6
authorNick Holland <nick.holland@partner.samsung.com>
Mon, 23 Mar 2015 09:21:49 +0000 (09:21 +0000)
committerNick Holland <nick.holland@partner.samsung.com>
Wed, 25 Mar 2015 07:54:23 +0000 (00:54 -0700)
Change-Id: If7bcca7975c75c6d59c6bd5fbe5b94c7a564d71c

13 files changed:
automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/utc-Dali-Handle.cpp
automated-tests/src/dali/utc-Dali-PropertyValue.cpp [new file with mode: 0644]
dali/public-api/math/matrix.h
dali/public-api/math/rect.h
dali/public-api/math/vector2.cpp
dali/public-api/math/vector2.h
dali/public-api/math/vector3.h
dali/public-api/math/vector4.h
dali/public-api/object/property-types.cpp
dali/public-api/object/property-types.h
dali/public-api/object/property-value.cpp
dali/public-api/object/property-value.h

index 4d1fc2b..645ce4a 100644 (file)
@@ -65,6 +65,7 @@ SET(TC_SOURCES
         utc-Dali-Pixel.cpp
         utc-Dali-PropertyMap.cpp
         utc-Dali-PropertyNotification.cpp
+        utc-Dali-PropertyValue.cpp
         utc-Dali-Quaternion.cpp
         utc-Dali-Radian.cpp
         utc-Dali-Random.cpp
index 1ff33c1..e25dd4b 100644 (file)
@@ -57,94 +57,6 @@ Handle ImplicitCopyConstructor(Handle passedByValue)
   return passedByValue;
 }
 
-void CheckTypeName(const Property::Type& type)
-{
-  switch(type)
-  {
-    case Property::NONE:
-    {
-      DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::BOOLEAN:
-    {
-      DALI_TEST_CHECK( "BOOLEAN" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::FLOAT:
-    {
-      DALI_TEST_CHECK( "FLOAT" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::INTEGER:
-    {
-      DALI_TEST_CHECK( "INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::UNSIGNED_INTEGER:
-    {
-      DALI_TEST_CHECK( "UNSIGNED_INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::VECTOR2:
-    {
-      DALI_TEST_CHECK( "VECTOR2" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::VECTOR3:
-    {
-      DALI_TEST_CHECK( "VECTOR3" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::VECTOR4:
-    {
-      DALI_TEST_CHECK( "VECTOR4" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::MATRIX3:
-    {
-      DALI_TEST_CHECK( "MATRIX3" == std::string(PropertyTypes::GetName( type  ) ) );
-      break;
-    }
-    case Property::MATRIX:
-    {
-      DALI_TEST_CHECK( "MATRIX" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::RECTANGLE:
-    {
-      DALI_TEST_CHECK( "RECTANGLE" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::ROTATION:
-    {
-      DALI_TEST_CHECK( "ROTATION" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::STRING:
-    {
-      DALI_TEST_CHECK( "STRING" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::ARRAY:
-    {
-      DALI_TEST_CHECK( "ARRAY" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::MAP:
-    {
-      DALI_TEST_CHECK( "MAP" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-    case Property::TYPE_COUNT:
-    {
-      DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
-      break;
-    }
-  } // switch(type)
-
-} // CheckTypeName
-
 } // anon namespace
 
 
@@ -797,187 +709,6 @@ int UtcDaliHandleDownCastNegative(void)
   END_TEST;
 }
 
-int UtcDaliHandleCreateProperty(void)
-{
-  TestApplication application;
-  tet_infoline("Testing PropertyTypes::GetName()");
-
-  Property::Type type = Property::NONE;
-  CheckTypeName(type);
-  // Value(Value&) ctor and Value(Type&) ctor
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( Property::NONE == type );
-
-  // PropertyTypes
-  type = Property::BOOLEAN;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<bool>()            == type );
-
-  type = Property::FLOAT;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<float>()           == type );
-
-  type = Property::INTEGER;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<int>()             == type );
-
-  type = Property::UNSIGNED_INTEGER;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<unsigned int>()    == type );
-
-  type = Property::VECTOR2;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Vector2>()         == type );
-
-  type = Property::VECTOR3;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Vector3>()         == type );
-
-  type = Property::VECTOR4;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Vector4>()         == type );
-
-  type = Property::MATRIX3;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Matrix3>()         == type );
-
-  type = Property::MATRIX;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Matrix>()          == type );
-
-  typedef Dali::Rect<int> Rectangle;
-  type = Property::RECTANGLE;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Rectangle>()       == type );
-
-  type = Property::ROTATION;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Quaternion>()      == type );
-
-  type = Property::ROTATION;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<AngleAxis>()       == type );
-
-  type = Property::STRING;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<std::string>()     == type );
-
-  type = Property::ARRAY;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Property::Array>() == type );
-
-  type = Property::MAP;
-  CheckTypeName(type);
-  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
-  DALI_TEST_CHECK( PropertyTypes::Get<Property::Map>()   == type );
-  END_TEST;
-}
-
-int UtcDaliHandleGetPropertyGet(void)
-{
-  TestApplication application;
-  tet_infoline("Testing PropertyTypes::GetName()");
-
-  Property::Value value;
-
-  bool b = false;
-  value = Property::Value(true);
-  value.Get(b);
-  DALI_TEST_CHECK( true == b );
-
-  float f = 5.f;
-  value = Property::Value(10.f);
-  value.Get(f);
-  DALI_TEST_CHECK( Dali::Equals(10.f, f) );
-
-  int i = 5;
-  value = Property::Value(10);
-  value.Get(i);
-  DALI_TEST_CHECK( 10 == i );
-
-  unsigned int ui = 5;
-  value = Property::Value(10U);
-  value.Get(ui);
-  DALI_TEST_CHECK( 10 == ui );
-
-  Vector2 v2 = Vector2(0,0);
-  value = Property::Value( Vector2(1,1) );
-  value.Get(v2);
-  DALI_TEST_CHECK( Vector2(1,1) == v2 );
-
-  Vector3 v3 = Vector3(0.f,0.f,0.f);
-  value = Property::Value( Vector3(1.f,1.f,1.f) );
-  value.Get(v3);
-  DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == v3 );
-
-  Vector4 v4 = Vector4(0,0,0,0);
-  value = Property::Value( Vector4(1,1,1,1) );
-  value.Get(v4);
-  DALI_TEST_CHECK( Vector4(1,1,1,1) == v4 );
-
-  Matrix3 m3 = Matrix3(0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f);
-  value = Property::Value( Matrix3::IDENTITY );
-  value.Get(m3);
-  DALI_TEST_CHECK( Matrix3::IDENTITY == m3 );
-
-  Matrix m = Matrix(true);
-  value = Property::Value( Matrix::IDENTITY );
-  value.Get(m);
-  DALI_TEST_CHECK( Matrix::IDENTITY == m );
-
-  typedef Dali::Rect<int> Rectangle;
-  Rectangle r = Rectangle(0,0,0,0);
-  value = Property::Value( Rectangle(1,1,1,1) );
-  value.Get(r);
-  DALI_TEST_CHECK( Rectangle(1,1,1,1) == r );
-
-  Quaternion q = Quaternion(0,0,0,0);
-  value = Property::Value( Quaternion(1,1,1,1) );
-  value.Get(q);
-  DALI_TEST_CHECK( Quaternion(1,1,1,1) == q );
-
-  AngleAxis aa = AngleAxis( Degree(0), Vector3(0.f,0.f,0.f) );
-  value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS  ));
-  value.Get(aa);
-  Quaternion r8(Radian(Degree(aa.angle)), aa.axis);
-  DALI_TEST_EQUALS(r8, Quaternion(Math::PI_2, Vector3::XAXIS), 0.001, TEST_LOCATION);
-
-  std::string s = "no";
-  value = Property::Value("yes");
-  value.Get(s);
-  DALI_TEST_CHECK( "yes" == s );
-
-  Property::Array array;
-  value = Property::Value(Property::ARRAY);
-  value.AppendItem(10);
-  value.Get(array);
-  int getItem = 0;
-  array[0].Get(getItem);
-  DALI_TEST_CHECK( getItem == 10 );
-
-  Property::Map map;
-  value = Property::Value(Property::MAP);
-  value.SetValue("key", "value");
-  value.Get(map);
-  DALI_TEST_CHECK( map.GetKey(0) == "key" );
-
-  END_TEST;
-}
-
 int UtcDaliHandleGetPropertyIndices(void)
 {
   TestApplication application;
diff --git a/automated-tests/src/dali/utc-Dali-PropertyValue.cpp b/automated-tests/src/dali/utc-Dali-PropertyValue.cpp
new file mode 100644 (file)
index 0000000..c6d462f
--- /dev/null
@@ -0,0 +1,660 @@
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <iostream>
+#include <iomanip>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+
+namespace
+{
+
+void CheckTypeName(const Property::Type& type)
+{
+  switch(type)
+  {
+    case Property::NONE:
+    {
+      DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::BOOLEAN:
+    {
+      DALI_TEST_CHECK( "BOOLEAN" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::FLOAT:
+    {
+      DALI_TEST_CHECK( "FLOAT" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::INTEGER:
+    {
+      DALI_TEST_CHECK( "INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::UNSIGNED_INTEGER:
+    {
+      DALI_TEST_CHECK( "UNSIGNED_INTEGER" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::VECTOR2:
+    {
+      DALI_TEST_CHECK( "VECTOR2" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::VECTOR3:
+    {
+      DALI_TEST_CHECK( "VECTOR3" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::VECTOR4:
+    {
+      DALI_TEST_CHECK( "VECTOR4" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::MATRIX3:
+    {
+      DALI_TEST_CHECK( "MATRIX3" == std::string(PropertyTypes::GetName( type  ) ) );
+      break;
+    }
+    case Property::MATRIX:
+    {
+      DALI_TEST_CHECK( "MATRIX" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::RECTANGLE:
+    {
+      DALI_TEST_CHECK( "RECTANGLE" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::ROTATION:
+    {
+      DALI_TEST_CHECK( "ROTATION" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::STRING:
+    {
+      DALI_TEST_CHECK( "STRING" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::ARRAY:
+    {
+      DALI_TEST_CHECK( "ARRAY" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::MAP:
+    {
+      DALI_TEST_CHECK( "MAP" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+    case Property::TYPE_COUNT:
+    {
+      DALI_TEST_CHECK( "NONE" == std::string(PropertyTypes::GetName( type ) ) );
+      break;
+    }
+  } // switch(type)
+
+} // CheckTypeName
+
+} // unnamed namespace
+
+void utc_dali_property_value_startup(void)
+{
+  test_return_value = TET_UNDEF;
+}
+
+void utc_dali_property_value_cleanup(void)
+{
+  test_return_value = TET_PASS;
+}
+
+int UtcDaliPropertyValueConstructors01(void)
+{
+  // Testing PropertyValue construction using Property::Type
+  // also testing the PropertyTypes::GetName is correct for each type
+
+  TestApplication application;
+  tet_infoline("Testing Property::Value construction using  Property::Type");
+
+  Property::Value value;
+  DALI_TEST_CHECK( value.GetType() == Property::NONE );
+
+  Property::Type type = Property::NONE;
+  CheckTypeName(type);
+  // Value(Value&) ctor and Value(Type&) ctor
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( Property::NONE == type );
+
+  // PropertyTypes
+  type = Property::BOOLEAN;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<bool>()            == type );
+
+  type = Property::FLOAT;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<float>()           == type );
+
+  type = Property::INTEGER;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<int>()             == type );
+
+  type = Property::UNSIGNED_INTEGER;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<unsigned int>()    == type );
+
+  type = Property::VECTOR2;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Vector2>()         == type );
+
+  type = Property::VECTOR3;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Vector3>()         == type );
+
+  type = Property::VECTOR4;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Vector4>()         == type );
+
+  type = Property::MATRIX3;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Matrix3>()         == type );
+
+  type = Property::MATRIX;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Matrix>()          == type );
+
+  typedef Dali::Rect<int> Rectangle;
+  type = Property::RECTANGLE;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Rectangle>()       == type );
+
+  type = Property::ROTATION;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Quaternion>()      == type );
+
+  type = Property::ROTATION;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<AngleAxis>()       == type );
+
+  type = Property::STRING;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<std::string>()     == type );
+
+  type = Property::ARRAY;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Property::Array>() == type );
+
+  type = Property::MAP;
+  CheckTypeName(type);
+  DALI_TEST_CHECK( Property::Value(Property::Value(type)).GetType() == type );
+  DALI_TEST_CHECK( PropertyTypes::Get<Property::Map>()   == type );
+  END_TEST;
+
+}
+
+int UtcDaliPropertyValueConstructors02(void)
+{
+  // Testing PropertyValue construction using value / reference types
+  // also testing the PropertyTypes::Get return same value as constructed
+
+  TestApplication application;
+  tet_infoline("Testing Property::Value construction using values / references");
+
+  Property::Value value;
+
+  bool b = false;
+  value = Property::Value(true);
+  value.Get(b);
+  DALI_TEST_CHECK( true == b );
+
+  float f = 5.f;
+  value = Property::Value(10.f);
+  value.Get(f);
+  DALI_TEST_CHECK( Dali::Equals(10.f, f) );
+
+  int i = 5;
+  value = Property::Value(10);
+  value.Get(i);
+  DALI_TEST_CHECK( 10 == i );
+
+  unsigned int ui = 5;
+  value = Property::Value(10U);
+  value.Get(ui);
+  DALI_TEST_CHECK( 10 == ui );
+
+  Vector2 v2 = Vector2(0,0);
+  value = Property::Value( Vector2(1,1) );
+  value.Get(v2);
+  DALI_TEST_CHECK( Vector2(1,1) == v2 );
+
+  Vector3 v3 = Vector3(0.f,0.f,0.f);
+  value = Property::Value( Vector3(1.f,1.f,1.f) );
+  value.Get(v3);
+  DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == v3 );
+
+  Vector4 v4 = Vector4(0,0,0,0);
+  value = Property::Value( Vector4(1,1,1,1) );
+  value.Get(v4);
+  DALI_TEST_CHECK( Vector4(1,1,1,1) == v4 );
+
+  Matrix3 m3 = Matrix3(0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f,0.f);
+  value = Property::Value( Matrix3::IDENTITY );
+  value.Get(m3);
+  DALI_TEST_CHECK( Matrix3::IDENTITY == m3 );
+
+  Matrix m = Matrix(true);
+  value = Property::Value( Matrix::IDENTITY );
+  value.Get(m);
+  DALI_TEST_CHECK( Matrix::IDENTITY == m );
+
+  typedef Dali::Rect<int> Rectangle;
+  Rectangle r = Rectangle(0,0,0,0);
+  value = Property::Value( Rectangle(1,1,1,1) );
+  value.Get(r);
+  DALI_TEST_CHECK( Rectangle(1,1,1,1) == r );
+
+  Quaternion q = Quaternion(0,0,0,0);
+  value = Property::Value( Quaternion(1,1,1,1) );
+  value.Get(q);
+  DALI_TEST_CHECK( Quaternion(1,1,1,1) == q );
+
+  AngleAxis aa = AngleAxis( Degree(0), Vector3(0.f,0.f,0.f) );
+  value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS  ));
+  value.Get(aa);
+  Quaternion r8(Radian(Degree(aa.angle)), aa.axis);
+  DALI_TEST_EQUALS(r8, Quaternion(Math::PI_2, Vector3::XAXIS), 0.001, TEST_LOCATION);
+
+  std::string s = "no";
+  value = Property::Value("yes");
+  value.Get(s);
+  DALI_TEST_CHECK( "yes" == s );
+
+  Property::Array array;
+  value = Property::Value(Property::ARRAY);
+  value.AppendItem(10);
+  value.Get(array);
+  int getItem = 0;
+  array[0].Get(getItem);
+  DALI_TEST_CHECK( getItem == 10 );
+
+  Property::Map map;
+  value = Property::Value(Property::MAP);
+  value.SetValue("key", "value");
+  value.Get(map);
+  DALI_TEST_CHECK( map.GetKey(0) == "key" );
+
+  END_TEST;
+}
+
+
+int UtcDaliPropertyValueCopyConstructors01(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Property::Value copy construction using values / references");
+
+  Property::Value value;
+
+  value = Property::Value(true);
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( true == copy.Get<bool>() );
+  }
+
+  value = Property::Value(10.f);
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Dali::Equals(10.f, copy.Get<float>() ) );
+  }
+
+  value = Property::Value(10);
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( 10 == copy.Get<int>() );
+  }
+
+  value = Property::Value(10U);
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( 10 == copy.Get< unsigned int>() );
+  }
+
+  value = Property::Value( Vector2(1,1) );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Vector2(1,1) == copy.Get<Vector2>() );
+  }
+
+  value = Property::Value( Vector3(1.f,1.f,1.f) );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == copy.Get<Vector3>() );
+  }
+
+  value = Property::Value( Vector4(1,1,1,1) );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Vector4(1,1,1,1) == copy.Get<Vector4>() );
+  }
+
+  value = Property::Value( Matrix3::IDENTITY );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Matrix3::IDENTITY == copy.Get<Matrix3>() );
+  }
+
+  value = Property::Value( Matrix::IDENTITY );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Matrix::IDENTITY == copy.Get<Matrix>()  );
+  }
+
+  typedef Dali::Rect<int> Rectangle;
+
+  value = Property::Value( Rectangle(1,1,1,1) );
+  {
+    Property::Value copy( value );
+    Rectangle copyRect;
+    copy.Get(copyRect);
+    DALI_TEST_CHECK(  Rectangle(1,1,1,1) == copyRect);
+  }
+
+  value = Property::Value( Quaternion(1,1,1,1) );
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( Quaternion(1,1,1,1) == copy.Get<Quaternion>() );
+  }
+
+  value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS  ));
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( value.Get<AngleAxis>().axis == copy.Get<AngleAxis>().axis );
+    DALI_TEST_CHECK( value.Get<AngleAxis>().angle == copy.Get<AngleAxis>().angle );
+  }
+
+  value = Property::Value("yes");
+  {
+    Property::Value copy( value );
+    DALI_TEST_CHECK( "yes" == copy.Get<std::string>() );
+  }
+
+  Property::Array array;
+  value = Property::Value(Property::ARRAY);
+  value.AppendItem(10);
+  {
+    Property::Value copy( value );
+    copy.Get( array );
+    int getItem = 0;
+    array[0].Get( getItem );
+    DALI_TEST_CHECK( getItem == 10 );
+  }
+  Property::Map map;
+  value = Property::Value(Property::MAP);
+  value.SetValue("key", "value");
+  {
+    Property::Value copy( value );
+    copy.Get( map );
+    DALI_TEST_CHECK( map.GetKey(0) == "key" );
+  }
+
+  END_TEST;
+}
+
+
+int UtcDaliPropertyValueAssignmentOperator01(void)
+{
+  // Testing Property Value assignment
+  TestApplication application;
+  tet_infoline("Testing Property::Value assignment operator");
+
+  Property::Value value;
+
+
+  value = Property::Value(true);
+  {
+    Property::Value copy( false );
+    copy = value;
+    DALI_TEST_CHECK( true == copy.Get<bool>() );
+  }
+
+  value = Property::Value(10.f);
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Dali::Equals(10.f, copy.Get<float>() ) );
+  }
+
+  value = Property::Value(10);
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( 10 == copy.Get<int>() );
+  }
+
+  value = Property::Value(10U);
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( 10 == copy.Get< unsigned int>() );
+  }
+
+  value = Property::Value( Vector2(1,1) );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Vector2(1,1) == copy.Get<Vector2>() );
+  }
+
+  value = Property::Value( Vector3(1.f,1.f,1.f) );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Vector3(1.f,1.f,1.f) == copy.Get<Vector3>() );
+  }
+
+  value = Property::Value( Vector4(1,1,1,1) );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Vector4(1,1,1,1) == copy.Get<Vector4>() );
+  }
+
+  value = Property::Value( Matrix3::IDENTITY );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Matrix3::IDENTITY == copy.Get<Matrix3>() );
+  }
+
+  value = Property::Value( Matrix::IDENTITY );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Matrix::IDENTITY == copy.Get<Matrix>()  );
+  }
+
+  typedef Dali::Rect<int> Rectangle;
+
+  value = Property::Value( Rectangle(1,1,1,1) );
+  {
+    Property::Value copy(false);
+    copy = value;
+    Rectangle copyRect;
+    copy.Get(copyRect);
+    DALI_TEST_CHECK(  Rectangle(1,1,1,1) == copyRect);
+  }
+
+  value = Property::Value( Quaternion(1,1,1,1) );
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( Quaternion(1,1,1,1) == copy.Get<Quaternion>() );
+  }
+
+  value = Property::Value( AngleAxis( Radian(Math::PI_2), Vector3::XAXIS  ));
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( value.Get<AngleAxis>().axis == copy.Get<AngleAxis>().axis );
+    DALI_TEST_CHECK( value.Get<AngleAxis>().angle == copy.Get<AngleAxis>().angle );
+  }
+
+  value = Property::Value("yes");
+  {
+    Property::Value copy(false);
+    copy = value;
+    DALI_TEST_CHECK( "yes" == copy.Get<std::string>() );
+  }
+
+  Property::Array array;
+  value = Property::Value(Property::ARRAY);
+  value.AppendItem(10);
+  {
+    Property::Value copy(false);
+    copy = value;
+    copy.Get( array );
+    int getItem = 0;
+    array[0].Get( getItem );
+    DALI_TEST_CHECK( getItem == 10 );
+  }
+  Property::Map map;
+  value = Property::Value(Property::MAP);
+  value.SetValue("key", "value");
+  {
+    Property::Value copy(false);
+    copy = value;
+    copy.Get( map );
+    DALI_TEST_CHECK( map.GetKey(0) == "key" );
+  }
+
+  END_TEST;
+}
+
+
+int UtcDaliPropertyValueOutputStream(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Property::Value output stream");
+  typedef Dali::Rect<int> Rectangle;
+
+  Property::Value value(true);
+  {
+    std::ostringstream stream;
+    stream << value;
+    DALI_TEST_CHECK( stream.str() == "1")
+  }
+
+  {
+    value = Property::Value(20.2f);
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "20.2")
+  }
+
+  {
+    value = Property::Value(-25);
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "-25")
+  }
+
+  {
+    value = Property::Value(25U);
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "25")
+  }
+
+  {
+    value = Property::Value( Vector2(1.f,1.f) );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[1, 1]");
+  }
+
+  {
+    value = Property::Value( Vector3(1.f,1.f,1.f) );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[1, 1, 1]");
+  }
+
+  {
+    value = Property::Value( Matrix3::IDENTITY );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]");
+  }
+
+  {
+    value = Property::Value( Matrix::IDENTITY );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1] ]");
+  }
+
+  {
+    value = Property::Value( Rectangle(1,2,3,4) );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( stream.str() == "[1, 2, 3, 4]");
+  }
+
+  {
+    value = Property::Value( AngleAxis( Radian(1.2f), Vector3::XAXIS ));
+    std::ostringstream stream;
+    stream <<  value;
+    tet_printf("angle axis = %s \n", stream.str().c_str() );
+    DALI_TEST_CHECK( stream.str() == "[1.2, -0, 0, 0]");
+  }
+
+  // Maps and arrays currently not supported, we just check a message is output
+  {
+    Property::Map map;
+    value = Property::Value( map );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( !stream.str().empty() );
+  }
+  {
+    Property::Array array;
+    value = Property::Value( array );
+    std::ostringstream stream;
+    stream <<  value;
+    DALI_TEST_CHECK( !stream.str().empty() );
+  }
+
+
+  END_TEST;
+
+}
index 15b8d7d..d483684 100644 (file)
  *
  */
 
+// EXTERNAL INCLUDES
+#include <ostream>
+
 // INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/vector4.h>
 
 namespace Dali
index 44ac5ed..89e815c 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <math.h>
+#include <ostream>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/math/math-utils.h>
@@ -264,6 +265,44 @@ inline bool Rect<float>::IsEmpty() const
           fabsf(height) <= GetRangedEpsilon(height, height));
 }
 
+/**
+ * @brief Convert the value of the rectangle into a string and insert in to an output stream.
+ *
+ * @param [in] stream The output stream operator.
+ * @param [in] rectangle the rectangle to output
+ * @return The output stream operator.
+ */
+inline std::ostream& operator<< (std::ostream& stream, const Rect<int>& rectangle)
+{
+  return stream << "[" << rectangle.x << ", " << rectangle.y << ", " << rectangle.width << ", " << rectangle.height << "]";
+}
+
+/**
+ * @brief Convert the value of the rectangle into a string and insert in to an output stream.
+ *
+ * @param [in] stream The output stream operator.
+ * @param [in] rectangle the rectangle to output
+ * @return The output stream operator.
+ */
+inline std::ostream& operator<< (std::ostream& stream, const Rect<unsigned int>& rectangle)
+{
+  return stream << "[" << rectangle.x << ", " << rectangle.y << ", " << rectangle.width << ", " << rectangle.height << "]";
+}
+
+/**
+ * @brief Convert the value of the rectangle into a string and insert in to an output stream.
+ *
+ * @param [in] stream The output stream operator.
+ * @param [in] rectangle the rectangle to output
+ * @return The output stream operator.
+ */
+inline std::ostream& operator<< (std::ostream& stream, const Rect<float>& rectangle)
+{
+  return stream << "[" << rectangle.x << ", " << rectangle.y << ", " << rectangle.width << ", " << rectangle.height << "]";
+}
+
+
+
 } // namespace Dali
 
 #endif // __DALI_RECT_H__
index d5475d0..52500ef 100644 (file)
@@ -20,7 +20,6 @@
 
 // EXTERNAL INCLUDES
 #include <math.h>
-#include <iostream>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
index dd1e7ab..7e4c552 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <iosfwd>
+#include <ostream>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
index 22d18bb..7531f2a 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <iosfwd>
+#include <ostream>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
index 6cfc206..132e7d1 100644 (file)
@@ -19,7 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
-#include <iosfwd>
+#include <ostream>
 
 // INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
index 6ad7d73..49e5cda 100644 (file)
@@ -47,7 +47,7 @@ namespace PropertyTypes
 {
 
 DALI_EXPORT_API
-const char* GetName(Property::Type type)
+const char* const GetName(Property::Type type)
 {
   if (type < Property::TYPE_COUNT)
   {
index 2c1df6d..35d6541 100644 (file)
@@ -46,7 +46,7 @@ namespace PropertyTypes
  * @param [in] type The property type.
  * @return The name of this type.
  */
-DALI_IMPORT_API const char* GetName(Property::Type type);
+DALI_IMPORT_API const char* const GetName(Property::Type type);
 
 /**
  * @brief Retrieve an enumerated property type.
index 2d91f3e..4e429f2 100644 (file)
@@ -975,5 +975,108 @@ int Property::Value::GetSize() const
   return ret;
 }
 
+std::ostream& operator<< (std::ostream& stream, const Property::Value& value )
+{
+
+  const Property::Value::Impl& impl( *value.mImpl );
+
+  switch( impl.mType )
+  {
+    case Dali::Property::STRING:
+    {
+      stream <<  AnyCast<std::string>(impl.mValue).c_str();
+      break;
+    }
+    case Dali::Property::VECTOR2:
+    {
+      stream << AnyCast<Vector2>(impl.mValue);
+      break;
+    }
+    case Dali::Property::VECTOR3:
+    {
+      stream << AnyCast<Vector3>(impl.mValue);
+      break;
+    }
+    case Dali::Property::VECTOR4:
+    {
+      stream << AnyCast<Vector4>(impl.mValue);
+      break;
+    }
+    case Dali::Property::MATRIX:
+    {
+      stream << AnyCast<Matrix>(impl.mValue);
+      break;
+    }
+    case Dali::Property::BOOLEAN:
+    {
+      stream << AnyCast<bool>(impl.mValue);
+      break;
+    }
+    case Dali::Property::FLOAT:
+    {
+      stream << AnyCast<float>(impl.mValue);
+      break;
+    }
+    case Dali::Property::INTEGER:
+    {
+       stream << AnyCast<int>(impl.mValue);
+       break;
+    }
+    case Dali::Property::UNSIGNED_INTEGER:
+    {
+      stream << AnyCast<unsigned int>(impl.mValue);
+      break;
+    }
+    case Dali::Property::RECTANGLE:
+    {
+      Dali::Rect<int> rect; // Propery Value rectangles are currently integer based
+      value.Get( rect );
+      stream << rect;
+      break;
+    }
+    case Dali::Property::MATRIX3:
+    {
+      stream << AnyCast<Matrix3>(impl.mValue);
+      break;
+    }
+    case Dali::Property::ROTATION:
+    {
+      // @todo this may change to Quaternion
+      Dali::Quaternion q;
+      value.Get( q );
+      Dali::Vector4 v4 = q.EulerAngles();
+      stream << v4;
+      break;
+    }
+
+    case Dali::Property::ARRAY:
+    {
+      // @todo Need to think about the best way to support array
+      // E.g Do we want to create a JSON style array like:
+      // [ {"property-name-0":"property-value-0", "property-name-1":"property-value-1"} ]
+      stream << "ARRAY unsupported";
+      break;
+    }
+    case Dali::Property::MAP:
+    {
+      Dali::Property::Map map;
+      value.Get( map );
+      stream << "Map containing " << map.Count() << " elements";
+      break;
+    }
+    case Dali::Property::TYPE_COUNT:
+    {
+      stream << "unsupported TYPE_COUNT";
+      break;
+    }
+    default:
+    {
+      stream << "unsupported type = " << value.GetType();
+      break;
+    }
+  }
+  return stream;
+}
+
 
 } // namespace Dali
index 55746bf..f45fa49 100644 (file)
@@ -18,6 +18,9 @@
  *
  */
 
+// EXTERNAL INCLUDES
+#include <ostream>
+
 // INTERNAL INCLUDES
 #include <dali/public-api/object/property.h>
 #include <dali/public-api/math/rect.h>
@@ -40,6 +43,8 @@ class DALI_IMPORT_API Property::Value
 {
 public:
 
+  friend std::ostream& operator<< (std::ostream& ouputStream, const Property::Value& value);
+
   /**
    * @brief Default constructor.
    *
@@ -417,6 +422,16 @@ private:
   Impl* mImpl; ///< Pointer to the implementation
 };
 
+/**
+ * @brief Convert the value of the property into a string and append to an output stream.
+ *
+ * @param [in] ouputStream The output stream operator.
+ * @param [in] value The value to insert
+ * @return The output stream operator.
+ */
+DALI_IMPORT_API std::ostream& operator<< (std::ostream& ouputStream, const Property::Value& value);
+
+
 } // namespace Dali
 
 #endif // __DALI_PROPERTY_VALUE_H__