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=9565d09debd20496c1c7ef4c16b2befd41ab5e03;hpb=ef1f2122e3825ec5fa1d2d3b568caec69ecd3d0c;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 9565d09..7f43240 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-AnimatedVectorImageVisual.cpp @@ -53,9 +53,6 @@ const char* TEST_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.jso const char* TEST_VECTOR_IMAGE_FILE_NAME_FRAME_DROP = "framedrop.json"; const char* TEST_VECTOR_IMAGE_INVALID_FILE_NAME = "invalid.json"; -const char* TEST_VECTOR_IMAGE_RIVE_FILE_NAME = TEST_RESOURCE_DIR "/juice.riv"; -const char* TEST_VECTOR_IMAGE_INVALID_RIVE_FILE_NAME = "invalid.riv"; - bool gAnimationFinishedSignalFired = false; void VisualEventSignal( Control control, Dali::Property::Index visualIndex, Dali::Property::Index signalId ) @@ -145,7 +142,8 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual03(void) .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_FILE_NAME ) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) .Add( DevelImageVisual::Property::PLAY_RANGE, playRange ) - .Add( DevelVisual::Property::CORNER_RADIUS, 50.0f ); + .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 ); @@ -177,6 +175,9 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) 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 ); @@ -189,7 +190,10 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) .Add( "stopBehavior", DevelImageVisual::StopBehavior::FIRST_FRAME ) .Add( "loopingMode", DevelImageVisual::LoopingMode::AUTO_REVERSE ) .Add( "redrawInScalingDown", false ) - .Add( "cornerRadius", cornerRadius ); + .Add( "cornerRadius", cornerRadius ) + .Add( "borderlineWidth", borderlineWidth ) + .Add( "borderlineColor", borderlineColor ) + .Add( "borderlineOffset", borderlineOffset ); Visual::Base visual = VisualFactory::Get().CreateVisual( propertyMap ); DALI_TEST_CHECK( visual ); @@ -253,6 +257,18 @@ int UtcDaliVisualFactoryGetAnimatedVectorImageVisual04(void) 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 ); @@ -266,6 +282,9 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) 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 ); @@ -276,7 +295,10 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) .Add( DevelImageVisual::Property::LOOP_COUNT, 3 ) .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::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(); @@ -344,6 +366,18 @@ int UtcDaliAnimatedVectorImageVisualGetPropertyMap01(void) 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() ); @@ -1556,222 +1590,26 @@ int UtcDaliAnimatedVectorImageVisualFrameDrops(void) application.GetScene().Add(actor); - application.SendNotification(); - application.Render(); + 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); - application.SendNotification(); - application.Render(); - - // Trigger count is 1 - render the first frame - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); - // Make delay to drop frames Test::VectorAnimationRenderer::DelayRendering(170); // longer than 16.6 * 10frames - // Check dropped frame - DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); - - uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames(); - DALI_TEST_CHECK(frames >= 9); - - END_TEST; -} - -int UtcDaliAnimatedVectorImageVisualLoadRiveFileP(void) -{ - ToolkitTestApplication application; - tet_infoline( "UtcDaliAnimatedVectorImageVisualLoadRiveFile: Request animated vector image visual with a rive url" ); - - VisualFactory factory = VisualFactory::Get(); - Visual::Base visual = factory.CreateVisual( TEST_VECTOR_IMAGE_RIVE_FILE_NAME, ImageDimensions() ); - 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( 200.0f, 200.0f ) ); - application.GetScene().Add( actor ); - application.SendNotification(); application.Render(); - // renderer is added to actor - DALI_TEST_CHECK( actor.GetRendererCount() == 1u ); - Renderer renderer = actor.GetRendererAt( 0u ); - DALI_TEST_CHECK( renderer ); + // Trigger count is 2 - render the first frame & calculating frame drops + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); - // Test SetOffScene(). - actor.Unparent(); - DALI_TEST_CHECK( actor.GetRendererCount() == 0u ); - - END_TEST; -} - -int UtcDaliAnimatedVectorImageVisualLoadRiveFileN(void) -{ - ToolkitTestApplication application; - tet_infoline("Request loading with invalid rive 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_RIVE_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); + // Check dropped frame + uint32_t frames = Test::VectorAnimationRenderer::GetDroppedFrames(); + DALI_TEST_CHECK(frames > 0); + DALI_TEST_CHECK(frames <= static_cast(totalFrameNumber)); END_TEST; } - -int UtcDaliAnimatedVectorImageVisualPlaybackRiveFile(void) -{ - ToolkitTestApplication application; - - tet_infoline( "UtcDaliAnimatedVectorImageVisualPlaybackRiveFile" ); - - { - // request AnimatedVectorImageVisual for Rive with a property map - VisualFactory factory = VisualFactory::Get(); - Visual::Base visual = factory.CreateVisual( - Property::Map() - .Add( Toolkit::Visual::Property::TYPE, DevelVisual::ANIMATED_VECTOR_IMAGE ) - .Add( ImageVisual::Property::URL, TEST_VECTOR_IMAGE_RIVE_FILE_NAME ) ); - - DummyControl dummyControl = DummyControl::New( true ); - Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummyControl.GetImplementation() ); - dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual ); - dummyControl.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - - Property::Map attributes; - tet_infoline( "Test Play action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes ); - - application.GetScene().Add( dummyControl ); - application.SendNotification(); - application.Render( 16 ); - - 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 ); - - tet_infoline( "Test Pause action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PAUSE, attributes ); - - application.SendNotification(); - application.Render(16); - - 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 ); - - tet_infoline( "Test Play action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING ); - - tet_infoline( "Test Stop action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED ); - - tet_infoline( "Test Stop action again" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::STOP, attributes ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED ); - - tet_infoline( "Test Play action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING ); - - tet_infoline( "Off stage" ); - dummyControl.Unparent(); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED ); - - tet_infoline( "On stage again" ); - application.GetScene().Add( dummyControl ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::STOPPED ); - - tet_infoline( "Test Play action" ); - DevelControl::DoAction( dummyControl, DummyControl::Property::TEST_VISUAL, Dali::Toolkit::DevelAnimatedVectorImageVisual::Action::PLAY, attributes ); - - application.SendNotification(); - application.Render(16); - - map = dummyControl.GetProperty< Property::Map >( DummyControl::Property::TEST_VISUAL ); - value = map.Find( DevelImageVisual::Property::PLAY_STATE ); - DALI_TEST_CHECK( value->Get< int >() == DevelImageVisual::PlayState::PLAYING ); - - // Change Size - Vector3 newSize( 100.0f, 100.0f, 0.0f ); - dummyControl.SetProperty( Actor::Property::SIZE, newSize ); - - application.SendNotification(); - application.Render(16); - - // Size should be changed - Vector3 naturalSize = dummyControl.GetNaturalSize(); - DALI_TEST_CHECK( naturalSize == newSize ); - - dummyControl.Unparent(); - } - - END_TEST; -} \ No newline at end of file