const char* TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insta_camera.json";
const char* TEST_WEBP_FILE_NAME = TEST_RESOURCE_DIR "/dali-logo.webp";
+const char* TEST_OVERWRITABLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/overwritable-image.jpg";
+
void TestUrl(ImageView imageView, const std::string url)
{
Property::Value value = imageView.GetProperty(imageView.GetPropertyIndex("image"));
DALI_TEST_EQUALS(urlActual, url, TEST_LOCATION);
}
+void OverwriteImage(const char* sourceFilename)
+{
+ FILE* fpOut = fopen(TEST_OVERWRITABLE_IMAGE_FILE_NAME, "wb");
+ DALI_TEST_CHECK(fpOut);
+ if(fpOut)
+ {
+ FILE* fpIn = fopen(sourceFilename, "rb");
+ if(fpIn)
+ {
+ fseek(fpIn, 0, SEEK_END);
+ size_t size = ftell(fpIn);
+
+ tet_printf("Open %s success! file size : %zu byte\n", sourceFilename, size);
+ Dali::Vector<uint8_t> data;
+ data.Resize(size);
+ fseek(fpIn, 0, SEEK_SET);
+ size_t realSize = fread(data.Begin(), sizeof(uint8_t), size, fpIn);
+ fclose(fpIn);
+ data.Resize(realSize);
+
+ // Overwrite
+ fwrite(data.Begin(), sizeof(uint8_t), size, fpOut);
+ }
+ else
+ {
+ tet_printf("Open %s failed! write invalid\n", sourceFilename);
+ fprintf(fpOut, "invalid\n");
+ }
+ fclose(fpOut);
+ }
+}
+
} // namespace
int UtcDaliImageViewNewP(void)
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 0), TEST_LOCATION); // OFFSET is zero
+ value = returnedMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<std::string>(), "FIT_HEIGHT", TEST_LOCATION); // OFFSET is zero
+
END_TEST;
}
DALI_TEST_CHECK(value);
DALI_TEST_EQUALS(value->Get<Vector2>(), Vector2(0, 50), TEST_LOCATION);
+ value = returnedMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE);
+ DALI_TEST_CHECK(value);
+ DALI_TEST_EQUALS(value->Get<std::string>(), "FIT_WIDTH", TEST_LOCATION); // OFFSET is zero
+
END_TEST;
}
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));
{
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));
END_TEST;
}
+
+int UtcDaliImageViewImageLoadFailureAndReload01(void)
+{
+ tet_infoline("Try to load invalid image first, and then reload after that image valid.");
+ ToolkitTestApplication application;
+
+ gResourceReadySignalFired = false;
+
+ // Make overwritable image invalid first.
+ OverwriteImage("");
+
+ ImageView imageView = ImageView::New(TEST_OVERWRITABLE_IMAGE_FILE_NAME);
+ 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::FAILED, TEST_LOCATION);
+
+ gResourceReadySignalFired = false;
+
+ // Make overwritable image valid now.
+ OverwriteImage(gImage_34_RGBA);
+
+ // Reload the image
+ Property::Map attributes;
+ DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
+ 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);
+
+ // Make overwritable image invalid end of test (for clean).
+ OverwriteImage("");
+
+ gResourceReadySignalFired = false;
+
+ END_TEST;
+}
+
+int UtcDaliImageViewImageLoadFailureAndReload02(void)
+{
+ tet_infoline("Try to load invalid image first, and then reload after that image valid.");
+ tet_infoline("This case, broken image was n-patch. So we should check whether Geometry / Shader changed after reload");
+ ToolkitTestApplication application;
+
+ Toolkit::StyleManager styleManager = Toolkit::StyleManager::Get();
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::SMALL, TEST_BROKEN_IMAGE_S);
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::NORMAL, TEST_BROKEN_IMAGE_M);
+ DevelStyleManager::SetBrokenImageUrl(styleManager, DevelStyleManager::BrokenImageType::LARGE, TEST_BROKEN_IMAGE_L);
+
+ gResourceReadySignalFired = false;
+
+ // Make overwritable image invalid first.
+ OverwriteImage("");
+
+ ImageView imageView = ImageView::New(TEST_OVERWRITABLE_IMAGE_FILE_NAME);
+ 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::FAILED, TEST_LOCATION);
+
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ Geometry brokenGeometry = imageView.GetRendererAt(0u).GetGeometry();
+ Shader brokenShader = imageView.GetRendererAt(0u).GetShader();
+ DALI_TEST_CHECK(brokenGeometry);
+ DALI_TEST_CHECK(brokenShader);
+
+ gResourceReadySignalFired = false;
+
+ // Make overwritable image valid now.
+ OverwriteImage(gImage_34_RGBA);
+
+ // Reload the image
+ Property::Map attributes;
+ DevelControl::DoAction(imageView, ImageView::Property::IMAGE, DevelImageVisual::Action::RELOAD, attributes);
+ 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);
+
+ // Check whether we don't use n-patch shader and geometry in this case.
+ DALI_TEST_EQUALS(imageView.GetRendererCount(), 1u, TEST_LOCATION);
+ DALI_TEST_CHECK(brokenGeometry != imageView.GetRendererAt(0u).GetGeometry());
+ DALI_TEST_CHECK(brokenShader != imageView.GetRendererAt(0u).GetShader());
+
+ // Make overwritable image invalid end of test (for clean).
+ OverwriteImage("");
+
+ 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