Emit ResourceReady signal in SvgVisual in case of loading failure
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ImageView.cpp
index 0124b73..bdf031d 100644 (file)
@@ -2432,3 +2432,59 @@ int UtcDaliImageViewLoadRemoteSVG(void)
   END_TEST;
 }
 
+int UtcDaliImageViewSvgLoadingFailure(void)
+{
+  ToolkitTestApplication application;
+
+  // Local svg file
+  {
+    gResourceReadySignalFired = false;
+
+    ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/Kid1.svg" );
+    imageView.SetSize( 200.f, 200.f );
+    imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
+
+    DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
+
+    Stage::GetCurrent().Add( imageView );
+
+    application.SendNotification();
+
+    // loading started, this waits for the loader thread
+    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render(16);
+
+    DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
+  }
+
+  // Remote svg file
+  {
+    gResourceReadySignalFired = false;
+
+    ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" );
+    imageView.SetSize( 200.f, 200.f );
+    imageView.ResourceReadySignal().Connect( &ResourceReadySignal);
+
+    DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION );
+
+    Stage::GetCurrent().Add( imageView );
+
+    application.SendNotification();
+
+    // loading started, this waits for the loader thread
+    DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
+
+    application.SendNotification();
+    application.Render(16);
+
+    DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION );
+    DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION );
+  }
+
+  END_TEST;
+}