Added more unit tests for NinePatchImage 88/24088/1
authorDavid Steele <david.steele@partner.samsung.com>
Mon, 23 Jun 2014 10:15:52 +0000 (11:15 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 13:19:05 +0000 (14:19 +0100)
Double checking the ImageActor behaviour with 9 patch images.

Change-Id: If00f9ca4425305885c965202a09d7862fe813d49
Signed-off-by: David Steele <david.steele@partner.samsung.com>
automated-tests/src/dali/tct-dali-core.h
automated-tests/src/dali/utc-Dali-ImageActor.cpp

index abfb082..85e58e4 100644 (file)
@@ -707,6 +707,8 @@ extern int UtcDaliImageActorPropertyIndices(void);
 extern int UtcDaliImageActorImageProperty(void);
 extern int UtcDaliImageActorNinePatch01(void);
 extern int UtcDaliImageActorNinePatch02(void);
+extern int UtcDaliImageActorNinePatch03(void);
+extern int UtcDaliImageActorNinePatch04(void);
 extern int UtcDaliImageAttributesConstructor(void);
 extern int UtcDaliImageAttributesLessThan(void);
 extern int UtcDaliImageAttributesEquality(void);
@@ -1932,6 +1934,8 @@ testcase tc_array[] = {
     {"UtcDaliImageActorImageProperty", UtcDaliImageActorImageProperty, image_actor_test_startup, image_actor_test_cleanup},
     {"UtcDaliImageActorNinePatch01", UtcDaliImageActorNinePatch01, image_actor_test_startup, image_actor_test_cleanup},
     {"UtcDaliImageActorNinePatch02", UtcDaliImageActorNinePatch02, image_actor_test_startup, image_actor_test_cleanup},
+    {"UtcDaliImageActorNinePatch03", UtcDaliImageActorNinePatch03, image_actor_test_startup, image_actor_test_cleanup},
+    {"UtcDaliImageActorNinePatch04", UtcDaliImageActorNinePatch04, image_actor_test_startup, image_actor_test_cleanup},
     {"UtcDaliImageAttributesConstructor", UtcDaliImageAttributesConstructor, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup},
     {"UtcDaliImageAttributesLessThan", UtcDaliImageAttributesLessThan, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup},
     {"UtcDaliImageAttributesEquality", UtcDaliImageAttributesEquality, utc_dali_image_attributes_startup, utc_dali_image_attributes_cleanup},
index d78782e..b30c625 100644 (file)
@@ -1047,3 +1047,100 @@ int UtcDaliImageActorNinePatch02(void)
 
   END_TEST;
 }
+
+
+int UtcDaliImageActorNinePatch03(void)
+{
+  TestApplication application;
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+  TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
+  TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
+
+  tet_infoline("Test the successful loading of a nine-patch image added using ImageActor::SetImage()\n");
+
+  platform.SetClosestImageSize(Vector2(4, 4));
+  Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false );
+  Integration::PixelBuffer* pixels = bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888,  4,4,4,4 );
+  memset( pixels, 0, 64 );
+
+  Integration::ResourcePointer resourcePtr(bitmap); // reference it
+  platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
+
+  Image ninePatchImage = Image::New( "blah.#.png" );
+  DALI_TEST_CHECK( ninePatchImage );
+
+  ImageActor imageActor = ImageActor::New();
+  DALI_TEST_CHECK( imageActor );
+  Stage::GetCurrent().Add( imageActor );
+
+  imageActor.SetImage( ninePatchImage );
+
+  drawTrace.Reset();
+  textureTrace.Reset();
+  drawTrace.Enable(true);
+  textureTrace.Enable(true);
+  glAbstraction.ClearBoundTextures();
+  std::vector<GLuint> ids;
+  ids.push_back( 23 );
+  glAbstraction.SetNextTextureIds( ids );
+
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_CHECK( drawTrace.FindMethod( "DrawArrays" ) );
+  typedef std::vector<GLuint> TexVec;
+  const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
+  DALI_TEST_CHECK( textures.size() > 0 );
+  if( textures.size() > 0 )
+  {
+    DALI_TEST_EQUALS( textures[0], 23u, TEST_LOCATION );
+  }
+
+  END_TEST;
+}
+
+
+int UtcDaliImageActorNinePatch04(void)
+{
+  TestApplication application;
+  TestPlatformAbstraction& platform = application.GetPlatform();
+  TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+  TraceCallStack& textureTrace = glAbstraction.GetTextureTrace();
+  TraceCallStack& drawTrace = glAbstraction.GetDrawTrace();
+
+  tet_infoline("Test the failed loading of a nine-patch image using ImageActor::SetImage()\n");
+
+  platform.SetClosestImageSize(Vector2(0, 0));
+  Integration::ResourcePointer resourcePtr;
+  platform.SetResourceLoaded( 0, Dali::Integration::ResourceBitmap, resourcePtr );
+
+  Image ninePatchImage = Image::New( "blah.#.png" );
+  DALI_TEST_CHECK( ninePatchImage );
+
+  ImageActor imageActor = ImageActor::New();
+  DALI_TEST_CHECK( imageActor );
+  Stage::GetCurrent().Add( imageActor );
+
+  imageActor.SetImage( ninePatchImage );
+
+  drawTrace.Reset();
+  textureTrace.Reset();
+  drawTrace.Enable(true);
+  textureTrace.Enable(true);
+  glAbstraction.ClearBoundTextures();
+  std::vector<GLuint> ids;
+  ids.push_back( 23 );
+  glAbstraction.SetNextTextureIds( ids );
+
+  application.SendNotification();
+  application.Render();
+
+  // Check that nothing was drawn.
+  DALI_TEST_CHECK( ! drawTrace.FindMethod( "DrawArrays" ) );
+  typedef std::vector<GLuint> TexVec;
+  const TexVec& textures = glAbstraction.GetBoundTextures(GL_TEXTURE0);
+  DALI_TEST_CHECK( textures.size() == 0u );
+
+  END_TEST;
+}