+
+int UtcDaliSceneEnsureReplacedSurfaceKeepsClearColor(void)
+{
+ tet_infoline( "Ensure we keep background color when the scene surface is replaced " );
+
+ TestApplication application;
+
+ // Create a new scene and set the background color of the main scene
+ auto defaultScene = application.GetScene();
+ defaultScene.SetBackgroundColor( Color::BLUE );
+
+ // Need to create a renderable as we don't start rendering until we have at least one
+ // We don't need to add this to any scene
+ auto actor = CreateRenderableActor();
+
+ auto& glAbstraction = application.GetGlAbstraction();
+ auto clearCountBefore = glAbstraction.GetClearCountCalled();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 1, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ defaultScene.SurfaceReplaced();
+
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 2, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ // Check when the main render task viewport is set the clear color is clipped using scissors
+ TraceCallStack& scissorTrace = glAbstraction.GetScissorTrace();
+ TraceCallStack& enabledDisableTrace = glAbstraction.GetEnableDisableTrace();
+ scissorTrace.Enable( true );
+ enabledDisableTrace.Enable( true );
+
+ defaultScene.GetRenderTaskList().GetTask( 0 ).SetViewport( Viewport( 0.0f, 0.0f, 100.0f, 100.0f ) );
+
+ application.SendNotification();
+ application.Render();
+
+ // Check scissor test was enabled.
+ DALI_TEST_CHECK( enabledDisableTrace.FindMethodAndParams( "Enable", "3089" ) ); // 3089 = 0xC11 (GL_SCISSOR_TEST)
+
+ // Check the scissor was set, and the coordinates are correct.
+ DALI_TEST_CHECK( scissorTrace.FindMethodAndParams( "Scissor", "0, 700, 100, 100" ) );
+
+ DALI_TEST_EQUALS( glAbstraction.GetClearCountCalled(), clearCountBefore + 3, TEST_LOCATION );
+ DALI_TEST_EQUALS( glAbstraction.GetLastClearColor(), Color::BLUE, TEST_LOCATION );
+
+ scissorTrace.Enable( false );
+ scissorTrace.Reset();
+
+ enabledDisableTrace.Enable( false );
+ enabledDisableTrace.Reset();
+
+ END_TEST;
+}