2 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <dali-toolkit-test-suite-utils.h>
26 #include <toolkit-environment-variable.h>
27 #include <toolkit-event-thread-callback.h>
28 #include <toolkit-texture-upload-manager.h>
29 #include <toolkit-timer.h>
31 #include <dali-toolkit/dali-toolkit.h>
32 #include <dali-toolkit/devel-api/controls/control-devel.h>
33 #include <dali-toolkit/devel-api/image-loader/texture-manager.h>
34 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
35 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
36 #include <dali-toolkit/devel-api/visuals/image-visual-actions-devel.h>
37 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
38 #include <dali-toolkit/public-api/image-loader/image-url.h>
39 #include <dali-toolkit/public-api/image-loader/image.h>
41 #include <dali/devel-api/adaptor-framework/texture-upload-manager.h>
43 #include "dummy-control.h"
44 #include "test-encoded-image-buffer.h"
45 #include "test-native-image-source.h"
48 using namespace Dali::Toolkit;
50 void dali_image_visual_startup(void)
52 test_return_value = TET_UNDEF;
55 void dali_image_visual_cleanup(void)
57 test_return_value = TET_PASS;
62 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
63 const char* TEST_BROKEN_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/a-random-nonimage.jpg";
64 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
65 const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png";
66 const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png";
67 const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg";
68 const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png";
69 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
70 const char* TEST_ROTATED_IMAGE = TEST_RESOURCE_DIR "/keyboard-Landscape.jpg";
71 const char* TEST_YUV420_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1-yuv420.jpg";
72 const char* TEST_N_PATCH_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/heartsframe.9.png";
74 constexpr auto LOAD_IMAGE_YUV_PLANES_ENV = "DALI_LOAD_IMAGE_YUV_PLANES";
75 constexpr auto ENABLE_DECODE_JPEG_TO_YUV_420_ENV = "DALI_ENABLE_DECODE_JPEG_TO_YUV_420";
77 bool gResourceReadySignalFired = false;
78 std::vector<int> gReadyIds = {};
79 void ResourceReadySignal(Control control)
81 gResourceReadySignalFired = true;
82 gReadyIds.push_back(control.GetProperty<int>(Actor::Property::ID));
89 Actor CreateActorWithImageVisual(const Property::Map& map)
91 VisualFactory factory = VisualFactory::Get();
92 DummyControl actor = DummyControl::New();
93 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
94 Visual::Base visual = factory.CreateVisual(map);
95 DALI_TEST_CHECK(visual);
96 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
97 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
98 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
102 Visual::Base CreateVisualWithPolicy(const char* url, Property::Index key, const Property::Value& value)
104 VisualFactory factory = VisualFactory::Get();
106 Property::Map propertyMap;
107 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
108 propertyMap.Insert(ImageVisual::Property::URL, url);
109 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
110 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
111 propertyMap.Insert(key, value);
113 return factory.CreateVisual(propertyMap);
118 void TestVisualRender(ToolkitTestApplication& application,
120 Visual::Base& visual,
121 std::size_t expectedSamplers = 0,
122 ImageDimensions imageDimensions = ImageDimensions(),
123 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
125 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
126 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
130 // set the image size, for test case, this needs to be set before loading started
131 application.GetPlatform().SetClosestImageSize(Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()));
134 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
135 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
137 application.GetScene().Add(actor);
139 application.SendNotification(); // Send messages to update
140 application.Render(); // process update and render
141 application.SendNotification(); // process any signals to event
145 DALI_TEST_EQUALS(application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc), true, TEST_LOCATION);
148 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
151 static void TestMixColor(Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor)
154 visual.CreatePropertyMap(map);
155 Property::Value* value = map.Find(mixColorIndex);
156 DALI_TEST_CHECK(value);
158 DALI_TEST_CHECK(value->Get(mixColor1));
159 DALI_TEST_EQUALS(mixColor1, Vector3(testColor), 0.001, TEST_LOCATION);
161 value = map.Find(Visual::Property::MIX_COLOR);
162 DALI_TEST_CHECK(value);
164 DALI_TEST_CHECK(value->Get(mixColor2));
165 DALI_TEST_EQUALS(mixColor2, testColor, 0.001, TEST_LOCATION);
167 value = map.Find(Visual::Property::OPACITY);
168 DALI_TEST_CHECK(value);
170 DALI_TEST_CHECK(value->Get(opacity));
171 DALI_TEST_EQUALS(opacity, testColor.a, 0.001, TEST_LOCATION);
174 int UtcDaliImageVisualPropertyMap(void)
176 ToolkitTestApplication application;
177 tet_infoline("Request image visual with a Property::Map");
179 VisualFactory factory = VisualFactory::Get();
180 DALI_TEST_CHECK(factory);
181 factory.SetPreMultiplyOnLoad(true);
183 Property::Map propertyMap;
184 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
185 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
187 Visual::Base visual = factory.CreateVisual(propertyMap);
188 DALI_TEST_CHECK(visual);
190 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
191 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
193 TestGlAbstraction& gl = application.GetGlAbstraction();
194 TraceCallStack& textureTrace = gl.GetTextureTrace();
195 textureTrace.Enable(true);
197 DummyControl actor = DummyControl::New();
198 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
199 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
201 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
202 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
204 application.GetScene().Add(actor);
205 application.SendNotification();
206 application.Render();
208 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
210 application.SendNotification();
211 application.Render();
213 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
214 auto renderer = actor.GetRendererAt(0);
215 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
216 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
217 auto preMultipliedAlpha = renderer.GetProperty<float>(preMultipliedIndex);
218 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
219 DALI_TEST_EQUALS(preMultipliedAlpha, 1.0f, TEST_LOCATION);
220 DALI_TEST_EQUALS(preMultipliedAlpha2, true, TEST_LOCATION);
221 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
223 application.GetScene().Remove(actor);
224 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
229 int UtcDaliImageVisualNoPremultipliedAlpha01(void)
231 ToolkitTestApplication application;
232 tet_infoline("Request image visual without pre-multiplied alpha");
234 VisualFactory factory = VisualFactory::Get();
235 DALI_TEST_CHECK(factory);
236 factory.SetPreMultiplyOnLoad(false);
238 Property::Map propertyMap;
239 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
240 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
242 Visual::Base visual = factory.CreateVisual(propertyMap);
243 DALI_TEST_CHECK(visual);
245 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
246 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
248 TestGlAbstraction& gl = application.GetGlAbstraction();
249 TraceCallStack& textureTrace = gl.GetTextureTrace();
250 textureTrace.Enable(true);
252 DummyControl actor = DummyControl::New();
253 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
254 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
256 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
257 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
259 application.GetScene().Add(actor);
260 application.SendNotification();
261 application.Render();
263 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
265 application.SendNotification();
266 application.Render();
268 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
269 auto renderer = actor.GetRendererAt(0);
270 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
271 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
272 auto preMultipliedAlpha = renderer.GetProperty<bool>(preMultipliedIndex);
273 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
275 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
276 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
278 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
280 application.GetScene().Remove(actor);
281 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
286 int UtcDaliImageVisualNoPremultipliedAlpha02(void)
288 ToolkitTestApplication application;
289 tet_infoline("Request image visual with no alpha channel");
291 VisualFactory factory = VisualFactory::Get();
292 DALI_TEST_CHECK(factory);
294 Property::Map propertyMap;
295 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
296 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
298 Visual::Base visual = factory.CreateVisual(propertyMap);
299 DALI_TEST_CHECK(visual);
301 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
302 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
304 TestGlAbstraction& gl = application.GetGlAbstraction();
305 TraceCallStack& textureTrace = gl.GetTextureTrace();
306 textureTrace.Enable(true);
308 DummyControl actor = DummyControl::New();
309 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
310 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
312 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
313 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
315 application.GetScene().Add(actor);
316 application.SendNotification();
317 application.Render();
319 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
321 application.SendNotification();
322 application.Render();
324 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
325 auto renderer = actor.GetRendererAt(0);
326 auto preMultipliedIndex = renderer.GetPropertyIndex("preMultipliedAlpha");
327 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
328 auto preMultipliedAlpha = renderer.GetProperty<bool>(preMultipliedIndex);
329 auto preMultipliedAlpha2 = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
331 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
332 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
334 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
336 int srcFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
337 int destFactorRgb = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
338 int srcFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
339 int destFactorAlpha = renderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
340 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
341 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
342 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
343 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
345 textureTrace.Reset();
347 // Make a new visual with the same image
348 Visual::Base newVisual = factory.CreateVisual(propertyMap);
349 DALI_TEST_CHECK(newVisual);
351 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
352 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
354 DummyControl newActor = DummyControl::New();
355 DummyControlImpl& newDummyImpl = static_cast<DummyControlImpl&>(newActor.GetImplementation());
356 newDummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, newVisual);
358 newActor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
359 DALI_TEST_EQUALS(newActor.GetRendererCount(), 0u, TEST_LOCATION);
361 application.GetScene().Add(newActor);
363 application.SendNotification();
364 application.Render();
366 DALI_TEST_EQUALS(newActor.GetRendererCount(), 1u, TEST_LOCATION);
367 auto newRenderer = newActor.GetRendererAt(0);
368 preMultipliedIndex = newRenderer.GetPropertyIndex("preMultipliedAlpha");
369 DALI_TEST_CHECK(preMultipliedIndex != Property::INVALID_INDEX);
370 preMultipliedAlpha = newRenderer.GetProperty<bool>(preMultipliedIndex);
371 preMultipliedAlpha2 = newRenderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
373 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
374 DALI_TEST_EQUALS(preMultipliedAlpha2, false, TEST_LOCATION);
376 srcFactorRgb = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_RGB);
377 destFactorRgb = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_RGB);
378 srcFactorAlpha = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_SRC_ALPHA);
379 destFactorAlpha = newRenderer.GetProperty<int>(Renderer::Property::BLEND_FACTOR_DEST_ALPHA);
380 DALI_TEST_CHECK(srcFactorRgb == BlendFactor::SRC_ALPHA);
381 DALI_TEST_CHECK(destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA);
382 DALI_TEST_CHECK(srcFactorAlpha == BlendFactor::ONE);
383 DALI_TEST_CHECK(destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA);
385 application.GetScene().Remove(actor);
386 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
391 int UtcDaliImageVisualRemoteImageLoad(void)
393 ToolkitTestApplication application;
394 tet_infoline("Request remote image visual with a Property::Map");
396 VisualFactory factory = VisualFactory::Get();
397 DALI_TEST_CHECK(factory);
399 Property::Map propertyMap;
400 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
401 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
403 Visual::Base visual = factory.CreateVisual(propertyMap);
404 DALI_TEST_CHECK(visual);
406 TestGlAbstraction& gl = application.GetGlAbstraction();
407 TraceCallStack& textureTrace = gl.GetTextureTrace();
408 textureTrace.Enable(true);
410 DummyControl actor = DummyControl::New();
411 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
412 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
414 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
415 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
417 application.GetScene().Add(actor);
418 application.SendNotification();
420 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
422 application.SendNotification();
423 application.Render();
425 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
426 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
428 application.GetScene().Remove(actor);
429 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
434 int UtcDaliImageVisualWithFrameBufferPreMultipliedAlpha01(void)
436 ToolkitTestApplication application;
437 tet_infoline("Use FrameBuffer as url");
441 FrameBuffer frameBuffer = Dali::FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
443 DALI_TEST_CHECK(frameBuffer);
444 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(frameBuffer, Pixel::Format::RGBA8888, width, height);
445 std::string url = imageUrl.GetUrl();
447 VisualFactory factory = VisualFactory::Get();
448 DALI_TEST_CHECK(factory);
450 Property::Map propertyMap;
451 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
452 propertyMap.Insert(ImageVisual::Property::URL, url);
454 Visual::Base visual = factory.CreateVisual(propertyMap);
455 DALI_TEST_CHECK(visual);
457 DummyControl actor = DummyControl::New();
458 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
459 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
461 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
463 application.GetScene().Add(actor);
465 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
467 application.SendNotification();
468 application.Render(16);
470 Renderer renderer = actor.GetRendererAt(0);
472 // Check whether preMultipliedAlpha is true.
473 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
474 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
479 int UtcDaliImageVisualWithFrameBufferPreMultipliedAlpha02(void)
481 ToolkitTestApplication application;
482 tet_infoline("Use FrameBuffer as url");
486 FrameBuffer frameBuffer = Dali::FrameBuffer::New(width, height, FrameBuffer::Attachment::NONE);
488 DALI_TEST_CHECK(frameBuffer);
490 Texture texture = Texture::New(TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height);
491 frameBuffer.AttachColorTexture(texture);
493 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(frameBuffer, 0u);
494 std::string url = imageUrl.GetUrl();
496 VisualFactory factory = VisualFactory::Get();
497 DALI_TEST_CHECK(factory);
499 Property::Map propertyMap;
500 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
501 propertyMap.Insert(ImageVisual::Property::URL, url);
503 Visual::Base visual = factory.CreateVisual(propertyMap);
504 DALI_TEST_CHECK(visual);
506 DummyControl actor = DummyControl::New();
507 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
508 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
510 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
512 application.GetScene().Add(actor);
514 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
516 application.SendNotification();
517 application.Render(16);
519 Renderer renderer = actor.GetRendererAt(0);
521 // Check whether preMultipliedAlpha is true.
522 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
523 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
528 int UtcDaliImageVisualWithPixelData(void)
530 ToolkitTestApplication application;
531 tet_infoline("Use PixelData as url");
535 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
537 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
538 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
540 DALI_TEST_CHECK(pixelData);
542 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData);
543 std::string url = imageUrl.GetUrl();
545 VisualFactory factory = VisualFactory::Get();
546 DALI_TEST_CHECK(factory);
548 Property::Map propertyMap;
549 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
550 propertyMap.Insert(ImageVisual::Property::URL, url);
552 Visual::Base visual = factory.CreateVisual(propertyMap);
553 DALI_TEST_CHECK(visual);
555 DummyControl actor = DummyControl::New();
556 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
557 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
559 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
561 application.GetScene().Add(actor);
563 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
565 application.SendNotification();
566 application.Render(16);
568 Renderer renderer = actor.GetRendererAt(0);
570 // Check whether preMultipliedAlpha is false.
571 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
572 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
577 int UtcDaliImageVisualWithPixelDataPreMultipliedAlpha(void)
579 ToolkitTestApplication application;
580 tet_infoline("Use PixelData as url");
584 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
586 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
587 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
589 DALI_TEST_CHECK(pixelData);
591 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
592 std::string url = imageUrl.GetUrl();
594 VisualFactory factory = VisualFactory::Get();
595 DALI_TEST_CHECK(factory);
597 Property::Map propertyMap;
598 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
599 propertyMap.Insert(ImageVisual::Property::URL, url);
601 Visual::Base visual = factory.CreateVisual(propertyMap);
602 DALI_TEST_CHECK(visual);
604 DummyControl actor = DummyControl::New();
605 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
606 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
608 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
610 application.GetScene().Add(actor);
612 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
614 application.SendNotification();
615 application.Render(16);
617 Renderer renderer = actor.GetRendererAt(0);
619 // Check whether preMultipliedAlpha is true.
620 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
621 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
626 int UtcDaliImageVisualWithPixelDataMasking(void)
628 ToolkitTestApplication application;
629 tet_infoline("Load external texture with mask");
631 TestGlAbstraction& gl = application.GetGlAbstraction();
632 TraceCallStack& textureTrace = gl.GetTextureTrace();
633 textureTrace.Enable(true);
637 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
639 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
640 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
642 DALI_TEST_CHECK(pixelData);
644 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
645 std::string url = imageUrl.GetUrl();
647 VisualFactory factory = VisualFactory::Get();
648 DALI_TEST_CHECK(factory);
650 Property::Map propertyMap;
651 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
652 propertyMap.Insert(ImageVisual::Property::URL, url);
653 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
655 Visual::Base visual = factory.CreateVisual(propertyMap);
656 DALI_TEST_CHECK(visual);
658 Property::Map testMap;
659 visual.CreatePropertyMap(testMap);
660 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
662 DummyControl actor = DummyControl::New();
663 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
664 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
666 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
668 application.GetScene().Add(actor);
669 application.SendNotification();
670 application.Render(16);
671 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
673 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
674 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
675 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
677 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
678 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
683 int UtcDaliImageVisualWithPixelDataMasking02(void)
685 ToolkitTestApplication application;
686 tet_infoline("Load premultiplied external texture with mask");
688 TestGlAbstraction& gl = application.GetGlAbstraction();
689 TraceCallStack& textureTrace = gl.GetTextureTrace();
690 textureTrace.Enable(true);
694 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
696 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
697 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
699 DALI_TEST_CHECK(pixelData);
701 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
702 std::string url = imageUrl.GetUrl();
704 VisualFactory factory = VisualFactory::Get();
705 DALI_TEST_CHECK(factory);
707 Property::Map propertyMap;
708 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
709 propertyMap.Insert(ImageVisual::Property::URL, url);
710 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
712 Visual::Base visual = factory.CreateVisual(propertyMap);
713 DALI_TEST_CHECK(visual);
715 Property::Map testMap;
716 visual.CreatePropertyMap(testMap);
717 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
719 DummyControl actor = DummyControl::New();
720 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
721 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
723 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
725 application.GetScene().Add(actor);
726 application.SendNotification();
727 application.Render(16);
728 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
730 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
731 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
732 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
734 Renderer renderer = actor.GetRendererAt(0);
736 //Check visual property
737 DALI_TEST_EQUALS(*testMap.Find(Visual::Property::PREMULTIPLIED_ALPHA), Property::Value(true), TEST_LOCATION);
739 // Check whether preMultipliedAlpha is true.
740 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
741 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
743 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
744 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
749 int UtcDaliImageVisualWithPixelDataMaskingSynchronously(void)
751 ToolkitTestApplication application;
752 tet_infoline("Load synchronously external texture with mask");
756 uint32_t bufferSize = width * height * Pixel::GetBytesPerPixel(Pixel::RGBA8888);
758 uint8_t* buffer = reinterpret_cast<uint8_t*>(malloc(bufferSize));
759 PixelData pixelData = PixelData::New(buffer, bufferSize, width, height, Pixel::RGBA8888, PixelData::FREE);
761 DALI_TEST_CHECK(pixelData);
763 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(pixelData, true);
764 std::string url = imageUrl.GetUrl();
766 VisualFactory factory = VisualFactory::Get();
767 DALI_TEST_CHECK(factory);
769 Property::Map propertyMap;
770 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
771 propertyMap.Insert(ImageVisual::Property::URL, url);
772 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
773 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
775 Visual::Base visual = factory.CreateVisual(propertyMap);
776 DALI_TEST_CHECK(visual);
778 Property::Map testMap;
779 visual.CreatePropertyMap(testMap);
780 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
782 DummyControl actor = DummyControl::New();
783 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
784 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
786 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
788 application.GetScene().Add(actor);
790 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
792 application.SendNotification();
793 application.Render(16);
798 int UtcDaliImageVisualWithNativeImage(void)
800 ToolkitTestApplication application;
801 tet_infoline("Use Native Image as url");
803 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
804 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
805 std::string url = imageUrl.GetUrl();
807 VisualFactory factory = VisualFactory::Get();
808 DALI_TEST_CHECK(factory);
810 Property::Map propertyMap;
811 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
812 propertyMap.Insert(ImageVisual::Property::URL, url);
814 Visual::Base visual = factory.CreateVisual(propertyMap);
815 DALI_TEST_CHECK(visual);
817 DummyControl actor = DummyControl::New();
818 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
819 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
821 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
823 application.GetScene().Add(actor);
825 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
827 application.SendNotification();
828 application.Render(16);
830 Renderer renderer = actor.GetRendererAt(0);
831 Shader shader = renderer.GetShader();
833 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
834 DALI_TEST_CHECK(value.GetType() == Property::MAP);
835 const Property::Map* outMap = value.GetMap();
836 std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
838 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
839 size_t pos = fragmentShader.find(fragmentPrefix);
841 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
843 // Check whether preMultipliedAlpha is false.
844 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
845 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
850 int UtcDaliImageVisualWithNativeImagePreMultipliedAlpha(void)
852 ToolkitTestApplication application;
853 tet_infoline("Use Native Image as url");
855 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
856 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource, true);
857 std::string url = imageUrl.GetUrl();
859 VisualFactory factory = VisualFactory::Get();
860 DALI_TEST_CHECK(factory);
862 Property::Map propertyMap;
863 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
864 propertyMap.Insert(ImageVisual::Property::URL, url);
866 Visual::Base visual = factory.CreateVisual(propertyMap);
867 DALI_TEST_CHECK(visual);
869 DummyControl actor = DummyControl::New();
870 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
871 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
873 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
875 application.GetScene().Add(actor);
877 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
879 application.SendNotification();
880 application.Render(16);
882 Renderer renderer = actor.GetRendererAt(0);
883 Shader shader = renderer.GetShader();
885 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
886 DALI_TEST_CHECK(value.GetType() == Property::MAP);
887 const Property::Map* outMap = value.GetMap();
888 std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
890 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
891 size_t pos = fragmentShader.find(fragmentPrefix);
893 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
895 // Check whether preMultipliedAlpha is true.
896 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
897 DALI_TEST_EQUALS(preMultipliedAlpha, true, TEST_LOCATION);
902 int UtcDaliImageVisualWithNativeImageCustomShader(void)
904 ToolkitTestApplication application;
905 tet_infoline("Use Native Image as url and Use custom shader");
907 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
908 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource, true);
909 std::string url = imageUrl.GetUrl();
911 VisualFactory factory = VisualFactory::Get();
912 DALI_TEST_CHECK(factory);
914 Property::Map propertyMap;
915 Property::Map shaderMap;
916 const std::string customVertexShaderSource = "Foobar";
917 const std::string customFragmentShaderSource = "Foobar";
918 shaderMap[Toolkit::Visual::Shader::Property::FRAGMENT_SHADER] = customFragmentShaderSource;
919 shaderMap[Toolkit::Visual::Shader::Property::VERTEX_SHADER] = customVertexShaderSource;
921 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
922 propertyMap.Insert(Toolkit::Visual::Property::SHADER, shaderMap);
923 propertyMap.Insert(ImageVisual::Property::URL, url);
925 Visual::Base visual = factory.CreateVisual(propertyMap);
926 DALI_TEST_CHECK(visual);
928 DummyControl actor = DummyControl::New();
929 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
930 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
932 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
933 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
935 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
937 application.GetScene().Add(actor);
939 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
941 application.SendNotification();
942 application.Render(16);
944 Renderer renderer = actor.GetRendererAt(0);
945 Shader shader = renderer.GetShader();
947 Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
948 DALI_TEST_CHECK(value.GetType() == Property::MAP);
949 const Property::Map* outMap = value.GetMap();
950 std::string fragmentShaderSource = (*outMap)["fragment"].Get<std::string>();
951 std::string vertexShaderSource = (*outMap)["vertex"].Get<std::string>();
953 // Compare vertex shader is equal
954 DALI_TEST_EQUALS(customVertexShaderSource, vertexShaderSource, TEST_LOCATION);
956 // Check fragment shader changed
957 const char* fragmentPrefix = Dali::NativeImageSourceTest::GetCustomFragmentPrefix();
958 size_t pos = fragmentShaderSource.find(fragmentPrefix);
960 DALI_TEST_EQUALS(pos != std::string::npos, true, TEST_LOCATION);
962 DALI_TEST_EQUALS(std::string(fragmentPrefix) + customFragmentShaderSource, fragmentShaderSource, TEST_LOCATION);
964 // Check whether preMultipliedAlpha is false.
965 // Note : We dont use preMultiplied alpha when app developer using custom shader.
966 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
967 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
972 int UtcDaliImageVisualWithNativeImageRemoved(void)
974 ToolkitTestApplication application;
975 tet_infoline("Use Native Image as url");
977 TestGlAbstraction& gl = application.GetGlAbstraction();
978 TraceCallStack& textureTrace = gl.GetTextureTrace();
979 textureTrace.Enable(true);
981 NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
982 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
983 std::string url = imageUrl.GetUrl();
985 VisualFactory factory = VisualFactory::Get();
986 DALI_TEST_CHECK(factory);
988 Property::Map propertyMap;
989 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
990 propertyMap.Insert(ImageVisual::Property::URL, url);
992 Visual::Base visual = factory.CreateVisual(propertyMap);
993 DALI_TEST_CHECK(visual);
995 DummyControl actor = DummyControl::New();
996 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
997 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
999 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1001 application.GetScene().Add(actor);
1002 application.SendNotification();
1003 application.Render();
1005 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1006 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1008 tet_infoline("No delete texture because reference count is not zero");
1010 application.GetScene().Remove(actor);
1011 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1012 application.SendNotification();
1013 application.Render();
1015 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1016 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1018 tet_infoline("Delete texture because reference count is zero");
1020 application.SendNotification();
1021 application.Render();
1023 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1028 int UtcDaliImageVisualWithEncodedImageBuffer(void)
1030 ToolkitTestApplication application;
1031 tet_infoline("Use Encoded Image Buffer as url");
1033 EncodedImageBuffer rawBuffer = ConvertFileToEncodedImageBuffer(TEST_LARGE_IMAGE_FILE_NAME);
1034 ImageUrl url = Dali::Toolkit::Image::GenerateUrl(rawBuffer);
1036 VisualFactory factory = VisualFactory::Get();
1037 DALI_TEST_CHECK(factory);
1039 Property::Map propertyMap;
1040 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1041 propertyMap.Insert(ImageVisual::Property::URL, url.GetUrl());
1043 Visual::Base visual = factory.CreateVisual(propertyMap);
1044 DALI_TEST_CHECK(visual);
1046 TestGlAbstraction& gl = application.GetGlAbstraction();
1047 TraceCallStack& textureTrace = gl.GetTextureTrace();
1048 textureTrace.Enable(true);
1050 DummyControl actor = DummyControl::New();
1051 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1052 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1054 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1055 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1057 application.GetScene().Add(actor);
1058 application.SendNotification();
1060 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1062 application.SendNotification();
1063 application.Render();
1065 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1066 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1068 application.GetScene().Remove(actor);
1069 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1074 int UtcDaliImageVisualWithEncodedImageBufferRemoved(void)
1076 ToolkitTestApplication application;
1077 tet_infoline("Use Encoded Image Buffer as url");
1079 TestGlAbstraction& gl = application.GetGlAbstraction();
1080 TraceCallStack& textureTrace = gl.GetTextureTrace();
1081 textureTrace.Enable(true);
1083 EncodedImageBuffer rawBuffer = ConvertFileToEncodedImageBuffer(TEST_LARGE_IMAGE_FILE_NAME);
1084 ImageUrl imageUrl = Dali::Toolkit::Image::GenerateUrl(rawBuffer);
1085 std::string url = imageUrl.GetUrl();
1087 VisualFactory factory = VisualFactory::Get();
1088 DALI_TEST_CHECK(factory);
1090 Property::Map propertyMap;
1091 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1092 propertyMap.Insert(ImageVisual::Property::URL, url);
1094 Visual::Base visual = factory.CreateVisual(propertyMap);
1095 DALI_TEST_CHECK(visual);
1097 DummyControl actor = DummyControl::New();
1098 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1099 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1101 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1103 application.GetScene().Add(actor);
1104 application.SendNotification();
1106 // Wait for decode buffer and make texture.
1107 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1109 application.SendNotification();
1110 application.Render();
1112 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1113 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1115 tet_infoline("Delete texture because there is no actor to use decoded texture");
1117 application.GetScene().Remove(actor);
1118 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
1119 application.SendNotification();
1120 application.Render();
1122 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1123 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1128 int UtcDaliImageVisualTextureReuse1(void)
1130 ToolkitTestApplication application;
1131 tet_infoline("Request remote image visual with a Property::Map; request a second visual with the same property map - should reuse texture");
1133 Property::Map propertyMap;
1134 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1135 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
1136 propertyMap.Insert(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
1138 TestGlAbstraction& gl = application.GetGlAbstraction();
1139 TraceCallStack& textureTrace = gl.GetTextureTrace();
1140 textureTrace.Enable(true);
1141 TraceCallStack& drawTrace = gl.GetDrawTrace();
1142 drawTrace.Enable(true);
1144 Actor actor = CreateActorWithImageVisual(propertyMap);
1145 application.GetScene().Add(actor);
1146 application.SendNotification();
1148 // Wait for image to load
1149 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1151 application.SendNotification();
1152 application.Render();
1154 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1155 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1156 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1157 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1158 textureTrace.Reset();
1161 Actor actor2 = CreateActorWithImageVisual(propertyMap);
1162 application.GetScene().Add(actor2);
1164 application.SendNotification(); // Send messages to update
1165 application.Render(); // process update and render
1166 application.SendNotification(); // process any signals to event
1168 DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
1170 // Testing for texture re-use in gl side is not relevant - we are not using actual graphics
1171 // backend here, but test graphics backend.
1172 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
1173 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
1175 tet_infoline("Test that removing 1 actor doesn't delete the texture\n");
1177 application.GetScene().Remove(actor);
1178 application.SendNotification();
1179 application.Render();
1181 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1182 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
1184 tet_infoline("Test that removing last actor does delete the texture\n");
1186 application.GetScene().Remove(actor2); // Detaches remaining ImageVisual
1187 application.SendNotification();
1188 application.Render();
1190 DALI_TEST_CHECK(actor2.GetRendererCount() == 0u);
1191 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1196 int UtcDaliImageVisualTextureReuse2(void)
1198 ToolkitTestApplication application;
1199 tet_infoline("Request remote image visual with a Property::Map; request a second visual with the same url but different property map - should create new texture");
1201 Property::Map propertyMap;
1202 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1203 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
1205 TestGlAbstraction& gl = application.GetGlAbstraction();
1206 TraceCallStack& textureTrace = gl.GetTextureTrace();
1207 textureTrace.Enable(true);
1208 TraceCallStack& drawTrace = gl.GetDrawTrace();
1209 drawTrace.Enable(true);
1211 Actor actor = CreateActorWithImageVisual(propertyMap);
1212 application.GetScene().Add(actor);
1213 application.SendNotification();
1215 // Wait for image to load
1216 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1218 application.SendNotification();
1219 application.Render();
1221 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1222 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1223 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1224 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1225 textureTrace.Reset();
1228 propertyMap.Insert(ImageVisual::Property::SAMPLING_MODE, Dali::SamplingMode::NEAREST);
1229 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 100);
1230 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 100);
1231 Actor actor2 = CreateActorWithImageVisual(propertyMap);
1232 application.GetScene().Add(actor2);
1234 application.SendNotification();
1236 // Wait for image to load
1237 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1239 application.SendNotification();
1240 application.Render();
1242 DALI_TEST_EQUALS(actor2.GetRendererCount(), 1u, TEST_LOCATION);
1245 "Test that 2 draw calls occur with 1 new texture gen/bind, i.e. both "
1246 "renderers are using different textures\n");
1248 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1249 DALI_TEST_EQUALS(drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION);
1250 TraceCallStack::NamedParams tex1;
1251 tex1["texture"] << 1;
1252 TraceCallStack::NamedParams tex2;
1253 tex2["texture"] << 2;
1254 DALI_TEST_EQUALS(textureTrace.FindMethodAndParams("BindTexture", tex1), true, TEST_LOCATION);
1255 DALI_TEST_EQUALS(textureTrace.FindMethodAndParams("BindTexture", tex2), true, TEST_LOCATION);
1257 tet_infoline("Test that removing 1 actor deletes it's texture\n");
1259 application.GetScene().Remove(actor);
1260 application.SendNotification();
1261 application.Render();
1263 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1264 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
1266 tet_infoline("Test that removing last actor deletes it's texture\n");
1268 application.GetScene().Remove(actor2);
1269 application.SendNotification();
1270 application.Render();
1272 DALI_TEST_CHECK(actor2.GetRendererCount() == 0u);
1273 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION);
1278 int UtcDaliImageVisualCustomWrapModePixelArea(void)
1280 ToolkitTestApplication application;
1281 tet_infoline("Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing");
1283 static std::vector<UniformData> customUniforms =
1285 UniformData("pixelArea", Property::Type::VECTOR4),
1286 UniformData("wrapMode", Property::Type::VECTOR2),
1289 TestGraphicsController& graphics = application.GetGraphicsController();
1290 graphics.AddCustomUniforms(customUniforms);
1292 VisualFactory factory = VisualFactory::Get();
1293 DALI_TEST_CHECK(factory);
1295 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1296 const int width = 34;
1297 const int height = 34;
1298 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
1300 Property::Map propertyMap;
1301 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1302 propertyMap.Insert(ImageVisual::Property::URL, TEST_SMALL_IMAGE_FILE_NAME);
1303 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, width);
1304 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, height);
1305 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1306 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1307 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT);
1308 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT);
1309 propertyMap.Insert(ImageVisual::Property::ATLASING, true);
1311 Visual::Base visual = factory.CreateVisual(propertyMap);
1312 DALI_TEST_CHECK(visual);
1314 TestGlAbstraction& gl = application.GetGlAbstraction();
1315 TraceCallStack& textureTrace = gl.GetTextureTrace();
1316 textureTrace.Enable(true);
1317 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1318 texParameterTrace.Enable(true);
1320 DummyControl actor = DummyControl::New();
1321 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1322 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1323 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1324 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1325 application.GetScene().Add(actor);
1328 application.SendNotification();
1329 application.Render();
1331 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1333 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1335 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
1336 std::stringstream out;
1337 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
1338 DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1340 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
1341 DALI_TEST_CHECK(!texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1343 // test the uniforms which used to handle the wrap mode
1344 Renderer renderer = actor.GetRendererAt(0u);
1345 DALI_TEST_CHECK(renderer);
1347 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1348 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1349 Vector4 pixelAreaUniform;
1350 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
1351 DALI_TEST_EQUALS(pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1353 Property::Value wrapModeValue = renderer.GetProperty(renderer.GetPropertyIndex("wrapMode"));
1354 Vector2 wrapMode(WrapMode::MIRRORED_REPEAT - 1, WrapMode::REPEAT - 1);
1355 DALI_TEST_EQUALS(wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION);
1356 Vector2 wrapModeUniform;
1357 DALI_TEST_CHECK(gl.GetUniformValue<Vector2>("wrapMode", wrapModeUniform));
1358 DALI_TEST_EQUALS(wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1361 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1366 int UtcDaliImageVisualCustomWrapModeNoAtlas(void)
1368 ToolkitTestApplication application;
1369 tet_infoline("Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing");
1371 static std::vector<UniformData> customUniforms =
1373 UniformData("pixelArea", Property::Type::VECTOR4),
1376 TestGraphicsController& graphics = application.GetGraphicsController();
1377 graphics.AddCustomUniforms(customUniforms);
1379 VisualFactory factory = VisualFactory::Get();
1380 DALI_TEST_CHECK(factory);
1382 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
1383 const int width = 600;
1384 const int height = 600;
1385 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
1387 Property::Map propertyMap;
1388 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1389 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
1390 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, width);
1391 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, height);
1392 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1393 propertyMap.Insert(ImageVisual::Property::PIXEL_AREA, pixelArea);
1394 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT);
1395 propertyMap.Insert(ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT);
1397 Visual::Base visual = factory.CreateVisual(propertyMap);
1398 DALI_TEST_CHECK(visual);
1400 TestGlAbstraction& gl = application.GetGlAbstraction();
1401 TraceCallStack& textureTrace = gl.GetTextureTrace();
1402 textureTrace.Enable(true);
1403 textureTrace.EnableLogging(true);
1404 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
1405 texParameterTrace.Enable(true);
1406 texParameterTrace.EnableLogging(true);
1408 DummyControl actor = DummyControl::New();
1409 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1410 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1411 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1412 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1413 application.GetScene().Add(actor);
1416 application.SendNotification();
1417 application.Render();
1418 application.SendNotification();
1420 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
1422 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1424 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
1425 std::stringstream out;
1426 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
1427 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1429 out << std::hex << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
1430 DALI_TEST_CHECK(texParameterTrace.FindMethodAndParams("TexParameteri", out.str()));
1432 // test the uniforms which used to handle the wrap mode
1433 Renderer renderer = actor.GetRendererAt(0u);
1434 DALI_TEST_CHECK(renderer);
1436 Property::Value pixelAreaValue = renderer.GetProperty(renderer.GetPropertyIndex("pixelArea"));
1437 DALI_TEST_EQUALS(pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION);
1438 Vector4 pixelAreaUniform;
1439 DALI_TEST_CHECK(gl.GetUniformValue<Vector4>("pixelArea", pixelAreaUniform));
1440 DALI_TEST_EQUALS(pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION);
1442 Property::Index wrapModeIndex = renderer.GetPropertyIndex("wrapMode");
1443 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
1446 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1451 int UtcDaliImageVisualAnimateMixColor(void)
1453 ToolkitTestApplication application;
1454 tet_infoline("Animate mix color");
1456 static std::vector<UniformData> customUniforms =
1458 UniformData("mixColor", Property::Type::VECTOR3),
1461 TestGraphicsController& graphics = application.GetGraphicsController();
1462 graphics.AddCustomUniforms(customUniforms);
1464 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1466 VisualFactory factory = VisualFactory::Get();
1467 Property::Map propertyMap;
1468 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1469 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1470 propertyMap.Insert("mixColor", Color::BLUE);
1471 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1472 Visual::Base visual = factory.CreateVisual(propertyMap);
1474 DummyControl actor = DummyControl::New(true);
1475 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1476 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1478 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1479 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1480 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1481 application.GetScene().Add(actor);
1483 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1485 Renderer renderer = actor.GetRendererAt(0);
1487 // @todo Should we add API to make this code work again?
1488 // Property::Index index = renderer.GetPropertyIndex( Visual::Property::MIX_COLOR );
1490 Property::Value blendModeValue = renderer.GetProperty(Renderer::Property::BLEND_MODE);
1491 DALI_TEST_EQUALS(blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION);
1493 const Vector4 TARGET_MIX_COLOR(1.0f, 0.0f, 0.0f, 0.5f);
1496 map["target"] = "testVisual";
1497 map["property"] = "mixColor";
1498 map["initialValue"] = Color::MAGENTA;
1499 map["targetValue"] = TARGET_MIX_COLOR;
1500 map["animator"] = Property::Map()
1501 .Add("alphaFunction", "LINEAR")
1502 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1504 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1506 Animation animation = dummyImpl.CreateTransition(transition);
1508 animation.AnimateTo(Property(actor, Actor::Property::COLOR), Color::WHITE);
1511 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1512 glAbstraction.EnableEnableDisableCallTrace(true);
1513 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1514 std::ostringstream blendStr;
1515 blendStr << std::hex << GL_BLEND;
1517 application.SendNotification();
1518 application.Render(0); // Ensure animation starts
1519 application.Render(2000u); // Halfway point
1520 Vector3 testColor(1.0f, 0.0f, 0.5f);
1522 // uColor.a should be actor's alpha * mixColor.a.
1523 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, 0.75f)), true, TEST_LOCATION);
1524 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", testColor), true, TEST_LOCATION);
1526 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1528 glEnableStack.Reset();
1530 application.SendNotification();
1531 application.Render(2000u);
1533 application.SendNotification();
1534 application.Render();
1535 application.SendNotification();
1537 DALI_TEST_EQUALS(actor.GetCurrentProperty<Vector4>(Actor::Property::COLOR), Color::WHITE, TEST_LOCATION);
1538 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(1.0f, 1.0f, 1.0f, 0.5f)), true, TEST_LOCATION);
1539 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR)), true, TEST_LOCATION);
1541 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1543 TestMixColor(visual, Visual::Property::MIX_COLOR, TARGET_MIX_COLOR);
1548 int UtcDaliImageVisualAnimateOpacity(void)
1550 ToolkitTestApplication application;
1551 tet_infoline("Animate image visual opacity");
1553 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1555 VisualFactory factory = VisualFactory::Get();
1556 Property::Map propertyMap;
1557 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1558 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1559 propertyMap.Insert("opacity", 0.5f);
1560 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1561 Visual::Base visual = factory.CreateVisual(propertyMap);
1563 DummyControl actor = DummyControl::New(true);
1564 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1565 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1567 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1568 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1569 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1570 application.GetScene().Add(actor);
1572 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1574 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1575 glAbstraction.EnableEnableDisableCallTrace(true);
1576 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1577 std::ostringstream blendStr;
1578 blendStr << std::hex << GL_BLEND;
1580 application.SendNotification();
1581 application.Render();
1583 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1586 tet_infoline("Test that the opacity can be increased to full via animation, and that the blend mode is set appropriately at the start and end of the animation.");
1589 map["target"] = "testVisual";
1590 map["property"] = "opacity";
1591 map["targetValue"] = 1.0f;
1592 map["animator"] = Property::Map()
1593 .Add("alphaFunction", "LINEAR")
1594 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1596 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1597 Animation animation = dummyImpl.CreateTransition(transition);
1600 glEnableStack.Reset();
1602 application.SendNotification();
1603 application.Render(0); // Ensure animation starts
1604 application.Render(2000u); // Halfway point through animation
1605 application.SendNotification(); // Handle any signals
1608 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1609 DALI_TEST_EQUALS(color.a, 0.75f, TEST_LOCATION);
1611 application.Render(2001u); // end
1612 application.SendNotification(); // ensure animation finished signal is sent
1614 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1615 DALI_TEST_EQUALS(color.a, 1.0f, TEST_LOCATION);
1617 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1618 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1622 tet_infoline("Test that the opacity can be reduced via animation, and that the blend mode is set appropriately at the start and end of the animation.");
1625 map["target"] = "testVisual";
1626 map["property"] = Visual::Property::OPACITY;
1627 map["targetValue"] = 0.1f;
1628 map["animator"] = Property::Map()
1629 .Add("alphaFunction", "LINEAR")
1630 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1632 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1633 Animation animation = dummyImpl.CreateTransition(transition);
1636 glEnableStack.Reset();
1638 application.SendNotification();
1639 application.Render(0); // Ensure animation starts
1640 application.Render(2000u); // Halfway point
1641 application.SendNotification();
1644 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1645 DALI_TEST_EQUALS(color.a, 0.55f, TEST_LOCATION);
1647 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1649 glEnableStack.Reset();
1651 application.Render(2016u); // end
1652 application.SendNotification();
1654 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1655 DALI_TEST_EQUALS(color.a, 0.1f, TEST_LOCATION);
1657 // (Don't test for caching of capabilities, toolkit uses Test graphics backend, not actual backend)
1658 DALI_TEST_CHECK(!glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1664 int UtcDaliImageVisualAnimateOpacity02(void)
1666 ToolkitTestApplication application;
1667 tet_infoline("Animate image visual opacity");
1669 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1671 VisualFactory factory = VisualFactory::Get();
1672 Property::Map propertyMap;
1673 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1674 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1675 propertyMap.Insert("opacity", 0.5f);
1676 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1677 Visual::Base visual = factory.CreateVisual(propertyMap);
1679 DummyControl actor = DummyControl::New(true);
1680 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1681 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1683 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1684 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1685 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1687 tet_infoline("Test that the opacity doesn't animate when actor not staged");
1689 Property::Array array;
1692 map["target"] = "testVisual";
1693 map["property"] = "opacity";
1694 map["initialValue"] = 0.0f;
1695 map["targetValue"] = 1.0f;
1696 map["animator"] = Property::Map()
1697 .Add("alphaFunction", "LINEAR")
1698 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1701 map2["target"] = "testVisual";
1702 map2["property"] = "size";
1703 map2["targetValue"] = Vector2(1.0f, 1.0f);
1705 array.Add(map).Add(map2);
1707 Dali::Toolkit::TransitionData transition = TransitionData::New(array);
1708 Animation animation = dummyImpl.CreateTransition(transition);
1710 application.GetScene().Add(actor);
1711 application.SendNotification();
1712 application.Render(0); // Ensure animation starts
1714 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1716 Renderer renderer = actor.GetRendererAt(0);
1717 Property::Value blendModeValue = renderer.GetProperty(Renderer::Property::BLEND_MODE);
1718 DALI_TEST_EQUALS(blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION);
1720 animation = dummyImpl.CreateTransition(transition);
1723 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
1724 glAbstraction.EnableEnableDisableCallTrace(true);
1725 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
1726 std::ostringstream blendStr;
1727 blendStr << std::hex << GL_BLEND;
1729 application.SendNotification();
1730 application.Render(0); // Ensure animation starts
1731 application.Render(2000u); // Halfway point through animation
1732 application.SendNotification(); // Handle any signals
1734 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
1737 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1738 DALI_TEST_EQUALS(color.a, 0.5f, TEST_LOCATION);
1740 glEnableStack.Reset();
1742 application.Render(2001u); // end
1743 application.SendNotification(); // ensure animation finished signal is sent
1745 DALI_TEST_CHECK(application.GetGlAbstraction().GetUniformValue<Vector4>("uColor", color));
1746 DALI_TEST_EQUALS(color.a, 1.0f, TEST_LOCATION);
1748 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Disable", blendStr.str()));
1753 int UtcDaliImageVisualAnimatePixelArea(void)
1755 ToolkitTestApplication application;
1756 tet_infoline("ImageVisual animate pixel area");
1758 static std::vector<UniformData> customUniforms =
1760 UniformData("pixelArea", Property::Type::VECTOR4),
1763 TestGraphicsController& graphics = application.GetGraphicsController();
1764 graphics.AddCustomUniforms(customUniforms);
1766 application.GetPlatform().SetClosestImageSize(Vector2(100, 100));
1768 VisualFactory factory = VisualFactory::Get();
1769 Property::Map propertyMap;
1770 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1771 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1772 propertyMap.Insert("mixColor", Color::BLUE);
1773 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1774 Visual::Base visual = factory.CreateVisual(propertyMap);
1776 DummyControl actor = DummyControl::New(true);
1777 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1778 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
1780 actor.SetProperty(Actor::Property::SIZE, Vector2(2000, 2000));
1781 actor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1782 actor.SetProperty(Actor::Property::COLOR, Color::BLACK);
1783 application.GetScene().Add(actor);
1785 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1787 Renderer renderer = actor.GetRendererAt(0);
1788 // @todo Implement this feature?
1789 //Property::Index index = renderer.GetPropertyIndex( Visual::Property::MIX_COLOR );
1790 //tet_infoline("Test that the renderer has the mixColor property");
1791 //DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1793 // TransitionData only takes string keys
1795 map["target"] = "testVisual";
1796 map["property"] = "pixelArea";
1797 map["initialValue"] = Vector4(0, 0, 0, 1);
1798 map["targetValue"] = Vector4(0, 0, 1, 1); // Animate width from zero to full
1799 map["animator"] = Property::Map()
1800 .Add("alphaFunction", "LINEAR")
1801 .Add("timePeriod", Property::Map().Add("delay", 0.0f).Add("duration", 4.0f));
1803 Dali::Toolkit::TransitionData transition = TransitionData::New(map);
1805 Animation animation = dummyImpl.CreateTransition(transition);
1806 animation.AnimateTo(Property(actor, Actor::Property::COLOR), Color::WHITE);
1809 application.SendNotification();
1810 application.Render(0); // Ensure animation starts
1811 application.Render(2000u); // Halfway point
1813 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f)), true, TEST_LOCATION);
1815 application.Render(2000u); // End of animation
1817 DALI_TEST_EQUALS(application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 1.0f, 1.0f)), true, TEST_LOCATION);
1822 int UtcDaliImageVisualTextureCancelRemoteLoad(void)
1824 ToolkitTestApplication application;
1825 tet_infoline("Request remote image visual, then destroy visual to cancel load");
1827 Property::Map propertyMap;
1828 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1829 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME);
1831 TestGlAbstraction& gl = application.GetGlAbstraction();
1832 TraceCallStack& textureTrace = gl.GetTextureTrace();
1833 textureTrace.Enable(true);
1834 TraceCallStack& drawTrace = gl.GetDrawTrace();
1835 drawTrace.Enable(true);
1837 Actor actor = CreateActorWithImageVisual(propertyMap);
1838 application.GetScene().Add(actor);
1839 application.SendNotification();
1841 application.GetScene().Remove(actor);
1842 application.SendNotification();
1844 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1845 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
1846 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
1847 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION);
1852 int UtcDaliImageVisualTextureCancelAsyncLoad(void)
1854 ToolkitTestApplication application;
1855 tet_infoline("Load image asynchronously, cancel loading, then load again");
1857 VisualFactory factory = VisualFactory::Get();
1858 DALI_TEST_CHECK(factory);
1860 Property::Map propertyMap;
1861 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1862 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
1864 Visual::Base visual = factory.CreateVisual(propertyMap);
1865 DALI_TEST_CHECK(visual);
1867 TestGlAbstraction& gl = application.GetGlAbstraction();
1868 TraceCallStack& textureTrace = gl.GetTextureTrace();
1869 textureTrace.Enable(true);
1870 TraceCallStack& drawTrace = gl.GetDrawTrace();
1871 drawTrace.Enable(true);
1873 DummyControl actor = DummyControl::New();
1874 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1875 dummyImpl.RegisterVisual(Control::Property::BACKGROUND, visual);
1877 application.GetScene().Add(actor);
1880 application.GetScene().Remove(actor);
1882 application.GetScene().Add(actor);
1884 // Create another visual with the same image
1885 visual = factory.CreateVisual(propertyMap);
1886 DALI_TEST_CHECK(visual);
1888 dummyImpl.RegisterVisual(Control::Property::BACKGROUND, visual);
1890 application.SendNotification();
1891 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1893 application.SendNotification();
1894 application.Render();
1896 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1897 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
1898 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1899 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION);
1904 int UtcDaliImageVisualSetInvalidAsyncImage(void)
1906 ToolkitTestApplication application;
1907 tet_infoline("Request image visual with invalid images - should draw broken.png");
1909 VisualFactory factory = VisualFactory::Get();
1910 DALI_TEST_CHECK(factory);
1912 Property::Map propertyMap;
1913 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1914 propertyMap.Insert(ImageVisual::Property::URL, TEST_INVALID_FILE_NAME);
1916 Visual::Base visual = factory.CreateVisual(propertyMap);
1917 DALI_TEST_CHECK(visual);
1919 TestGlAbstraction& gl = application.GetGlAbstraction();
1920 TraceCallStack& textureTrace = gl.GetTextureTrace();
1921 textureTrace.Enable(true);
1923 DummyControl actor = DummyControl::New();
1924 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1925 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1927 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1928 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1930 application.GetScene().Add(actor);
1932 application.SendNotification();
1933 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
1935 application.SendNotification();
1936 application.Render();
1938 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1939 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1941 application.GetScene().Remove(actor);
1942 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1947 int UtcDaliImageVisualSetInvalidSyncImage(void)
1949 ToolkitTestApplication application;
1950 tet_infoline("Request image visual with invalid images - should draw broken.png");
1952 VisualFactory factory = VisualFactory::Get();
1953 DALI_TEST_CHECK(factory);
1955 Property::Map propertyMap;
1956 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
1957 propertyMap.Insert(ImageVisual::Property::URL, TEST_INVALID_FILE_NAME);
1958 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1960 Visual::Base visual = factory.CreateVisual(propertyMap);
1961 DALI_TEST_CHECK(visual);
1963 TestGlAbstraction& gl = application.GetGlAbstraction();
1964 TraceCallStack& textureTrace = gl.GetTextureTrace();
1965 textureTrace.Enable(true);
1967 DummyControl actor = DummyControl::New();
1968 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1969 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
1971 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
1972 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
1974 application.GetScene().Add(actor);
1976 application.SendNotification();
1977 application.Render();
1979 // Check resource status
1980 Visual::ResourceStatus status = actor.GetVisualResourceStatus(Control::CONTROL_PROPERTY_END_INDEX + 1);
1981 DALI_TEST_EQUALS(status, Visual::ResourceStatus::FAILED, TEST_LOCATION);
1983 // The broken image should be shown.
1984 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
1985 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
1987 application.GetScene().Remove(actor);
1988 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
1993 int UtcDaliImageVisualSetInvalidRemoteImage(void)
1995 ToolkitTestApplication application;
1996 tet_infoline("Request image visual with invalid images - should draw broken.png");
1998 VisualFactory factory = VisualFactory::Get();
1999 DALI_TEST_CHECK(factory);
2001 // Local invalid file, asynchronous loading
2002 Property::Map propertyMap;
2003 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2004 propertyMap.Insert(ImageVisual::Property::URL, TEST_REMOTE_INVALID_FILE_NAME);
2006 Visual::Base visual = factory.CreateVisual(propertyMap);
2007 DALI_TEST_CHECK(visual);
2009 TestGlAbstraction& gl = application.GetGlAbstraction();
2010 TraceCallStack& textureTrace = gl.GetTextureTrace();
2011 textureTrace.Enable(true);
2013 DummyControl actor = DummyControl::New();
2014 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2015 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2017 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2018 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2020 application.GetScene().Add(actor);
2022 application.SendNotification();
2023 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2025 application.SendNotification();
2026 application.Render();
2028 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2029 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2031 application.GetScene().Remove(actor);
2032 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2037 int UtcDaliImageVisualSetInvalidImageWithDisabledBroken(void)
2039 ToolkitTestApplication application;
2040 tet_infoline("Request image visual with invalid images - should draw broken.png");
2042 VisualFactory factory = VisualFactory::Get();
2043 DALI_TEST_CHECK(factory);
2045 // Load invalid file
2046 Property::Map propertyMap;
2047 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2048 propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
2050 Visual::Base visual = factory.CreateVisual(propertyMap);
2051 DALI_TEST_CHECK(visual);
2053 TestGlAbstraction& gl = application.GetGlAbstraction();
2054 TraceCallStack& textureTrace = gl.GetTextureTrace();
2055 textureTrace.Enable(true);
2057 DummyControl actor = DummyControl::New();
2058 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2059 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2061 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2062 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2064 application.GetScene().Add(actor);
2066 application.SendNotification();
2067 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2069 application.SendNotification();
2070 application.Render();
2072 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2073 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2075 application.GetScene().Remove(actor);
2076 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2077 textureTrace.Reset();
2079 // Load invalid file with disabled broken
2080 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2081 propertyMap.Insert(ImageVisual::Property::URL, "InvalidImage.png");
2082 propertyMap.Insert(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, false);
2084 visual = factory.CreateVisual(propertyMap);
2085 DALI_TEST_CHECK(visual);
2087 actor = DummyControl::New();
2088 DummyControlImpl& dummyImpl2 = static_cast<DummyControlImpl&>(actor.GetImplementation());
2089 dummyImpl2.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2091 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2092 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2094 application.GetScene().Add(actor);
2096 application.SendNotification();
2097 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2099 application.SendNotification();
2100 application.Render();
2102 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2103 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION);
2105 application.GetScene().Remove(actor);
2106 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2111 int UtcDaliImageVisualAlphaMask01(void)
2113 ToolkitTestApplication application;
2114 tet_infoline("Request image visual with a Property::Map containing an Alpha mask");
2116 VisualFactory factory = VisualFactory::Get();
2117 DALI_TEST_CHECK(factory);
2119 Property::Map propertyMap;
2120 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2121 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2122 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2124 Visual::Base visual = factory.CreateVisual(propertyMap);
2125 DALI_TEST_CHECK(visual);
2127 Property::Map testMap;
2128 visual.CreatePropertyMap(testMap);
2129 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2131 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2132 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2134 TestGlAbstraction& gl = application.GetGlAbstraction();
2135 TraceCallStack& textureTrace = gl.GetTextureTrace();
2136 textureTrace.Enable(true);
2138 DummyControl actor = DummyControl::New();
2139 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2140 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2142 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2143 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2144 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2146 application.GetScene().Add(actor);
2147 application.SendNotification();
2148 application.Render();
2150 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2156 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2157 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2159 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2160 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2165 int UtcDaliImageVisualAlphaMask02(void)
2167 ToolkitTestApplication application;
2168 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU");
2170 VisualFactory factory = VisualFactory::Get();
2171 DALI_TEST_CHECK(factory);
2173 Property::Map propertyMap;
2174 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2175 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2176 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2177 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2178 propertyMap.Insert(DevelImageVisual::Property::CROP_TO_MASK, false);
2180 Visual::Base visual = factory.CreateVisual(propertyMap);
2181 DALI_TEST_CHECK(visual);
2183 Property::Map testMap;
2184 visual.CreatePropertyMap(testMap);
2185 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2186 DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::MASKING_TYPE), Property::Value(DevelImageVisual::MaskingType::MASKING_ON_RENDERING), TEST_LOCATION);
2188 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2189 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2191 TestGlAbstraction& gl = application.GetGlAbstraction();
2192 TraceCallStack& textureTrace = gl.GetTextureTrace();
2193 textureTrace.Enable(true);
2195 DummyControl actor = DummyControl::New();
2196 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2197 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2199 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2200 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2201 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2203 application.GetScene().Add(actor);
2204 application.SendNotification();
2205 application.Render();
2207 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2209 application.SendNotification();
2210 application.Render();
2212 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2213 Renderer renderer = actor.GetRendererAt(0u);
2214 TextureSet textures = renderer.GetTextures();
2215 DALI_TEST_CHECK(textures);
2216 DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
2218 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2219 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2221 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2222 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2224 auto index = renderer.GetPropertyIndex("maskTextureRatio");
2225 DALI_TEST_NOT_EQUALS(index, Property::INVALID_INDEX, 0.1f, TEST_LOCATION);
2226 DALI_TEST_EQUALS(renderer.GetProperty<Vector2>(index), Vector2::ONE, TEST_LOCATION);
2231 int UtcDaliImageVisualAlphaMask03(void)
2233 ToolkitTestApplication application;
2234 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with fail case");
2236 VisualFactory factory = VisualFactory::Get();
2237 DALI_TEST_CHECK(factory);
2239 Property::Map propertyMap;
2240 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2241 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2242 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, "dummy_path");
2243 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2245 Visual::Base visual = factory.CreateVisual(propertyMap);
2246 DALI_TEST_CHECK(visual);
2248 Property::Map testMap;
2249 visual.CreatePropertyMap(testMap);
2251 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2252 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2254 TestGlAbstraction& gl = application.GetGlAbstraction();
2255 TraceCallStack& textureTrace = gl.GetTextureTrace();
2256 textureTrace.Enable(true);
2258 DummyControl actor = DummyControl::New();
2259 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2260 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2262 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2263 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2264 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2266 application.GetScene().Add(actor);
2267 application.SendNotification();
2268 application.Render();
2270 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2272 application.SendNotification();
2273 application.Render();
2275 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2276 Renderer renderer = actor.GetRendererAt(0u);
2277 TextureSet textures = renderer.GetTextures();
2278 DALI_TEST_CHECK(textures);
2279 DALI_TEST_EQUALS(textures.GetTextureCount(), 1u, TEST_LOCATION);
2281 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2282 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2284 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2285 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2290 int UtcDaliImageVisualSynchronousLoadAlphaMask01(void)
2292 ToolkitTestApplication application;
2293 tet_infoline("Request image visual with a Property::Map containing an Alpha mask with synchronous loading");
2295 VisualFactory factory = VisualFactory::Get();
2296 DALI_TEST_CHECK(factory);
2298 Property::Map propertyMap;
2299 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2300 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2301 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2302 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2304 Visual::Base visual = factory.CreateVisual(propertyMap);
2305 DALI_TEST_CHECK(visual);
2307 Property::Map testMap;
2308 visual.CreatePropertyMap(testMap);
2309 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2311 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2312 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2314 TestGlAbstraction& gl = application.GetGlAbstraction();
2315 TraceCallStack& textureTrace = gl.GetTextureTrace();
2316 textureTrace.Enable(true);
2318 DummyControl actor = DummyControl::New();
2319 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2320 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2322 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2323 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2324 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2326 application.GetScene().Add(actor);
2328 // Do not wait for any EventThreadTrigger in synchronous alpha mask.
2330 application.SendNotification();
2331 application.Render();
2333 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2334 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2335 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2337 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2338 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2343 int UtcDaliImageVisualSynchronousLoadAlphaMask02(void)
2345 ToolkitTestApplication application;
2346 tet_infoline("Request image visual with a Property::Map containing an Alpha mask for GPU with synchronous loading");
2348 VisualFactory factory = VisualFactory::Get();
2349 DALI_TEST_CHECK(factory);
2351 Property::Map propertyMap;
2352 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2353 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2354 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2355 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
2356 propertyMap.Insert(DevelImageVisual::Property::MASKING_TYPE, DevelImageVisual::MaskingType::MASKING_ON_RENDERING);
2358 Visual::Base visual = factory.CreateVisual(propertyMap);
2359 DALI_TEST_CHECK(visual);
2361 Property::Map testMap;
2362 visual.CreatePropertyMap(testMap);
2363 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2365 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2366 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2368 TestGlAbstraction& gl = application.GetGlAbstraction();
2369 TraceCallStack& textureTrace = gl.GetTextureTrace();
2370 textureTrace.Enable(true);
2372 DummyControl actor = DummyControl::New();
2373 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2374 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2376 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2377 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2378 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2380 application.GetScene().Add(actor);
2382 // Do not wait for any EventThreadTrigger in synchronous alpha mask.
2384 application.SendNotification();
2385 application.Render();
2387 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2388 Renderer renderer = actor.GetRendererAt(0u);
2389 TextureSet textures = renderer.GetTextures();
2390 DALI_TEST_CHECK(textures);
2391 DALI_TEST_EQUALS(textures.GetTextureCount(), 2u, TEST_LOCATION);
2393 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2394 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2396 dummyImpl.UnregisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1);
2397 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2402 int UtcDaliImageVisualRemoteAlphaMask(void)
2404 ToolkitTestApplication application;
2405 tet_infoline("Request image visual with a Property::Map containing an Alpha mask");
2407 VisualFactory factory = VisualFactory::Get();
2408 DALI_TEST_CHECK(factory);
2410 const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME;
2412 Property::Map propertyMap;
2413 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2414 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
2415 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, MASK_IMAGE);
2417 Visual::Base visual = factory.CreateVisual(propertyMap);
2418 DALI_TEST_CHECK(visual);
2420 Property::Map testMap;
2421 visual.CreatePropertyMap(testMap);
2423 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(MASK_IMAGE), TEST_LOCATION);
2425 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2426 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2428 TestGlAbstraction& gl = application.GetGlAbstraction();
2429 TraceCallStack& textureTrace = gl.GetTextureTrace();
2430 textureTrace.Enable(true);
2432 DummyControl actor = DummyControl::New();
2433 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2434 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2436 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2438 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2439 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2441 application.GetScene().Add(actor);
2442 application.SendNotification();
2443 application.Render();
2445 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2447 application.SendNotification();
2448 application.Render();
2450 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2451 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2452 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2457 int UtcDaliImageVisualAlphaMaskCrop(void)
2459 ToolkitTestApplication application;
2460 tet_infoline("Request image visual with an Alpha mask and scale/cropping");
2462 VisualFactory factory = VisualFactory::Get();
2463 DALI_TEST_CHECK(factory);
2465 Property::Map propertyMap;
2466 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
2467 propertyMap.Insert(ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME);
2468 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
2469 propertyMap.Insert(ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f);
2470 propertyMap.Insert(ImageVisual::Property::CROP_TO_MASK, true);
2472 Visual::Base visual = factory.CreateVisual(propertyMap);
2473 DALI_TEST_CHECK(visual);
2475 Property::Map testMap;
2476 visual.CreatePropertyMap(testMap);
2477 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL), Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION);
2478 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE), Property::Value(1.6f), TEST_LOCATION);
2479 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::CROP_TO_MASK), Property::Value(true), TEST_LOCATION);
2481 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
2482 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
2484 TestGlAbstraction& gl = application.GetGlAbstraction();
2485 TraceCallStack& textureTrace = gl.GetTextureTrace();
2486 textureTrace.Enable(true);
2488 DummyControl actor = DummyControl::New();
2489 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
2490 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
2492 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2493 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
2494 DALI_TEST_EQUALS(actor.IsResourceReady(), false, TEST_LOCATION);
2496 application.GetScene().Add(actor);
2497 application.SendNotification();
2498 application.Render();
2500 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
2502 application.SendNotification();
2503 application.Render();
2506 visual.GetNaturalSize(size);
2508 DALI_TEST_EQUALS(size, Vector2(100.0f, 100.0f), 0.001f, TEST_LOCATION);
2509 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2510 DALI_TEST_EQUALS(textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION);
2511 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
2516 int UtcDaliImageVisualReleasePolicy01(void)
2518 ToolkitTestApplication application;
2519 tet_infoline("UtcDaliImageVisualReleasePolicy01 Detached Policy, disabling visual with this policy deletes texture");
2521 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
2522 DALI_TEST_CHECK(imageVisual);
2524 // Set up debug trace
2525 TestGlAbstraction& gl = application.GetGlAbstraction();
2526 TraceCallStack& textureTrace = gl.GetTextureTrace();
2527 textureTrace.Enable(true);
2529 tet_infoline("Register visual with control and ensure it has the only handle");
2530 DummyControl actor = DummyControl::New(true);
2531 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2532 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2533 imageVisual.Reset();
2535 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2537 application.SendNotification();
2538 application.Render(0);
2539 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2540 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2542 application.GetScene().Add(actor);
2544 // Wait for image to load
2545 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2547 application.SendNotification();
2548 application.Render(0);
2549 // Test renderer and texture created
2550 tet_infoline("Confirm texture created");
2551 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2552 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2554 tet_infoline("Disable visual causing the texture to be deleted");
2555 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2557 application.SendNotification();
2558 application.Render(0);
2559 // Test renderer and textures removed.
2560 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2561 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2566 int UtcDaliImageVisualReleasePolicy02(void)
2568 ToolkitTestApplication application;
2569 tet_infoline("UtcDaliImageVisualReleasePolicy02 Destroyed Policy, Texture should be deleted when visual destroyed");
2571 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2572 DALI_TEST_CHECK(imageVisual);
2574 // Setup debug trace
2575 TestGlAbstraction& gl = application.GetGlAbstraction();
2576 TraceCallStack& textureTrace = gl.GetTextureTrace();
2577 textureTrace.Enable(true);
2579 tet_infoline("Register visual with control and ensure it has the only handle");
2580 DummyControl actor = DummyControl::New(true);
2581 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2582 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2583 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2585 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2587 application.SendNotification();
2588 application.Render(0);
2589 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2590 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2592 application.GetScene().Add(actor);
2594 // Wait for image to load
2595 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2597 application.SendNotification();
2598 application.Render(0);
2599 // Test renderer and texture created
2600 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2601 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2603 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2604 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
2605 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2606 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2607 application.SendNotification();
2608 application.Render();
2610 // Test texture removed after visual destroyed.
2611 tet_infoline("Ensure texture is deleted after visual destroyed");
2612 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2617 int UtcDaliImageVisualReleasePolicy03(void)
2619 ToolkitTestApplication application;
2620 tet_infoline("UtcDaliImageVisualReleasePolicy03 Never Policy, texture should not be deleted after visual destroyed");
2622 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2623 DALI_TEST_CHECK(imageVisual);
2625 TestGlAbstraction& gl = application.GetGlAbstraction();
2626 TraceCallStack& textureTrace = gl.GetTextureTrace();
2627 textureTrace.Enable(true);
2629 tet_infoline("Register visual with control and ensure it has the only handle");
2630 DummyControl actor = DummyControl::New(true);
2631 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2632 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2633 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2635 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2637 application.SendNotification();
2638 application.Render(0);
2639 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2640 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2642 application.GetScene().Add(actor);
2644 // Wait for image to load
2645 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2647 application.SendNotification();
2648 application.Render(0);
2649 // Test renderer and texture created
2650 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2651 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2653 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
2654 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2655 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2656 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2657 application.SendNotification();
2658 application.Render();
2660 tet_infoline("Ensure texture is not deleted as policy is set to NEVER");
2661 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2666 int UtcDaliImageVisualReleasePolicy04(void)
2668 ToolkitTestApplication application;
2669 tet_infoline("UtcDaliImageVisualReleasePolicy04 Two visuals with different policies sharing a texture");
2671 tet_infoline("Create first visual with Never release policy");
2672 Visual::Base imageVisualNever = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2674 tet_infoline("Create second visual with Destroyed release policy");
2675 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2677 // Set up trace debug
2678 TestGlAbstraction& gl = application.GetGlAbstraction();
2679 TraceCallStack& textureTrace = gl.GetTextureTrace();
2680 textureTrace.Enable(true);
2682 tet_infoline("Register visuals with control and ensure it has the only handles");
2683 DummyControl actor = DummyControl::New(true);
2684 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2685 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualNever);
2686 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, imageVisualDestroyed);
2687 imageVisualNever.Reset(); // reduce ref count so only the control keeps the visual alive.
2688 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2690 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2692 // Test initially zero renderers
2693 application.SendNotification();
2694 application.Render(0);
2695 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2696 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2698 application.GetScene().Add(actor);
2700 // Wait for image to load
2701 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2703 application.SendNotification();
2704 application.Render(0);
2705 tet_infoline("Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer");
2706 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
2707 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2709 // Test renderer removed when visual destroyed
2710 DALI_TEST_CHECK(actor.GetRendererCount() == 2u);
2711 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL2); // TEST_VISUAL2 no longer requires the texture as release policy DESTROYED
2712 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2713 application.SendNotification();
2714 application.Render();
2716 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
2717 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2719 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2720 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2721 application.SendNotification();
2722 application.Render();
2724 tet_infoline("Ensure a texture is not deleted as second visual used the NEVER release policy");
2725 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
2726 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2731 int UtcDaliImageVisualReleasePolicy05(void)
2733 ToolkitTestApplication application;
2734 tet_infoline("UtcDaliImageVisualReleasePolicy05 Testing settung by string currents correct enum");
2736 VisualFactory factory = VisualFactory::Get();
2738 Property::Map propertyMapNeverReleasePolicy;
2739 propertyMapNeverReleasePolicy.Insert(Visual::Property::TYPE, Visual::IMAGE);
2740 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
2741 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
2742 propertyMapNeverReleasePolicy.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
2743 propertyMapNeverReleasePolicy.Insert("releasePolicy", "never");
2745 Visual::Base imageVisualNever = factory.CreateVisual(propertyMapNeverReleasePolicy);
2747 Property::Map resultMap;
2748 imageVisualNever.CreatePropertyMap(resultMap);
2749 DALI_TEST_CHECK(!resultMap.Empty());
2751 DALI_TEST_EQUALS((resultMap.Find(ImageVisual::Property::RELEASE_POLICY))->Get<int>(), (int)ImageVisual::ReleasePolicy::NEVER, TEST_LOCATION);
2756 int UtcDaliImageVisualReleasePolicy06(void)
2758 ToolkitTestApplication application;
2759 tet_infoline("UtcDaliImageVisualReleasePolicy06 Never Policy, texture should not be affected by Disabling and Enabling visual");
2761 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER);
2762 DALI_TEST_CHECK(imageVisual);
2764 TestGlAbstraction& gl = application.GetGlAbstraction();
2765 TraceCallStack& textureTrace = gl.GetTextureTrace();
2766 textureTrace.Enable(true);
2768 tet_infoline("Register visual with control and ensure it has the only handle");
2769 DummyControl actor = DummyControl::New(true);
2770 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2771 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2772 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2774 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2776 application.SendNotification();
2777 application.Render(0);
2778 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2779 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2781 application.GetScene().Add(actor);
2783 // Wait for image to load
2784 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2786 application.SendNotification();
2787 application.Render(0);
2788 // Test renderer and texture created
2789 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2790 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2791 textureTrace.Reset();
2793 tet_infoline("Disable Visual and check texture not affected");
2794 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2795 application.SendNotification();
2796 application.Render(0);
2797 tet_infoline("Check renderer is destroyed when visual off stage");
2798 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2799 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2800 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2801 textureTrace.Reset();
2803 tet_infoline("Re-enable Visual and check texture not affected");
2804 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, true);
2805 application.SendNotification();
2806 application.Render(0);
2807 tet_infoline("Check texture not affected and renderer is destroyed when visual off stage");
2808 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2809 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2810 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2815 int UtcDaliImageVisualReleasePolicy07(void)
2817 ToolkitTestApplication application;
2818 tet_infoline("UtcDaliImageVisualReleasePolicy07 Two visuals with different policies sharing a texture DETACHED and DESTROYED");
2820 tet_infoline("Create first visual with DESTROYED release policy");
2821 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2823 tet_infoline("Create second visual with DETACHED release policy");
2824 Visual::Base imageVisualDetached = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED);
2826 // Set up trace debug
2827 TestGlAbstraction& gl = application.GetGlAbstraction();
2828 TraceCallStack& textureTrace = gl.GetTextureTrace();
2829 textureTrace.Enable(true);
2831 tet_infoline("Register visuals with control and ensure it has the only handles");
2832 DummyControl actor = DummyControl::New(true);
2833 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2834 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualDestroyed);
2835 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL2, imageVisualDetached);
2836 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2837 imageVisualDetached.Reset(); // reduce ref count so only the control keeps the visual alive.
2839 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2841 // Test initially zero renderers
2842 application.SendNotification();
2843 application.Render(0);
2844 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2845 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2847 application.GetScene().Add(actor);
2849 // Wait for image to load
2850 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2852 application.SendNotification();
2853 application.Render(0);
2854 tet_infoline("Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer");
2855 DALI_TEST_EQUALS(actor.GetRendererCount(), 2u, TEST_LOCATION);
2856 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2858 // Test renderer removed when visual destroyed
2859 DALI_TEST_CHECK(actor.GetRendererCount() == 2u);
2860 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL2, false); // TEST_VISUAL2 no longer requires the texture as release policy DETACHED
2861 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2862 application.SendNotification();
2863 application.Render();
2865 // Test texture was not deleted as TEST_VISUAL release policy is DESTROYED and is still required.
2866 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2868 dummyImpl.EnableVisual(DummyControl::Property::TEST_VISUAL, false);
2869 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2870 application.SendNotification();
2871 application.Render();
2873 tet_infoline("Ensure a texture is not deleted as second visual used the DESTROYED release policy");
2874 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2879 int UtcDaliImageVisualReleasePolicy08(void)
2881 ToolkitTestApplication application;
2882 tet_infoline("UtcDaliImageVisualReleasePolicy08 Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy");
2884 tet_infoline("Create first visual with DESTROYED release policy");
2885 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2887 // Set up trace debug
2888 TestGlAbstraction& gl = application.GetGlAbstraction();
2889 TraceCallStack& textureTrace = gl.GetTextureTrace();
2890 textureTrace.Enable(true);
2892 tet_infoline("Register visuals with control and ensure it has the only handles");
2893 DummyControl actor = DummyControl::New(true);
2894 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2895 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisualDestroyed);
2896 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
2898 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2900 // Test initially zero renderers
2901 application.SendNotification();
2902 application.Render(0);
2903 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2904 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2905 textureTrace.Reset();
2907 application.GetScene().Add(actor);
2909 // Wait for image to load
2910 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
2912 application.SendNotification();
2913 application.Render(0);
2914 tet_infoline("Ensure a texture is created");
2915 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
2916 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
2917 textureTrace.Reset();
2919 // Ensure Texture is same after detach/attach on stage when texture used the DESTROYED release policy
2921 Texture textureBefore = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
2923 // 2.Remove actor from stage. In this case, renderer also is deleted.
2924 tet_infoline("Remove actor from stage");
2925 application.GetScene().Remove(actor);
2926 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2927 application.SendNotification();
2928 application.Render();
2930 tet_infoline("Ensure a texture is not deleted as visual used the DESTROYED release policy");
2931 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION);
2932 textureTrace.Reset();
2934 // 3.Add actor in stage. In this case, renderer is created.
2935 tet_infoline("Add actor in stage");
2936 application.GetScene().Add(actor);
2937 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
2938 application.SendNotification();
2939 application.Render();
2940 tet_infoline("Ensure a texture is not created again");
2941 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
2942 textureTrace.Reset();
2944 // 4.Compare Texture with before and after. texture need to be same because release policy is the DESTROYED.
2945 tet_infoline("Ensure a texture is not deleted because it is used the DESTROYED release policy");
2946 Texture textureAfter = actor.GetRendererAt(0u).GetTextures().GetTexture(0u);
2947 DALI_TEST_CHECK(textureBefore == textureAfter);
2948 textureBefore.Reset();
2949 textureAfter.Reset();
2951 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
2952 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2953 application.SendNotification();
2954 application.Render();
2955 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
2960 int UtcDaliImageVisualReleasePolicy09(void)
2962 ToolkitTestApplication application;
2963 tet_infoline("UtcDaliImageVisualReleasePolicy09 Destroyed Policy with N-Patch, Texture should be deleted when visual destroyed");
2965 Property::Map propertyMapNPatchReleasePolicy;
2966 propertyMapNPatchReleasePolicy.Insert(Visual::Property::TYPE, Visual::N_PATCH);
2967 propertyMapNPatchReleasePolicy.Insert(ImageVisual::Property::URL, TEST_N_PATCH_IMAGE_FILE_NAME);
2968 propertyMapNPatchReleasePolicy.Insert(DevelImageVisual::Property::AUXILIARY_IMAGE, TEST_MASK_IMAGE_FILE_NAME);
2969 propertyMapNPatchReleasePolicy.Insert(DevelImageVisual::Property::AUXILIARY_IMAGE_ALPHA, 0.9f);
2970 propertyMapNPatchReleasePolicy.Insert(ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED);
2972 VisualFactory factory = VisualFactory::Get();
2973 Visual::Base imageVisual = factory.CreateVisual(propertyMapNPatchReleasePolicy);
2974 DALI_TEST_CHECK(imageVisual);
2976 // Setup debug trace
2977 TestGlAbstraction& gl = application.GetGlAbstraction();
2978 TraceCallStack& textureTrace = gl.GetTextureTrace();
2979 textureTrace.Enable(true);
2981 tet_infoline("Register visual with control and ensure it has the only handle");
2982 DummyControl actor = DummyControl::New(true);
2983 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2984 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
2985 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2987 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2989 application.SendNotification();
2990 application.Render(0);
2991 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
2992 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
2994 application.GetScene().Add(actor);
2996 // Wait for image to load
2997 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(2), true, TEST_LOCATION);
2999 application.SendNotification();
3000 application.Render(0);
3001 // Test renderer and texture created
3002 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3003 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3005 DALI_TEST_CHECK(actor.GetRendererCount() == 1u);
3006 tet_infoline("Destroy visual by UnRegistering visual with control, check renderer is destroyed");
3007 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3008 DALI_TEST_CHECK(actor.GetRendererCount() == 0u);
3009 application.SendNotification();
3010 application.Render();
3012 // Test texture removed after visual destroyed.
3013 tet_infoline("Ensure texture is deleted after visual destroyed");
3014 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION);
3019 int UtcDaliImageVisualLoadPolicy01(void)
3021 ToolkitTestApplication application;
3022 tet_infoline("UtcDaliImageVisualLoadPolicy01 Load a visual image before attaching to stage");
3024 // Set up trace debug
3025 TestGlAbstraction& gl = application.GetGlAbstraction();
3026 TraceCallStack& textureTrace = gl.GetTextureTrace();
3027 textureTrace.Enable(true);
3029 tet_infoline("Create visual with IMMEDIATE load policy");
3030 VisualFactory factory = VisualFactory::Get();
3032 Property::Map propertyMap;
3033 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3034 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3035 propertyMap.Insert(ImageVisual::Property::DESIRED_WIDTH, 20);
3036 propertyMap.Insert(ImageVisual::Property::DESIRED_HEIGHT, 30);
3037 propertyMap.Insert("loadPolicy", ImageVisual::LoadPolicy::IMMEDIATE);
3039 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
3041 Property::Map resultMap;
3042 imageVisual.CreatePropertyMap(resultMap);
3043 DALI_TEST_CHECK(!resultMap.Empty());
3044 DALI_TEST_EQUALS((resultMap.Find(ImageVisual::Property::LOAD_POLICY))->Get<int>(), (int)ImageVisual::LoadPolicy::IMMEDIATE, TEST_LOCATION);
3046 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3048 // Ensure texture has been uploaded
3049 application.SendNotification();
3050 application.Render();
3052 tet_infoline("Ensure texture loading starts after visual created");
3053 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3054 textureTrace.Reset();
3056 tet_infoline("Register visuals with control and ensure it has the only handles");
3057 DummyControl actor = DummyControl::New(true);
3058 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3059 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3060 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3062 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3063 application.GetScene().Add(actor);
3064 tet_infoline("Ensure nothing triggers another load as texure already loaded");
3065 const unsigned int TIME_OUT_3_SECONDS = 3;
3066 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, TIME_OUT_3_SECONDS), false, TEST_LOCATION);
3068 application.SendNotification();
3069 application.Render();
3071 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3072 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
3074 // Ensure texture is deleted when no longer needed (ref count was correct )
3075 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3077 application.SendNotification();
3078 application.Render();
3080 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3081 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
3086 int UtcDaliImageVisualLoadPolicy02(void)
3088 ToolkitTestApplication application;
3089 tet_infoline("UtcDaliImageVisualLoadPolicy01 Load a visual image only after attached to stage");
3091 // Set up trace debug
3092 TestGlAbstraction& gl = application.GetGlAbstraction();
3093 TraceCallStack& textureTrace = gl.GetTextureTrace();
3094 textureTrace.Enable(true);
3096 tet_infoline("Create visual with IMMEDIATE load policy");
3097 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3099 const unsigned int TIME_OUT_3_SECONDS = 3;
3100 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, TIME_OUT_3_SECONDS), false, TEST_LOCATION);
3102 // Act on meeage queue even although nothing expected to load
3103 application.SendNotification();
3104 application.Render();
3106 tet_infoline("Ensure texture is not generated yet");
3107 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION);
3108 textureTrace.Reset();
3110 tet_infoline("Register visuals with control and ensure it has the only handles");
3111 DummyControl actor = DummyControl::New(true);
3112 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3113 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3114 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3116 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3117 application.GetScene().Add(actor);
3118 tet_infoline("Allow image time to load");
3119 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3121 application.SendNotification();
3122 application.Render();
3124 tet_infoline("Ensure texture generated and renderer created");
3125 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3126 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3128 // Ensure texture is delete when no longer needed
3129 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3131 application.SendNotification();
3132 application.Render();
3134 DALI_TEST_EQUALS(actor.GetRendererCount(), 0u, TEST_LOCATION);
3135 DALI_TEST_EQUALS(textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION);
3140 int UtcDaliImageVisualLoadPolicy03(void)
3142 ToolkitTestApplication application;
3143 tet_infoline("UtcDaliImageVisualLoadPolicy03 Load a visual image and receive ResourceReady Signal when loaded");
3145 const bool VISUAL_NOT_ENABLED(false); // Instead of just passing 'false' into an API.
3147 // Set up trace debug
3148 TestGlAbstraction& gl = application.GetGlAbstraction();
3149 TraceCallStack& textureTrace = gl.GetTextureTrace();
3150 textureTrace.Enable(true);
3152 tet_infoline("Create a control and connect to resource ready signal without adding to stage");
3153 DummyControl actor = DummyControl::New(true);
3154 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3155 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3156 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3158 tet_infoline("Create visual with IMMEDIATE load policy");
3159 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3161 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( not staged )");
3162 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED);
3163 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3165 tet_infoline("Allow image time to load resource");
3166 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3167 application.SendNotification();
3168 application.Render();
3170 // Ensure texture has been uploaded
3171 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3172 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
3177 int UtcDaliImageVisualLoadPolicy04(void)
3179 ToolkitTestApplication application;
3180 tet_infoline("UtcDaliImageVisualLoadPolicy04 First part Load a visual image before attaching to stage");
3181 tet_infoline("Second part, Reuse the same image in aonther control and check resource ready signal fired");
3183 const bool VISUAL_NOT_ENABLED(false); // Instead of just passing false into an API.
3185 // Set up trace debug
3186 TestGlAbstraction& gl = application.GetGlAbstraction();
3187 TraceCallStack& textureTrace = gl.GetTextureTrace();
3188 textureTrace.Enable(true);
3190 tet_infoline("Create a control and connect to resource ready signal");
3191 DummyControl actor = DummyControl::New(true);
3192 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3193 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3194 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3196 tet_infoline("Create visual with IMMEDIATE load policy");
3197 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3199 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( staged )");
3200 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED);
3201 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3203 tet_infoline("Allow image time to load");
3204 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3205 application.SendNotification();
3206 application.Render();
3208 tet_infoline("Testing texture is loaded and resource ready signal fired");
3209 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3210 DALI_TEST_EQUALS(gResourceReadySignalFired, false, TEST_LOCATION);
3212 tet_infoline("Original control correctly signalled, now testing for signal with new Control reusing the image");
3214 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3215 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3216 DummyControl actor2 = DummyControl::New(true);
3217 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3218 actor2.ResourceReadySignal().Connect(&ResourceReadySignal);
3220 tet_infoline("Registering visual this should trigger the loading signal as is already image loaded for previous control");
3221 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3222 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
3223 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3224 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(0), true, TEST_LOCATION); // Not expecting any further loading as texture is being reused.
3225 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3230 int UtcDaliImageVisualLoadPolicy05(void)
3232 ToolkitTestApplication application;
3233 tet_infoline("UtcDaliImageVisualLoadPolicy05 LoadPolicy::ATTACHED (default) First part Load a visual image before attaching to stage");
3234 tet_infoline("Second part, Reuse the same image in aonther control and check resource ready signal fired");
3235 // Set up trace debug
3236 TestGlAbstraction& gl = application.GetGlAbstraction();
3237 TraceCallStack& textureTrace = gl.GetTextureTrace();
3238 textureTrace.Enable(true);
3240 tet_infoline("Create a control and connect to resource ready signal");
3241 DummyControl actor = DummyControl::New(true);
3242 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3243 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3244 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3245 application.GetScene().Add(actor);
3247 tet_infoline("Create visual with ATTACHED load policy");
3248 Visual::Base imageVisual = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3250 tet_infoline("Registering visual allows control to get a signal once loaded");
3251 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3252 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
3254 tet_infoline("Allow image time to load");
3255 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3256 application.SendNotification();
3257 application.Render();
3259 tet_infoline("Testing texture is loaded and resource ready signal fired");
3260 DALI_TEST_EQUALS(textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION);
3261 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3263 tet_infoline("Original control correctly signalled, now testing for signal with new Control reusing the image");
3265 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3266 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED);
3267 DummyControl actor2 = DummyControl::New(true);
3268 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3269 actor2.ResourceReadySignal().Connect(&ResourceReadySignal);
3271 tet_infoline("Registering visual this should trigger the loading signal as is already image loaded for previous control");
3272 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3273 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
3274 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3275 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(0), true, TEST_LOCATION); // Not expecting any further loading as texture is being reused.
3276 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3281 int UtcDaliImageVisualOrientationCorrection(void)
3283 ToolkitTestApplication application;
3284 tet_infoline("UtcDaliImageVisualOrientationCorrection Enabling OrientationCorrection should rotate an image with exif (90deg) orientation data with requested");
3286 VisualFactory factory = VisualFactory::Get();
3287 tet_infoline("Create visual with Orientation correction set OFF");
3288 Property::Map propertyMap;
3289 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3290 propertyMap.Insert(ImageVisual::Property::URL, TEST_ROTATED_IMAGE);
3291 propertyMap.Insert("orientationCorrection", false);
3292 Visual::Base imageVisual = factory.CreateVisual(propertyMap);
3294 tet_infoline("Create control for visual, need to loaded it");
3295 DummyControl actor = DummyControl::New(true);
3296 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3297 application.GetScene().Add(actor);
3299 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3300 // Wait for image to load
3301 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3303 Vector2 originalImageSize;
3304 tet_infoline("Get size of original visual to compare later with rotated image");
3305 imageVisual.GetNaturalSize(originalImageSize);
3306 DALI_TEST_GREATER(originalImageSize.width, originalImageSize.height, TEST_LOCATION); // Width and Height must be different for this test.
3307 imageVisual.Reset(); // remove handle so can unregister it and remove from cache
3308 dummyImpl.UnregisterVisual(DummyControl::Property::TEST_VISUAL);
3309 application.SendNotification();
3310 application.Render();
3312 tet_infoline("Create visual with Orientation correction set ON ");
3313 propertyMap.Clear();
3314 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
3315 propertyMap.Insert(ImageVisual::Property::URL, TEST_ROTATED_IMAGE);
3316 propertyMap.Insert(ImageVisual::Property::ORIENTATION_CORRECTION, true);
3317 imageVisual = factory.CreateVisual(propertyMap);
3319 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual);
3320 // Wait for image to load
3321 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3323 Vector2 rotatedImageSize;
3324 imageVisual.GetNaturalSize(rotatedImageSize);
3325 tet_infoline("Confirm that visual has rotated");
3326 DALI_TEST_EQUALS(originalImageSize.width, rotatedImageSize.height, TEST_LOCATION);
3327 DALI_TEST_EQUALS(originalImageSize.height, rotatedImageSize.width, TEST_LOCATION);
3329 Property::Map resultMap;
3330 imageVisual.CreatePropertyMap(resultMap);
3332 // check the Property::ORIENTATION_CORRECTION value from the returned map
3333 Property::Value* typeValue = resultMap.Find(ImageVisual::Property::ORIENTATION_CORRECTION, Property::BOOLEAN);
3334 DALI_TEST_EQUALS(typeValue->Get<bool>(), true, TEST_LOCATION);
3339 int UtcDaliImageVisualCustomShader(void)
3341 ToolkitTestApplication application;
3342 tet_infoline("UtcDaliImageVisualCustomShader Test custom shader");
3344 VisualFactory factory = VisualFactory::Get();
3345 Property::Map properties;
3346 Property::Map shader;
3347 const std::string vertexShader = "Foobar";
3348 const std::string fragmentShader = "Foobar";
3349 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
3350 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
3352 properties[Visual::Property::TYPE] = Visual::IMAGE;
3353 properties[Visual::Property::SHADER] = shader;
3354 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
3356 Visual::Base visual = factory.CreateVisual(properties);
3358 // trigger creation through setting on stage
3359 DummyControl dummy = DummyControl::New(true);
3360 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(dummy.GetImplementation());
3361 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual);
3363 dummy.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3364 dummy.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3365 application.GetScene().Add(dummy);
3367 application.SendNotification();
3368 application.Render();
3370 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3372 Renderer renderer = dummy.GetRendererAt(0);
3373 Shader shader2 = renderer.GetShader();
3374 Property::Value value = shader2.GetProperty(Shader::Property::PROGRAM);
3375 Property::Map* map = value.GetMap();
3376 DALI_TEST_CHECK(map);
3378 Property::Value* fragment = map->Find("fragment"); // fragment key name from shader-impl.cpp
3379 DALI_TEST_EQUALS(fragmentShader, fragment->Get<std::string>(), TEST_LOCATION);
3381 Property::Value* vertex = map->Find("vertex"); // vertex key name from shader-impl.cpp
3382 DALI_TEST_EQUALS(vertexShader, vertex->Get<std::string>(), TEST_LOCATION);
3386 shader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
3387 properties[Visual::Property::SHADER] = shader;
3389 Visual::Base visual1 = factory.CreateVisual(properties);
3391 // trigger creation through setting on stage
3392 DummyControl dummy1 = DummyControl::New(true);
3393 Impl::DummyControl& dummyImpl1 = static_cast<Impl::DummyControl&>(dummy1.GetImplementation());
3394 dummyImpl1.RegisterVisual(DummyControl::Property::TEST_VISUAL, visual1);
3395 dummy1.SetProperty(Actor::Property::SIZE, Vector2(200, 200));
3396 dummy1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
3397 application.GetScene().Add(dummy1);
3399 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
3400 glAbstraction.EnableEnableDisableCallTrace(true);
3402 application.SendNotification();
3403 application.Render();
3405 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
3406 std::ostringstream blendStr;
3407 blendStr << std::hex << GL_BLEND;
3408 DALI_TEST_CHECK(glEnableStack.FindMethodAndParams("Enable", blendStr.str()));
3413 void ResourceReadyLoadNext(Control control)
3415 static int callNumber = 0;
3417 gResourceReadySignalFired = true;
3418 gReadyIds.push_back(control.GetProperty<int>(Actor::Property::ID));
3422 DALI_TEST_EQUALS(control.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL), Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION);
3424 tet_infoline("Create visual with loaded image from within the signal handler");
3425 VisualFactory factory = VisualFactory::Get();
3426 Visual::Base imageVisual = factory.CreateVisual(TEST_IMAGE_FILE_NAME, ImageDimensions{20, 30});
3428 Impl::DummyControl& controlImpl = static_cast<Impl::DummyControl&>(control.GetImplementation());
3429 controlImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual); // This should trigger another signal.
3434 tet_infoline("3rd signal called");
3435 DALI_TEST_CHECK(true);
3439 int UtcDaliImageVisualLoadReady01(void)
3441 ToolkitTestApplication application;
3442 tet_infoline("UtcDaliImageVisualLoadReady01");
3443 tet_infoline("First part: Load an image visual for one resource, then another image visual for a second resource.");
3444 tet_infoline("Second part, In the ready signal for the second image visual, add a 3rd visual with the first URL");
3445 tet_infoline("Should get a ready signal for all three visuals");
3449 tet_infoline("Create a control and connect to resource ready signal");
3450 DummyControl actor = DummyControl::New(true);
3451 int actor1Id = actor.GetProperty<int>(Actor::Property::ID);
3452 actor.ResourceReadySignal().Connect(&ResourceReadySignal);
3453 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
3454 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3455 application.GetScene().Add(actor);
3457 tet_infoline("Create visual with IMMEDIATE load policy");
3458 Visual::Base imageVisual1 = CreateVisualWithPolicy(TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3460 tet_infoline("Registering visual allows control to get a signal once loaded even if visual not enabled( staged )");
3461 dummyImpl.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual1);
3463 tet_infoline("Allow image time to load");
3464 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3465 application.SendNotification();
3466 application.Render();
3468 tet_infoline("Testing texture is loaded and resource ready signal fired");
3469 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3470 DALI_TEST_EQUALS(gReadyIds[0], actor1Id, TEST_LOCATION);
3472 tet_infoline("Original control correctly signalled, now testing failing image");
3474 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
3477 Visual::Base imageVisual2 = CreateVisualWithPolicy(TEST_BROKEN_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE);
3479 DummyControl actor2 = DummyControl::New(true);
3480 int actor2Id = actor2.GetProperty<int>(Actor::Property::ID);
3481 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor2.GetImplementation());
3482 actor2.ResourceReadySignal().Connect(&ResourceReadyLoadNext);
3484 tet_infoline("Registering visual this should trigger the ready signal when the image fails to load");
3485 dummyImpl2.RegisterVisual(DummyControl::Property::TEST_VISUAL, imageVisual2);
3487 actor2.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3488 application.GetScene().Add(actor2);
3490 tet_infoline("Wait for loading thread to finish");
3491 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3492 DALI_TEST_EQUALS(gResourceReadySignalFired, true, TEST_LOCATION);
3494 DALI_TEST_EQUALS(gReadyIds[0], actor2Id, TEST_LOCATION);
3496 tet_infoline("Check for 3rd signal");
3497 application.SendNotification();
3498 DALI_TEST_EQUALS(gReadyIds.size(), 2, TEST_LOCATION);
3499 DALI_TEST_EQUALS(gReadyIds[1], actor2Id, TEST_LOCATION);
3504 int UtcDaliImageVisualLoadImagePlanes01(void)
3506 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3507 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3509 ToolkitTestApplication application;
3511 VisualFactory factory = VisualFactory::Get();
3512 DALI_TEST_CHECK(factory);
3514 Property::Map propertyMap;
3515 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3516 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3518 Visual::Base visual = factory.CreateVisual(propertyMap);
3519 DALI_TEST_CHECK(visual);
3521 DummyControl actor = DummyControl::New();
3522 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3523 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3524 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3525 application.GetScene().Add(actor);
3527 application.SendNotification();
3528 application.Render();
3530 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3532 TestGlAbstraction& gl = application.GetGlAbstraction();
3533 TraceCallStack& textureTrace = gl.GetTextureTrace();
3534 textureTrace.Enable(true);
3536 application.SendNotification();
3537 application.Render();
3539 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3540 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3541 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3543 Renderer renderer = actor.GetRendererAt(0);
3544 auto preMultipliedAlpha = renderer.GetProperty<bool>(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA);
3545 DALI_TEST_EQUALS(preMultipliedAlpha, false, TEST_LOCATION);
3550 int UtcDaliImageVisualLoadImagePlanes02(void)
3552 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3553 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3555 ToolkitTestApplication application;
3557 VisualFactory factory = VisualFactory::Get();
3558 DALI_TEST_CHECK(factory);
3560 // Alpha masking case - not support yuv planes
3561 Property::Map propertyMap;
3562 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3563 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3564 propertyMap.Insert(ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME);
3566 Visual::Base visual = factory.CreateVisual(propertyMap);
3567 DALI_TEST_CHECK(visual);
3569 DummyControl actor = DummyControl::New();
3570 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3571 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3572 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3573 application.GetScene().Add(actor);
3575 application.SendNotification();
3576 application.Render();
3578 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(3), true, TEST_LOCATION);
3580 TestGlAbstraction& gl = application.GetGlAbstraction();
3581 TraceCallStack& textureTrace = gl.GetTextureTrace();
3582 textureTrace.Enable(true);
3584 application.SendNotification();
3585 application.Render();
3587 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3588 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3589 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 1, TEST_LOCATION);
3594 int UtcDaliImageVisualLoadImagePlanes03(void)
3596 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3597 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3599 ToolkitTestApplication application;
3601 VisualFactory factory = VisualFactory::Get();
3602 DALI_TEST_CHECK(factory);
3604 TestGlAbstraction& gl = application.GetGlAbstraction();
3605 TraceCallStack& textureTrace = gl.GetTextureTrace();
3606 textureTrace.Enable(true);
3608 Property::Map propertyMap;
3609 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3610 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3611 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
3613 Visual::Base visual = factory.CreateVisual(propertyMap);
3614 DALI_TEST_CHECK(visual);
3616 DummyControl actor = DummyControl::New();
3617 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3618 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3619 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3620 application.GetScene().Add(actor);
3622 application.SendNotification();
3623 application.Render();
3625 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3626 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3627 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3632 int UtcDaliImageVisualLoadFastTrackImage01(void)
3634 tet_infoline("Test worker thread uploading with Local URL");
3635 ToolkitTestApplication application;
3637 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3639 VisualFactory factory = VisualFactory::Get();
3640 DALI_TEST_CHECK(factory);
3642 // Pair of filename - expect GenTextures count.
3643 std::vector<std::pair<std::string, int>> testCases = {
3644 {TEST_IMAGE_FILE_NAME, 1},
3645 {TEST_REMOTE_IMAGE_FILE_NAME, 1},
3646 {TEST_INVALID_FILE_NAME, 0},
3649 for(auto&& tc : testCases)
3651 auto& filename = tc.first;
3652 auto& expectValue = tc.second;
3654 tet_printf("Test %s\n", filename.c_str());
3656 Property::Map propertyMap;
3657 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3658 propertyMap.Insert(ImageVisual::Property::URL, filename.c_str());
3659 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3661 Visual::Base visual = factory.CreateVisual(propertyMap);
3662 DALI_TEST_CHECK(visual);
3664 DummyControl actor = DummyControl::New();
3665 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3666 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3667 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3669 TestGlAbstraction& gl = application.GetGlAbstraction();
3670 TraceCallStack& textureTrace = gl.GetTextureTrace();
3671 textureTrace.Enable(true);
3673 application.GetScene().Add(actor);
3675 application.SendNotification();
3676 application.Render();
3678 // EventThread without callback
3679 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3681 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3684 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3685 // How can we make it? Should it be integration-api?
3686 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3687 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), expectValue > 0, TEST_LOCATION);
3689 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3690 application.Render();
3692 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), expectValue, TEST_LOCATION);
3694 application.SendNotification();
3695 application.Render();
3697 textureTrace.Reset();
3703 int UtcDaliImageVisualLoadFastTrackImage02(void)
3705 tet_infoline("Test worker thread uploading with Local URL");
3706 ToolkitTestApplication application;
3708 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3710 VisualFactory factory = VisualFactory::Get();
3711 DALI_TEST_CHECK(factory);
3714 auto filename = std::string(TEST_IMAGE_FILE_NAME);
3715 auto expectValue = 1;
3717 tet_printf("Test %s\n", filename.c_str());
3719 Property::Map propertyMap;
3720 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3721 propertyMap.Insert(ImageVisual::Property::URL, filename.c_str());
3722 propertyMap.Insert("fastTrackUploading", true);
3724 Visual::Base visual = factory.CreateVisual(propertyMap);
3725 DALI_TEST_CHECK(visual);
3727 DummyControl actor = DummyControl::New();
3728 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3729 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3730 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3732 TestGlAbstraction& gl = application.GetGlAbstraction();
3733 TraceCallStack& textureTrace = gl.GetTextureTrace();
3734 textureTrace.Enable(true);
3736 application.GetScene().Add(actor);
3738 application.SendNotification();
3739 application.Render();
3741 // EventThread without callback
3742 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3744 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3747 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3748 // How can we make it? Should it be integration-api?
3749 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3750 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), expectValue > 0, TEST_LOCATION);
3752 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3753 application.Render();
3755 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), expectValue, TEST_LOCATION);
3757 application.SendNotification();
3758 application.Render();
3760 textureTrace.Reset();
3766 int UtcDaliImageVisualLoadFastTrackImageResourceReady(void)
3768 tet_infoline("Test worker thread uploading with Local URL");
3769 ToolkitTestApplication application;
3771 VisualFactory factory = VisualFactory::Get();
3772 DALI_TEST_CHECK(factory);
3774 Property::Map propertyMap;
3775 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3776 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3777 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3779 Visual::Base visual = factory.CreateVisual(propertyMap);
3780 DALI_TEST_CHECK(visual);
3782 DummyControl actor = DummyControl::New();
3783 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3784 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3785 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3787 TestGlAbstraction& gl = application.GetGlAbstraction();
3788 TraceCallStack& textureTrace = gl.GetTextureTrace();
3789 textureTrace.Enable(true);
3791 application.GetScene().Add(actor);
3793 application.SendNotification();
3794 application.Render();
3796 // EventThread with callback
3797 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3799 // Check resource ready comes after
3800 application.SendNotification();
3801 application.Render();
3803 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3804 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3809 int UtcDaliImageVisualLoadFastTrackImageReload(void)
3811 tet_infoline("Test worker thread uploading with Local URL");
3812 ToolkitTestApplication application;
3814 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3816 VisualFactory factory = VisualFactory::Get();
3817 DALI_TEST_CHECK(factory);
3819 Property::Map propertyMap;
3820 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3821 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3822 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3824 Visual::Base visual = factory.CreateVisual(propertyMap);
3825 DALI_TEST_CHECK(visual);
3827 DummyControl actor = DummyControl::New();
3828 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3829 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3830 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3832 TestGlAbstraction& gl = application.GetGlAbstraction();
3833 TraceCallStack& textureTrace = gl.GetTextureTrace();
3834 textureTrace.Enable(true);
3836 application.GetScene().Add(actor);
3838 application.SendNotification();
3839 application.Render();
3841 // EventThread without callback
3842 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3844 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3847 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3848 // How can we make it? Should it be integration-api?
3849 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3850 DALI_TEST_EQUALS(textureUploadManager.ResourceUpload(), true, TEST_LOCATION);
3852 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3853 application.Render();
3855 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 1, TEST_LOCATION);
3858 Property::Map attributes;
3859 DevelControl::DoAction(actor, Control::CONTROL_PROPERTY_END_INDEX + 1, DevelImageVisual::Action::RELOAD, attributes);
3861 // EventThread with callback
3862 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1), true, TEST_LOCATION);
3864 // Check resource ready comes after
3865 application.SendNotification();
3866 application.Render();
3868 // Check whether renderer count is 1 or not.
3869 DALI_TEST_EQUALS(actor.GetRendererCount(), 1u, TEST_LOCATION);
3870 DALI_TEST_EQUALS(actor.IsResourceReady(), true, TEST_LOCATION);
3875 int UtcDaliImageVisualLoadFastTrackImagePlanes01(void)
3877 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3878 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3880 ToolkitTestApplication application;
3882 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3884 VisualFactory factory = VisualFactory::Get();
3885 DALI_TEST_CHECK(factory);
3887 Property::Map propertyMap;
3888 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3889 propertyMap.Insert(ImageVisual::Property::URL, TEST_YUV420_IMAGE_FILE_NAME);
3890 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3892 Visual::Base visual = factory.CreateVisual(propertyMap);
3893 DALI_TEST_CHECK(visual);
3895 DummyControl actor = DummyControl::New();
3896 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3897 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3898 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3900 TestGlAbstraction& gl = application.GetGlAbstraction();
3901 TraceCallStack& textureTrace = gl.GetTextureTrace();
3902 textureTrace.Enable(true);
3904 application.GetScene().Add(actor);
3906 application.SendNotification();
3907 application.Render();
3909 // EventThread without callback
3910 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3912 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3915 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3916 // How can we make it? Should it be integration-api?
3917 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3918 textureUploadManager.ResourceUpload();
3919 application.Render();
3921 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3922 application.Render();
3924 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 3, TEST_LOCATION);
3926 application.SendNotification();
3927 application.Render();
3932 int UtcDaliImageVisualLoadFastTrackImagePlanes02(void)
3934 EnvironmentVariable::SetTestEnvironmentVariable(LOAD_IMAGE_YUV_PLANES_ENV, "1");
3935 EnvironmentVariable::SetTestEnvironmentVariable(ENABLE_DECODE_JPEG_TO_YUV_420_ENV, "1");
3937 ToolkitTestApplication application;
3939 Test::TextureUploadManager::InitalizeGraphicsController(application.GetGraphicsController());
3941 VisualFactory factory = VisualFactory::Get();
3942 DALI_TEST_CHECK(factory);
3944 Property::Map propertyMap;
3945 propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
3946 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME);
3947 propertyMap.Insert(DevelImageVisual::Property::FAST_TRACK_UPLOADING, true);
3949 Visual::Base visual = factory.CreateVisual(propertyMap);
3950 DALI_TEST_CHECK(visual);
3952 DummyControl actor = DummyControl::New();
3953 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
3954 dummyImpl.RegisterVisual(Control::CONTROL_PROPERTY_END_INDEX + 1, visual);
3955 actor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
3957 TestGlAbstraction& gl = application.GetGlAbstraction();
3958 TraceCallStack& textureTrace = gl.GetTextureTrace();
3959 textureTrace.Enable(true);
3961 application.GetScene().Add(actor);
3963 application.SendNotification();
3964 application.Render();
3966 // EventThread without callback
3967 DALI_TEST_EQUALS(Test::WaitForEventThreadTrigger(1, 30, false), true, TEST_LOCATION);
3969 DALI_TEST_EQUALS(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3972 // TODO : There is no way to flush TextureUploadManager in test-application's Render() now.
3973 // How can we make it? Should it be integration-api?
3974 auto textureUploadManager = Dali::Devel::TextureUploadManager::Get();
3975 textureUploadManager.ResourceUpload();
3976 application.Render();
3978 // Render only without SendNotification(). And check whether glTexImage2D called or not.
3979 application.Render();
3981 DALI_TEST_GREATER(textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION);
3983 application.SendNotification();
3984 application.Render();