/*
- * Copyright (c) 2018 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.
DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
Renderer renderer = actor.GetRendererAt( 0u );
DALI_TEST_CHECK( renderer );
- // Test SetOffStage().
+ // Test SetOffScene().
actor.Unparent();
DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
+ // Trigger count is 1 - render a frame
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
Renderer renderer = actor.GetRendererAt( 0u );
DALI_TEST_CHECK( renderer );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
Property::Map resultMap;
resultMap = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
tet_infoline( "Test Play action" );
DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render( 16 );
- std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); // wait for one animation loop (16fps, 5frames, need 80ms)
-
Property::Map map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING );
application.SendNotification();
application.Render(16);
- std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
-
map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_STATE );
DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PAUSED );
DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED );
tet_infoline( "On stage again" );
- Stage::GetCurrent().Add( dummyControl );
+ application.GetScene().Add( dummyControl );
application.SendNotification();
application.Render(16);
dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
- Stage::GetCurrent().Add( dummy );
+ application.GetScene().Add( dummy );
application.SendNotification();
application.Render();
Vector2 controlSize( 20.f, 30.f );
Vector2 naturalSize;
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.SendNotification();
application.Render();
- // Trigger count is 1 - animation finished
+ // Trigger count is 1 - render a frame
DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
// renderer is added to actor
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
// renderer is added to actor
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.Render();
// Wait for animation finish
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::PLAY_STATE );
Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap );
DALI_TEST_CHECK( visual );
+ tet_printf( "1. Visual is created.\n" );
+
DummyControl actor = DummyControl::New( true );
DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 2, TEST_LOCATION );
+ tet_printf( "2. The current frame number is [%d].\n", value->Get< int >() );
+
Property::Array array;
array.PushBack( 0 );
array.PushBack( 2 );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 2, TEST_LOCATION );
+ tet_printf( "3. The current frame number is [%d].\n", value->Get< int >() );
+
// Change play range
attributes.Clear();
array.Clear();
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
+ tet_printf( "4. The current frame number is [%d].\n", value->Get< int >() );
+
// Jump to the same position
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::JUMP_TO, 3 );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
+ tet_printf( "5. The current frame number is [%d].\n", value->Get< int >() );
+
END_TEST;
}
int UtcDaliAnimatedVectorImageVisualUpdateProperty(void)
{
ToolkitTestApplication application;
- tet_infoline( "UtcDaliAnimatedVectorImageVisualJumpToCurrentProgress" );
+ tet_infoline( "UtcDaliAnimatedVectorImageVisualUpdateProperty" );
int startFrame = 1, endFrame = 3;
Property::Array playRange;
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
DALI_TEST_EQUALS( value->Get< int >(), 3, TEST_LOCATION );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::LOOP_COUNT );
DALI_TEST_EQUALS( value->Get< int >(), 5, TEST_LOCATION );
application.SendNotification();
application.Render();
+ std::this_thread::sleep_for( std::chrono::milliseconds( 20 ) ); // wait for next rasterize thread run
+
map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
value = map.Find( DevelImageVisual::Property::PLAY_RANGE );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.Render();
// Trigger count is 1 - animation finished
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
application.Render();
// Trigger count is 1 - animation finished
- DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL );
Property::Value* value = map.Find( DevelImageVisual::Property::CURRENT_FRAME_NUMBER );
actor.SetProperty( Actor::Property::SIZE, controlSize );
actor.SetProperty( Actor::Property::SCALE, controlScale );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
Vector2 controlSize( 20.f, 30.f );
actor1.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor1 );
+ application.GetScene().Add( actor1 );
propertyMap.Clear();
propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE )
actor2.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor2 );
+ application.GetScene().Add( actor2 );
DevelControl::DoAction( actor2, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, Property::Map() );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+ application.SendNotification();
+ application.Render();
+
// Check rendering behavior
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );
Vector2 controlSize( 20.f, 30.f );
actor.SetProperty( Actor::Property::SIZE, controlSize );
- Stage::GetCurrent().Add( actor );
+ application.GetScene().Add( actor );
application.SendNotification();
application.Render();
Property::Map attributes;
DevelControl::DoAction( actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes );
+ application.SendNotification();
+ application.Render();
+
// Check rendering behavior
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
Renderer renderer = actor.GetRendererAt( 0u );