X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AnimatedVectorImageVisual.cpp;h=7f432401227533c2d55a073557cc2fbdeeb987ca;hb=bd04df1ac18ac7446e95192724272d6a95f8e0eb;hp=069a64452fa8c85731a2f7dc0b60e8d0db2f9692;hpb=e8c7108458ad329752077dd2e8586785dbe8fb76;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 069a644..7f43240 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -50,6 +50,8 @@ namespace { const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; +const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json"; +const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json"; bool gAnimationFinishedSignalFired = false; @@ -75,8 +77,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void) DummyControl actor = DummyControl::New( true ); DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -86,7 +88,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void) Renderer renderer = actor.GetRendererAt( 0u ); DALI_TEST_CHECK( renderer ); - // Test SetOffStage(). + // Test SetOffScene(). actor.Unparent(); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); @@ -108,8 +110,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void) DummyControl actor = DummyControl::New( true ); DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -139,7 +141,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ); + .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ) + .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f ) + .Add( DevelVisual::Property::BORDERLINE_WIDTH, 20.0f ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -147,8 +151,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) DummyControl actor = DummyControl::New( true ); DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -170,6 +174,10 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" ); int startFrame = 1, endFrame = 3; + float cornerRadius = 22.0f; + float borderlineWidth = 2.0f; + Vector4 borderlineColor = Vector4(1.0f, 1.0f, 1.0f, 1.0f); + float borderlineOffset = 0.1f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -180,7 +188,12 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) .Add( "loopCount", 3 ) .Add( "playRange", playRange ) .Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME ) - .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE ); + .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE ) + .Add( "redrawInScalingDown", false ) + .Add( "cornerRadius", cornerRadius ) + .Add( "borderlineWidth", borderlineWidth ) + .Add( "borderlineColor", borderlineColor ) + .Add( "borderlineOffset", borderlineOffset ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -188,14 +201,18 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) DummyControl actor = DummyControl::New( true ); DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - actor.SetSize( 200.0f, 200.0f ); - Stage::GetCurrent().Add( actor ); + actor.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 200.0f ) ); + 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 ); @@ -228,6 +245,30 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::LoopingMode::AUTO_REVERSE ); + value = resultMap.Find( DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< bool >() == false ); + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< Vector4 >(), Vector4(cornerRadius, cornerRadius, cornerRadius, cornerRadius), TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::ABSOLUTE ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_WIDTH, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), borderlineWidth, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< Vector4 >(), borderlineColor, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), borderlineOffset, TEST_LOCATION ); + actor.Unparent( ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); @@ -240,6 +281,10 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" ); int startFrame = 1, endFrame = 3; + Vector4 cornerRadius(50.0f, 22.0f, 0.0f, 3.0f); + float borderlineWidth = 2.3f; + Vector4 borderlineColor = Vector4(0.3f, 0.3f, 1.0f, 1.0f); + float borderlineOffset = 0.3f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -248,7 +293,12 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) propertyMap.Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) - .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ); + .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ) + .Add( DevelVisual::Property::CORNER_RADIUS, cornerRadius ) + .Add( DevelVisual::Property::CORNER_RADIUS_POLICY, Visual::Transform::Policy::RELATIVE) + .Add( DevelVisual::Property::BORDERLINE_WIDTH, borderlineWidth ) + .Add( DevelVisual::Property::BORDERLINE_COLOR, borderlineColor ) + .Add( DevelVisual::Property::BORDERLINE_OFFSET, borderlineOffset ); // request AnimatedVectorImageVisual with a property map VisualFactory factory = VisualFactory::Get(); @@ -259,13 +309,15 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -302,6 +354,30 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) value = resultMap.Find( DevelImageVisual::Property::CONTENT_INFO, Property::MAP ); DALI_TEST_CHECK( value ); + value = resultMap.Find( DevelImageVisual::Property::REDRAW_IN_SCALING_DOWN, Property::BOOLEAN ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< bool >() == true ); // Check default value + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< Vector4 >(), cornerRadius, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::CORNER_RADIUS_POLICY, "cornerRadiusPolicy" ); + DALI_TEST_CHECK( value ); + DALI_TEST_CHECK( value->Get< int >() == Visual::Transform::Policy::RELATIVE ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_WIDTH, "borderlineWidth" ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), borderlineWidth, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_COLOR, Property::VECTOR4 ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< Vector4 >(), borderlineColor, TEST_LOCATION ); + + value = resultMap.Find( DevelVisual::Property::BORDERLINE_OFFSET, Property::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), borderlineOffset, TEST_LOCATION ); + // request AnimatedVectorImageVisual with an URL Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() ); @@ -343,12 +419,10 @@ int UtcDaliAnimatedVectorImageVisualPlayback(void) 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 ); @@ -359,8 +433,6 @@ int UtcDaliAnimatedVectorImageVisualPlayback(void) 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 ); @@ -416,7 +488,7 @@ int UtcDaliAnimatedVectorImageVisualPlayback(void) 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); @@ -437,7 +509,7 @@ int UtcDaliAnimatedVectorImageVisualPlayback(void) // Change Size Vector3 newSize( 100.0f, 100.0f, 0.0f ); - dummyControl.SetSize( newSize ); + dummyControl.SetProperty( Actor::Property::SIZE, newSize ); application.SendNotification(); application.Render(16); @@ -476,9 +548,9 @@ int UtcDaliAnimatedVectorImageVisualCustomShader(void) Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() ); dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - dummy.SetSize( 200.f, 200.f ); - dummy.SetParentOrigin( ParentOrigin::CENTER ); - Stage::GetCurrent().Add( dummy ); + dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) ); + dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + application.GetScene().Add( dummy ); application.SendNotification(); application.Render(); @@ -517,7 +589,7 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void) Vector2 controlSize( 20.f, 30.f ); Vector2 naturalSize; - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -526,7 +598,7 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void) DALI_TEST_EQUALS( naturalSize, Vector2( 100.0f, 100.0f ), TEST_LOCATION ); // 100x100 is the content default size. - actor.SetSize( controlSize ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); application.SendNotification(); application.Render(); @@ -556,9 +628,9 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -566,7 +638,7 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void) 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 @@ -600,9 +672,9 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -610,6 +682,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) 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 ); @@ -638,6 +712,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) 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 ); @@ -658,6 +734,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) 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 ); @@ -673,6 +751,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) 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 ); @@ -710,9 +790,9 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -720,6 +800,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) 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 ); @@ -748,6 +830,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) 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 ); @@ -770,6 +854,8 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) 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 ); @@ -803,9 +889,9 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) DevelControl::VisualEventSignal( actor ).Connect( &VisualEventSignal ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -814,7 +900,7 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) 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 ); @@ -837,14 +923,16 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) 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.SetSize( controlSize ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -854,10 +942,14 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) 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 ); @@ -871,10 +963,14 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) 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(); @@ -899,27 +995,35 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) 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; @@ -940,13 +1044,15 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -973,6 +1079,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) 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 ); @@ -997,6 +1105,8 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) 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 ); @@ -1046,9 +1156,9 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -1057,7 +1167,7 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) 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 ); @@ -1141,9 +1251,9 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + 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 ); @@ -1152,7 +1262,7 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) 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 ); @@ -1218,10 +1328,10 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) Vector2 controlSize( 20.f, 30.f ); Vector3 controlScale( 2.0f, 2.0f, 1.0f ); - actor.SetSize( controlSize ); - actor.SetScale( controlScale ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); + actor.SetProperty( Actor::Property::SCALE, controlScale ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1241,8 +1351,8 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) // Change scale and size controlSize = Vector2( 50.f, 40.f ); controlScale= Vector3( 0.5f, 0.5f, 1.0f ); - actor.SetSize( controlSize ); - actor.SetScale( controlScale ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); + actor.SetProperty( Actor::Property::SCALE, controlScale ); application.SendNotification(); application.Render(); @@ -1279,9 +1389,9 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual1 ); Vector2 controlSize( 20.f, 30.f ); - actor1.SetSize( controlSize ); + 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 ) @@ -1294,9 +1404,9 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) DummyControlImpl& dummyImpl2 = static_cast< DummyControlImpl& >( actor2.GetImplementation() ); dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual2 ); - actor2.SetSize( controlSize ); + 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() ); @@ -1343,9 +1453,9 @@ int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1353,13 +1463,16 @@ int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void) 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 ); DALI_TEST_CHECK( renderer ); DALI_TEST_CHECK( renderer.GetProperty< int >( DevelRenderer::Property::RENDERING_BEHAVIOR ) == DevelRenderer::Rendering::CONTINUOUSLY ); - actor.SetVisible( false ); + actor.SetProperty( Actor::Property::VISIBLE, false ); application.SendNotification(); application.Render(); @@ -1387,9 +1500,9 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); Vector2 controlSize( 20.f, 30.f ); - actor.SetSize( controlSize ); + actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1397,6 +1510,9 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) 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 ); @@ -1414,3 +1530,86 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) END_TEST; } + +int UtcDaliAnimatedVectorImageVisualInvalidFile(void) +{ + ToolkitTestApplication application; + tet_infoline("Request loading with invalid file - should draw broken image"); + + TestGlAbstraction& gl = application.GetGlAbstraction(); + TraceCallStack& textureTrace = gl.GetTextureTrace(); + textureTrace.Enable(true); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_INVALID_FILE_NAME); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f)); + + application.GetScene().Add(actor); + + application.SendNotification(); + application.Render(); + + // Check resource status + Visual::ResourceStatus status = actor.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL); + DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION); + + // The broken image should be shown. + DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION); + DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION); + + END_TEST; +} + +int UtcDaliAnimatedVectorImageVisualFrameDrops(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliAnimatedVectorImageVisualFrameDrops"); + + Property::Map propertyMap; + propertyMap.Add(Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE) + .Add(ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP); + + Visual::Base visual = VisualFactory::Get().CreateVisual(propertyMap); + DALI_TEST_CHECK(visual); + + DummyControl actor = DummyControl::New(true); + DummyControlImpl& dummyImpl = static_cast(actor.GetImplementation()); + dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual); + + Vector2 controlSize(20.f, 30.f); + actor.SetProperty(Actor::Property::SIZE, controlSize); + + application.GetScene().Add(actor); + + Property::Map map = actor.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); + Property::Value* value = map.Find( DevelImageVisual::Property::TOTAL_FRAME_NUMBER ); + int totalFrameNumber = value->Get< int >(); + + Property::Map attributes; + DevelControl::DoAction(actor, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes); + + // Make delay to drop frames + Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames + + application.SendNotification(); + application.Render(); + + // Trigger count is 2 - render the first frame & calculating frame drops + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + // Check dropped frame + uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames(); + DALI_TEST_CHECK(frames > 0); + DALI_TEST_CHECK(frames <= static_cast(totalFrameNumber)); + + END_TEST; +}