Revert "[3.0] (FrameBufferImage) Store ReleasePolicy to satisfy Tizen API policy"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-FrameBufferImage.cpp
index f282693..b79619a 100644 (file)
@@ -21,6 +21,8 @@
 #include <stdlib.h>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
+#include <test-native-image.h>
+#include <dali/integration-api/gl-abstraction.h>
 
 using std::max;
 using namespace Dali;
@@ -35,9 +37,6 @@ void utc_dali_framebuffer_cleanup(void)
   test_return_value = TET_PASS;
 }
 
-static const float ROTATION_EPSILON = 0.0001f;
-
-
 int UtcDaliFrameBufferImageNew01(void)
 {
   TestApplication application;
@@ -76,6 +75,163 @@ int UtcDaliFrameBufferImageNew01(void)
   END_TEST;
 }
 
+int UtcDaliFrameBufferImageNew02(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageNew02 - FrameBufferImage::New(NativeImageInterface&)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+  TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
+
+  DALI_TEST_CHECK( !image );
+
+  // initialise handle
+  image = FrameBufferImage::New(*(nativeImage.Get()));
+
+  DALI_TEST_CHECK( image );
+  END_TEST;
+}
+
+int UtcDaliFrameBufferImageNew03(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageNew03 - FrameBufferImage::New(NativeImageInterface&, ReleasePolicy)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+  TestNativeImagePointer nativeImage = TestNativeImage::New(16, 16);
+
+  DALI_TEST_CHECK( !image );
+
+  // initialise handle with UNUSED release policy
+  image = FrameBufferImage::New(*(nativeImage.Get()), Image::UNUSED);
+
+  DALI_TEST_CHECK( image );
+
+  //ReleasePolicy is always never for framebuffer images
+  DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
+
+  // initialise handle with NEVER release policy
+  image.Reset();
+  DALI_TEST_CHECK( !image );
+
+  image = FrameBufferImage::New(*(nativeImage.Get()), Image::NEVER);
+
+  DALI_TEST_CHECK( image );
+
+  //ReleasePolicy is always never for framebuffer images
+  DALI_TEST_EQUALS( image.GetReleasePolicy(), Image::NEVER, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliFrameBufferImageAttachments01(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageAttachments01 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+
+  // initialise handle
+  image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR);       // create framebuffer with Color buffer
+  ImageActor actor=ImageActor::New(image);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render();
+  application.Render();
+  application.SendNotification();
+
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFrameBufferImageAttachments02(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageAttachments02 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+
+  // initialise handle
+  image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH); // create framebuffer with Color and Depth buffer
+  ImageActor actor=ImageActor::New(image);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render();
+  application.Render();
+  application.SendNotification();
+
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFrameBufferImageAttachments03(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageAttachments03 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+
+  // initialise handle
+  image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_STENCIL);  // create framebuffer with Color and Stencil
+  ImageActor actor=ImageActor::New(image);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render();
+  application.Render();
+  application.SendNotification();
+
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_FALSE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+  END_TEST;
+}
+
+int UtcDaliFrameBufferImageAttachments04(void)
+{
+  TestApplication application;
+
+  tet_infoline("UtcDaliFrameBufferImageAttachments04 - FrameBufferImage::New(unsigned int, unsigned int, Pixel::Format, RenderBuffer::Format)");
+
+  // invoke default handle constructor
+  FrameBufferImage image;
+
+  // initialise handle
+  image = FrameBufferImage::New(64, 64, Pixel::RGBA8888, RenderBuffer::COLOR_DEPTH_STENCIL);  // create framebuffer with Color, Depth and Stencil buffers
+  ImageActor actor=ImageActor::New(image);
+  Stage::GetCurrent().Add(actor);
+
+  application.SendNotification();
+  application.Render();
+  application.Render();
+  application.SendNotification();
+
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferColorAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferDepthAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+  DALI_TEST_EQUALS(application.GetGlAbstraction().CheckFramebufferStencilAttachment(), (GLenum)GL_TRUE, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliFrameBufferImageDownCast(void)
 {
   TestApplication application;