Add UTCs for public-api 16/44216/1
authortaeyoon <taeyoon0.lee@samsung.com>
Mon, 20 Jul 2015 02:58:58 +0000 (11:58 +0900)
committertaeyoon <taeyoon0.lee@samsung.com>
Mon, 20 Jul 2015 03:01:47 +0000 (12:01 +0900)
Change-Id: I50392f9caceebb5a39846058181f79ddada9a443

automated-tests/src/dali/CMakeLists.txt
automated-tests/src/dali/utc-Dali-AngleAxis.cpp
automated-tests/src/dali/utc-Dali-BaseHandle.cpp
automated-tests/src/dali/utc-Dali-Constrainer.cpp [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-MathUtils.cpp
automated-tests/src/dali/utc-Dali-PropertyArray.cpp
automated-tests/src/dali/utc-Dali-Rect.cpp

index a508a2b..d474038 100644 (file)
@@ -75,6 +75,7 @@ SET(TC_SOURCES
         utc-Dali-Vector3.cpp
         utc-Dali-Vector4.cpp
         utc-Dali-WheelEvent.cpp
+        utc-Dali-Constrainer.cpp
 )
 
 LIST(APPEND TC_SOURCES
index c4fd31a..515ead5 100644 (file)
@@ -98,3 +98,18 @@ int UtcDaliAngleAxisCopy(void)
   DALI_TEST_EQUALS(b.axis, Vector3::ZAXIS, 0.001f, TEST_LOCATION);
   END_TEST;
 }
+
+int UtcDaliAngleAxisEqual(void)
+{
+  TestApplication application;
+
+  Radian r(Math::PI_2);
+  AngleAxis a(r, Vector3::ZAXIS);
+  AngleAxis b(a);
+
+  tet_result((a == b) ? TET_PASS : TET_FAIL);
+
+  b.axis = Vector3::YAXIS;
+  tet_result(!(a == b) ? TET_PASS : TET_FAIL);
+  END_TEST;
+}
index 79dadba..9e3da41 100644 (file)
@@ -522,3 +522,14 @@ int UtcDaliBaseHandleBooleanCast(void)
   DALI_TEST_CHECK( static_cast<BaseHandle::BooleanType>( handle ) );
   END_TEST;
 }
