int UtcDaliImageActorSetImage(void) { TestApplication application; ImageActor actor = ImageActor::New(Image()); DALI_TEST_CHECK(actor); actor.SetImage( Image() ); DALI_TEST_CHECK(!actor.GetImage()); END_TEST; }
int UtcDaliImageActorGetCurrentImageSize05(void) { TestApplication application; tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete"); Vector2 closestImageSize( 80, 45); application.GetPlatform().SetClosestImageSize(closestImageSize); ImageAttributes attrs; attrs.SetSize(40, 30); // Request a really small size we won't get. Image image = Image::New("image.jpg", attrs); ImageActor actor = ImageActor::New( image ); Stage::GetCurrent().Add(actor); application.SendNotification(); // Flush update messages application.Render(); // Process resource request DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); // Now complete the image load Integration::ResourceRequest* req = application.GetPlatform().GetRequest(); Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, closestImageSize.width, closestImageSize.height, closestImageSize.width, closestImageSize.height ); Integration::ResourcePointer resourcePtr(bitmap); // reference it application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr); application.Render(); // Process LoadComplete application.SendNotification(); // Process event messages application.GetPlatform().DiscardRequest(); // Ensure load request is discarded application.GetPlatform().ClearReadyResources(); // DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); // Load a different image Vector2 image2ClosestSize = Vector2(240, 150); application.GetPlatform().SetClosestImageSize(image2ClosestSize); attrs.SetSize(100, 100); Image image2 = Image::New("image2.jpg", attrs); actor.SetImage(image2); application.SendNotification(); // Flush update messages application.Render(); // Process resource request application.SendNotification(); // Flush update messages application.Render(); // Process resource request // Ensure the actor size is kept DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION ); // Now complete the image load req = application.GetPlatform().GetRequest(); Integration::Bitmap* bitmap2 = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, false ); bitmap2->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, image2ClosestSize.width, image2ClosestSize.height, image2ClosestSize.width, image2ClosestSize.height ); Integration::ResourcePointer resourcePtr2(bitmap2); // reference it application.GetPlatform().SetResourceLoaded(req->GetId(), req->GetType()->id, resourcePtr2); application.Render(); // Process LoadComplete application.SendNotification(); // Process event messages application.GetPlatform().DiscardRequest(); // Ensure load request is discarded application.GetPlatform().ClearReadyResources(); // application.SendNotification(); // Process event messages application.Render(); // Process LoadComplete // Ensure the actor size gets the new image's natural size DALI_TEST_EQUALS( actor.GetCurrentImageSize(), image2ClosestSize, TEST_LOCATION ); END_TEST; }