X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-ImageView.cpp;h=942fb76f2cbf7c2fc418ecd8d08ece186189278b;hb=25a048bee3efc9f047e5cd91d6e438eb9245c18c;hp=a1629650cb6237576088294f51d4fe535dc4f1c1;hpb=63f75d33a1c166cd6999803744563206578e59e7;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index a162965..942fb76 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,6 +85,8 @@ const char* TEST_SVG_FILE_NAME = TEST_RESOURCE_DIR "/svg1.svg" 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")); @@ -94,6 +96,38 @@ void TestUrl(ImageView imageView, const std::string url) 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 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) @@ -576,16 +610,8 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing(void) // loading is not started if the actor is offScene application.GetScene().Add(imageView); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); // loading started, this waits for the loader thread for max 30 seconds DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); @@ -623,10 +649,6 @@ int UtcDaliImageViewAsyncLoadingWithAtlasing02(void) imageView.SetProperty(ImageView::Property::IMAGE, asyncLoadingMap); application.GetScene().Add(imageView); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); // loading started, this waits for the loader thread for max 30 seconds DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); @@ -831,10 +853,6 @@ int UtcDaliImageViewAsyncLoadingEncodedBufferWithAtlasing(void) imageView.SetProperty(ImageView::Property::IMAGE, imageMap); imageView.SetProperty(Dali::Actor::Property::LAYOUT_DIRECTION, Dali::LayoutDirection::RIGHT_TO_LEFT); - application.SendNotification(); - application.Render(16); - application.Render(16); - application.SendNotification(); // loading started, this waits for the loader thread for max 30 seconds DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); @@ -895,6 +913,126 @@ int UtcDaliImageViewSyncLoadingEncodedBuffer(void) END_TEST; } +int UtcDaliImageViewEncodedBufferWithSvg(void) +{ + ToolkitTestApplication application; + TestGlAbstraction& gl = application.GetGlAbstraction(); + const std::vector& textures = gl.GetBoundTextures(); + size_t numTextures = textures.size(); + + // Get encoded raw-buffer svg image and generate url + EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_SVG_FILE_NAME, EncodedImageBuffer::ImageType::VECTOR_IMAGE); + ImageUrl url = Toolkit::Image::GenerateUrl(buffer); + + // Async loading, no atlasing for big size image + ImageView imageView = ImageView::New(url.GetUrl()); + + // By default, Aysnc loading is used + application.GetScene().Add(imageView); + imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + application.SendNotification(); + application.Render(16); + + // Load svg image + rasterize. + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + const std::vector& textures2 = gl.GetBoundTextures(); + DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION); + + // Remove visual, for line coverage. + imageView.Unparent(); + application.SendNotification(); + application.Render(16); + + END_TEST; +} + +int UtcDaliImageViewEncodedBufferWithAnimatedVectorImage(void) +{ + ToolkitTestApplication application; + TestGlAbstraction& gl = application.GetGlAbstraction(); + const std::vector& textures = gl.GetBoundTextures(); + size_t numTextures = textures.size(); + + // Get encoded raw-buffer lottie image and generate url + EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(TEST_ANIMATED_VECTOR_IMAGE_FILE_NAME, EncodedImageBuffer::ImageType::ANIMATED_VECTOR_IMAGE); + ImageUrl url = Toolkit::Image::GenerateUrl(buffer); + + // Async loading, no atlasing for big size image + ImageView imageView = ImageView::New(url.GetUrl()); + + // By default, Aysnc loading is used + application.GetScene().Add(imageView); + imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + application.SendNotification(); + application.Render(16); + + // Load lottie image is sync. Only wait rasterize. + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + const std::vector& textures2 = gl.GetBoundTextures(); + DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION); + + // Remove visual, for line coverage. + imageView.Unparent(); + application.SendNotification(); + application.Render(16); + + END_TEST; +} + +int UtcDaliImageViewEncodedBufferWithInvalidImageType(void) +{ + ToolkitTestApplication application; + TestGlAbstraction& gl = application.GetGlAbstraction(); + const std::vector& textures = gl.GetBoundTextures(); + size_t numTextures = textures.size(); + + // Get encoded raw-buffer jpg image with invalid image type, and generate url + EncodedImageBuffer buffer = ConvertFileToEncodedImageBuffer(gImage_34_RGBA, static_cast(-1)); + ImageUrl url = Toolkit::Image::GenerateUrl(buffer); + + // Async loading, no atlasing for big size image + ImageView imageView = ImageView::New(url.GetUrl()); + + // By default, Aysnc loading is used + application.GetScene().Add(imageView); + imageView.SetProperty(Actor::Property::SIZE, Vector2(100, 100)); + imageView.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + + application.SendNotification(); + application.Render(16); + + // Load image + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + application.SendNotification(); + application.Render(16); + application.SendNotification(); + + const std::vector& textures2 = gl.GetBoundTextures(); + DALI_TEST_GREATER(textures2.size(), numTextures, TEST_LOCATION); + + // Remove visual, for line coverage. + imageView.Unparent(); + application.SendNotification(); + application.Render(16); + + END_TEST; +} + int UtcDaliImageViewAddedTexture(void) { ToolkitTestApplication application; @@ -1068,7 +1206,7 @@ void OnResourceReadySignalSVG(Control control) DALI_TEST_CHECK(retMap); // Fitting mode should not be applied at this point - DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get(), Vector2::ZERO, TEST_LOCATION); + DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get(), Vector2::ZERO, TEST_LOCATION); } int UtcDaliImageViewCheckResourceReady(void) @@ -2082,6 +2220,10 @@ int UtcDaliImageViewFittingModesFitHeight01(void) DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), 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(), "FIT_HEIGHT", TEST_LOCATION); // OFFSET is zero + END_TEST; } @@ -2172,6 +2314,10 @@ int UtcDaliImageViewFittingModesFitWidth01(void) DALI_TEST_CHECK(value); DALI_TEST_EQUALS(value->Get(), Vector2(0, 50), TEST_LOCATION); + value = returnedMap.Find(DevelVisual::Property::VISUAL_FITTING_MODE); + DALI_TEST_CHECK(value); + DALI_TEST_EQUALS(value->Get(), "FIT_WIDTH", TEST_LOCATION); // OFFSET is zero + END_TEST; } @@ -2750,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)); @@ -2780,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)); @@ -2805,6 +2953,34 @@ int UtcDaliImageViewLoadRemoteSVG(void) END_TEST; } +int UtcDaliImageViewLoadRemoteLottie(void) +{ + tet_infoline("Test load from a remote server. (Note we don't support real download now. Just for line coverage)"); + + ToolkitTestApplication application; + + { + Toolkit::ImageView imageView; + imageView = Toolkit::ImageView::New(); + imageView.SetImage("https://lottie.json"); + 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)); + imageView.SetProperty(Actor::Property::POSITION, Vector3(150.0f, 150.0f, 0.0f)); + + application.GetScene().Add(imageView); + + DALI_TEST_CHECK(imageView); + + application.SendNotification(); + application.Render(); + + // Do not check anything for here. + } + + END_TEST; +} + int UtcDaliImageViewSyncSVGLoading(void) { ToolkitTestApplication application; @@ -2869,7 +3045,7 @@ int UtcDaliImageViewSyncSVGLoading02(void) DALI_TEST_CHECK(retMap); // Image Visual should be positioned depending on ImageView's padding - DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get(), Vector2(100, 100), TEST_LOCATION); + DALI_TEST_EQUALS(retMap->Find(Visual::Transform::Property::SIZE)->Get(), Vector2(100, 100), TEST_LOCATION); Vector3 naturalSize = imageView.GetNaturalSize(); DALI_TEST_EQUALS(naturalSize.width, 100.0f, TEST_LOCATION); @@ -3789,6 +3965,34 @@ void OnResourceReadySignal10(Control control) } } +void OnResourceReadySignal11(Control control) +{ + gResourceReadySignalCounter++; + + if(!gImageView2) + { + auto scene = gImageView1.GetParent(); + + // Try to load animated image visual here which is already cached, and then ignore forcely. + + Property::Map map1; + map1[Toolkit::ImageVisual::Property::URL] = TEST_GIF_FILE_NAME; + + gImageView2 = ImageView::New(); + gImageView2.SetProperty(Toolkit::ImageView::Property::IMAGE, map1); + + gImageView3 = ImageView::New(); + gImageView3.SetProperty(Toolkit::ImageView::Property::IMAGE, map1); + + scene.Add(gImageView2); + gImageView2.Unparent(); + + scene.Add(gImageView3); + gImageView3.Unparent(); + gImageView3.Reset(); // Destroy visual + } +} + } // namespace int UtcDaliImageViewSetImageOnResourceReadySignal01(void) @@ -4269,7 +4473,13 @@ int UtcDaliImageViewSetImageOnResourceReadySignal06(void) DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION); DALI_TEST_EQUALS(gResourceReadySignalCounter, 2, TEST_LOCATION); - tet_infoline("load done"); + tet_infoline("Note that resource ready should not come now."); + tet_infoline("Try to load remained 2 valid image + apply masking"); + + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(4), true, TEST_LOCATION); + DALI_TEST_EQUALS(gResourceReadySignalCounter, 4, TEST_LOCATION); + + tet_infoline("Check all resource ready comes now."); } END_TEST; } @@ -4633,6 +4843,162 @@ int UtcDaliImageViewSetImageOnResourceReadySignal10(void) END_TEST; } +int UtcDaliImageViewSetImageOnResourceReadySignal10WhenAddIdleFailed(void) +{ + tet_infoline("Test ResourceReady signal comes more than 2 times, but do not call again if AddIdle failed"); + + ToolkitTestApplication application; + + gResourceReadySignalCounter = 0; + + // Clear image view for clear test + + if(gImageView1) + { + gImageView1.Reset(); + } + + // Dummy view to cache image. + ImageView dummyView = ImageView::New(gImage_34_RGBA); + application.GetScene().Add(dummyView); + + application.SendNotification(); + application.Render(); + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + application.SendNotification(); + application.Render(); + + // Make AddIdle failed. + ToolkitApplication::ADD_IDLE_SUCCESS = false; + + try + { + gImageView1 = ImageView::New(); + gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, gImage_34_RGBA); + gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal10); + application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time. + + tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter); + + DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready call too much. + + for(int i = 0; i < gResourceReadySignal10MaxCounter; ++i) + { + tet_printf("RunIdles\n"); + // Executes the idle callbacks. + application.RunIdles(); + application.SendNotification(); + application.Render(); + tet_printf("RunIdles done\n"); + } + tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter); + + DALI_TEST_GREATER(gResourceReadySignal10MaxCounter, gResourceReadySignalCounter, TEST_LOCATION); // Check whether resource ready not called multiple times. + + DALI_TEST_CHECK(true); + } + catch(...) + { + // Exception should not happened + DALI_TEST_CHECK(false); + } + + ToolkitApplication::ADD_IDLE_SUCCESS = true; + + // Clear cache. + application.SendNotification(); + application.Render(); + + gResourceReadySignalCounter = 0; + + gResourceReadySignalCounter = 0; + + // Clear image view for clear test + + if(gImageView1) + { + gImageView1.Reset(); + } + + END_TEST; +} + +int UtcDaliImageViewSetImageOnResourceReadySignal11(void) +{ + tet_infoline("Test ResourceReady Add AnimatedImageVisual and then Remove immediately."); + + ToolkitTestApplication application; + + gResourceReadySignalCounter = 0; + + // Clear image view for clear test + + if(gImageView1) + { + gImageView1.Reset(); + } + if(gImageView2) + { + gImageView2.Reset(); + } + if(gImageView3) + { + gImageView3.Reset(); + } + + try + { + gImageView1 = ImageView::New(); + gImageView1.SetProperty(Toolkit::ImageView::Property::IMAGE, TEST_GIF_FILE_NAME); + gImageView1.ResourceReadySignal().Connect(&OnResourceReadySignal11); + application.GetScene().Add(gImageView1); // It will call resourceReady signal 1 time. + + tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter); + + DALI_TEST_EQUALS(gResourceReadySignalCounter, 0, TEST_LOCATION); + + application.SendNotification(); + application.Render(); + + // Load gImageView1 + DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION); + + tet_printf("ResourceReady called %d times\n", gResourceReadySignalCounter); + + DALI_TEST_EQUALS(gResourceReadySignalCounter, 1, TEST_LOCATION); + + DALI_TEST_CHECK(true); + } + catch(...) + { + // Exception should not happened + DALI_TEST_CHECK(false); + } + + // Clear cache. + application.SendNotification(); + application.Render(); + + gResourceReadySignalCounter = 0; + + // Clear image view for clear test + + if(gImageView1) + { + gImageView1.Reset(); + } + if(gImageView2) + { + gImageView2.Reset(); + } + if(gImageView3) + { + gImageView3.Reset(); + } + + END_TEST; +} + int UtcDaliImageViewUseSameUrlWithAnimatedImageVisual(void) { tet_infoline("Test multiple views with same image in animated image visual"); @@ -5153,3 +5519,168 @@ int UtcDaliImageViewTransitionEffect03(void) 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