[3.0] Remove/move experimental features
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-BufferImage.cpp
index bd3a05c..7258578 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -74,104 +74,19 @@ int UtcDaliBufferImageNew02(void)
   END_TEST;
 }
 
-int UtcDaliBufferImageNewWithPolicy01(void)
-{
-  TestApplication application;
-
-  tet_infoline("UtcDaliBufferImageNewWithPolicy01 - BufferImage::New(unsigned int, unsigned int, Pixel::Format, LoadPolicy, ReleasePolicy)");
-
-  // Force texture id's
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-
-  // invoke default handle constructor
-  BufferImage image;
-
-  // initialise handle
-  image = BufferImage::New(16, 16, Pixel::A8, Image::UNUSED);
-  application.SendNotification();
-  application.Render(16);
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK( image.GetWidth() == 16);
-  ImageActor actor = ImageActor::New(image);
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-  // testing ReleasePolicy::Unused
-  // fake loading image
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
-  // discard texture when actor comes off stage
-  Stage::GetCurrent().Remove(actor);
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
-  END_TEST;
-}
-
-int UtcDaliBufferImageNewWithPolicy02(void)
-{
-  TestApplication application;
-
-  tet_infoline("UtcDaliBufferImageNewWithPolicy02 - BufferImage::New(PixelBuffer*, unsigned int, unsigned int, Pixel::Format, unsigned int, ReleasePolicy)");
-
-  // Force texture id's
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-
-  PixelBuffer* buffer = new PixelBuffer[16 * 16];
-  BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8, 16, Image::UNUSED);
-  application.SendNotification();
-  application.Render(16);
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK( image.GetWidth() == 16);
-  ImageActor actor = ImageActor::New(image);
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-  // testing ReleasePolicy::Unused
-  // fake loading image
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
-  // discard texture when actor comes off stage
-  Stage::GetCurrent().Remove(actor);
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  DALI_TEST_CHECK ( application.GetGlAbstraction().CheckTextureDeleted(23) );
-  END_TEST;
-}
-
 int UtcDaliBufferImageDownCast(void)
 {
   TestApplication application;
   tet_infoline("Testing Dali::BufferImage::DownCast()");
 
   BufferImage bitmap = BufferImage::New(1, 1, Dali::Pixel::BGRA8888);
-  ImageActor imageActor = ImageActor::New(bitmap);
+  Actor actor = CreateRenderableActor( bitmap );
   application.SendNotification();
   application.Render(16);
   application.Render(16);
   application.SendNotification();
 
-  Image image = imageActor.GetImage();
+  Image image = GetTexture( actor );
   BufferImage bufferImage = BufferImage::DownCast( image );
 
   DALI_TEST_CHECK(bufferImage);
@@ -184,13 +99,13 @@ int UtcDaliBufferImageDownCast2(void)
   tet_infoline("Testing Dali::BufferImage::DownCast()");
 
   Image image = ResourceImage::New("IncorrectImageName");
-  ImageActor imageActor = ImageActor::New(image);
+  Actor actor = CreateRenderableActor( image );
   application.SendNotification();
   application.Render(16);
   application.Render(16);
   application.SendNotification();
 
-  Image image1 = imageActor.GetImage();
+  Image image1 = GetTexture( actor );
 
   BufferImage bufferImage = BufferImage::DownCast( image1 );
   DALI_TEST_CHECK(!bufferImage);
@@ -351,7 +266,7 @@ int UtcDaliBufferImageUpdate01(void)
   PixelBuffer* buffer = new PixelBuffer[16 * 16];
 
   BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
-  ImageActor actor = ImageActor::New(image);
+  Actor actor = CreateRenderableActor( image );
   Stage::GetCurrent().Add(actor);
   actor.SetVisible(true);
 
@@ -384,7 +299,10 @@ int UtcDaliBufferImageUpdate01(void)
   application.SendNotification();
 
   const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "0, 0, 16, 16"), true, TEST_LOCATION);
