/*
- * Copyright (c) 2015 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.
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)
{
END_TEST;
}
-// 1.12
-int UtcDaliResourceImageGetLoadPolicy(void)
-{
- TestApplication application;
-
- tet_infoline("UtcDaliImageGetLoadPolicy");
-
- ResourceImage image = ResourceImage::New(gTestImageFilename, ResourceImage::ON_DEMAND, Image::NEVER);
-
- DALI_TEST_CHECK( image );
-
- DALI_TEST_CHECK( ResourceImage::ON_DEMAND == image.GetLoadPolicy());
- END_TEST;
-}
-
static bool SignalLoadFlag = false;
static void SignalLoadHandler(ResourceImage image)