X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-Visual.cpp;h=ff64e24b559998d3e65bdb200031854e77bde437;hb=f52e1560139d8b38f846be2125b0125a726ed979;hp=4959ed91f84233dfaf6197c85f4f567aa99fb5d7;hpb=babef00662186629afb90e87a37834ff9b5d997f;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 4959ed9..ff64e24 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp @@ -191,16 +191,7 @@ int UtcDaliVisualSize(void) imageVisual.GetNaturalSize(naturalSize); DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 200.f), TEST_LOCATION ); - // n patch visual - TestPlatformAbstraction& platform = application.GetPlatform(); - Vector2 testSize(80.f, 160.f); - platform.SetClosestImageSize(testSize); - image = ResourceImage::New(TEST_NPATCH_FILE_NAME); - Visual::Base nPatchVisual = factory.CreateVisual( image ); - nPatchVisual.SetSize( visualSize ); - DALI_TEST_EQUALS( nPatchVisual.GetSize(), visualSize, TEST_LOCATION ); - nPatchVisual.GetNaturalSize(naturalSize); - DALI_TEST_EQUALS( naturalSize, testSize, TEST_LOCATION ); + // n patch visual is tested in the utc-Dali-VisualFactory.cpp // border visual float borderSize = 5.f; @@ -250,6 +241,9 @@ int UtcDaliVisualSize(void) DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100 // Batch Image visual + TestPlatformAbstraction& platform = application.GetPlatform(); + Vector2 testSize(80.f, 160.f); + platform.SetClosestImageSize(testSize); propertyMap.Clear(); propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); @@ -707,10 +701,6 @@ int UtcDaliVisualGetPropertyMap5(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == false ); - // Test the properties. TODO: to be completed. - imageVisual.SetProperty( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME ); - Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL ); - END_TEST; } @@ -742,9 +732,6 @@ int UtcDaliVisualGetPropertyMap6(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() ); - // Test the properties. TODO: to be completed. - nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); - Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL ); END_TEST; } @@ -1060,8 +1047,7 @@ int UtcDaliVisualGetPropertyMap10(void) DALI_TEST_CHECK( !value->Get() ); value = resultMap.Find( TextVisual::Property::ENABLE_AUTO_SCROLL, Property::BOOLEAN ); - DALI_TEST_CHECK( value ); - DALI_TEST_CHECK( !value->Get() ); + DALI_TEST_CHECK( !value ); value = resultMap.Find( TextVisual::Property::LINE_SPACING, Property::FLOAT ); DALI_TEST_CHECK( value ); @@ -1596,4 +1582,74 @@ int UtcDaliVisualSetTransform7(void) END_TEST; } +int UtcDaliNPatchVisualCustomShader(void) +{ + ToolkitTestApplication application; + tet_infoline( "NPatchVisual with custom shader" ); + + VisualFactory factory = VisualFactory::Get(); + Property::Map properties; + Property::Map shader; + const std::string fragmentShader = "Foobar"; + shader[Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + properties[Dali::Toolkit::Visual::Property::TYPE] = Dali::Toolkit::Visual::IMAGE; + properties[Dali::Toolkit::Visual::Property::SHADER]=shader; + properties[Dali::Toolkit::ImageVisual::Property::URL] = TEST_NPATCH_FILE_NAME; + + Visual::Base visual = factory.CreateVisual( properties ); + Actor dummy = Actor::New(); + // trigger creation through setting on stage + visual.SetOnStage( dummy ); + + Renderer renderer = dummy.GetRendererAt( 0 ); + Shader shader2 = renderer.GetShader(); + Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM ); + Property::Map* map = value.GetMap(); + DALI_TEST_CHECK( map ); + + Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp + // *map["vertex"]; is default here so not verifying it + + DALI_TEST_EQUALS( fragmentShader, fragment->Get(), TEST_LOCATION ); + + END_TEST; +} + +int UtcDaliGradientVisualBlendMode(void) +{ + ToolkitTestApplication application; + + VisualFactory factory = VisualFactory::Get(); + + Visual::Base opaqueGradientVisual = factory.CreateVisual( + Property::Map().Add( Visual::Property::TYPE, Visual::GRADIENT ) + .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) ) + .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) ) + .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED ) + .Add( Color::GREEN ) ) ); + Visual::Base alphaGradientVisual = factory.CreateVisual( + Property::Map().Add( Visual::Property::TYPE, Visual::GRADIENT ) + .Add( GradientVisual::Property::START_POSITION, Vector2( -0.5f, -0.5f ) ) + .Add( GradientVisual::Property::END_POSITION, Vector2( 0.5f, 0.5f ) ) + .Add( GradientVisual::Property::STOP_COLOR, Property::Array().Add( Color::RED ) + .Add( Vector4( 1.0f, 1.0f, 1.0f, 0.5f ) ) ) ); + + DummyControl control = DummyControl::New(); + control.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + Stage::GetCurrent().Add( control ); + + DummyControlImpl& dummyImpl = static_cast( control.GetImplementation() ); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, opaqueGradientVisual ); + dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 2, alphaGradientVisual ); + + application.SendNotification(); + application.Render(); + + // Control should have two renderers, the first one is opaque so our blending mode should be off, the second one has some alpha so should be set to automatic + DALI_TEST_EQUALS( 2u, control.GetRendererCount(), TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetRendererAt( 0 ).GetProperty( Renderer::Property::BLEND_MODE ).Get(), (int)BlendMode::OFF, TEST_LOCATION ); + DALI_TEST_EQUALS( control.GetRendererAt( 1 ).GetProperty( Renderer::Property::BLEND_MODE ).Get(), (int)BlendMode::AUTO, TEST_LOCATION ); + + END_TEST; +}