+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetImageRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetImageRenderer1: Request image renderer with a Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "image-renderer" );
+ propertyMap.Insert( "image-url", TEST_IMAGE_FILE_NAME );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetImageRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetImageRenderer2: Request image renderer with an image handle" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
+ ControlRenderer controlRenderer = factory.GetControlRenderer( image );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer1: Request n-patch renderer with a Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ const unsigned int ninePatchImageHeight = 18;
+ const unsigned int ninePatchImageWidth = 28;
+ const Vector4 requiredStretchBorder( 3, 4, 5, 6 );
+ Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, requiredStretchBorder );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "n-patch-renderer" );
+ propertyMap.Insert( "image-url", TEST_NPATCH_FILE_NAME );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, ninePatchResource );
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRenderer2: Request n-patch renderer with an image url" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ const unsigned int ninePatchImageHeight = 18;
+ const unsigned int ninePatchImageWidth = 28;
+ const Vector4 requiredStretchBorder( 3, 4, 5, 6 );
+ Integration::ResourcePointer ninePatchResource = CustomizeNinePatch( application, ninePatchImageWidth, ninePatchImageHeight, requiredStretchBorder );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( TEST_NPATCH_FILE_NAME );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
+ if(request)
+ {
+ application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, ninePatchResource );
+ }
+
+ application.Render();
+ application.SendNotification();
+
+ DALI_TEST_CHECK(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceFunc));
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRendererN1(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid image url" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( "ERROR.9.jpg" );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryGetNPatchRendererN2(void)
+{
+ //This should still load but display an error image
+
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryGetNPatchRendererN: Request n-patch renderer with an invalid Property::Map" );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( "renderer-type", "n-patch-renderer" );
+ propertyMap.Insert( "image-url", 111 );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( propertyMap );
+ DALI_TEST_CHECK( controlRenderer );
+
+ Actor actor = Actor::New();
+ actor.SetSize( 200.f, 200.f );
+ Stage::GetCurrent().Add( actor );
+ controlRenderer.SetSize( Vector2(200.f, 200.f) );
+ controlRenderer.SetOnStage( actor );
+
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render();
+
+ int textureUnit = -1;
+ DALI_TEST_CHECK( gl.GetUniformValue< int >( "sTexture", textureUnit ) );
+ DALI_TEST_EQUALS( textureUnit, 0, TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryResetRenderer1(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryResetRenderer1" );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ ControlRenderer controlRenderer = factory.GetControlRenderer( Color::RED );
+ DALI_TEST_CHECK( controlRenderer );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render(0);
+ Vector4 actualValue(Vector4::ZERO);
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
+
+ bool isNewRenderer = factory.ResetRenderer( controlRenderer, Color::GREEN );
+ DALI_TEST_CHECK( !isNewRenderer );
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
+
+ Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ isNewRenderer = factory.ResetRenderer( controlRenderer, bufferImage );
+ DALI_TEST_CHECK( isNewRenderer );
+
+ Actor actor2 = Actor::New();
+ actor2.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor2 );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor2 );
+ application.SendNotification();
+ application.Render(0);
+ Image samplerImage = actor2.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
+ DALI_TEST_CHECK( BufferImage::DownCast( samplerImage ) );
+
+ END_TEST;
+}
+
+int UtcDaliRendererFactoryResetRenderer2(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliRendererFactoryResetRenderer2" );
+
+ Actor actor = Actor::New();
+ actor.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor );
+ RendererFactory factory = RendererFactory::Get();
+ DALI_TEST_CHECK( factory );
+
+ Image resourceImage = ResourceImage::New(TEST_IMAGE_FILE_NAME);
+ ControlRenderer controlRenderer = factory.GetControlRenderer( resourceImage );
+ DALI_TEST_CHECK( controlRenderer );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ application.SendNotification();
+ application.Render(0);
+ Image samplerImage = actor.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
+ DALI_TEST_CHECK( ResourceImage::DownCast( samplerImage ) );
+
+ Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
+ bool isNewRenderer = factory.ResetRenderer( controlRenderer, bufferImage );
+ DALI_TEST_CHECK( !isNewRenderer );
+ application.SendNotification();
+ application.Render(0);
+ samplerImage = actor.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
+ DALI_TEST_CHECK( BufferImage::DownCast( samplerImage ) );
+
+ isNewRenderer = factory.ResetRenderer( controlRenderer, Color::RED );
+ DALI_TEST_CHECK( isNewRenderer );
+
+ Actor actor2 = Actor::New();
+ actor2.SetSize(200.f, 200.f);
+ Stage::GetCurrent().Add( actor2 );
+ controlRenderer.SetSize(Vector2(200.f, 200.f));
+ controlRenderer.SetOnStage( actor2 );
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ application.SendNotification();
+ application.Render(0);
+ Vector4 actualValue(Vector4::ZERO);
+ DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uBlendColor", actualValue ) );
+ DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );