Emit ResourceReady if we call Reload even if it was ready visual. 83/306183/1
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 16 Feb 2024 11:25:09 +0000 (20:25 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 16 Feb 2024 12:25:33 +0000 (21:25 +0900)
If the visual was already ready state, and if we call Reload, the visual state
still ResourceReady. So ResourceReady signal was not be emitted.

Since someone might need to know the timing of resource loaded after Reload(),
Make we reset status as PREPARE, and wait callback again.

Change-Id: Id0ddb6523c4d9fcd58aab63a2fb07d27fdd9c5b5
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp

index c92f4c3..c242df6 100644 (file)
@@ -5635,4 +5635,50 @@ int UtcDaliImageViewImageLoadFailureAndReload02(void)
   gResourceReadySignalFired = false;
 
   END_TEST;
+}
+
+int UtcDaliImageViewImageLoadSuccessAndReload01(void)
+{
+  tet_infoline("Try to load valid image first, and then reload again. Check whether ResourceReady signal comes well");
+  ToolkitTestApplication application;
+
+  gResourceReadySignalFired = false;
+
+  ImageView imageView = ImageView::New(gImage_34_RGBA);
+  imageView.SetProperty(Actor::Property::SIZE, Vector2(100.f, 100.f));
+  imageView.ResourceReadySignal().Connect(&ResourceReadySignal);
+
+  application.GetScene().Add(imageView);
+  application.SendNotification();
+  application.Render(16);
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  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::READY, TEST_LOCATION);
+
+  gResourceReadySignalFired = false;
+
+  // Reload the image
+  Property::Map attributes;
+  DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
+  application.SendNotification();
+  application.Render(16);
+
+  DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
+  DALI_TEST_EQUALS(imageView.IsResourceReady(), false, TEST_LOCATION);
+  DALI_TEST_EQUALS(imageView.GetVisualResourceStatus(ImageView::Property::IMAGE), Visual::ResourceStatus::PREPARING, TEST_LOCATION);
+
+  // loading started, this waits for the loader thread
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  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::READY, TEST_LOCATION);
+
+  gResourceReadySignalFired = false;
+
+  END_TEST;
 }
\ No newline at end of file
index 980c63a..6b30a02 100644 (file)
@@ -934,6 +934,11 @@ void ImageVisual::OnDoAction(const Dali::Property::Index actionId, const Dali::P
     case DevelImageVisual::Action::RELOAD:
     {
       auto attemptAtlasing = AttemptAtlasing();
+
+      // Reset resource ready status when we call reload.
+      ResourceReady(Toolkit::Visual::ResourceStatus::PREPARING);
+      mLoadState = TextureManager::LoadState::NOT_STARTED;
+
       LoadTexture(attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, TextureManager::ReloadPolicy::FORCED);
       break;
     }