From 44a5352ea2a8571b9e12df1b90756953d2678d5e Mon Sep 17 00:00:00 2001 From: Lee Morgan Date: Wed, 27 May 2015 11:50:49 +0100 Subject: [PATCH] UTC test coverage Change-Id: I17b3366f7f287d5b4f233515490c76506cd7ecaf --- .../dali-test-suite-utils/test-intrusive-ptr.h | 60 ++++++++++++++++++++++ .../src/dali/utc-Dali-GestureDetector.cpp | 47 +++++++++++++---- automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp | 34 +++--------- .../src/dali/utc-Dali-LongPressGestureDetector.cpp | 8 +-- automated-tests/src/dali/utc-Dali-NativeImage.cpp | 15 ++++++ .../src/dali/utc-Dali-PanGestureDetector.cpp | 5 +- .../src/dali/utc-Dali-PinchGestureDetector.cpp | 5 +- automated-tests/src/dali/utc-Dali-Stage.cpp | 27 ++++++++++ .../src/dali/utc-Dali-TapGestureDetector.cpp | 7 +-- automated-tests/src/dali/utc-Dali-TypeRegistry.cpp | 14 +++++ automated-tests/src/dali/utc-Dali-Vector2.cpp | 35 ++++++++++++- dali/public-api/common/intrusive-ptr.h | 12 +++++ 12 files changed, 221 insertions(+), 48 deletions(-) create mode 100644 automated-tests/src/dali/dali-test-suite-utils/test-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 index 0000000..03aafe3 --- /dev/null +++ b/automated-tests/src/dali/dali-test-suite-utils/test-intrusive-ptr.h @@ -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 +#include +#include +#include + +namespace Dali +{ + +template +struct UtcCoverageIntrusivePtr +{ + typedef IntrusivePtr (*Creator)(); + + void Check( Creator creator) + { + IntrusivePtr a = creator(); + IntrusivePtr b = creator(); + + DALI_TEST_CHECK( a.Get() ); + + a.Reset(); + + T* pB = b.Detach(); + + a.Reset(pB); + + DALI_TEST_CHECK(a); + + a.Reset(); + + }; + +}; + +} // Dali + +#endif + + diff --git a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp index 4d06575..710c23b 100644 --- a/automated-tests/src/dali/utc-Dali-GestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-GestureDetector.cpp @@ -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(); diff --git a/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp b/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp index af67735..ccc6336 100644 --- a/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp +++ b/automated-tests/src/dali/utc-Dali-IntrusivePtr.cpp @@ -20,6 +20,7 @@ #include #include #include +#include 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( new Counted ); DALI_TEST_CHECK( counted.operator BooleanType() != 0 ); DALI_TEST_CHECK( counted ); + + typedef void (IntrusivePtr::*BoolIdiomFunc)() const; + BoolIdiomFunc func = static_cast( 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; } - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp index 8744860..6c7ba81 100644 --- a/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-LongPressGestureDetector.cpp @@ -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 ); diff --git a/automated-tests/src/dali/utc-Dali-NativeImage.cpp b/automated-tests/src/dali/utc-Dali-NativeImage.cpp index 9082546..6368762 100644 --- a/automated-tests/src/dali/utc-Dali-NativeImage.cpp +++ b/automated-tests/src/dali/utc-Dali-NativeImage.cpp @@ -21,6 +21,7 @@ #include #include #include +#include using namespace Dali; @@ -34,6 +35,20 @@ void utc_dali_native_image_cleanup(void) test_return_value = TET_PASS; } +IntrusivePtr Creator() +{ + return TestNativeImage::New(10,10); +} + +int UtcDaliIntrusivePtrTestNativeImage(void) +{ + UtcCoverageIntrusivePtr pointer; + + pointer.Check(Creator); + + END_TEST; +} + int UtcDaliNativeImageNew(void) { TestApplication application; diff --git a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp index 7d4ff6c..b68da92 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureDetector.cpp @@ -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; } diff --git a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp index a68cf12..5fb8b27 100644 --- a/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-PinchGestureDetector.cpp @@ -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; } diff --git a/automated-tests/src/dali/utc-Dali-Stage.cpp b/automated-tests/src/dali/utc-Dali-Stage.cpp index 95e8570..b41d9cf 100644 --- a/automated-tests/src/dali/utc-Dali-Stage.cpp +++ b/automated-tests/src/dali/utc-Dali-Stage.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -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; diff --git a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp index 8efcad1..eed11ca 100644 --- a/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp +++ b/automated-tests/src/dali/utc-Dali-TapGestureDetector.cpp @@ -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; } diff --git a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp index b9657e1..71e6cf8 100644 --- a/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp +++ b/automated-tests/src/dali/utc-Dali-TypeRegistry.cpp @@ -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; diff --git a/automated-tests/src/dali/utc-Dali-Vector2.cpp b/automated-tests/src/dali/utc-Dali-Vector2.cpp index 761e762..2a9bf4c 100644 --- a/automated-tests/src/dali/utc-Dali-Vector2.cpp +++ b/automated-tests/src/dali/utc-Dali-Vector2.cpp @@ -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; diff --git a/dali/public-api/common/intrusive-ptr.h b/dali/public-api/common/intrusive-ptr.h index 808a7ba..13a36e6 100644 --- a/dali/public-api/common/intrusive-ptr.h +++ b/dali/public-api/common/intrusive-ptr.h @@ -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: /** -- 2.7.4