-//
-// 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 <iostream>
#include <stdlib.h>
-#include <dali/dali.h>
+#include <dali/public-api/dali-core.h>
#include <dali/integration-api/events/touch-event-integ.h>
#include "dali-test-suite-utils/dali-test-suite-utils.h"
{
}
- void operator()(Animation& animation)
+ void operator()()
{
mSignalReceived = true;
}
}
};
+// 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)
END_TEST;
}
-
int UtcDaliBaseHandleCopyConstructor(void)
{
TestApplication application;
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<int>(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;
}
DALI_TEST_CHECK(actorObject);
// Check that an invalid command is not performed
- std::vector<Property::Value> 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);
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);
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);
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<uint32_t>(newDurationSeconds * 500.0f) /* half of time */);
+ DALI_TEST_EQUALS( signalReceived, false, TEST_LOCATION );
+ // pause
+ animationObject.DoAction("pause", attributes);
+ application.SendNotification();
+ application.Render(static_cast<uint32_t>(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<unsigned int>(newDurationSeconds * 1000.0f) + 1u/*just beyond the animation duration*/);
+ application.Render(static_cast<uint32_t>(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<uint32_t>(newDurationSeconds * 500.0f) /* half of time */);
+ animationObject.DoAction("stop", attributes);
+ application.SendNotification();
+ application.Render(static_cast<uint32_t>(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);
// 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 );
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 );
END_TEST;
}
-int UtcDaliBaseHandleGetTypeName(void)
+int UtcDaliBaseHandleGetTypeNameP(void)
{
TestApplication application;
tet_infoline("Testing Dali::BaseHandle::GetTypeName");
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;
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;
+}