[dali_1.9.14] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Rect.cpp
index dfe0278..b5f50a6 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.
@@ -18,7 +18,7 @@
 #include <iostream>
 
 #include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 
 using namespace Dali;
@@ -65,7 +65,7 @@ int UtcDaliRectCons03(void)
 
   Rect<float> rect(10.0f, 20.0f, 400.0f, 200.0f);
 
-  Rect<float> r2 = rect;
+  Rect<float> r2(rect);
 
   DALI_TEST_EQUALS(r2.x, 10.0f, 0.001, TEST_LOCATION);
   DALI_TEST_EQUALS(r2.y, 20.0f, 0.001, TEST_LOCATION);
@@ -78,9 +78,25 @@ int UtcDaliRectCons04(void)
 {
   TestApplication application;
 
+  Vector4 vec4(10.0f, 20.0f, 400.0f, 200.0f);
+
+  Rect<float> rect(vec4);
+
+  DALI_TEST_EQUALS(rect.x, 10.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.y, 20.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.width, 400.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.height, 200.0f, 0.001, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliRectAssignmentOperatorRect(void)
+{
+  TestApplication application;
+
   Rect<float> rect(10.0f, 20.0f, 400.0f, 200.0f);
 
-  Rect<float> r2(rect);
+  Rect<float> r2;
+  r2 = rect;
 
   DALI_TEST_EQUALS(r2.x, 10.0f, 0.001, TEST_LOCATION);
   DALI_TEST_EQUALS(r2.y, 20.0f, 0.001, TEST_LOCATION);
@@ -89,6 +105,22 @@ int UtcDaliRectCons04(void)
   END_TEST;
 }
 
+int UtcDaliRectAssignmentOperatorVector4(void)
+{
+  TestApplication application;
+
+  Vector4 vec4(10.0f, 20.0f, 400.0f, 200.0f);
+
+  Rect<float> rect;
+  rect = vec4;
+
+  DALI_TEST_EQUALS(rect.x, 10.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.y, 20.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.width, 400.0f, 0.001, TEST_LOCATION);
+  DALI_TEST_EQUALS(rect.height, 200.0f, 0.001, TEST_LOCATION);
+  END_TEST;
+}
+
 int UtcDaliRectSet(void)
 {
   TestApplication application;
@@ -126,6 +158,16 @@ int UtcDaliRectIsEmpty(void)
   END_TEST;
 }
 
+int UtcDaliRectLeft(void)
+{
+  TestApplication application;
+
+  Rect<float> rf(10.0f, 20.0f, 400.0f, 200.0f);
+
+  DALI_TEST_EQUALS(rf.Left(), 10.0f, 0.001, TEST_LOCATION);
+  END_TEST;
+}
+
 int UtcDaliRectRight(void)
 {
   TestApplication application;
@@ -136,6 +178,15 @@ int UtcDaliRectRight(void)
   END_TEST;
 }
 
+int UtcDaliRectTop(void)
+{
+  TestApplication application;
+
+  Rect<float> rf(10.0f, 20.0f, 400.0f, 200.0f);
+
+  DALI_TEST_EQUALS(rf.Top(), 20.0f, 0.001, TEST_LOCATION);
+  END_TEST;
+}
 
 int UtcDaliRectBottom(void)
 {
@@ -276,3 +327,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;
+}