[Tizen] Revert "Support multiple window rendering"
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-ResourceImage.cpp
index 134b112..ccd3eb4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
@@ -33,25 +33,10 @@ void utc_dali_resource_image_cleanup(void)
   test_return_value = TET_PASS;
 }
 
-static const char* gTestImageFilename = "icon_wrt.png";
-
 namespace
 {
-
-void LoadBitmapResource(TestPlatformAbstraction& platform)
-{
-  Integration::ResourceRequest* request = platform.GetRequest();
-  Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
-  Integration::ResourcePointer resource(bitmap);
-  bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, 80, 80, 80, 80);
-
-  if(request)
-  {
-    platform.SetResourceLoaded(request->GetId(), request->GetType()->id, resource);
-  }
-}
-
-} // namespace
+const char* gTestImageFilename = "icon_wrt.png";
+} // unnamed namespace
 
 
 // 1.1
@@ -92,230 +77,6 @@ int UtcDaliResourceImageNew02(void)
   END_TEST;
 }
 
-// 1.3
-int UtcDaliResourceImageNewWithPolicies01(void)
-{
-  TestApplication application;
-  TestPlatformAbstraction& platform = application.GetPlatform();
-
-  // testing delayed loading
-  tet_infoline("UtcDaliResourceImageNewWithPolicies01 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Never");
-  DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-  ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
-
-  DALI_TEST_CHECK( image );
-
-  application.SendNotification();
-  application.Render(16);
-
-  // request file loading only when actor added to stage
-  DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  Actor actor = CreateRenderableActor(image);
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-
-  DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  // testing ReleasePolicy::Never
-  // fake loading image
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-  LoadBitmapResource( platform );
-
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
-  // never discard texture
-  Stage::GetCurrent().Remove(actor);
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-  END_TEST;
-}
-
-// 1.4
-int UtcDaliResourceImageNewWithPolicies02(void)
-{
-  TestApplication application;
-  TestPlatformAbstraction& platform = application.GetPlatform();
-  const Vector2 closestImageSize( 80, 45);
-  platform.SetClosestImageSize(closestImageSize);
-
-  // testing resource deletion when taken off stage
-  tet_infoline("UtcDaliResourceImageNewWithPolicies02 - Load image with LoadPolicy::OnDemand, ReleasePolicy::Unused");
-
-  ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::UNUSED);
-
-  DALI_TEST_CHECK( image );
-
-  application.SendNotification();
-  application.Render(16);
-
-  // request file loading only when actor added to stage
-  DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  Actor actor = CreateRenderableActor(image);
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-
-  DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  // testing ReleasePolicy::Unused
-  // fake loading image
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-  LoadBitmapResource( platform );
-
-  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;
-}
-
-// 1.5
-int UtcDaliResourceImageNewWithPolicies03(void)
-{
-  TestApplication application;
-  TestPlatformAbstraction& platform = application.GetPlatform();
-  const Vector2 closestImageSize( 80, 45);
-  platform.SetClosestImageSize(closestImageSize);
-
-  // load immediately -> resource deletion when taken off stage -> put actor back on stage -> load resource again
-  tet_infoline("UtcDaliResourceImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Unused");
-
-  ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::UNUSED);
-
-  DALI_TEST_CHECK( image );
-
-  application.SendNotification();
-  application.Render(16);
-
-  // request file loading immediately
-  DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  Actor actor = CreateRenderableActor(image);
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-
-  // testing ReleasePolicy::Unused
-  // fake loading image
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-  LoadBitmapResource( platform );
-
-  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) );
-
-  // check load request when actor added back to stage
-  application.GetPlatform().ResetTrace();
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-
-  DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-  END_TEST;
-}
-
-// 1.6
-int UtcDaliResourceImageNewWithPolicies04(void)
-{
-  TestApplication application;
-  TestPlatformAbstraction& platform = application.GetPlatform();
-
-  // load immediately, don't release texture when off stage
-  tet_infoline("UtcDaliResourceImageNewWithPolicies03 - Load image with LoadPolicy::Immediate, ReleasePolicy::Never");
-
-  ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::IMMEDIATE, Image::NEVER);
-
-  DALI_TEST_CHECK( image );
-
-  application.SendNotification();
-  application.Render(16);
-
-  // request file loading immediately
-  DALI_TEST_CHECK( platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-
-  Actor actor = CreateRenderableActor(image);
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-
-  // testing ReleasePolicy::Never
-  // fake loading image
-  std::vector<GLuint> ids;
-  ids.push_back( 23 );
-  application.GetGlAbstraction().SetNextTextureIds( ids );
-  LoadBitmapResource(platform);
-
-  application.Render(16);
-  application.SendNotification();
-
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
-  // texture is not discarded
-  Stage::GetCurrent().Remove(actor);
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  DALI_TEST_CHECK ( !application.GetGlAbstraction().CheckTextureDeleted(23) );
-
-  // no load request when actor added back to stage
-  application.GetPlatform().ResetTrace();
-
-  Stage::GetCurrent().Add(actor);
-
-  application.SendNotification();
-  application.Render(16);
-  application.SendNotification();
-  application.Render(16);
-
-  DALI_TEST_CHECK( !platform.WasCalled(TestPlatformAbstraction::LoadResourceFunc) );
-  END_TEST;
-}
-
 // 1.7
 int UtcDaliResourceImageDownCast(void)
 {
@@ -389,15 +150,11 @@ int UtcDaliResourceImageGetLoadingState01(void)
   tet_infoline("UtcDaliResourceImageGetLoadingState01");
 
   ResourceImage image = ResourceImage::New(gTestImageFilename);
-  DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
-  application.SendNotification();
-  application.Render(16);
+  DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed);
 
   // simulate load success
