X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali%2Futc-Dali-BaseHandle.cpp;h=8bf71c4922f310e0dc5597e18ddf49ddea5301e4;hb=c5015fd94aa766b0c8aa652dbfc7ad3e24758199;hp=d430d88a07ed582131a0f9a994f27e38348a250b;hpb=8f2c5571c924479b6a07a2c2187dedd9c685baf0;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp index d430d88..8bf71c4 100644 --- a/automated-tests/src/dali/utc-Dali-BaseHandle.cpp +++ b/automated-tests/src/dali/utc-Dali-BaseHandle.cpp @@ -1,23 +1,24 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.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://floralicense.org/license/ -// -// 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. -// +/* + * 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 #include -#include +#include #include #include "dali-test-suite-utils/dali-test-suite-utils.h" @@ -47,7 +48,7 @@ struct AnimationFinishCheck { } - void operator()(Animation& animation) + void operator()() { mSignalReceived = true; } @@ -95,6 +96,20 @@ struct TestCallback } }; +// Used for testing BaseObject::GetTypeName with an object that is not registered +class FakeObject : public BaseObject +{ +}; +// used for testing ThisIsSaferThanReturningVoidStar +class FakeHandle : public BaseHandle +{ +public: + + void RunTest() + { + return ThisIsSaferThanReturningVoidStar(); + } +}; } // anon namespace int UtcDaliBaseHandleConstructorVoid(void) @@ -108,7 +123,6 @@ int UtcDaliBaseHandleConstructorVoid(void) END_TEST; } - int UtcDaliBaseHandleCopyConstructor(void) { TestApplication application; @@ -274,18 +288,18 @@ int UtcDaliBaseHandleStlVector(void) std::stringstream stream; stream << "Actor " << i+1; - actor.SetName(stream.str()); + actor.SetProperty( Actor::Property::NAME,stream.str()); myVector.push_back(actor); } DALI_TEST_EQUALS(TargetVectorSize, static_cast(myVector.size()), TEST_LOCATION); - DALI_TEST_CHECK(myVector[0].GetName() == "Actor 1"); - DALI_TEST_CHECK(myVector[1].GetName() == "Actor 2"); - DALI_TEST_CHECK(myVector[2].GetName() == "Actor 3"); - DALI_TEST_CHECK(myVector[3].GetName() == "Actor 4"); - DALI_TEST_CHECK(myVector[4].GetName() == "Actor 5"); + DALI_TEST_CHECK(myVector[0].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 1"); + DALI_TEST_CHECK(myVector[1].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 2"); + DALI_TEST_CHECK(myVector[2].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 3"); + DALI_TEST_CHECK(myVector[3].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 4"); + DALI_TEST_CHECK(myVector[4].GetProperty< std::string >( Actor::Property::NAME ) == "Actor 5"); END_TEST; } @@ -300,12 +314,12 @@ int UtcDaliBaseHandleDoAction(void) DALI_TEST_CHECK(actorObject); // Check that an invalid command is not performed - std::vector attributes; + Property::Map attributes; DALI_TEST_CHECK(actorObject.DoAction("invalidCommand", attributes) == false); // Check that the actor is visible - actor.SetVisible(true); - DALI_TEST_CHECK(actor.IsVisible() == true); + actor.SetProperty( Actor::Property::VISIBLE,true); + DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true); // Check the actor performed an action to hide itself DALI_TEST_CHECK(actorObject.DoAction("hide", attributes) == true); @@ -315,7 +329,7 @@ int UtcDaliBaseHandleDoAction(void) application.Render(); // Check that the actor is now invisible - DALI_TEST_CHECK(actor.IsVisible() == false); + DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == false); // Check the actor performed an action to show itself DALI_TEST_CHECK(actorObject.DoAction("show", attributes) == true); @@ -325,7 +339,7 @@ int UtcDaliBaseHandleDoAction(void) application.Render(); // Check that the actor is now visible - DALI_TEST_CHECK(actor.IsVisible() == true); + DALI_TEST_CHECK(actor.GetCurrentProperty< bool >( Actor::Property::VISIBLE ) == true); Stage::GetCurrent().Add(actor); @@ -340,27 +354,54 @@ int UtcDaliBaseHandleDoAction(void) DALI_TEST_EQUALS(animation.GetDuration(), durationSeconds, TEST_LOCATION); Vector3 targetPosition(100.0f, 100.0f, 100.0f); - animation.MoveTo(actor, targetPosition, AlphaFunctions::Linear); + animation.AnimateTo(Property(actor, Actor::Property::POSITION), targetPosition, AlphaFunction::LINEAR); // Set the new duration to be 2 seconds float newDurationSeconds(2.0f); Property::Value newDurationSecondsValue = Property::Value( newDurationSeconds ); - attributes.push_back(newDurationSecondsValue); + attributes["duration"] = newDurationSecondsValue; // Check the animation performed an action to play itself with the specified duration of 2 seconds animationObject.DoAction("play", attributes); bool signalReceived(false); AnimationFinishCheck finishCheck(signalReceived); - animation.FinishedSignal().Connect(&application, finishCheck); + // use the handle API to connect the signal + animation.ConnectSignal( &application, "finished", finishCheck ); + // just for coverage connect to non-existant signal as well + animation.ConnectSignal( &application, "foo", finishCheck ); + DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION ); + + application.SendNotification(); + application.Render(static_cast(newDurationSeconds * 500.0f) /* half of time */); + DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION ); + // pause + animationObject.DoAction("pause", attributes); + application.SendNotification(); + application.Render(static_cast(newDurationSeconds * 500.0f) + 1u/*just beyond the animation duration*/); + DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION ); + + // continue + animationObject.DoAction("play", attributes); application.SendNotification(); - application.Render(static_cast(newDurationSeconds * 1000.0f) + 1u/*just beyond the animation duration*/); + application.Render(static_cast(newDurationSeconds * 500.0f) + 1u/*just beyond the animation duration*/); // We expect the animation to finish application.SendNotification(); finishCheck.CheckSignalReceived(); - DALI_TEST_EQUALS( actor.GetCurrentPosition(), targetPosition, TEST_LOCATION ); + DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ), targetPosition, TEST_LOCATION ); + + // play again + signalReceived = false; + animationObject.DoAction("play", attributes); + DALI_TEST_EQUALS(animation.GetCurrentProgress(), 0.f, TEST_LOCATION); + application.SendNotification(); + application.Render(static_cast(newDurationSeconds * 500.0f) /* half of time */); + animationObject.DoAction("stop", attributes); + application.SendNotification(); + application.Render(static_cast(newDurationSeconds * 1000.0f) /* full time */); + DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION ); // Check the new animation duration is 2 seconds DALI_TEST_EQUALS(animation.GetDuration(), newDurationSeconds, TEST_LOCATION); @@ -377,10 +418,10 @@ int UtcDaliBaseHandleConnectSignal(void) // get the root layer Actor actor = Actor::New(); - actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); - actor.SetPosition( 240, 400 ); - actor.SetSize( 100, 100 ); + actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + actor.SetProperty( Actor::Property::POSITION, Vector2( 240, 400 )); + actor.SetProperty( Actor::Property::SIZE, Vector2( 100, 100 ) ); Stage::GetCurrent().Add( actor ); @@ -395,7 +436,9 @@ int UtcDaliBaseHandleConnectSignal(void) application.Render(1000); // simulate a touch event - Dali::TouchPoint point( 0, TouchPoint::Down, 240, 400 ); + Dali::Integration::Point point; + point.SetState( PointState::DOWN ); + point.SetScreenPosition( Vector2( 240, 400 ) ); Dali::Integration::TouchEvent event; event.AddPoint( point ); application.ProcessEvent( event ); @@ -418,7 +461,7 @@ int UtcDaliBaseHandleConnectSignal(void) END_TEST; } -int UtcDaliBaseHandleGetTypeName(void) +int UtcDaliBaseHandleGetTypeNameP(void) { TestApplication application; tet_infoline("Testing Dali::BaseHandle::GetTypeName"); @@ -433,6 +476,55 @@ int UtcDaliBaseHandleGetTypeName(void) END_TEST; } +int UtcDaliBaseHandleGetTypeNameN(void) +{ + + TestApplication application; + tet_infoline("Testing Dali::BaseObject::GetTypeName"); + FakeObject object; + std::string typeName = object.GetTypeName(); + + DALI_TEST_CHECK( typeName.empty() ); + END_TEST; +} + +int UtcDaliBaseHandleGetTypeInfoP(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetTypeInfo"); + + Dali::TypeInfo info; + Actor actor = Actor::New(); + + bool ok = actor.GetTypeInfo( info ); + DALI_TEST_CHECK( ok ); + END_TEST; +} + +int UtcDaliBaseHandleThisIsSaferThanReturningVoidStar(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetTypeInfo"); + FakeHandle handle; + handle.RunTest(); + tet_result(TET_PASS); + END_TEST; + +} + +int UtcDaliBaseHandleGetTypeInfoN(void) +{ + TestApplication application; + tet_infoline("Testing Dali::BaseHandle::GetTypeInfo"); + + Dali::TypeInfo info; + FakeObject object; + + bool ok = object.GetTypeInfo( info ); + DALI_TEST_CHECK( !ok ); + END_TEST; +} + int UtcDaliBaseHandleGetObjectPtr(void) { TestApplication application; @@ -458,3 +550,14 @@ int UtcDaliBaseHandleBooleanCast(void) DALI_TEST_CHECK( static_cast( handle ) ); END_TEST; } + +int UtcDaliBaseHandleCompareOperatorN(void) +{ + TestApplication application; + BaseHandle handle1 = Actor::New(); + BaseHandle handle2 = handle1; + + DALI_TEST_CHECK( (handle1 < handle2) == false ); + + END_TEST; +}