[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-ImageView.cpp
index c92f4c3..4eb38b8 100644 (file)
@@ -2896,10 +2896,12 @@ int UtcDaliImageViewLoadRemoteSVG(void)
 
   ToolkitTestApplication application;
 
+  const std::string svgImageUrl("https://dalihub.github.io/images/check.svg");
+
   {
     Toolkit::ImageView imageView;
     imageView = Toolkit::ImageView::New();
-    imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
+    imageView.SetImage(svgImageUrl);
     imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
     imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
     imageView.SetProperty(Actor::Property::SIZE, Vector2(300, 300));
@@ -2926,7 +2928,7 @@ int UtcDaliImageViewLoadRemoteSVG(void)
   {
     Toolkit::ImageView imageView;
     imageView = Toolkit::ImageView::New();
-    imageView.SetImage("https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/check.svg");
+    imageView.SetImage(svgImageUrl);
     imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
     imageView.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
     imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f));
@@ -5518,6 +5520,66 @@ int UtcDaliImageViewTransitionEffect03(void)
   END_TEST;
 }
 
+int UtcDaliImageViewTransitionEffect04(void)
+{
+  tet_infoline("Test transitoin effect operation when image is changed quickly ");
+
+  ToolkitTestApplication application;
+  Property::Map          map;
+
+  ImageView imageView = ImageView::New();
+  imageView.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
+  imageView.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
+  imageView.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
+  imageView.SetImage("");
+  application.GetScene().Add(imageView);
+
+  ImageView imageView2 = ImageView::New();
+  imageView2.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 200.0f));
+  imageView2.SetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT, true);
+  imageView2.SetProperty(Toolkit::ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
+  imageView2.SetImage("");
+  application.GetScene().Add(imageView2);
+  application.SendNotification();
+  application.Render();
+
+  //PLACEHOLDER_IMAGE is not call WaitForEventThreadTrigger because it is not shown url is null.
+  //DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
+
+  imageView.SetImage(gImage_600_RGB);
+  imageView.SetProperty(ImageView::Property::PLACEHOLDER_IMAGE, gImage_34_RGBA);
+  imageView2.SetImage(TEST_IMAGE_1);
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
+
+  imageView.SetImage(TEST_IMAGE_1);
+  imageView2.SetImage(gImage_600_RGB);
+  application.SendNotification();
+  application.Render(3000);
+
+  imageView.SetImage("");
+  application.SendNotification();
+  application.Render();
+
+  imageView.SetImage(TEST_IMAGE_2);
+  application.SendNotification();
+  application.Render();
+  DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
+
+  Property::Value value;
+  value = imageView.GetProperty(ImageView::Property::ENABLE_TRANSITION_EFFECT);
+  bool transition;
+  DALI_TEST_CHECK(value.Get(transition));
+  DALI_TEST_CHECK(transition == true);
+
+  // Clear all cached
+  imageView.Unparent();
+  imageView.Reset();
+
+  END_TEST;
+}
+
 int UtcDaliImageViewImageLoadFailureAndReload01(void)
 {
   tet_infoline("Try to load invalid image first, and then reload after that image valid.");
@@ -5635,4 +5697,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