X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-AnimatedVectorImageVisual.cpp;h=b692ebb94daf50cac63214cae7ae54fc0bfb39ba;hp=90bb27bf03bff97d13ec27e7b2c35b500297a4e6;hb=34acf01671928c22fe260fe8aa365ec2d0e05525;hpb=2c705b780a4afc9c098484b51a6892e562146977 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp index 90bb27b..b692ebb 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) 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. @@ -50,6 +50,7 @@ namespace { const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json"; +const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json"; bool gAnimationFinishedSignalFired = false; @@ -76,7 +77,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual01(void) 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(); @@ -86,7 +87,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 ); @@ -109,7 +110,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual02(void) 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(); @@ -139,7 +140,8 @@ 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 ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -148,7 +150,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) 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(); @@ -170,6 +172,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) tet_infoline( "UtcDaliVisualFactoryGetAnimatedVectorImageVisual04: Request animated vector image visual with a Property::Map" ); int startFrame = 1, endFrame = 3; + float cornerRadius = 50.0f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -180,7 +183,9 @@ 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 ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -189,7 +194,7 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) 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(); @@ -232,6 +237,18 @@ 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::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), 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 ); + actor.Unparent( ); DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); @@ -244,6 +261,7 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) tet_infoline( "UtcDaliAnimatedVectorImageVisualGetPropertyMap01" ); int startFrame = 1, endFrame = 3; + float cornerRadius = 50.0f; Property::Array playRange; playRange.PushBack( startFrame ); playRange.PushBack( endFrame ); @@ -252,7 +270,9 @@ 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); // request AnimatedVectorImageVisual with a property map VisualFactory factory = VisualFactory::Get(); @@ -265,11 +285,13 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) 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 ); @@ -306,6 +328,18 @@ 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::FLOAT ); + DALI_TEST_CHECK( value ); + DALI_TEST_EQUALS( value->Get< float >(), 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 ); + // request AnimatedVectorImageVisual with an URL Visual::Base visual2 = factory.CreateVisual( TEST_VECTOR_IMAGE_FILE_NAME, ImageDimensions() ); @@ -347,7 +381,7 @@ 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 ); @@ -416,7 +450,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); @@ -478,7 +512,7 @@ int UtcDaliAnimatedVectorImageVisualCustomShader(void) 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(); @@ -517,7 +551,7 @@ int UtcDaliAnimatedVectorImageVisualNaturalSize(void) Vector2 controlSize( 20.f, 30.f ); Vector2 naturalSize; - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -558,7 +592,7 @@ int UtcDaliAnimatedVectorImageVisualLoopCount(void) 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 ); @@ -602,7 +636,7 @@ int UtcDaliAnimatedVectorImageVisualPlayRange(void) 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 ); @@ -679,6 +713,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 ); @@ -718,7 +754,7 @@ int UtcDaliAnimatedVectorImageVisualPlayRangeMarker(void) 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 ); @@ -817,7 +853,7 @@ int UtcDaliAnimatedVectorImageVisualAnimationFinishedSignal(void) 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 ); @@ -858,7 +894,7 @@ int UtcDaliAnimatedVectorImageVisualJumpTo(void) Vector2 controlSize( 20.f, 30.f ); actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -972,7 +1008,7 @@ int UtcDaliAnimatedVectorImageVisualUpdateProperty(void) Vector2 controlSize( 20.f, 30.f ); actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1084,7 +1120,7 @@ int UtcDaliAnimatedVectorImageVisualStopBehavior(void) 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 ); @@ -1179,7 +1215,7 @@ int UtcDaliAnimatedVectorImageVisualLoopingMode(void) 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 ); @@ -1257,7 +1293,7 @@ int UtcDaliAnimatedVectorImageVisualPropertyNotification(void) actor.SetProperty( Actor::Property::SIZE, controlSize ); actor.SetProperty( Actor::Property::SCALE, controlScale ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1317,7 +1353,7 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) 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 ) @@ -1332,7 +1368,7 @@ int UtcDaliAnimatedVectorImageVisualMultipleInstances(void) 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() ); @@ -1381,7 +1417,7 @@ int UtcDaliAnimatedVectorImageVisualControlVisibilityChanged(void) Vector2 controlSize( 20.f, 30.f ); actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1428,7 +1464,7 @@ int UtcDaliAnimatedVectorImageVisualWindowVisibilityChanged(void) Vector2 controlSize( 20.f, 30.f ); actor.SetProperty( Actor::Property::SIZE, controlSize ); - Stage::GetCurrent().Add( actor ); + application.GetScene().Add( actor ); application.SendNotification(); application.Render(); @@ -1456,3 +1492,41 @@ 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; +}