-  TestPlatformAbstraction& platform = application.GetPlatform();
-  LoadBitmapResource( platform );
-  application.Render(16);
-  application.SendNotification();
+  PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 );
+  image.Reload();
 
   // Test state == ResourceLoadingSucceeded
   DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded);
@@ -419,37 +176,14 @@ int UtcDaliResourceImageGetLoadingState02(void)
   // initialise handle
   image = ResourceImage::New(gTestImageFilename);
 
-  // Test state == ResourceLoading
-  DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoading);
-  application.SendNotification();
-  application.Render(16);
-
-  // simulate load failure
-  Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
-  if(request)
-  {
-    application.GetPlatform().SetResourceLoadFailed(request->GetId(), Integration::FailureUnknown);
-  }
-  application.Render(16);
-  application.SendNotification();
-
   // Test state == ResourceLoadingFailed
   DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingFailed);
-  END_TEST;
-}
-
-// 1.12
-int UtcDaliResourceImageGetLoadPolicy(void)
-{
-  TestApplication application;
-
-  tet_infoline("UtcDaliImageGetLoadPolicy");
 
-  ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
+  PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 );
+  image.Reload();
 
-  DALI_TEST_CHECK( image );
-
-  DALI_TEST_CHECK( ResourceImage::ON_DEMAND == image.GetLoadPolicy());
+  // Test state == ResourceLoadingFailed
+  DALI_TEST_CHECK(image.GetLoadingState() == ResourceLoadingSucceeded);
   END_TEST;
 }
 
@@ -471,21 +205,14 @@ int UtcDaliResourceImageSignalLoadingFinished(void)
 
   SignalLoadFlag = false;
 
+  PrepareResourceImage( application, 100u, 100u, Pixel::RGBA8888 );
   ResourceImage image = ResourceImage::New(gTestImageFilename);
 
   image.LoadingFinishedSignal().Connect( SignalLoadHandler );
+  image.Reload();
   application.SendNotification();
   application.Render(16);
 
-  Integration::ResourceRequest* request = application.GetPlatform().GetRequest();
-  if(request)
-  {
-    application.GetPlatform().SetResourceLoaded(request->GetId(), request->GetType()->id, Integration::ResourcePointer(Integration::Bitmap::New(Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD)));
-  }
-
-  application.Render(16);
-  application.SendNotification();
-
   DALI_TEST_CHECK( SignalLoadFlag == true );
   END_TEST;
 }