void ResourceReadySignal( Control control )
{
gResourceReadySignalFired = true;
- gReadyIds.push_back(control.GetId());
+ gReadyIds.push_back(control.GetProperty< int >( Actor::Property::ID ));
}
void ClearReadyIds()
{
}
-int UtcDaliImageVisualImageHandle(void)
-{
- ToolkitTestApplication application;
- tet_infoline( "Request image visual with an image handle" );
-
- VisualFactory factory = VisualFactory::Get();
- DALI_TEST_CHECK( factory );
-
- Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
- Visual::Base visual = factory.CreateVisual( image );
-
- // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
- // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
-
- const int width=512;
- const int height=513;
-
- Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
- bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
-
- TestGlAbstraction& gl = application.GetGlAbstraction();
- TraceCallStack& textureTrace = gl.GetTextureTrace();
- textureTrace.Enable(true);
-
- DummyControl actor = DummyControl::New();
- TestVisualRender( application, actor, visual, 1u,
- ImageDimensions(width, height),
- Integration::ResourcePointer(bitmap) );
-
- DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliImageVisualCustomWrapModePixelArea(void)
{
ToolkitTestApplication application;
END_TEST;
}
+int UtcDaliImageVisualReleasePolicy08(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliImageVisualReleasePolicy08 Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy" );
+
+ tet_infoline( "Create first visual with DESTROYED release policy" );
+ Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
+
+ // Set up trace debug
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ tet_infoline( "Register visuals with control and ensure it has the only handles" );
+ DummyControl actor = DummyControl::New(true);
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
+ dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualDestroyed );
+ imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
+
+ actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
+
+ // Test initially zero renderers
+ application.SendNotification();
+ application.Render(0);
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
+ textureTrace.Reset();
+
+ Stage::GetCurrent().Add( actor );
+
+ // Wait for image to load
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render(0);
+ tet_infoline( "Ensure a texture is created" );
+ DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
+ textureTrace.Reset();
+
+ // Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy
+ // 1. Get TextureSet
+ TextureSet textureSetBefore = actor.GetRendererAt( 0u ).GetTextures();
+
+ // 2.Remove actor from stage. In this case, renderer also is deleted.
+ tet_infoline( "Remove actor from stage" );
+ Stage::GetCurrent().Remove( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ application.SendNotification();
+ application.Render();
+
+ tet_infoline( "Ensure a texture is not deleted as visual used the DESTROYED release policy" );
+ DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
+ textureTrace.Reset();
+
+ // 3.Add actor in stage. In this case, renderer is created.
+ tet_infoline( "Add actor in stage" );
+ Stage::GetCurrent().Add( actor );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+ application.SendNotification();
+ application.Render();
+ tet_infoline( "Ensure a texture is not created again" );
+ DALI_TEST_EQUALS( textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION );
+ textureTrace.Reset();
+
+ // 4.Compare Texture with before and after. textureSet need to be same because release policy is the DESTROYED.
+ tet_infoline( "Ensure a textureSet is not deleted because it is used the DESTROYED release policy" );
+ TextureSet textureSetAfter = actor.GetRendererAt( 0u ).GetTextures();
+ DALI_TEST_CHECK( textureSetBefore == textureSetAfter );
+ textureSetBefore.Reset();
+ textureSetAfter.Reset();
+
+ dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+ application.SendNotification();
+ application.Render();
+ DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliImageVisualLoadPolicy01(void)
{
ToolkitTestApplication application;
static int callNumber = 0;
gResourceReadySignalFired = true;
- gReadyIds.push_back(control.GetId());
+ gReadyIds.push_back(control.GetProperty< int >( Actor::Property::ID ));
if( callNumber == 0 )
{
tet_infoline( "Create a control and connect to resource ready signal" );
DummyControl actor = DummyControl::New(true);
- int actor1Id = actor.GetId();
+ int actor1Id = actor.GetProperty< int >( Actor::Property::ID );
actor.ResourceReadySignal().Connect( &ResourceReadySignal);
Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_BROKEN_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
DummyControl actor2 = DummyControl::New(true);
- int actor2Id = actor2.GetId();
+ int actor2Id = actor2.GetProperty< int >( Actor::Property::ID );
Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor2.GetImplementation());
actor2.ResourceReadySignal().Connect( &ResourceReadyLoadNext);