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-ImageView.cpp;h=98ff4619376fd29e3d3061f40ff928c1a5bb8f27;hp=77121d5792653aeb4830c76bf813ae6cbb33c1f1;hb=108a91b70f76ed395aaff1694010c56f3d1a653c;hpb=7098ad0a9a657b68b37d5fd759662a2d08b47433 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 77121d5..98ff461 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -1775,3 +1775,185 @@ int UtcDaliImageViewFillMode(void) END_TEST; } + +int UtcDaliImageViewCustomShader(void) +{ + ToolkitTestApplication application; + + // Set a custom shader with an image url + { + Property::Map properties; + Property::Map shader; + const std::string vertexShader = "Foobar"; + const std::string fragmentShader = "Foobar"; + shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader; + + properties[Visual::Property::TYPE] = Visual::IMAGE; + properties[Visual::Property::SHADER] = shader; + properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + + ImageView imageView = ImageView::New(); + imageView.SetProperty( ImageView::Property::IMAGE, properties ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + application.Render(); + + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + Renderer renderer = imageView.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 + DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION ); + } + + // Set a custom shader after setting an image url + { + Property::Map properties; + Property::Map shader; + const std::string vertexShader = "Foobar"; + const std::string fragmentShader = "Foobar"; + shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader; + + properties[Visual::Property::SHADER] = shader; + + ImageView imageView = ImageView::New( TEST_IMAGE_FILE_NAME ); + imageView.SetProperty( ImageView::Property::IMAGE, properties ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + application.Render(); + + Renderer renderer = imageView.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 + DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION ); + } + + // Set a custom shader before setting an image url + { + Property::Map properties; + Property::Map shader; + const std::string vertexShader = "Foobar"; + const std::string fragmentShader = "Foobar"; + shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader; + + properties[Visual::Property::SHADER] = shader; + + ImageView imageView = ImageView::New(); + imageView.SetProperty( ImageView::Property::IMAGE, properties ); + imageView.SetProperty( ImageView::Property::IMAGE, TEST_IMAGE_FILE_NAME ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + application.Render(); + + Renderer renderer = imageView.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 + DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION ); + } + + // Set a custom shader after setting a property map + { + Property::Map properties; + Property::Map shader; + const std::string vertexShader = "Foobar"; + const std::string fragmentShader = "Foobar"; + shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader; + + properties[Visual::Property::SHADER] = shader; + + Property::Map properties1; + properties1[Visual::Property::TYPE] = Visual::IMAGE; + properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + + ImageView imageView = ImageView::New(); + imageView.SetProperty( ImageView::Property::IMAGE, properties1 ); + imageView.SetProperty( ImageView::Property::IMAGE, properties ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + application.Render(); + + Renderer renderer = imageView.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 + DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION ); + } + + // Set a custom shader before setting a property map + { + Property::Map properties; + Property::Map shader; + const std::string vertexShader = "Foobar"; + const std::string fragmentShader = "Foobar"; + shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader; + shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader; + + properties[Visual::Property::SHADER] = shader; + + Property::Map properties1; + properties1[Visual::Property::TYPE] = Visual::IMAGE; + properties1[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME; + + ImageView imageView = ImageView::New(); + imageView.SetProperty( ImageView::Property::IMAGE, properties ); + imageView.SetProperty( ImageView::Property::IMAGE, properties1 ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + application.Render(); + + Renderer renderer = imageView.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 + DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION ); + + Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp + DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION ); + } + + END_TEST; +}