[Tizen] Emit ResourceReady signal in SvgVisual in case of loading failure 86/223786/1 accepted/tizen/5.5/unified/20200206.060322 submit/tizen_5.5/20200205.062646 submit/tizen_5.5/20200212.054229
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 31 Jan 2020 07:52:07 +0000 (16:52 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Tue, 4 Feb 2020 03:41:19 +0000 (12:41 +0900)
Change-Id: I0f52fb5f298b5cfe1b5e13eb78c330b044d55149

automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
dali-toolkit/internal/visuals/svg/svg-visual.cpp
dali-toolkit/internal/visuals/svg/svg-visual.h

index 7d709d8..127a314 100644 (file)
@@ -2400,3 +2400,60 @@ int UtcDaliImageViewReloadFailedOnResourceReadySignal(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;
+}
index e5fbcac..d08f3c8 100644 (file)
@@ -290,6 +290,10 @@ void SvgVisual::ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterized
    // Svg loaded and ready to display
    ResourceReady( Toolkit::Visual::ResourceStatus::READY );
   }
+  else if( !mParsedImage )
+  {
+    ResourceReady( Toolkit::Visual::ResourceStatus::FAILED );
+  }
 }
 
 void SvgVisual::OnSetTransform()
@@ -311,6 +315,12 @@ void SvgVisual::OnSetTransform()
   }
 }
 
+bool SvgVisual::IsResourceReady() const
+{
+  return ( mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY ||
+           mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED );
+}
+
 } // namespace Internal
 
 } // namespace Toolkit
index 87e9d43..81bfb5d 100644 (file)
@@ -135,6 +135,11 @@ protected:
    */
   void OnSetTransform() override;
 
+  /**
+   * @copydoc Visual::Base::IsResourceReady
+   */
+  bool IsResourceReady() const override;
+
 public:
 
   /**