END_TEST;
}
-int UtcDaliImageActorGetCurrentImageSize01(void)
+int UtcDaliImageActorGetCurrentSize01(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize");
Vector2 initialImageSize(100, 50);
BitmapImage image = BitmapImage::New( initialImageSize.width, initialImageSize.height );
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
Vector2 size(200.0f, 200.0f);
actor.SetSize(size);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
size.x = 200.0f;
size.y = 200.0f;
ImageActor::PixelArea area(0, 0, 10, 10);
actor.SetPixelArea(area);
application.Render(9);
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2( area.width, area.height ), TEST_LOCATION );
+ // natural size is not used as setsize is called
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
+
+ actor.SetToNaturalSize();
+ application.SendNotification();
+ application.Render(9);
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2( area.width, area.height ), TEST_LOCATION );
+
END_TEST;
}
-int UtcDaliImageActorGetCurrentImageSize02(void)
+int UtcDaliImageActorGetCurrentSize02(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - Test that using an image resource sets the actor size with it's natural size immediately rather than on load");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - Test that using an image resource sets the actor size with it's natural size immediately rather than on load");
Vector2 initialImageSize(100, 50);
application.SendNotification(); // Flush update messages
application.Render(); // Process resource request
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
Vector2 size(200.0f, 200.0f);
actor.SetSize(size);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
actor.SetToNaturalSize();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), initialImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), initialImageSize, TEST_LOCATION );
END_TEST;
}
-int UtcDaliImageActorGetCurrentImageSize03(void)
+int UtcDaliImageActorGetCurrentSize03(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - Test that using an image resource with a requested size sets the actor size with it's nearest size immediately rather than on load");
-
- Vector2 closestImageSize( 80, 45);
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - Test that using an image resource with a requested size sets the actor size with it's nearest size immediately rather than on load");
+ const Vector2 closestImageSize( 80, 45);
application.GetPlatform().SetClosestImageSize(closestImageSize);
ImageAttributes attrs;
- attrs.SetSize(40, 30);
+ const Vector2 requestedSize( 40, 30 );
+ attrs.SetSize( requestedSize.width, requestedSize.height );
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 );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Test that setting a size on the actor can be 'undone' with SetNaturalSize()
Vector2 size(200.0f, 200.0f);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
actor.SetToNaturalSize();
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
END_TEST;
}
-int UtcDaliImageActorGetCurrentImageSize04(void)
+int UtcDaliImageActorGetCurrentSize04(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doesn't change a set actor size");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doesn't change a set actor size");
- Vector2 closestImageSize( 80, 45);
+ const Vector2 closestImageSize( 80, 45);
application.GetPlatform().SetClosestImageSize(closestImageSize);
+ const Vector2 requestedSize( 40, 30 );
ImageAttributes attrs;
- attrs.SetSize(40, 30); // Request a really small size we won't get.
+ attrs.SetSize( requestedSize.width, requestedSize.height );
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 );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
Vector2 size(200.0f, 200.0f);
actor.SetSize(size);
// flush the queue and render once
application.SendNotification();
application.Render();
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
// Load a different image
Vector2 image2ClosestSize = Vector2(240, 150); // The actual size image loader will return for the request below
application.GetPlatform().SetClosestImageSize(image2ClosestSize);
- attrs.SetSize(100, 100);
+ const Vector2 request2Size( 100, 100 );
+ attrs.SetSize( request2Size.width, request2Size.height );
Image image2 = Image::New("image2.jpg", attrs);
actor.SetImage(image2);
application.Render(); // Process resource request
// Ensure the actor size is kept
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
// Now complete the image load
req = application.GetPlatform().GetRequest();
application.GetPlatform().ClearReadyResources(); //
// Ensure the actor size is kept
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), size, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), size, TEST_LOCATION );
actor.SetToNaturalSize();
application.SendNotification();
application.Render();
// Ensure the actor size gets the new image's natural size
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), image2ClosestSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), request2Size, TEST_LOCATION );
END_TEST;
}
-int UtcDaliImageActorGetCurrentImageSize05(void)
+int UtcDaliImageActorGetCurrentSize05(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - 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.
+ const Vector2 requestedSize( 40, 30 );
+ attrs.SetSize( requestedSize.width, requestedSize.height );
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 );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Load a different image
Vector2 image2ClosestSize = Vector2(240, 150);
application.GetPlatform().SetClosestImageSize(image2ClosestSize);
- attrs.SetSize(100, 100);
+ const Vector2 requestedSize2( 100, 100 );
+ attrs.SetSize( requestedSize2.width, requestedSize2.height );
Image image2 = Image::New("image2.jpg", attrs);
actor.SetImage(image2);
application.Render(); // Process resource request
// Ensure the actor size is kept
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize2, TEST_LOCATION );
// Now complete the image load
req = application.GetPlatform().GetRequest();
application.Render(); // Process LoadComplete
// Ensure the actor size gets the new image's natural size
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), image2ClosestSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize2, TEST_LOCATION );
END_TEST;
}
int UtcDaliImageActorNaturalPixelAreaSize01(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doens't change actor size until load complete");
//If an image is loaded without setting size, then the actor gets the natural size of the image
//Setting the pixel area will change the actor size to match the pixel area
application.GetPlatform().SetClosestImageSize(closestImageSize);
ImageAttributes attrs;
- attrs.SetSize(40, 30); // Request a really small size we won't get.
+ const Vector2 requestedSize( 40, 30 );
+ attrs.SetSize( requestedSize.width, requestedSize.height );
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 );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Set a pixel area on a naturally sized actor - expect the actor to take the
// pixel area as size
actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30));
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION );
// Set a size. Expect the partial image to stretch to fill the new size
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
// Clear the pixel area. Expect the whole image to be shown, filling the set size.
actor.ClearPixelArea();
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(100, 100), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
END_TEST;
}
int UtcDaliImageActorNaturalPixelAreaSize02(void)
{
TestApplication application;
- tet_infoline("Positive test for Dali::ImageActor::GetCurrentImageSize - check a new image doens't change actor size until load complete");
+ tet_infoline("Positive test for Dali::ImageActor::GetCurrentSize - check a new image doens't change actor size until load complete");
//If an image is loaded without setting size, then the actor gets the natural size of the image
//Setting the pixel area will change the actor size to match the pixel area
application.GetPlatform().SetClosestImageSize(closestImageSize);
ImageAttributes attrs;
- attrs.SetSize(40, 30); // Request a really small size we won't get.
+ const Vector2 requestedSize( 40, 30 );
+ attrs.SetSize( requestedSize.width, requestedSize.height );
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 );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Now complete the image load
Integration::ResourceRequest* req = application.GetPlatform().GetRequest();
application.GetPlatform().DiscardRequest(); // Ensure load request is discarded
application.GetPlatform().ClearReadyResources(); //
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Set a pixel area on a naturally sized actor - expect the actor to take the
// pixel area as size
actor.SetPixelArea(ImageActor::PixelArea(0, 0, 30, 30));
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(30, 30), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(30, 30), TEST_LOCATION );
// Clear the pixel area. Expect the whole image to be shown, changing actor size
actor.ClearPixelArea();
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
// Set a size. Expect the partial image to stretch to fill the new size
actor.SetSize(100, 100);
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(100, 100), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
// Set a pixel area, don't expect size to change
actor.SetPixelArea(ImageActor::PixelArea(0, 0, 40, 40));
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(40, 40), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(100, 100), TEST_LOCATION );
// Use natural size - expect actor to change to pixel area
actor.SetToNaturalSize();
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), Vector2(40, 40), TEST_LOCATION );
DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), Vector2(40, 40), TEST_LOCATION );
// Clearing pixel area should change actor size to image size
actor.ClearPixelArea();
application.SendNotification(); // Process event messages
application.Render(); // Process LoadComplete
- DALI_TEST_EQUALS( actor.GetCurrentImageSize(), closestImageSize, TEST_LOCATION );
- DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), closestImageSize, TEST_LOCATION );
+ DALI_TEST_EQUALS( Vector2(actor.GetCurrentSize()), requestedSize, TEST_LOCATION );
END_TEST;
}
std::vector<Property::Index> indices;
indices.push_back(ImageActor::PIXEL_AREA );
- indices.push_back(ImageActor::FADE_IN );
- indices.push_back(ImageActor::FADE_IN_DURATION);
indices.push_back(ImageActor::STYLE );
indices.push_back(ImageActor::BORDER );
indices.push_back(ImageActor::IMAGE );
END_TEST;
}
-int UtcDaliImageSetFadeIn(void)
-{
- TestApplication application;
-
- Image image = Image::New(TestImageFilename);
- ImageActor actor = ImageActor::New(image);
-
- actor.SetFadeIn(true);
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( true, actor.GetFadeIn(), TEST_LOCATION );
-
- actor.SetFadeIn(false);
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( false, actor.GetFadeIn(), TEST_LOCATION );
- END_TEST;
-}
-
-
-int UtcDaliImageSetFadeInDuration(void)
-{
- TestApplication application;
-
- Image image = Image::New(TestImageFilename);
- ImageActor actor = ImageActor::New(image);
-
- actor.SetFadeInDuration( 1.0f );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( 1.0f, actor.GetFadeInDuration(), TEST_LOCATION );
-
- actor.SetFadeInDuration( 3.0f );
-
- // flush the queue and render once
- application.SendNotification();
- application.Render();
-
- DALI_TEST_EQUALS( 3.0f, actor.GetFadeInDuration(), TEST_LOCATION );
- END_TEST;
-}
-
int UtcDaliImageActorNewNull(void)
{
TestApplication application;
END_TEST;
}
+
+int UtcDaliImageActorGetNaturalSize(void)
+{
+ TestApplication application;
+
+ // Standard image
+ BitmapImage img = BitmapImage::New( 10, 10 );
+ ImageActor actor = ImageActor::New( img );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 10, 10 ) );
+
+ // Pixel area set
+ ImageActor::PixelArea area( 1, 2, 3, 4 );
+ actor.SetPixelArea( area );
+
+ DALI_TEST_CHECK( actor.GetNaturalSize().GetVectorXY() == Vector2( 3, 4 ) );
+
+ END_TEST;
+}