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-Visual.cpp;h=7cda6e5a950fb595439626068398804d76b9e413;hp=263e79e6f541de13d3ed4ec6c3ebac0fc39b1208;hb=84c98859f482a168f4cc5f4d84b3a08c39b8902c;hpb=406208364fe0ee31f31f475ba7ee7709e56d3e27 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp b/automated-tests/src/dali-toolkit/utc-Dali-Visual.cpp index 263e79e..7cda6e5 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 ); @@ -662,19 +656,6 @@ int UtcDaliVisualGetPropertyMap5(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() == true ); - // Test the properties.. - Property::Value imageValue = imageVisual.GetProperty( ImageVisual::Property::URL ); - DALI_TEST_CHECK( imageValue.Get() == TEST_IMAGE_FILE_NAME ); - - // Other Properties for Image Visual can be tested here once implemented in the Visual - - tet_infoline( "UtcDaliVisualGetPropertyMap5 Ensuring Property without a Getter is not problematic" ); - imageValue = imageVisual.GetProperty( ImageVisual::Property::DESIRED_HEIGHT ); - DALI_TEST_CHECK( imageValue.Get() != 30 ); - - - // Rest of test uses Image not an url ( legacy ) - // Get an image visual with an image handle, and test the default property values Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME, ImageDimensions(100, 200)); imageVisual = factory.CreateVisual(image); @@ -728,13 +709,11 @@ int UtcDaliVisualGetPropertyMap6(void) ToolkitTestApplication application; tet_infoline( "UtcDaliVisualGetPropertyMap6: NPatchVisual" ); - bool BORDER_ONLY_SETTING = true; - VisualFactory factory = VisualFactory::Get(); Property::Map propertyMap; propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE ); propertyMap.Insert( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); - propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, BORDER_ONLY_SETTING ); + propertyMap.Insert( ImageVisual::Property::BORDER_ONLY, true ); Visual::Base nPatchVisual = factory.CreateVisual( propertyMap ); Property::Map resultMap; @@ -753,19 +732,6 @@ int UtcDaliVisualGetPropertyMap6(void) DALI_TEST_CHECK( value ); DALI_TEST_CHECK( value->Get() ); - // Test the properties via Index. - nPatchVisual.SetProperty( ImageVisual::Property::URL, TEST_NPATCH_FILE_NAME ); // May not able to change URL in future using SetProperty - Property::Value nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::URL ); - DALI_TEST_CHECK( nPatchValue.Get() == TEST_NPATCH_FILE_NAME ); - - nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::BORDER_ONLY ); - DALI_TEST_CHECK( nPatchValue.Get() == BORDER_ONLY_SETTING ); - - // Other Properties for N-Patch Visual can be tested here once implemented in the Visual - - tet_infoline( "UtcDaliVisualGetPropertyMap6 Ensuring Property without a Getter is not problematic" ); - nPatchValue = nPatchVisual.GetProperty( ImageVisual::Property::DESIRED_HEIGHT ); - DALI_TEST_CHECK( nPatchValue.Get() != 30 ); END_TEST; } @@ -1616,4 +1582,37 @@ 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; +} +