UTC test coverage 98/39998/3
authorLee Morgan <Lee.morgan@partner.samsung.com>
Wed, 27 May 2015 10:50:49 +0000 (11:50 +0100)
committerLee Morgan <Lee.morgan@partner.samsung.com>
Wed, 27 May 2015 15:00:07 +0000 (16:00 +0100)
Change-Id: I17b3366f7f287d5b4f233515490c76506cd7ecaf

12 files changed:
automated-tests/src/dali/dali-test-suite-utils/test-intrusive-ptr.h [new file with mode: 0644]
automated-tests/src/dali/utc-Dali-GestureDetector.cpp
automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp
automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp
automated-tests/src/dali/utc-Dali-NativeImage.cpp
automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp
automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp
automated-tests/src/dali/utc-Dali-Stage.cpp
automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp
automated-tests/src/dali/utc-Dali-TypeRegistry.cpp
automated-tests/src/dali/utc-Dali-Vector2.cpp
dali/public-api/common/intrusive-ptr.h

diff --git a/automated-tests/src/dali/dali-test-suite-utils/test-intrusive-ptr.h b/automated-tests/src/dali/dali-test-suite-utils/test-intrusive-ptr.h
new file mode 100644 (file)
index 0000000..03aafe3
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef __TEST_INTRUSIVE_PTR_H__
+#define __TEST_INTRUSIVE_PTR_H__
+
+/*
+ * 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.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <iostream>
+#include <stdlib.h>
+#include <dali/public-api/dali-core.h>
+#include <dali-test-suite-utils.h>
+
+namespace Dali
+{
+
+template <typename T>
+struct UtcCoverageIntrusivePtr
+{
+  typedef IntrusivePtr<T> (*Creator)();
+
+  void Check( Creator creator)
+  {
+    IntrusivePtr<T> a = creator();
+    IntrusivePtr<T> b = creator();
+
+    DALI_TEST_CHECK( a.Get() );
+
+    a.Reset();
+
+    T* pB = b.Detach();
+
+    a.Reset(pB);
+
+    DALI_TEST_CHECK(a);
+
+    a.Reset();
+
+  };
+
+};
+
+} // Dali
+
+#endif
+
+
index 4d06575..710c23b 100644 (file)
@@ -35,7 +35,7 @@ void utc_dali_gesture_detector_cleanup(void)
 }
 
 
-int UtcDaliGestureDetectorConstructorNegative(void)
+int UtcDaliGestureDetectorConstructorN(void)
 {
   TestApplication application;
 
@@ -55,7 +55,7 @@ int UtcDaliGestureDetectorConstructorNegative(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorConstructorPositive(void)
+int UtcDaliGestureDetectorConstructorP(void)
 {
   TestApplication application;
 
@@ -77,7 +77,32 @@ int UtcDaliGestureDetectorConstructorPositive(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDownCast(void)
+int UtcDaliGestureDetectorAssignP(void)
+{
+  TestApplication application;
+
+  // Use pan gesture as GestureDetector cannot be created.
+  GestureDetector detector = PanGestureDetector::New();
+  GestureDetector detector2;
+
+  detector2 = detector;
+
+  Actor actor = Actor::New();
+
+  try
+  {
+    detector2.Attach(actor);
+    tet_result(TET_PASS);
+  }
+  catch (DaliException& e)
+  {
+    DALI_TEST_PRINT_ASSERT( e );
+    tet_result(TET_FAIL);
+  }
+  END_TEST;
+}
+
+int UtcDaliGestureDetectorDownCastP(void)
 {
   TestApplication application;
   tet_infoline("Testing Dali::GestureDetector::DownCast()");
@@ -101,7 +126,7 @@ int UtcDaliGestureDetectorDownCast(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorAttachPositive(void)
+int UtcDaliGestureDetectorAttachP(void)
 {
   TestApplication application;
 
@@ -134,7 +159,7 @@ int UtcDaliGestureDetectorAttachPositive(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorAttachNegative(void)
+int UtcDaliGestureDetectorAttachN(void)
 {
   TestApplication application;
 
@@ -156,7 +181,7 @@ int UtcDaliGestureDetectorAttachNegative(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachPositive(void)
+int UtcDaliGestureDetectorDetachP(void)
 {
   TestApplication application;
 
@@ -191,7 +216,7 @@ int UtcDaliGestureDetectorDetachPositive(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative01(void)
+int UtcDaliGestureDetectorDetachN01(void)
 {
   TestApplication application;
 
@@ -213,7 +238,7 @@ int UtcDaliGestureDetectorDetachNegative01(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative02(void)
+int UtcDaliGestureDetectorDetachN02(void)
 {
   TestApplication application;
 
@@ -238,7 +263,7 @@ int UtcDaliGestureDetectorDetachNegative02(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachNegative03(void)
+int UtcDaliGestureDetectorDetachN03(void)
 {
   TestApplication application;
   TestGestureManager& gestureManager = application.GetGestureManager();
@@ -267,7 +292,7 @@ int UtcDaliGestureDetectorDetachNegative03(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachAll(void)
+int UtcDaliGestureDetectorDetachAllP(void)
 {
   TestApplication application;
 
@@ -295,7 +320,7 @@ int UtcDaliGestureDetectorDetachAll(void)
   END_TEST;
 }
 
-int UtcDaliGestureDetectorDetachAllNegative(void)
+int UtcDaliGestureDetectorDetachAllN(void)
 {
   TestApplication application;
   TestGestureManager& gestureManager = application.GetGestureManager();
index af67735..ccc6336 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
+#include <test-native-image.h>
 
 using namespace Dali;
 
@@ -340,6 +341,8 @@ int UtcDaliIntrusivePtrResetTN(void)
   END_TEST;
 }
 
+
+
 int UtcDaliIntrusivePtrOperatorBooleanTypeP(void)
 {
   tet_infoline( "Positive Test for Dali::IntrusivePtr::operator Booleantype()" );
@@ -347,6 +350,11 @@ int UtcDaliIntrusivePtrOperatorBooleanTypeP(void)
   IntrusivePtr<Counted> counted( new Counted );
   DALI_TEST_CHECK( counted.operator BooleanType() != 0 );
   DALI_TEST_CHECK( counted );
+
+  typedef void (IntrusivePtr<Counted>::*BoolIdiomFunc)() const;
+  BoolIdiomFunc func = static_cast<BoolIdiomFunc>( counted.operator BooleanType() );
+  ((counted).*func)(); // purely for test coverage
+
   counted.Reset();
   DALI_TEST_CHECK( counted.operator BooleanType() == 0 );
 
@@ -452,29 +460,3 @@ int UtcDaliIntrusivePtrOperatorNotEqualLeftPointerTU(void)
   DALI_TEST_EQUALS( operator!=( counted2.Get(), countedSubclass2 ), false, TEST_LOCATION );
   END_TEST;
 }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
index 8744860..6c7ba81 100644 (file)
@@ -147,7 +147,7 @@ Integration::LongPressGestureEvent GenerateLongPress(
 
 
 // Positive test case for a method
-int UtcDaliLongPressGestureDetectorConstructor(void)
+int UtcDaliLongPressGestureDetectorConstructorP(void)
 {
   TestApplication application;
 
@@ -171,9 +171,11 @@ int UtcDaliLongPressGestureDetectorAssignmentOperatorP(void)
 {
   TestApplication application;
 
-  LongPressGestureDetector detector = LongPressGestureDetector::New();;
+  LongPressGestureDetector detector;
+  detector = LongPressGestureDetector::New();;
 
-  LongPressGestureDetector copy = detector;
+  LongPressGestureDetector copy;
+  copy = detector;
   DALI_TEST_CHECK( detector );
 
   DALI_TEST_CHECK( detector == copy );
index 9082546..6368762 100644 (file)
@@ -21,6 +21,7 @@
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 #include <test-native-image.h>
+#include <test-intrusive-ptr.h>
 
 using namespace Dali;
 
@@ -34,6 +35,20 @@ void utc_dali_native_image_cleanup(void)
   test_return_value = TET_PASS;
 }
 
+IntrusivePtr<TestNativeImage> Creator()
+{
+  return TestNativeImage::New(10,10);
+}
+
+int UtcDaliIntrusivePtrTestNativeImage(void)
+{
+  UtcCoverageIntrusivePtr<TestNativeImage> pointer;
+
+  pointer.Check(Creator);
+
+  END_TEST;
+}
+
 int UtcDaliNativeImageNew(void)
 {
   TestApplication application;
index 7d4ff6c..b68da92 100644 (file)
@@ -305,10 +305,11 @@ int UtcDaliPanGestureDetectorAssignmentOperatorP(void)
 
   PanGestureDetector detector = PanGestureDetector::New();;
 
-  PanGestureDetector copy = detector;
+  PanGestureDetector assign;
+  assign = detector;
   DALI_TEST_CHECK( detector );
 
-  DALI_TEST_CHECK( detector == copy );
+  DALI_TEST_CHECK( detector == assign );
   END_TEST;
 }
 
index a68cf12..5fb8b27 100644 (file)
@@ -167,10 +167,11 @@ int UtcDaliPinchGestureDetectorAssignmentOperatorP(void)
 
   PinchGestureDetector detector = PinchGestureDetector::New();;
 
-  PinchGestureDetector copy = detector;
+  PinchGestureDetector assign;
+  assign = detector;
   DALI_TEST_CHECK( detector );
 
-  DALI_TEST_CHECK( detector == copy );
+  DALI_TEST_CHECK( detector == assign );
   END_TEST;
 }
 
index 95e8570..b41d9cf 100644 (file)
@@ -23,6 +23,7 @@
 #include <dali/integration-api/context-notifier.h>
 #include <dali/integration-api/events/key-event-integ.h>
 #include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/devel-api/dynamics/dynamics.h>
 
 #include <dali-test-suite-utils.h>
 
@@ -206,6 +207,17 @@ int UtcDaliStageGetCurrent(void)
   END_TEST;
 }
 
+int UtcDaliStageAssign(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+  Stage stage2;
+  stage2 = stage;
+
+  DALI_TEST_CHECK(stage2);
+  END_TEST;
+}
+
 int UtcDaliStageIsInstalled(void)
 {
   DALI_TEST_CHECK(!Stage::IsInstalled());
@@ -303,6 +315,21 @@ int UtcDaliStageGetDpi03(void)
   END_TEST;
 }
 
+int UtcDaliStageInitializeDynamicsP(void)
+{
+  TestApplication application;
+  Stage stage = Stage::GetCurrent();
+  DynamicsWorld world = stage.InitializeDynamics( DynamicsWorldConfig::New() );
+
+#if !defined(DYNAMICS_SUPPORT)
+  DALI_TEST_CHECK(true);
+#else
+  DALI_TEST_CHECK( world );
+#endif
+
+  END_TEST;
+}
+
 int UtcDaliStageGetLayerCount(void)
 {
   TestApplication application;
index 8efcad1..eed11ca 100644 (file)
@@ -151,7 +151,7 @@ int UtcDaliTapGestureDetectorCopyConstructorP(void)
 {
   TestApplication application;
 
-  TapGestureDetector detector = TapGestureDetector::New();;
+  TapGestureDetector detector = TapGestureDetector::New();
 
   TapGestureDetector copy( detector );
   DALI_TEST_CHECK( detector );
@@ -164,10 +164,11 @@ int UtcDaliTapGestureDetectorAssignmentOperatorP(void)
 
   TapGestureDetector detector = TapGestureDetector::New();;
 
-  TapGestureDetector copy = detector;
+  TapGestureDetector assign;
+  assign = detector;
   DALI_TEST_CHECK( detector );
 
-  DALI_TEST_CHECK( detector == copy );
+  DALI_TEST_CHECK( detector == assign );
   END_TEST;
 }
 
index b9657e1..71e6cf8 100644 (file)
@@ -574,6 +574,20 @@ int UtcDaliTypeRegistryAssignmentOperatorP(void)
   END_TEST;
 }
 
+int UtcDaliTypeRegistryAssignP(void)
+{
+  TestApplication application;
+
+  TypeRegistry registry = TypeRegistry::Get();
+  TypeRegistry registry2;
+  registry2 = registry;
+  DALI_TEST_CHECK( registry2 );
+
+  DALI_TEST_CHECK( registry2.GetTypeInfo( "Actor" ).GetName() == registry2.GetTypeInfo( "Actor" ).GetName() );
+
+  END_TEST;
+}
+
 int UtcDaliTypeRegistryGetTypeInfoFromTypeNameP(void)
 {
   TestApplication application;
index 761e762..2a9bf4c 100644 (file)
@@ -77,7 +77,7 @@ int UtcDaliVector2Constructor05P(void)
 {
   TestApplication application;
   Vector4 vec4(1.f,1.f,1.f,1.f);
-  Vector3 vec2(vec4);
+  Vector2 vec2(vec4);
   DALI_TEST_EQUALS(vec2.x, 1.0f, 0.001, TEST_LOCATION);
   DALI_TEST_EQUALS(vec2.y, 1.0f, 0.001, TEST_LOCATION);
   END_TEST;
@@ -116,6 +116,39 @@ int UtcDaliVector2CopyConstructor03P(void)
   END_TEST;
 }
 
+int UtcDaliVector2AssignP(void)
+{
+  TestApplication application;
+  Vector2 v1(10.0f, 20.0f);
+  Vector2 r0(11.0f, 22.0f);
+
+  v1 = r0;
+  DALI_TEST_EQUALS(v1, r0, TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliVector2AssignP02(void)
+{
+  TestApplication application;
+  Vector2 v1(10.0f, 20.0f);
+  Vector4 r0(11.0f, 22.0f, 33.f, 44.f);
+
+  v1 = r0;
+  DALI_TEST_EQUALS(v1, Vector2(r0.x, r0.y), TEST_LOCATION);
+  END_TEST;
+}
+
+int UtcDaliVector2AssignP03(void)
+{
+  TestApplication application;
+  Vector2 v1(10.0f, 20.0f);
+  Vector3 r0(11.0f, 22.0f, 33.f);
+
+  v1 = r0;
+  DALI_TEST_EQUALS(v1, Vector2(r0.x, r0.y), TEST_LOCATION);
+  END_TEST;
+}
+
 int UtcDaliVector2AddP(void)
 {
   TestApplication application;
index 808a7ba..13a36e6 100644 (file)
@@ -184,6 +184,18 @@ public:
     return mPtr ? &IntrusivePtr::ThisIsSaferThanReturningVoidStar : 0;
   }
 
+  /**
+   * @brief Detach pointer from intrusive ptr counting.
+   *
+   * Use with care.
+   */
+  T* Detach()
+  {
+    T* ptr = mPtr;
+    mPtr = 0;
+    return ptr;
+  }
+
 private:
 
   /**