+
+int UtcDaliBaseHandleCompareOperatorN(void)
+{
+  TestApplication application;
+  BaseHandle handle1 = Actor::New();
+  BaseHandle handle2 = handle1;
+
+  DALI_TEST_CHECK( (handle1 < handle2) == false );
+
+  END_TEST;
+}
diff --git a/automated-tests/src/dali/utc-Dali-Constrainer.cpp b/automated-tests/src/dali/utc-Dali-Constrainer.cpp
new file mode 100644 (file)
index 0000000..3398341
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2014 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 <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali/devel-api/animation/path-constrainer.h>
+#include <dali-test-suite-utils.h>
+
+using namespace Dali;
+using namespace Dali::Internal;
+
+namespace
+{
+static void SetupLinearConstrainerUniformProgress( Dali::LinearConstrainer& linearConstrainer)
+{
+  Dali::Property::Array points;
+  points.Resize(3);
+  points[0] = 0.0f;
+  points[1] = 1.0f;
+  points[2] = 0.0f;
+  linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
+}
+
+static void SetupLinearConstrainerNonUniformProgress( Dali::LinearConstrainer& linearConstrainer)
+{
+  Dali::Property::Array points;
+  points.Resize(3);
+  points[0] = 0.0f;
+  points[1] = 1.0f;
+  points[2] = 0.0f;
+  linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::VALUE, points );
+
+  points[0] = 0.0f;
+  points[1] = 0.25f;
+  points[2] = 1.0f;
+  linearConstrainer.SetProperty( Dali::LinearConstrainer::Property::PROGRESS, points );
+}
+
+} // anonymous namespace
+
+int UtcLinearConstrainerApply(void)
+{
+  TestApplication application;
+
+  Dali::Actor actor = Dali::Actor::New();
+
+  // Register a float property
+  Property::Index index = actor.RegisterProperty( "t", 0.0f );
+
+  Dali::Stage::GetCurrent().Add(actor);
+
+
+  //Create a LinearConstrainer without specifying progress for values
+  Dali::LinearConstrainer linearConstrainer = Dali::LinearConstrainer::New();
+  SetupLinearConstrainerUniformProgress( linearConstrainer );
+
+  //Apply the linear constraint to the actor's position. The source property for the constraint will be the custom property "t"
+  Vector2 range( 0.0f, 1.0f );
+  linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+  //Create an animation to animate the custom property
+  float durationSeconds(1.0f);
+  Dali::Animation animation = Dali::Animation::New(durationSeconds);
+  animation.AnimateTo(Dali::Property(actor,index),1.0f);
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.5f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+  //Setup a LinearConstrainer specifying the progress for each value
+  linearConstrainer.Remove(actor);
+  SetupLinearConstrainerNonUniformProgress( linearConstrainer );
+  linearConstrainer.Apply( Property(actor,Dali::Actor::Property::POSITION_X), Property(actor,index), range );
+
+  actor.SetProperty(index,0.0f);
+  animation.Play();
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 25% progress */);
+
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 50% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 2.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 75% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 1.0f/3.0f, Math::MACHINE_EPSILON_1, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* 100% progress */);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render(static_cast<unsigned int>(durationSeconds*250.0f)/* beyond the animation duration*/);
+  DALI_TEST_EQUALS( actor.GetCurrentPosition().x, 0.0f, TEST_LOCATION );
+
+  END_TEST;
+}
+
index 1bed5ef..d8a5b4e 100644 (file)
@@ -33,6 +33,32 @@ void utc_dali_math_utils_cleanup(void)
   test_return_value = TET_PASS;
 }
 
+int UtcDaliMathUtilsIsPowerOfTwo(void)
+{
+  Dali::TestApplication testApp;
+  DALI_TEST_EQUALS(IsPowerOfTwo(0), false, TEST_LOCATION);
+
+  DALI_TEST_EQUALS(IsPowerOfTwo(1), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(2), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(3), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(4), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(5), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(6), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(7), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(8), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(255), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(256), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(257), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(511), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(512), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(513), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(768), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(1023), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(1024), true, TEST_LOCATION);
+  DALI_TEST_EQUALS(IsPowerOfTwo(1025), false, TEST_LOCATION);
+
+  END_TEST;
+}
 
 int UtcDaliMathUtilsNextPowerOfTwoP(void)
 {
index 84b33d7..f55004b 100644 (file)
@@ -206,3 +206,16 @@ int UtcDaliPropertyArrayAssignmentOperatorP(void)
 
   END_TEST;
 }
+
+int UtcDaliPropertyArrayResize(void)
+{
+  Property::Array array;
+
+  array.Resize(3);
+  DALI_TEST_CHECK( array.Count() == 3 );
+
+  array.Resize(5);
+  DALI_TEST_CHECK( array.Count() == 5 );
+
+  END_TEST;
+}
index 708c25c..24ce9d8 100644 (file)
@@ -295,3 +295,18 @@ int UtcDaliRectOperatorEquals(void)
   DALI_TEST_CHECK(ri1 == ri1p);
   END_TEST;
 }
+
+int UtcDaliRectOStreamOperatorP(void)
+{
+  TestApplication application;
+  std::ostringstream oss;
+
+  Rect<int> rect( 1, 2, 10, 10 );
+
+  oss << rect;
+
+  std::string expectedOutput = "[1, 2, 10, 10]";
+
+  DALI_TEST_EQUALS( oss.str(), expectedOutput, TEST_LOCATION);
+  END_TEST;
+}