+
+  std::stringstream out;
+  out << GL_TEXTURE_2D <<", "<< 0u << ", " << 0u << ", " << 0u << ", " << 16u <<", "<< 16u;
+  DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", out.str().c_str() ), true, TEST_LOCATION);
 
   DALI_TEST_CHECK( SignalReceived == true );
   SignalReceived = false;
@@ -399,19 +317,13 @@ int UtcDaliBufferImageUpdate02(void)
 
   PixelBuffer* buffer = new PixelBuffer[16 * 16];
   BufferImage image = BufferImage::New(buffer, 16, 16, Pixel::A8);
-  ImageActor actor = ImageActor::New(image);
+  Actor actor = CreateRenderableActor( image );
   Stage::GetCurrent().Add(actor);
   actor.SetVisible(true);
 
   SignalReceived = false;
   image.UploadedSignal().Connect( ImageUploaded );
 
-  std::vector<GLuint> ids;
-  ids.push_back(200);
-  ids.push_back(201);
-  ids.push_back(202);
-  application.GetGlAbstraction().SetNextTextureIds(ids);
-
   application.SendNotification();
   application.Render(0);
   application.Render(16);
@@ -422,7 +334,10 @@ int UtcDaliBufferImageUpdate02(void)
   DALI_TEST_CHECK( image.IsDataExternal() );
   application.GetGlAbstraction().EnableTextureCallTrace(true);
 
-  image.Update(RectArea(9,9,5,5));              // notify Core that the image has been updated
+  // Check that multiple updates in a frame will be properly uploaded
+  image.Update(RectArea(9,9,5,5));
+  image.Update(RectArea(2,2,4,4));
+  image.Update(RectArea(3,3,1,6));
 
   application.SendNotification();
   application.Render(16);
@@ -432,11 +347,24 @@ int UtcDaliBufferImageUpdate02(void)
   application.SendNotification();
 
   const TraceCallStack& callStack = application.GetGlAbstraction().GetTextureTrace();
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", "9, 9, 5, 1"), true, TEST_LOCATION);
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", "9, 10, 5, 1"), true, TEST_LOCATION);
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", "9, 11, 5, 1"), true, TEST_LOCATION);
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(3, "TexSubImage2D", "9, 12, 5, 1"), true, TEST_LOCATION);
-  DALI_TEST_EQUALS( callStack.TestMethodAndParams(4, "TexSubImage2D", "9, 13, 5, 1"), true, TEST_LOCATION);
+
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D <<", "<< 0u << ", " << 9u << ", " << 9u << ", " << 5u <<", "<< 5u;
+    DALI_TEST_EQUALS( callStack.TestMethodAndParams(0, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+  }
+
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D <<", "<< 0u << ", " << 2u << ", " << 2u << ", " << 4u <<", "<< 4u;
+    DALI_TEST_EQUALS( callStack.TestMethodAndParams(1, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+  }
+
+  {
+    std::stringstream out;
+    out << GL_TEXTURE_2D <<", "<< 0u << ", " << 3u << ", " << 3u << ", " << 1u <<", "<< 6u;
+    DALI_TEST_EQUALS( callStack.TestMethodAndParams(2, "TexSubImage2D", out.str().c_str()), true, TEST_LOCATION);
+  }
 
   DALI_TEST_CHECK( SignalReceived == true );
   SignalReceived = false;
@@ -459,8 +387,8 @@ int UtcDaliBufferImageUploadedSignal01(void)
   application.Render(16);
   application.SendNotification();
 
-  Dali::ImageActor imageActor = ImageActor::New(image);
-  Stage::GetCurrent().Add(imageActor);
+  Actor actor = CreateRenderableActor( image );
+  Stage::GetCurrent().Add(actor);
   application.SendNotification();
   application.Render(16);
   application.SendNotification();
@@ -490,8 +418,8 @@ int UtcDaliBufferImageUploadedSignal02(void)
   application.Render(16);
   application.SendNotification();
 
-  Dali::ImageActor imageActor = ImageActor::New(image);
-  Stage::GetCurrent().Add(imageActor);
+  Actor actor = CreateRenderableActor( image );
+  Stage::GetCurrent().Add(actor);
   application.SendNotification();
   application.Render(16);
   application.SendNotification();