+
+
+int UtcDaliImageViewReplaceImage(void)
+{
+ ToolkitTestApplication application;
+
+ gResourceReadySignalFired = false;
+
+ int width = 100;
+ int height = 200;
+ Image image = CreateBufferImage( width, height, Vector4(1.f, 1.f, 1.f, 1.f) );
+
+ // Check ImageView with background and main image, to ensure both visuals are marked as loaded
+ ImageView imageView = ImageView::New( TEST_IMAGE_1 );
+
+ DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
+
+ imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
+
+ Stage::GetCurrent().Add( imageView );
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+
+ gResourceReadySignalFired = false;
+
+ imageView.SetImage(TEST_IMAGE_2);
+
+ application.SendNotification();
+ application.Render(16);
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.GetRendererCount(), 1u, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+
+ END_TEST;
+}
+
+void OnRelayoutOverride( Size size )
+{
+ gNaturalSize = size; // Size Relayout is using
+}
+
+int UtcDaliImageViewReplaceImageAndGetNaturalSize(void)
+{
+ ToolkitTestApplication application;
+
+ // Check ImageView with background and main image, to ensure both visuals are marked as loaded
+ ImageView imageView = ImageView::New( TEST_IMAGE_1 );
+ imageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+
+ DummyControl dummyControl = DummyControl::New( true );
+ Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummyControl.GetImplementation());
+ dummyControl.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::ALL_DIMENSIONS );
+
+ dummyControl.Add( imageView );
+ dummyImpl.SetRelayoutCallback( &OnRelayoutOverride );
+ Stage::GetCurrent().Add( dummyControl );
+
+ application.SendNotification();
+ application.Render();
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( gNaturalSize.width, 1024.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( gNaturalSize.height, 1024.0f, TEST_LOCATION );
+
+ gNaturalSize = Vector3::ZERO;
+
+ imageView.SetImage(gImage_600_RGB);
+
+ // Waiting for resourceReady so SendNotifcation not called here.
+
+ // loading started, this waits for the loader thread for max 30 seconds
+ DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+ // Trigger a potential relayout
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( gNaturalSize.width, 600.0f, TEST_LOCATION );
+ DALI_TEST_EQUALS( gNaturalSize.height, 600.0f, TEST_LOCATION );
+
+ END_TEST;
+}