+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererOpacity(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test OPACITY property");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ float opacity;
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ Vector4 actualValue;
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
+ DALI_TEST_EQUALS(actualValue.a, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.5f);
+
+ application.SendNotification();
+ application.Render();
+
+ value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ value = renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("uColor", actualValue));
+ DALI_TEST_EQUALS(actualValue.a, 0.5f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererOpacityAnimation(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test OPACITY property animation");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ float opacity;
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 1.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 0.0f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ // Need to clear the animation before setting the property as the animation value is baked and will override any previous setters
+ animation.Clear();
+ renderer.SetProperty(DevelRenderer::Property::OPACITY, 0.1f);
+
+ animation.AnimateBy(Property(renderer, DevelRenderer::Property::OPACITY), 0.5f);
+ animation.Play();
+
+ application.SendNotification();
+ application.Render(1000);
+
+ value = renderer.GetProperty(DevelRenderer::Property::OPACITY);
+ DALI_TEST_CHECK(value.Get(opacity));
+ DALI_TEST_EQUALS(opacity, 0.6f, Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+ DALI_TEST_EQUALS(opacity, renderer.GetCurrentProperty(DevelRenderer::Property::OPACITY).Get<float>(), Dali::Math::MACHINE_EPSILON_1, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliRendererInvalidProperty(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test invalid property");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render(0);
+
+ Property::Value value = renderer.GetProperty(Renderer::Property::DEPTH_INDEX + 100);
+ DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
+
+ value = renderer.GetCurrentProperty(Renderer::Property::DEPTH_INDEX + 100);
+ DALI_TEST_CHECK(value.GetType() == Property::Type::NONE);
+
+ END_TEST;
+}
+
+int UtcDaliRendererRenderingBehavior(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test RENDERING_BEHAVIOR property");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ Property::Value value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
+ int renderingBehavior;
+ DALI_TEST_CHECK(value.Get(renderingBehavior));
+ DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::IF_REQUIRED, TEST_LOCATION);
+
+ application.SendNotification();
+ application.Render();
+
+ uint32_t updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
+ drawTrace.Enable(true);
+ drawTrace.Reset();
+
+ renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::CONTINUOUSLY);
+
+ value = renderer.GetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
+ DALI_TEST_CHECK(value.Get(renderingBehavior));
+ DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
+
+ // Render and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
+
+ value = renderer.GetCurrentProperty(DevelRenderer::Property::RENDERING_BEHAVIOR);
+ DALI_TEST_CHECK(value.Get(renderingBehavior));
+ DALI_TEST_EQUALS(static_cast<DevelRenderer::Rendering::Type>(renderingBehavior), DevelRenderer::Rendering::CONTINUOUSLY, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ drawTrace.Reset();
+
+ // Render again and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ {
+ // Render again and check the update status
+ Animation animation = Animation::New(1.0f);
+ animation.AnimateTo(Property(renderer, DevelRenderer::Property::OPACITY), 0.0f, TimePeriod(0.5f, 0.5f));
+ animation.Play();
+
+ drawTrace.Reset();
+
+ application.SendNotification();
+ application.Render(0);
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ drawTrace.Reset();
+
+ application.SendNotification();
+ application.Render(100);
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+ }
+
+ // Change rendering behavior
+ renderer.SetProperty(DevelRenderer::Property::RENDERING_BEHAVIOR, DevelRenderer::Rendering::IF_REQUIRED);
+
+ // Render and check the update status
+ application.SendNotification();
+ application.Render();
+
+ updateStatus = application.GetUpdateStatus();
+
+ DALI_TEST_CHECK(!(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING));
+
+ END_TEST;
+}
+
+int UtcDaliRendererRegenerateUniformMap(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test regenerating uniform map when attaching renderer to the node");
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ application.SendNotification();
+ application.Render();
+
+ actor.RemoveRenderer(renderer);
+ shader = Shader::New("vertexSrc", "fragmentSrc");
+ shader.RegisterProperty("opacity", 0.5f);
+ renderer.SetShader(shader);
+
+ Stage::GetCurrent().KeepRendering(1.0f);
+
+ // Update for several frames
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+ application.SendNotification();
+ application.Render();
+
+ // Add Renderer
+ actor.AddRenderer(renderer);
+ application.SendNotification();
+ application.Render();
+
+ // Nothing to test here, the test must not crash
+ auto updateStatus = application.GetUpdateStatus();
+ DALI_TEST_CHECK(updateStatus & Integration::KeepUpdating::STAGE_KEEP_RENDERING);
+
+ END_TEST;
+}
+
+int UtcDaliRendererAddDrawCommands(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test adding draw commands to the renderer");
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableEnableDisableCallTrace(true);
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ // Expect delivering a single draw call
+ auto& drawTrace = glAbstraction.GetDrawTrace();
+ drawTrace.Reset();
+ drawTrace.Enable(true);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 1, TEST_LOCATION);
+
+ tet_infoline("\n\nTesting extension draw commands\n");
+ tet_infoline("TEMPORARILY REMOVED. MUST PUT BACK!\n");
+#ifdef TEMPORARY_TEST_REMOVAL
+ auto drawCommand1 = DevelRenderer::DrawCommand{};
+ drawCommand1.drawType = DevelRenderer::DrawType::INDEXED;
+ drawCommand1.firstIndex = 0;
+ drawCommand1.elementCount = 2;
+ drawCommand1.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
+
+ auto drawCommand2 = DevelRenderer::DrawCommand{};
+ drawCommand2.drawType = DevelRenderer::DrawType::INDEXED;
+ drawCommand2.firstIndex = 2;
+ drawCommand2.elementCount = 2;
+ drawCommand2.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT;
+
+ auto drawCommand3 = DevelRenderer::DrawCommand{};
+ drawCommand3.drawType = DevelRenderer::DrawType::ARRAY;
+ drawCommand3.firstIndex = 2;
+ drawCommand3.elementCount = 2;
+ drawCommand3.queue = DevelRenderer::RENDER_QUEUE_OPAQUE;
+
+ DevelRenderer::AddDrawCommand(renderer, drawCommand1);
+ DevelRenderer::AddDrawCommand(renderer, drawCommand2);
+ DevelRenderer::AddDrawCommand(renderer, drawCommand3);
+
+ drawTrace.Reset();
+ drawTrace.Enable(true);
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS(drawTrace.CountMethod("DrawElements"), 3, TEST_LOCATION);
+#endif
+ END_TEST;
+}
+int UtcDaliRendererSetGeometryNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ Dali::Geometry arg1;
+ instance.SetGeometry(arg1);
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererSetTexturesNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ Dali::TextureSet arg1;
+ instance.SetTextures(arg1);
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererSetShaderNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ Dali::Shader arg1;
+ instance.SetShader(arg1);
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererGetGeometryNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ instance.GetGeometry();
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererGetTexturesNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ instance.GetTextures();
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererGetShaderNegative(void)
+{
+ TestApplication application;
+ Dali::Renderer instance;
+ try
+ {
+ instance.GetShader();
+ DALI_TEST_CHECK(false); // Should not get here
+ }
+ catch(...)
+ {
+ DALI_TEST_CHECK(true); // We expect an assert
+ }
+ END_TEST;
+}
+
+int UtcDaliRendererCheckTextureBindingP(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test adding draw commands to the renderer");
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableEnableDisableCallTrace(true);
+
+ Geometry geometry = CreateQuadGeometry();
+ Shader shader = Shader::New("vertexSrc", "fragmentSrc");
+ Renderer renderer = Renderer::New(geometry, shader);
+
+ renderer.SetProperty(Renderer::Property::BLEND_MODE, Dali::BlendMode::ON);
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 400.0f));
+ actor.SetProperty(Actor::Property::COLOR, Vector4(1.0f, 0.0f, 1.0f, 1.0f));
+ application.GetScene().Add(actor);
+
+ TestGraphicsController& graphics = application.GetGraphicsController();
+ TraceCallStack& cmdBufCallstack = graphics.mCommandBufferCallStack;
+ cmdBufCallstack.Enable(true);
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(!cmdBufCallstack.FindMethod("BindTextures"));
+
+ Texture image0 = CreateTexture(TextureType::TEXTURE_2D, Pixel::RGB888, 64, 64);
+ TextureSet textureSet0 = CreateTextureSet(image0);
+ renderer.SetTextures(textureSet0);
+
+ application.SendNotification();
+ application.Render();