Adding 'override', removing 'virtual' from overriding functions' declarations in...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-Texture.cpp
index 0222064..b170b6a 100644 (file)
@@ -59,7 +59,7 @@ int UtcDaliTextureNew03(void)
   TestApplication application;
 
   // Create a native image source.
-  TestNativeImageNoExtPointer testNativeImage = TestNativeImageNoExt::New( 64u, 64u );
+  TestNativeImagePointer testNativeImage = TestNativeImage::New( 64u, 64u );
 
   // Create a texture from the native image source.
   Texture nativeTexture = Texture::New( *testNativeImage );
@@ -101,6 +101,51 @@ int UtcDaliTextureAssignmentOperator(void)
   END_TEST;
 }
 
+int UtcDaliTextureMoveConstructor(void)
+{
+  TestApplication application;
+
+  uint32_t width = 64;
+  uint32_t height = 64;
+  Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+  DALI_TEST_CHECK( texture );
+  DALI_TEST_EQUALS( 1, texture.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( texture.GetWidth(), width, TEST_LOCATION );
+  DALI_TEST_EQUALS( texture.GetHeight(), height, TEST_LOCATION );
+
+  Texture move = std::move( texture );
+  DALI_TEST_CHECK( move );
+  DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( move.GetWidth(), width, TEST_LOCATION );
+  DALI_TEST_EQUALS( move.GetHeight(), height, TEST_LOCATION );
+  DALI_TEST_CHECK( !texture );
+
+  END_TEST;
+}
+
+int UtcDaliTextureMoveAssignment(void)
+{
+  TestApplication application;
+
+  uint32_t width = 64;
+  uint32_t height = 64;
+  Texture texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height );
+  DALI_TEST_CHECK( texture );
+  DALI_TEST_EQUALS( 1, texture.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( texture.GetWidth(), width, TEST_LOCATION );
+  DALI_TEST_EQUALS( texture.GetHeight(), height, TEST_LOCATION );
+
+  Texture move;
+  move = std::move( texture );
+  DALI_TEST_CHECK( move );
+  DALI_TEST_EQUALS( 1, move.GetBaseObject().ReferenceCount(), TEST_LOCATION );
+  DALI_TEST_EQUALS( move.GetWidth(), width, TEST_LOCATION );
+  DALI_TEST_EQUALS( move.GetHeight(), height, TEST_LOCATION );
+  DALI_TEST_CHECK( !texture );
+
+  END_TEST;
+}
+
 int UtcDaliTextureDownCast01(void)
 {
   TestApplication application;
@@ -738,20 +783,162 @@ int UtcDaliTextureContextLoss(void)
   END_TEST;
 }
 
-int UtcDaliNativeImageTexture(void)
+int UtcDaliNativeImageTexture01(void)
 {
   TestApplication application;
-  tet_infoline( "UtcDaliNativeImageTexture" );
+  tet_infoline( "UtcDaliNativeImageTexture01" );
 
   TestNativeImagePointer imageInterface = TestNativeImage::New( 16, 16 );
-  Texture texture = Texture::New( *(imageInterface.Get()) );
-  DALI_TEST_CHECK( texture );
+  {
+    Texture texture = Texture::New( *(imageInterface.Get()) );
+    Actor actor = CreateRenderableActor(texture, "", "");
+    application.GetScene().Add(actor);
+
+    DALI_TEST_CHECK( texture );
+
+    application.SendNotification();
+    application.Render(16);
+
+    DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageInterface->mExtensionDestroyCalls, 0, TEST_LOCATION );
+    DALI_TEST_EQUALS( actor.GetProperty(Actor::Property::SIZE), Property::Value(Vector3(16,16,0)), TEST_LOCATION);
+
+    UnparentAndReset(actor);
 
+    application.SendNotification();
+    application.Render(16);
+  }
   application.SendNotification();
   application.Render(16);
 
-  DALI_TEST_CHECK( texture );
+  DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 1, TEST_LOCATION );
+  DALI_TEST_EQUALS( imageInterface->mExtensionDestroyCalls, 1, TEST_LOCATION );
 
   END_TEST;
 }
 
+
+int UtcDaliNativeImageTexture02(void)
+{
+  TestApplication application;
+  tet_infoline( "UtcDaliNativeImageTexture02 - test error on TargetTexture" );
+
+  TestNativeImagePointer imageInterface = TestNativeImage::New( 16, 16 );
+  imageInterface->mTargetTextureError = 1u;
+  {
+    Texture texture = Texture::New( *(imageInterface.Get()) );
+    Actor actor = CreateRenderableActor(texture, "", "");
+    application.GetScene().Add(actor);
+
+    DALI_TEST_CHECK( texture );
+
+    application.SendNotification();
+    application.Render(16);
+
+    // Expect 2 attempts to create the texture - once when adding the texture
+    // to the scene-graph, and again since that failed, during the Bind.
+    DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 2, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageInterface->mExtensionDestroyCalls, 2, TEST_LOCATION );
+
+    UnparentAndReset(actor);
+
+    application.SendNotification();
+    application.Render(16);
+  }
+  application.SendNotification();
+  application.Render(16);
+
+  // Expect that there are no further calls to create/destroy resource
+  DALI_TEST_EQUALS( imageInterface->mExtensionCreateCalls, 2, TEST_LOCATION );
+  DALI_TEST_EQUALS( imageInterface->mExtensionDestroyCalls, 2, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliTextureGenerateMipmapsNegative(void)
+{
+  TestApplication application;
+  Dali::Texture instance;
+  try
+  {
+    instance.GenerateMipmaps();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliTextureUploadNegative01(void)
+{
+  TestApplication application;
+  Dali::Texture instance;
+  try
+  {
+    Dali::PixelData arg1;
+    instance.Upload(arg1);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliTextureUploadNegative02(void)
+{
+  TestApplication application;
+  Dali::Texture instance;
+  try
+  {
+    Dali::PixelData arg1;
+    unsigned int arg2(0u);
+    unsigned int arg3(0u);
+    unsigned int arg4(0u);
+    unsigned int arg5(0u);
+    unsigned int arg6(0u);
+    unsigned int arg7(0u);
+    instance.Upload(arg1,arg2,arg3,arg4,arg5,arg6,arg7);
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliTextureGetWidthNegative(void)
+{
+  TestApplication application;
+  Dali::Texture instance;
+  try
+  {
+    instance.GetWidth();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}
+
+int UtcDaliTextureGetHeightNegative(void)
+{
+  TestApplication application;
+  Dali::Texture instance;
+  try
+  {
+    instance.GetHeight();
+    DALI_TEST_CHECK(false); // Should not get here
+  }
+  catch(...)
+  {
+    DALI_TEST_CHECK(true); // We expect an assert
+  }
+  END_TEST;
+}