Add a test case for RenderTask
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-RenderTask.cpp
index 0b86a22..4bd248e 100644 (file)
@@ -552,6 +552,41 @@ int UtcDaliRenderTaskSetSourceActorEmpty(void)
   END_TEST;
 }
 
+int UtcDaliRenderTaskSetSourceActorDestroyed(void)
+{
+  TestApplication application;
+
+  tet_infoline( "Testing RenderTask::SetSourceActor - Set a source actor and destroy the source actor" );
+
+  Stage stage = Stage::GetCurrent();
+  RenderTaskList taskList = stage.GetRenderTaskList();
+  RenderTask task = taskList.GetTask( 0u );
+
+  Actor actor = task.GetSourceActor();
+  DALI_TEST_CHECK( actor );
+
+  BufferImage img = BufferImage::New( 1,1 );
+  Actor newActor = CreateRenderableActor( img );
+  newActor.SetSize(1,1);
+  stage.Add( newActor );
+
+  task.SetSourceActor( newActor );
+
+  DALI_TEST_CHECK( task.GetSourceActor() != actor );
+  DALI_TEST_CHECK( task.GetSourceActor() == newActor );
+
+  application.SendNotification();
+  application.Render();
+
+  // Destroy the source actor
+  stage.Remove( newActor );
+  newActor.Reset();
+
+  DALI_TEST_CHECK( !task.GetSourceActor() );  // The source actor should be an empty handle.
+
+  END_TEST;
+}
+
 int UtcDaliRenderTaskGetSourceActorP01(void)
 {
   TestApplication application;
@@ -967,6 +1002,29 @@ int UtcDaliRenderTaskSetCameraActorN(void)
   END_TEST;
 }
 
+int UtcDaliRenderTaskSetCameraActorDestroyed(void)
+{
+  TestApplication application;
+
+  tet_infoline( "Testing RenderTask::SetCameraActor - Set a camera actor and destroy the camera actor" );
+
+  Stage stage = Stage::GetCurrent();
+  RenderTaskList taskList = stage.GetRenderTaskList();
+  RenderTask task = taskList.GetTask( 0u );
+
+  CameraActor newCameraActor = CameraActor::New();
+  task.SetCameraActor( newCameraActor );
+
+  DALI_TEST_EQUALS( task.GetCameraActor(), newCameraActor, TEST_LOCATION );
+
+  // Destroy the camera actor
+  newCameraActor.Reset();
+
+  CameraActor camera = task.GetCameraActor();
+  DALI_TEST_CHECK( !camera );  // The camera actor should be an empty handle.
+
+  END_TEST;
+}
 
 int UtcDaliRenderTaskGetCameraActorP(void)
 {
@@ -2770,3 +2828,45 @@ int UtcDaliRenderTaskRequiresSync(void)
 
   END_TEST;
 }
+
+int UtcDaliRenderTaskSetClearEnabled(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliRenderTaskSetClearEnabled");
+
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  Actor renderableActor = CreateRenderableActorSuccess( application, "aFile.jpg" );
+  Stage::GetCurrent().Add( renderableActor );
+
+  Actor rootActor = Actor::New();
+  Stage::GetCurrent().Add( rootActor );
+
+  CameraActor offscreenCameraActor = CameraActor::New( Size( TestApplication::DEFAULT_SURFACE_WIDTH, TestApplication::DEFAULT_SURFACE_HEIGHT ) );
+  Stage::GetCurrent().Add( offscreenCameraActor );
+
+  Actor sourceActor = CreateRenderableActorSuccess( application, "aFile.jpg" );
+  Stage::GetCurrent().Add( sourceActor );
+
+  RenderTask newTask = CreateRenderTask( application, offscreenCameraActor, rootActor, sourceActor, RenderTask::REFRESH_ALWAYS, false );
+
+  DALI_TEST_EQUALS( gl.GetClearCountCalled(), 0, TEST_LOCATION );
+
+  application.SendNotification();
+  application.Render();
+
+  // glClear should be called twice - default task and the new task.
+  DALI_TEST_EQUALS( gl.GetClearCountCalled(), 2, TEST_LOCATION );
+
+  newTask.SetClearEnabled( false );
+
+  application.SendNotification();
+  application.Render();
+
+  // The count should increase by 1 - default task only.
+  DALI_TEST_EQUALS( gl.GetClearCountCalled(), 3, TEST_LOCATION );
+
+  END_TEST;
+}