2 * Copyright (c) 2020 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.
20 #include <dali-toolkit-test-suite-utils.h>
21 #include <toolkit-timer.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <dali/devel-api/object/handle-devel.h>
24 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
26 #include <dali-toolkit/devel-api/controls/control-devel.h>
27 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include "dummy-control.h"
32 using namespace Dali::Toolkit;
34 void dali_image_visual_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_image_visual_cleanup(void)
41 test_return_value = TET_PASS;
46 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
47 const char* TEST_BROKEN_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/a-random-nonimage.jpg";
48 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
49 const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png";
50 const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png";
51 const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg";
52 const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png";
53 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
54 const char* TEST_ROTATED_IMAGE = TEST_RESOURCE_DIR "/keyboard-Landscape.jpg";
57 bool gResourceReadySignalFired = false;
58 std::vector<int> gReadyIds = {};
59 void ResourceReadySignal( Control control )
61 gResourceReadySignalFired = true;
62 gReadyIds.push_back(control.GetProperty< int >( Actor::Property::ID ));
69 Actor CreateActorWithImageVisual(const Property::Map& map)
71 VisualFactory factory = VisualFactory::Get();
72 DummyControl actor = DummyControl::New();
73 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
74 Visual::Base visual = factory.CreateVisual( map );
75 DALI_TEST_CHECK( visual );
76 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
77 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
78 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
83 Visual::Base CreateVisualWithPolicy( const char* url, Property::Index key, const Property::Value& value )
85 VisualFactory factory = VisualFactory::Get();
87 Property::Map propertyMap;
88 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
89 propertyMap.Insert( ImageVisual::Property::URL, url );
90 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
91 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
92 propertyMap.Insert( key , value );
94 return factory.CreateVisual( propertyMap );
99 void TestVisualRender( ToolkitTestApplication& application,
101 Visual::Base& visual,
102 std::size_t expectedSamplers = 0,
103 ImageDimensions imageDimensions = ImageDimensions(),
104 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
106 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
107 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
111 // set the image size, for test case, this needs to be set before loading started
112 application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
115 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
116 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
118 application.GetScene().Add( actor );
120 application.SendNotification(); // Send messages to update
121 application.Render(); // process update and render
122 application.SendNotification(); // process any signals to event
126 DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
129 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
132 static void TestMixColor( Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor )
135 visual.CreatePropertyMap(map);
136 Property::Value* value = map.Find( mixColorIndex );
137 DALI_TEST_CHECK( value );
139 DALI_TEST_CHECK( value->Get( mixColor1 ) );
140 DALI_TEST_EQUALS( mixColor1, Vector3(testColor), 0.001, TEST_LOCATION );
142 value = map.Find( Visual::Property::MIX_COLOR );
143 DALI_TEST_CHECK( value );
145 DALI_TEST_CHECK( value->Get( mixColor2 ) );
146 DALI_TEST_EQUALS( mixColor2, testColor, 0.001, TEST_LOCATION );
148 value = map.Find( Visual::Property::OPACITY );
149 DALI_TEST_CHECK( value );
151 DALI_TEST_CHECK( value->Get( opacity ) );
152 DALI_TEST_EQUALS( opacity, testColor.a, 0.001, TEST_LOCATION );
157 int UtcDaliImageVisualPropertyMap(void)
159 ToolkitTestApplication application;
160 tet_infoline( "Request image visual with a Property::Map" );
162 VisualFactory factory = VisualFactory::Get();
163 DALI_TEST_CHECK( factory );
164 factory.SetPreMultiplyOnLoad( true );
166 Property::Map propertyMap;
167 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
168 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
170 Visual::Base visual = factory.CreateVisual( propertyMap );
171 DALI_TEST_CHECK( visual );
173 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
174 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
176 TestGlAbstraction& gl = application.GetGlAbstraction();
177 TraceCallStack& textureTrace = gl.GetTextureTrace();
178 textureTrace.Enable(true);
180 DummyControl actor = DummyControl::New();
181 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
182 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
184 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
185 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
187 application.GetScene().Add( actor );
188 application.SendNotification();
189 application.Render();
191 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
193 application.SendNotification();
194 application.Render();
196 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
197 auto renderer = actor.GetRendererAt(0);
198 auto preMultipliedIndex = renderer.GetPropertyIndex( "preMultipliedAlpha" );
199 DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
200 auto preMultipliedAlpha = renderer.GetProperty<float>( preMultipliedIndex );
201 auto preMultipliedAlpha2 = renderer.GetProperty<bool>( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
202 DALI_TEST_EQUALS( preMultipliedAlpha, 1.0f, TEST_LOCATION );
203 DALI_TEST_EQUALS( preMultipliedAlpha2, true, TEST_LOCATION );
204 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
206 application.GetScene().Remove( actor );
207 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
213 int UtcDaliImageVisualNoPremultipliedAlpha01(void)
215 ToolkitTestApplication application;
216 tet_infoline( "Request image visual without pre-multiplied alpha" );
218 VisualFactory factory = VisualFactory::Get();
219 DALI_TEST_CHECK( factory );
220 factory.SetPreMultiplyOnLoad( false );
222 Property::Map propertyMap;
223 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
224 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
226 Visual::Base visual = factory.CreateVisual( propertyMap );
227 DALI_TEST_CHECK( visual );
229 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
230 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
232 TestGlAbstraction& gl = application.GetGlAbstraction();
233 TraceCallStack& textureTrace = gl.GetTextureTrace();
234 textureTrace.Enable(true);
236 DummyControl actor = DummyControl::New();
237 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
238 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
240 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
241 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
243 application.GetScene().Add( actor );
244 application.SendNotification();
245 application.Render();
247 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
249 application.SendNotification();
250 application.Render();
252 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
253 auto renderer = actor.GetRendererAt(0);
254 auto preMultipliedIndex = renderer.GetPropertyIndex( "preMultipliedAlpha" );
255 DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
256 auto preMultipliedAlpha = renderer.GetProperty<bool>( preMultipliedIndex );
257 auto preMultipliedAlpha2 = renderer.GetProperty<bool>( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
259 DALI_TEST_EQUALS( preMultipliedAlpha, false, TEST_LOCATION );
260 DALI_TEST_EQUALS( preMultipliedAlpha2, false, TEST_LOCATION );
262 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
264 application.GetScene().Remove( actor );
265 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
271 int UtcDaliImageVisualNoPremultipliedAlpha02(void)
273 ToolkitTestApplication application;
274 tet_infoline( "Request image visual with no alpha channel" );
276 VisualFactory factory = VisualFactory::Get();
277 DALI_TEST_CHECK( factory );
279 Property::Map propertyMap;
280 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
281 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
283 Visual::Base visual = factory.CreateVisual( propertyMap );
284 DALI_TEST_CHECK( visual );
286 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
287 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
289 TestGlAbstraction& gl = application.GetGlAbstraction();
290 TraceCallStack& textureTrace = gl.GetTextureTrace();
291 textureTrace.Enable(true);
293 DummyControl actor = DummyControl::New();
294 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
295 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
297 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
298 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
300 application.GetScene().Add( actor );
301 application.SendNotification();
302 application.Render();
304 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
306 application.SendNotification();
307 application.Render();
309 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
310 auto renderer = actor.GetRendererAt(0);
311 auto preMultipliedIndex = renderer.GetPropertyIndex( "preMultipliedAlpha" );
312 DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
313 auto preMultipliedAlpha = renderer.GetProperty<bool>( preMultipliedIndex );
314 auto preMultipliedAlpha2 = renderer.GetProperty<bool>( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
316 DALI_TEST_EQUALS( preMultipliedAlpha, false, TEST_LOCATION );
317 DALI_TEST_EQUALS( preMultipliedAlpha2, false, TEST_LOCATION );
319 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
321 int srcFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
322 int destFactorRgb = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
323 int srcFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
324 int destFactorAlpha = renderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
325 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
326 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
327 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
328 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
330 textureTrace.Reset();
332 // Make a new visual with the same image
333 Visual::Base newVisual = factory.CreateVisual( propertyMap );
334 DALI_TEST_CHECK( newVisual );
336 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
337 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
339 DummyControl newActor = DummyControl::New();
340 DummyControlImpl& newDummyImpl = static_cast< DummyControlImpl& >( newActor.GetImplementation() );
341 newDummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, newVisual );
343 newActor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
344 DALI_TEST_EQUALS( newActor.GetRendererCount(), 0u, TEST_LOCATION );
346 application.GetScene().Add( newActor );
348 application.SendNotification();
349 application.Render();
351 DALI_TEST_EQUALS( newActor.GetRendererCount(), 1u, TEST_LOCATION );
352 auto newRenderer = newActor.GetRendererAt( 0 );
353 preMultipliedIndex = newRenderer.GetPropertyIndex( "preMultipliedAlpha" );
354 DALI_TEST_CHECK( preMultipliedIndex != Property::INVALID_INDEX );
355 preMultipliedAlpha = newRenderer.GetProperty< bool >( preMultipliedIndex );
356 preMultipliedAlpha2 = newRenderer.GetProperty< bool >( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
358 DALI_TEST_EQUALS( preMultipliedAlpha, false, TEST_LOCATION );
359 DALI_TEST_EQUALS( preMultipliedAlpha2, false, TEST_LOCATION );
361 srcFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_RGB );
362 destFactorRgb = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_RGB );
363 srcFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_SRC_ALPHA );
364 destFactorAlpha = newRenderer.GetProperty<int>( Renderer::Property::BLEND_FACTOR_DEST_ALPHA );
365 DALI_TEST_CHECK( srcFactorRgb == BlendFactor::SRC_ALPHA );
366 DALI_TEST_CHECK( destFactorRgb == BlendFactor::ONE_MINUS_SRC_ALPHA );
367 DALI_TEST_CHECK( srcFactorAlpha == BlendFactor::ONE );
368 DALI_TEST_CHECK( destFactorAlpha == BlendFactor::ONE_MINUS_SRC_ALPHA );
370 application.GetScene().Remove( actor );
371 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
377 int UtcDaliImageVisualRemoteImageLoad(void)
379 ToolkitTestApplication application;
380 tet_infoline( "Request remote image visual with a Property::Map" );
382 VisualFactory factory = VisualFactory::Get();
383 DALI_TEST_CHECK( factory );
385 Property::Map propertyMap;
386 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
387 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
389 Visual::Base visual = factory.CreateVisual( propertyMap );
390 DALI_TEST_CHECK( visual );
392 TestGlAbstraction& gl = application.GetGlAbstraction();
393 TraceCallStack& textureTrace = gl.GetTextureTrace();
394 textureTrace.Enable(true);
396 DummyControl actor = DummyControl::New();
397 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
398 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
400 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
401 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
403 application.GetScene().Add( actor );
404 application.SendNotification();
406 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
408 application.SendNotification();
409 application.Render();
411 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
412 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
414 application.GetScene().Remove( actor );
415 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
420 int UtcDaliImageVisualTextureReuse1(void)
422 ToolkitTestApplication application;
423 tet_infoline( "Request remote image visual with a Property::Map; request a second visual with the same property map - should reuse texture" );
425 Property::Map propertyMap;
426 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
427 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
428 propertyMap.Insert( ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED );
430 TestGlAbstraction& gl = application.GetGlAbstraction();
431 TraceCallStack& textureTrace = gl.GetTextureTrace();
432 textureTrace.Enable(true);
433 TraceCallStack& drawTrace = gl.GetDrawTrace();
434 drawTrace.Enable(true);
436 Actor actor = CreateActorWithImageVisual( propertyMap );
437 application.GetScene().Add( actor );
438 application.SendNotification();
440 // Wait for image to load
441 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
443 application.SendNotification();
444 application.Render();
446 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
447 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
448 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
449 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
450 textureTrace.Reset();
453 Actor actor2 = CreateActorWithImageVisual( propertyMap );
454 application.GetScene().Add(actor2);
456 application.SendNotification(); // Send messages to update
457 application.Render(); // process update and render
458 application.SendNotification(); // process any signals to event
460 DALI_TEST_EQUALS( actor2.GetRendererCount(), 1u, TEST_LOCATION );
462 tet_infoline("Test that 2 draw calls occur with no new texture gens/binds, i.e. both\n"
463 "draw calls use the same texture as the previous draw call\n" );
465 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
466 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
467 DALI_TEST_EQUALS( textureTrace.CountMethod("BindTexture"), 0, TEST_LOCATION );
469 tet_infoline("Test that removing 1 actor doesn't delete the texture\n");
471 application.GetScene().Remove( actor );
472 application.SendNotification();
473 application.Render();
475 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
476 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
478 tet_infoline("Test that removing last actor does delete the texture\n");
480 application.GetScene().Remove( actor2 ); // Detaches remaining ImageVisual
481 application.SendNotification();
482 application.Render();
484 DALI_TEST_CHECK( actor2.GetRendererCount() == 0u );
485 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
491 int UtcDaliImageVisualTextureReuse2(void)
493 ToolkitTestApplication application;
494 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" );
496 Property::Map propertyMap;
497 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
498 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
500 TestGlAbstraction& gl = application.GetGlAbstraction();
501 TraceCallStack& textureTrace = gl.GetTextureTrace();
502 textureTrace.Enable(true);
503 TraceCallStack& drawTrace = gl.GetDrawTrace();
504 drawTrace.Enable(true);
506 Actor actor = CreateActorWithImageVisual( propertyMap );
507 application.GetScene().Add( actor );
508 application.SendNotification();
510 // Wait for image to load
511 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
513 application.SendNotification();
514 application.Render();
516 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
517 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
518 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
519 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
520 textureTrace.Reset();
523 propertyMap.Insert( ImageVisual::Property::SAMPLING_MODE, Dali::SamplingMode::NEAREST );
524 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 100 );
525 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 100 );
526 Actor actor2 = CreateActorWithImageVisual( propertyMap );
527 application.GetScene().Add(actor2);
529 application.SendNotification();
531 // Wait for image to load
532 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
534 application.SendNotification();
535 application.Render();
537 DALI_TEST_EQUALS( actor2.GetRendererCount(), 1u, TEST_LOCATION );
539 tet_infoline("Test that 2 draw calls occur with 1 new texture gen/bind, i.e. both "
540 "renderers are using different textures\n" );
542 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
543 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
544 TraceCallStack::NamedParams tex1;
545 tex1["texture"] = "1";
546 TraceCallStack::NamedParams tex2;
547 tex1["texture"] = "2";
548 DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex1), true, TEST_LOCATION );
549 DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex2), true, TEST_LOCATION );
551 tet_infoline("Test that removing 1 actor deletes it's texture\n");
553 application.GetScene().Remove( actor );
554 application.SendNotification();
555 application.Render();
557 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
558 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
560 tet_infoline("Test that removing last actor deletes it's texture\n");
562 application.GetScene().Remove( actor2 );
563 application.SendNotification();
564 application.Render();
566 DALI_TEST_CHECK( actor2.GetRendererCount() == 0u );
567 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION );
573 int UtcDaliImageVisualCustomWrapModePixelArea(void)
575 ToolkitTestApplication application;
576 tet_infoline( "Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
578 VisualFactory factory = VisualFactory::Get();
579 DALI_TEST_CHECK( factory );
581 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
584 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
586 Property::Map propertyMap;
587 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
588 propertyMap.Insert( ImageVisual::Property::URL, TEST_SMALL_IMAGE_FILE_NAME );
589 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
590 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
591 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
592 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
593 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
594 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
595 propertyMap.Insert( ImageVisual::Property::ATLASING, true );
597 Visual::Base visual = factory.CreateVisual( propertyMap );
598 DALI_TEST_CHECK( visual );
600 TestGlAbstraction& gl = application.GetGlAbstraction();
601 TraceCallStack& textureTrace = gl.GetTextureTrace();
602 textureTrace.Enable(true);
603 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
604 texParameterTrace.Enable( true );
606 DummyControl actor = DummyControl::New();
607 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
608 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
609 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
610 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
611 application.GetScene().Add( actor );
614 application.SendNotification();
615 application.Render();
617 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
619 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
621 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
622 std::stringstream out;
623 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
624 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
626 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
627 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
629 // test the uniforms which used to handle the wrap mode
630 Renderer renderer = actor.GetRendererAt( 0u );
631 DALI_TEST_CHECK( renderer );
633 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
634 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
635 Vector4 pixelAreaUniform;
636 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
637 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
639 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
640 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
641 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
642 Vector2 wrapModeUniform;
643 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
644 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
647 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
652 int UtcDaliImageVisualCustomWrapModeNoAtlas(void)
654 ToolkitTestApplication application;
655 tet_infoline( "Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
657 VisualFactory factory = VisualFactory::Get();
658 DALI_TEST_CHECK( factory );
660 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
662 const int height=600;
663 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
665 Property::Map propertyMap;
666 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
667 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
668 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
669 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
670 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
671 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
672 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
673 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
675 Visual::Base visual = factory.CreateVisual( propertyMap );
676 DALI_TEST_CHECK( visual );
678 TestGlAbstraction& gl = application.GetGlAbstraction();
679 TraceCallStack& textureTrace = gl.GetTextureTrace();
680 textureTrace.Enable(true);
681 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
682 texParameterTrace.Enable( true );
684 DummyControl actor = DummyControl::New();
685 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
686 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
687 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
688 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
689 application.GetScene().Add( actor );
692 application.SendNotification();
693 application.Render();
695 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
697 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
699 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
700 std::stringstream out;
701 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
702 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
704 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
705 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
707 // test the uniforms which used to handle the wrap mode
708 Renderer renderer = actor.GetRendererAt( 0u );
709 DALI_TEST_CHECK( renderer );
711 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
712 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
713 Vector4 pixelAreaUniform;
714 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
715 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
717 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
718 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
721 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
726 int UtcDaliImageVisualAnimateMixColor(void)
728 ToolkitTestApplication application;
729 tet_infoline( "Animate mix color" );
731 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
733 VisualFactory factory = VisualFactory::Get();
734 Property::Map propertyMap;
735 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
736 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
737 propertyMap.Insert("mixColor", Color::BLUE);
738 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
739 Visual::Base visual = factory.CreateVisual( propertyMap );
741 DummyControl actor = DummyControl::New(true);
742 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
743 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
745 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
746 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
747 actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
748 application.GetScene().Add(actor);
750 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
752 Renderer renderer = actor.GetRendererAt(0);
753 Property::Index index = DevelHandle::GetPropertyIndex( renderer, Visual::Property::MIX_COLOR );
754 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
755 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
757 tet_infoline("Test that the renderer has the mixColor property");
758 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
760 const Vector4 TARGET_MIX_COLOR( 1.0f, 0.0f, 0.0f, 0.5f );
763 map["target"] = "testVisual";
764 map["property"] = "mixColor";
765 map["initialValue"] = Color::MAGENTA;
766 map["targetValue"] = TARGET_MIX_COLOR;
767 map["animator"] = Property::Map()
768 .Add("alphaFunction", "LINEAR")
769 .Add("timePeriod", Property::Map()
771 .Add("duration", 4.0f));
773 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
775 Animation animation = dummyImpl.CreateTransition( transition );
777 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
778 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
780 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
783 application.SendNotification();
784 application.Render(0); // Ensure animation starts
785 application.Render(2000u); // Halfway point
786 Vector3 testColor( 1.0f, 0.0f, 0.5f );
788 // uColor.a should be actor's alpha * mixColor.a.
789 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "uColor", Vector4( 0.5f, 0.5f, 0.5f, 0.75f ) ), true, TEST_LOCATION );
790 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>( "mixColor", testColor ), true, TEST_LOCATION );
792 application.Render(2000u); // Halfway point between blue and white
794 DALI_TEST_EQUALS( actor.GetCurrentProperty< Vector4 >( Actor::Property::COLOR ), Color::WHITE, TEST_LOCATION );
795 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>( "uColor", Vector4( 1.0f, 1.0f, 1.0f, 0.5f ) ), true, TEST_LOCATION );
796 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>( "mixColor", Vector3( TARGET_MIX_COLOR ) ), true, TEST_LOCATION );
798 TestMixColor( visual, Visual::Property::MIX_COLOR, TARGET_MIX_COLOR );
800 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
801 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
806 int UtcDaliImageVisualAnimateOpacity(void)
808 ToolkitTestApplication application;
809 tet_infoline( "Animate image visual opacity" );
811 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
813 VisualFactory factory = VisualFactory::Get();
814 Property::Map propertyMap;
815 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
816 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
817 propertyMap.Insert("opacity", 0.5f);
818 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
819 Visual::Base visual = factory.CreateVisual( propertyMap );
821 DummyControl actor = DummyControl::New(true);
822 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
823 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
825 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
826 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
827 actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
828 application.GetScene().Add(actor);
830 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
832 Renderer renderer = actor.GetRendererAt(0);
833 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
834 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
837 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." );
840 map["target"] = "testVisual";
841 map["property"] = "opacity";
842 map["targetValue"] = 1.0f;
843 map["animator"] = Property::Map()
844 .Add("alphaFunction", "LINEAR")
845 .Add("timePeriod", Property::Map()
847 .Add("duration", 4.0f));
849 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
850 Animation animation = dummyImpl.CreateTransition( transition );
853 application.SendNotification();
854 application.Render(0); // Ensure animation starts
855 application.Render(2000u); // Halfway point through animation
856 application.SendNotification(); // Handle any signals
859 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
860 DALI_TEST_EQUALS( color.a, 0.75f, TEST_LOCATION );
862 application.Render(2001u); // end
863 application.SendNotification(); // ensure animation finished signal is sent
865 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
866 DALI_TEST_EQUALS( color.a, 1.0f, TEST_LOCATION );
868 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
869 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
874 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." );
877 map["target"] = "testVisual";
878 map["property"] = Visual::Property::OPACITY;
879 map["targetValue"] = 0.1f;
880 map["animator"] = Property::Map()
881 .Add("alphaFunction", "LINEAR")
882 .Add("timePeriod", Property::Map()
884 .Add("duration", 4.0f));
886 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
887 Animation animation = dummyImpl.CreateTransition( transition );
890 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
891 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
893 application.SendNotification();
894 application.Render(0); // Ensure animation starts
895 application.Render(2000u); // Halfway point
896 application.SendNotification();
899 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
900 DALI_TEST_EQUALS( color.a, 0.55f, TEST_LOCATION );
902 application.Render(2016u); // end
903 application.SendNotification();
905 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
906 DALI_TEST_EQUALS( color.a, 0.1f, TEST_LOCATION );
908 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
909 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
918 int UtcDaliImageVisualAnimateOpacity02(void)
920 ToolkitTestApplication application;
921 tet_infoline( "Animate image visual opacity" );
923 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
925 VisualFactory factory = VisualFactory::Get();
926 Property::Map propertyMap;
927 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
928 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
929 propertyMap.Insert("opacity", 0.5f);
930 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
931 Visual::Base visual = factory.CreateVisual( propertyMap );
933 DummyControl actor = DummyControl::New(true);
934 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
935 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
937 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
938 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
939 actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
941 tet_infoline( "Test that the opacity doesn't animate when actor not staged" );
943 Property::Array array;
946 map["target"] = "testVisual";
947 map["property"] = "opacity";
948 map["initialValue"] = 0.0f;
949 map["targetValue"] = 1.0f;
950 map["animator"] = Property::Map()
951 .Add("alphaFunction", "LINEAR")
952 .Add("timePeriod", Property::Map()
954 .Add("duration", 4.0f));
957 map2["target"] = "testVisual";
958 map2["property"] = "size";
959 map2["targetValue"] = Vector2(1.0f, 1.0f);
961 array.Add( map ).Add(map2);
963 Dali::Toolkit::TransitionData transition = TransitionData::New( array );
964 Animation animation = dummyImpl.CreateTransition( transition );
966 application.GetScene().Add(actor);
967 application.SendNotification();
968 application.Render(0); // Ensure animation starts
970 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
972 Renderer renderer = actor.GetRendererAt(0);
973 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
974 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
976 animation = dummyImpl.CreateTransition( transition );
979 application.SendNotification();
980 application.Render(0); // Ensure animation starts
981 application.Render(2000u); // Halfway point through animation
982 application.SendNotification(); // Handle any signals
984 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
985 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
988 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
989 DALI_TEST_EQUALS( color.a, 0.5f, TEST_LOCATION );
991 application.Render(2001u); // end
992 application.SendNotification(); // ensure animation finished signal is sent
994 DALI_TEST_CHECK( application.GetGlAbstraction().GetUniformValue< Vector4 >( "uColor", color ) );
995 DALI_TEST_EQUALS( color.a, 1.0f, TEST_LOCATION );
997 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
998 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
1005 int UtcDaliImageVisualAnimatePixelArea(void)
1007 ToolkitTestApplication application;
1008 tet_infoline( "ImageVisual animate pixel area" );
1010 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
1012 VisualFactory factory = VisualFactory::Get();
1013 Property::Map propertyMap;
1014 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
1015 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1016 propertyMap.Insert("mixColor", Color::BLUE);
1017 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
1018 Visual::Base visual = factory.CreateVisual( propertyMap );
1020 DummyControl actor = DummyControl::New(true);
1021 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1022 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
1024 actor.SetProperty( Actor::Property::SIZE, Vector2(2000, 2000) );
1025 actor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
1026 actor.SetProperty( Actor::Property::COLOR,Color::BLACK);
1027 application.GetScene().Add(actor);
1029 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
1031 Renderer renderer = actor.GetRendererAt(0);
1032 Property::Index index = DevelHandle::GetPropertyIndex( renderer, Visual::Property::MIX_COLOR );
1034 tet_infoline("Test that the renderer has the mixColor property");
1035 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
1037 // TransitionData only takes string keys
1039 map["target"] = "testVisual";
1040 map["property"] = "pixelArea";
1041 map["initialValue"] = Vector4( 0,0,0,1 );
1042 map["targetValue"] = Vector4( 0,0,1,1 ); // Animate width from zero to full
1043 map["animator"] = Property::Map()
1044 .Add("alphaFunction", "LINEAR")
1045 .Add("timePeriod", Property::Map()
1047 .Add("duration", 4.0f));
1049 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
1051 Animation animation = dummyImpl.CreateTransition( transition );
1052 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
1055 application.SendNotification();
1056 application.Render(0); // Ensure animation starts
1057 application.Render(2000u); // Halfway point
1059 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f )), true, TEST_LOCATION );
1061 application.Render(2000u); // End of animation
1063 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4( 0.0f, 0.0f, 1.0f, 1.0f )), true, TEST_LOCATION );
1068 int UtcDaliImageVisualTextureCancelRemoteLoad(void)
1070 ToolkitTestApplication application;
1071 tet_infoline( "Request remote image visual, then destroy visual to cancel load" );
1073 Property::Map propertyMap;
1074 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1075 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
1077 TestGlAbstraction& gl = application.GetGlAbstraction();
1078 TraceCallStack& textureTrace = gl.GetTextureTrace();
1079 textureTrace.Enable(true);
1080 TraceCallStack& drawTrace = gl.GetDrawTrace();
1081 drawTrace.Enable(true);
1083 Actor actor = CreateActorWithImageVisual( propertyMap );
1084 application.GetScene().Add( actor );
1085 application.SendNotification();
1087 application.GetScene().Remove( actor );
1088 application.SendNotification();
1090 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1091 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1092 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION );
1093 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION );
1098 int UtcDaliImageVisualTextureCancelAsyncLoad(void)
1100 ToolkitTestApplication application;
1101 tet_infoline( "Load image asynchronously, cancel loading, then load again" );
1103 VisualFactory factory = VisualFactory::Get();
1104 DALI_TEST_CHECK( factory );
1106 Property::Map propertyMap;
1107 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1108 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1110 Visual::Base visual = factory.CreateVisual( propertyMap );
1111 DALI_TEST_CHECK( visual );
1113 TestGlAbstraction& gl = application.GetGlAbstraction();
1114 TraceCallStack& textureTrace = gl.GetTextureTrace();
1115 textureTrace.Enable( true );
1116 TraceCallStack& drawTrace = gl.GetDrawTrace();
1117 drawTrace.Enable( true );
1119 DummyControl actor = DummyControl::New();
1120 DummyControlImpl& dummyImpl = static_cast< DummyControlImpl& >( actor.GetImplementation() );
1121 dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual );
1123 application.GetScene().Add( actor );
1126 application.GetScene().Remove( actor );
1128 application.GetScene().Add( actor );
1130 // Create another visual with the same image
1131 visual = factory.CreateVisual( propertyMap );
1132 DALI_TEST_CHECK( visual );
1134 dummyImpl.RegisterVisual( Control::Property::BACKGROUND, visual );
1136 application.SendNotification();
1137 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1139 application.SendNotification();
1140 application.Render();
1142 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1143 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1144 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1145 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
1150 int UtcDaliImageVisualSetInvalidAsyncImage(void)
1152 ToolkitTestApplication application;
1153 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
1155 VisualFactory factory = VisualFactory::Get();
1156 DALI_TEST_CHECK( factory );
1158 Property::Map propertyMap;
1159 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1160 propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
1162 Visual::Base visual = factory.CreateVisual( propertyMap );
1163 DALI_TEST_CHECK( visual );
1165 TestGlAbstraction& gl = application.GetGlAbstraction();
1166 TraceCallStack& textureTrace = gl.GetTextureTrace();
1167 textureTrace.Enable(true);
1169 DummyControl actor = DummyControl::New();
1170 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1171 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1173 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1174 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1176 application.GetScene().Add( actor );
1178 application.SendNotification();
1179 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1181 application.SendNotification();
1182 application.Render();
1184 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1185 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1187 application.GetScene().Remove( actor );
1188 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1193 int UtcDaliImageVisualSetInvalidSyncImage(void)
1195 ToolkitTestApplication application;
1196 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
1198 VisualFactory factory = VisualFactory::Get();
1199 DALI_TEST_CHECK( factory );
1201 Property::Map propertyMap;
1202 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1203 propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
1204 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
1206 Visual::Base visual = factory.CreateVisual( propertyMap );
1207 DALI_TEST_CHECK( visual );
1209 TestGlAbstraction& gl = application.GetGlAbstraction();
1210 TraceCallStack& textureTrace = gl.GetTextureTrace();
1211 textureTrace.Enable(true);
1213 DummyControl actor = DummyControl::New();
1214 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1215 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1217 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1218 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1220 application.GetScene().Add( actor );
1222 application.SendNotification();
1223 application.Render();
1225 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1226 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1228 application.GetScene().Remove( actor );
1229 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1234 int UtcDaliImageVisualSetInvalidRemoteImage(void)
1236 ToolkitTestApplication application;
1237 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
1239 VisualFactory factory = VisualFactory::Get();
1240 DALI_TEST_CHECK( factory );
1242 // Local invalid file, asynchronous loading
1243 Property::Map propertyMap;
1244 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1245 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_INVALID_FILE_NAME );
1247 Visual::Base visual = factory.CreateVisual( propertyMap );
1248 DALI_TEST_CHECK( visual );
1250 TestGlAbstraction& gl = application.GetGlAbstraction();
1251 TraceCallStack& textureTrace = gl.GetTextureTrace();
1252 textureTrace.Enable(true);
1254 DummyControl actor = DummyControl::New();
1255 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1256 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1258 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1259 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1261 application.GetScene().Add( actor );
1263 application.SendNotification();
1264 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1266 application.SendNotification();
1267 application.Render();
1269 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1270 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1272 application.GetScene().Remove( actor );
1273 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1278 int UtcDaliImageVisualAlphaMask(void)
1280 ToolkitTestApplication application;
1281 tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" );
1283 VisualFactory factory = VisualFactory::Get();
1284 DALI_TEST_CHECK( factory );
1286 Property::Map propertyMap;
1287 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1288 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
1289 propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
1291 Visual::Base visual = factory.CreateVisual( propertyMap );
1292 DALI_TEST_CHECK( visual );
1294 Property::Map testMap;
1295 visual.CreatePropertyMap(testMap);
1296 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
1298 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1299 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1301 TestGlAbstraction& gl = application.GetGlAbstraction();
1302 TraceCallStack& textureTrace = gl.GetTextureTrace();
1303 textureTrace.Enable(true);
1305 DummyControl actor = DummyControl::New();
1306 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1307 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1309 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1310 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1311 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
1313 application.GetScene().Add( actor );
1314 application.SendNotification();
1315 application.Render();
1317 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
1319 application.SendNotification();
1320 application.Render();
1322 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1323 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1324 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1326 dummyImpl.UnregisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1 );
1327 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1332 int UtcDaliImageVisualSynchronousLoadAlphaMask(void)
1334 ToolkitTestApplication application;
1335 tet_infoline( "Request image visual with a Property::Map containing an Alpha mask with synchronous loading" );
1337 VisualFactory factory = VisualFactory::Get();
1338 DALI_TEST_CHECK( factory );
1340 Property::Map propertyMap;
1341 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1342 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
1343 propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
1344 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
1346 Visual::Base visual = factory.CreateVisual( propertyMap );
1347 DALI_TEST_CHECK( visual );
1349 Property::Map testMap;
1350 visual.CreatePropertyMap(testMap);
1351 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
1353 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1354 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1356 TestGlAbstraction& gl = application.GetGlAbstraction();
1357 TraceCallStack& textureTrace = gl.GetTextureTrace();
1358 textureTrace.Enable(true);
1360 DummyControl actor = DummyControl::New();
1361 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1362 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1364 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1365 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1366 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
1368 application.GetScene().Add( actor );
1370 // Do not wait for any EventThreadTrigger in synchronous alpha mask.
1372 application.SendNotification();
1373 application.Render();
1375 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1376 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1377 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1379 dummyImpl.UnregisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1 );
1380 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1385 int UtcDaliImageVisualRemoteAlphaMask(void)
1387 ToolkitTestApplication application;
1388 tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" );
1390 VisualFactory factory = VisualFactory::Get();
1391 DALI_TEST_CHECK( factory );
1393 const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME;
1395 Property::Map propertyMap;
1396 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1397 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1398 propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, MASK_IMAGE );
1400 Visual::Base visual = factory.CreateVisual( propertyMap );
1401 DALI_TEST_CHECK( visual );
1403 Property::Map testMap;
1404 visual.CreatePropertyMap(testMap);
1406 DALI_TEST_EQUALS(*testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(MASK_IMAGE), TEST_LOCATION );
1408 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1409 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1411 TestGlAbstraction& gl = application.GetGlAbstraction();
1412 TraceCallStack& textureTrace = gl.GetTextureTrace();
1413 textureTrace.Enable(true);
1415 DummyControl actor = DummyControl::New();
1416 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1417 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1419 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
1421 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1422 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1424 application.GetScene().Add( actor );
1425 application.SendNotification();
1426 application.Render();
1428 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
1430 application.SendNotification();
1431 application.Render();
1433 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1434 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1435 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1440 int UtcDaliImageVisualAlphaMaskCrop(void)
1442 ToolkitTestApplication application;
1443 tet_infoline( "Request image visual with an Alpha mask and scale/cropping" );
1445 VisualFactory factory = VisualFactory::Get();
1446 DALI_TEST_CHECK( factory );
1448 Property::Map propertyMap;
1449 propertyMap.Insert( Toolkit::Visual::Property::TYPE, Visual::IMAGE );
1450 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
1451 propertyMap.Insert( ImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
1452 propertyMap.Insert( ImageVisual::Property::MASK_CONTENT_SCALE, 1.6f );
1453 propertyMap.Insert( ImageVisual::Property::CROP_TO_MASK, true );
1455 Visual::Base visual = factory.CreateVisual( propertyMap );
1456 DALI_TEST_CHECK( visual );
1458 Property::Map testMap;
1459 visual.CreatePropertyMap(testMap);
1460 DALI_TEST_EQUALS( *testMap.Find(ImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
1461 DALI_TEST_EQUALS( *testMap.Find(ImageVisual::Property::MASK_CONTENT_SCALE), Property::Value(1.6f), TEST_LOCATION );
1462 DALI_TEST_EQUALS( *testMap.Find(ImageVisual::Property::CROP_TO_MASK),Property::Value(true), TEST_LOCATION );
1464 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1465 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1467 TestGlAbstraction& gl = application.GetGlAbstraction();
1468 TraceCallStack& textureTrace = gl.GetTextureTrace();
1469 textureTrace.Enable(true);
1471 DummyControl actor = DummyControl::New();
1472 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1473 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1475 actor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
1476 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1477 DALI_TEST_EQUALS( actor.IsResourceReady(), false, TEST_LOCATION );
1479 application.GetScene().Add( actor );
1480 application.SendNotification();
1481 application.Render();
1483 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 3 ), true, TEST_LOCATION );
1485 application.SendNotification();
1486 application.Render();
1489 visual.GetNaturalSize(size);
1491 DALI_TEST_EQUALS( size, Vector2( 100.0f, 100.0f ), 0.001f, TEST_LOCATION );
1492 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1493 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1494 DALI_TEST_EQUALS( actor.IsResourceReady(), true, TEST_LOCATION );
1499 int UtcDaliImageVisualReleasePolicy01(void)
1501 ToolkitTestApplication application;
1502 tet_infoline( "UtcDaliImageVisualReleasePolicy01 Detached Policy, disabling visual with this policy deletes texture" );
1504 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED );
1505 DALI_TEST_CHECK( imageVisual );
1507 // Set up debug trace
1508 TestGlAbstraction& gl = application.GetGlAbstraction();
1509 TraceCallStack& textureTrace = gl.GetTextureTrace();
1510 textureTrace.Enable(true);
1512 tet_infoline( "Register visual with control and ensure it has the only handle" );
1513 DummyControl actor = DummyControl::New(true);
1514 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1515 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1516 imageVisual.Reset();
1518 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1520 application.SendNotification();
1521 application.Render(0);
1522 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1523 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1525 application.GetScene().Add( actor );
1527 // Wait for image to load
1528 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1530 application.SendNotification();
1531 application.Render(0);
1532 // Test renderer and texture created
1533 tet_infoline( "Confirm texture created" );
1534 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1535 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1537 tet_infoline( "Disable visual causing the texture to be deleted" );
1538 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
1540 application.SendNotification();
1541 application.Render(0);
1542 // Test renderer and textures removed.
1543 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1544 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1549 int UtcDaliImageVisualReleasePolicy02(void)
1551 ToolkitTestApplication application;
1552 tet_infoline( "UtcDaliImageVisualReleasePolicy02 Destroyed Policy, Texture should be deleted when visual destroyed" );
1554 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
1555 DALI_TEST_CHECK( imageVisual );
1557 // Setup debug trace
1558 TestGlAbstraction& gl = application.GetGlAbstraction();
1559 TraceCallStack& textureTrace = gl.GetTextureTrace();
1560 textureTrace.Enable(true);
1562 tet_infoline( "Register visual with control and ensure it has the only handle" );
1563 DummyControl actor = DummyControl::New(true);
1564 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1565 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1566 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
1568 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1570 application.SendNotification();
1571 application.Render(0);
1572 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1573 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1575 application.GetScene().Add( actor );
1577 // Wait for image to load
1578 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1580 application.SendNotification();
1581 application.Render(0);
1582 // Test renderer and texture created
1583 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1584 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1587 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1588 tet_infoline( "Destroy visual by UnRegistering visual with control, check renderer is destroyed" );
1589 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1590 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1591 application.SendNotification();
1592 application.Render();
1594 // Test texture removed after visual destroyed.
1595 tet_infoline( "Ensure texture is deleted after visual destroyed" );
1596 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1601 int UtcDaliImageVisualReleasePolicy03(void)
1603 ToolkitTestApplication application;
1604 tet_infoline( "UtcDaliImageVisualReleasePolicy03 Never Policy, texture should not be deleted after visual destroyed" );
1606 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
1607 DALI_TEST_CHECK( imageVisual );
1609 TestGlAbstraction& gl = application.GetGlAbstraction();
1610 TraceCallStack& textureTrace = gl.GetTextureTrace();
1611 textureTrace.Enable(true);
1613 tet_infoline( "Register visual with control and ensure it has the only handle" );
1614 DummyControl actor = DummyControl::New(true);
1615 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1616 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1617 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
1619 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1621 application.SendNotification();
1622 application.Render(0);
1623 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1624 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1626 application.GetScene().Add( actor );
1628 // Wait for image to load
1629 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1631 application.SendNotification();
1632 application.Render(0);
1633 // Test renderer and texture created
1634 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1635 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1637 tet_infoline( "Destroy visual by UnRegistering visual with control, check renderer is destroyed" );
1638 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1639 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1640 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1641 application.SendNotification();
1642 application.Render();
1644 tet_infoline( "Ensure texture is not deleted as policy is set to NEVER" );
1645 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1650 int UtcDaliImageVisualReleasePolicy04(void)
1652 ToolkitTestApplication application;
1653 tet_infoline( "UtcDaliImageVisualReleasePolicy04 Two visuals with different policies sharing a texture" );
1655 tet_infoline( "Create first visual with Never release policy" );
1656 Visual::Base imageVisualNever = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
1658 tet_infoline( "Create second visual with Destroyed release policy");
1659 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
1661 // Set up trace debug
1662 TestGlAbstraction& gl = application.GetGlAbstraction();
1663 TraceCallStack& textureTrace = gl.GetTextureTrace();
1664 textureTrace.Enable(true);
1666 tet_infoline( "Register visuals with control and ensure it has the only handles" );
1667 DummyControl actor = DummyControl::New(true);
1668 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1669 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualNever );
1670 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, imageVisualDestroyed );
1671 imageVisualNever.Reset(); // reduce ref count so only the control keeps the visual alive.
1672 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
1674 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1676 // Test initially zero renderers
1677 application.SendNotification();
1678 application.Render(0);
1679 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1680 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1682 application.GetScene().Add( actor );
1684 // Wait for image to load
1685 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1687 application.SendNotification();
1688 application.Render(0);
1689 tet_infoline( "Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer" );
1690 DALI_TEST_EQUALS( actor.GetRendererCount(), 2u, TEST_LOCATION );
1691 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1693 // Test renderer removed when visual destroyed
1694 DALI_TEST_CHECK( actor.GetRendererCount() == 2u );
1695 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL2 ); // TEST_VISUAL2 no longer requires the texture as release policy DESTROYED
1696 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1697 application.SendNotification();
1698 application.Render();
1700 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
1701 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1703 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1704 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1705 application.SendNotification();
1706 application.Render();
1708 tet_infoline( "Ensure a texture is not deleted as second visual used the NEVER release policy" );
1709 // Test texture was not deleted as TEST_VISUAL release policy is NEVER so it is still required.
1710 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1715 int UtcDaliImageVisualReleasePolicy05(void)
1717 ToolkitTestApplication application;
1718 tet_infoline( "UtcDaliImageVisualReleasePolicy05 Testing settung by string currents correct enum" );
1720 VisualFactory factory = VisualFactory::Get();
1722 Property::Map propertyMapNeverReleasePolicy;
1723 propertyMapNeverReleasePolicy.Insert( Visual::Property::TYPE, Visual::IMAGE );
1724 propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1725 propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
1726 propertyMapNeverReleasePolicy.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
1727 propertyMapNeverReleasePolicy.Insert( "releasePolicy" , "never" );
1729 Visual::Base imageVisualNever = factory.CreateVisual( propertyMapNeverReleasePolicy );
1731 Property::Map resultMap;
1732 imageVisualNever.CreatePropertyMap( resultMap );
1733 DALI_TEST_CHECK( ! resultMap.Empty() );
1735 DALI_TEST_EQUALS( ( resultMap.Find( ImageVisual::Property::RELEASE_POLICY ) )->Get<int>(), (int)ImageVisual::ReleasePolicy::NEVER, TEST_LOCATION );
1740 int UtcDaliImageVisualReleasePolicy06(void)
1742 ToolkitTestApplication application;
1743 tet_infoline( "UtcDaliImageVisualReleasePolicy06 Never Policy, texture should not be affected by Disabling and Enabling visual" );
1745 Visual::Base imageVisual= CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::NEVER );
1746 DALI_TEST_CHECK( imageVisual );
1748 TestGlAbstraction& gl = application.GetGlAbstraction();
1749 TraceCallStack& textureTrace = gl.GetTextureTrace();
1750 textureTrace.Enable(true);
1752 tet_infoline( "Register visual with control and ensure it has the only handle" );
1753 DummyControl actor = DummyControl::New(true);
1754 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1755 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1756 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
1758 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1760 application.SendNotification();
1761 application.Render(0);
1762 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1763 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1765 application.GetScene().Add( actor );
1767 // Wait for image to load
1768 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1770 application.SendNotification();
1771 application.Render(0);
1772 // Test renderer and texture created
1773 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1774 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1775 textureTrace.Reset();
1777 tet_infoline( "Disable Visual and check texture not affected" );
1778 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
1779 application.SendNotification();
1780 application.Render(0);
1781 tet_infoline( "Check renderer is destroyed when visual off stage" );
1782 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1783 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1784 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1785 textureTrace.Reset();
1787 tet_infoline( "Re-enable Visual and check texture not affected" );
1788 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, true );
1789 application.SendNotification();
1790 application.Render(0);
1791 tet_infoline( "Check texture not affected and renderer is destroyed when visual off stage" );
1792 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1793 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1794 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1799 int UtcDaliImageVisualReleasePolicy07(void)
1801 ToolkitTestApplication application;
1802 tet_infoline( "UtcDaliImageVisualReleasePolicy07 Two visuals with different policies sharing a texture DETACHED and DESTROYED" );
1804 tet_infoline( "Create first visual with DESTROYED release policy" );
1805 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
1808 tet_infoline( "Create second visual with DETACHED release policy");
1809 Visual::Base imageVisualDetached = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DETACHED );
1811 // Set up trace debug
1812 TestGlAbstraction& gl = application.GetGlAbstraction();
1813 TraceCallStack& textureTrace = gl.GetTextureTrace();
1814 textureTrace.Enable(true);
1816 tet_infoline( "Register visuals with control and ensure it has the only handles" );
1817 DummyControl actor = DummyControl::New(true);
1818 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1819 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualDestroyed );
1820 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL2, imageVisualDetached );
1821 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
1822 imageVisualDetached.Reset(); // reduce ref count so only the control keeps the visual alive.
1824 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1826 // Test initially zero renderers
1827 application.SendNotification();
1828 application.Render(0);
1829 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1830 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1832 application.GetScene().Add( actor );
1834 // Wait for image to load
1835 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1837 application.SendNotification();
1838 application.Render(0);
1839 tet_infoline( "Ensure a texture is created, shared amongst both visuals. Each visual has its own renderer" );
1840 DALI_TEST_EQUALS( actor.GetRendererCount(), 2u, TEST_LOCATION );
1841 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1843 // Test renderer removed when visual destroyed
1844 DALI_TEST_CHECK( actor.GetRendererCount() == 2u );
1845 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL2, false ); // TEST_VISUAL2 no longer requires the texture as release policy DETACHED
1846 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1847 application.SendNotification();
1848 application.Render();
1850 // Test texture was not deleted as TEST_VISUAL release policy is DESTROYED and is still required.
1851 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1853 dummyImpl.EnableVisual( DummyControl::Property::TEST_VISUAL, false );
1854 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1855 application.SendNotification();
1856 application.Render();
1858 tet_infoline( "Ensure a texture is not deleted as second visual used the DESTROYED release policy" );
1859 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1864 int UtcDaliImageVisualReleasePolicy08(void)
1866 ToolkitTestApplication application;
1867 tet_infoline( "UtcDaliImageVisualReleasePolicy08 Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy" );
1869 tet_infoline( "Create first visual with DESTROYED release policy" );
1870 Visual::Base imageVisualDestroyed = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::RELEASE_POLICY, ImageVisual::ReleasePolicy::DESTROYED );
1872 // Set up trace debug
1873 TestGlAbstraction& gl = application.GetGlAbstraction();
1874 TraceCallStack& textureTrace = gl.GetTextureTrace();
1875 textureTrace.Enable(true);
1877 tet_infoline( "Register visuals with control and ensure it has the only handles" );
1878 DummyControl actor = DummyControl::New(true);
1879 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1880 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisualDestroyed );
1881 imageVisualDestroyed.Reset(); // reduce ref count so only the control keeps the visual alive.
1883 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1885 // Test initially zero renderers
1886 application.SendNotification();
1887 application.Render(0);
1888 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1889 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
1890 textureTrace.Reset();
1892 application.GetScene().Add( actor );
1894 // Wait for image to load
1895 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1897 application.SendNotification();
1898 application.Render(0);
1899 tet_infoline( "Ensure a texture is created" );
1900 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1901 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1902 textureTrace.Reset();
1904 // Ensure TextureSet is same after detach/attach on stage when texture used the DESTROYED release policy
1905 // 1. Get TextureSet
1906 TextureSet textureSetBefore = actor.GetRendererAt( 0u ).GetTextures();
1908 // 2.Remove actor from stage. In this case, renderer also is deleted.
1909 tet_infoline( "Remove actor from stage" );
1910 application.GetScene().Remove( actor );
1911 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1912 application.SendNotification();
1913 application.Render();
1915 tet_infoline( "Ensure a texture is not deleted as visual used the DESTROYED release policy" );
1916 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
1917 textureTrace.Reset();
1919 // 3.Add actor in stage. In this case, renderer is created.
1920 tet_infoline( "Add actor in stage" );
1921 application.GetScene().Add( actor );
1922 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
1923 application.SendNotification();
1924 application.Render();
1925 tet_infoline( "Ensure a texture is not created again" );
1926 DALI_TEST_EQUALS( textureTrace.CountMethod("GenTextures"), 0, TEST_LOCATION );
1927 textureTrace.Reset();
1929 // 4.Compare Texture with before and after. textureSet need to be same because release policy is the DESTROYED.
1930 tet_infoline( "Ensure a textureSet is not deleted because it is used the DESTROYED release policy" );
1931 TextureSet textureSetAfter = actor.GetRendererAt( 0u ).GetTextures();
1932 DALI_TEST_CHECK( textureSetBefore == textureSetAfter );
1933 textureSetBefore.Reset();
1934 textureSetAfter.Reset();
1936 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
1937 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
1938 application.SendNotification();
1939 application.Render();
1940 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
1945 int UtcDaliImageVisualLoadPolicy01(void)
1947 ToolkitTestApplication application;
1948 tet_infoline( "UtcDaliImageVisualLoadPolicy01 Load a visual image before attaching to stage" );
1950 // Set up trace debug
1951 TestGlAbstraction& gl = application.GetGlAbstraction();
1952 TraceCallStack& textureTrace = gl.GetTextureTrace();
1953 textureTrace.Enable(true);
1955 tet_infoline( "Create visual with IMMEDIATE load policy" );
1956 VisualFactory factory = VisualFactory::Get();
1958 Property::Map propertyMap;
1959 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1960 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1961 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 20 );
1962 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 30 );
1963 propertyMap.Insert( "loadPolicy" , ImageVisual::LoadPolicy::IMMEDIATE );
1965 Visual::Base imageVisual = factory.CreateVisual( propertyMap );
1967 Property::Map resultMap;
1968 imageVisual.CreatePropertyMap( resultMap );
1969 DALI_TEST_CHECK( ! resultMap.Empty() );
1970 DALI_TEST_EQUALS( ( resultMap.Find( ImageVisual::Property::LOAD_POLICY ) )->Get<int>(), (int)ImageVisual::LoadPolicy::IMMEDIATE, TEST_LOCATION );
1972 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
1974 // Ensure texture has been uploaded
1975 application.SendNotification();
1976 application.Render();
1978 tet_infoline( "Ensure texture loading starts after visual created" );
1979 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
1980 textureTrace.Reset();
1982 tet_infoline( "Register visuals with control and ensure it has the only handles" );
1983 DummyControl actor = DummyControl::New(true);
1984 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
1985 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
1986 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
1988 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
1989 application.GetScene().Add( actor );
1990 tet_infoline( "Ensure nothing triggers another load as texure already loaded" );
1991 const unsigned int TIME_OUT_3_SECONDS = 3;
1992 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, TIME_OUT_3_SECONDS ), false, TEST_LOCATION );
1994 application.SendNotification();
1995 application.Render();
1997 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1998 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
2000 // Ensure texture is deleted when no longer needed (ref count was correct )
2001 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
2003 application.SendNotification();
2004 application.Render();
2006 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
2007 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
2012 int UtcDaliImageVisualLoadPolicy02(void)
2014 ToolkitTestApplication application;
2015 tet_infoline( "UtcDaliImageVisualLoadPolicy01 Load a visual image only after attached to stage" );
2017 // Set up trace debug
2018 TestGlAbstraction& gl = application.GetGlAbstraction();
2019 TraceCallStack& textureTrace = gl.GetTextureTrace();
2020 textureTrace.Enable(true);
2022 tet_infoline( "Create visual with IMMEDIATE load policy" );
2023 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
2025 const unsigned int TIME_OUT_3_SECONDS = 3;
2026 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1, TIME_OUT_3_SECONDS ), false, TEST_LOCATION );
2028 // Act on meeage queue even although nothing expected to load
2029 application.SendNotification();
2030 application.Render();
2032 tet_infoline( "Ensure texture is not generated yet" );
2033 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
2034 textureTrace.Reset();
2036 tet_infoline( "Register visuals with control and ensure it has the only handles" );
2037 DummyControl actor = DummyControl::New(true);
2038 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2039 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
2040 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2042 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2043 application.GetScene().Add( actor );
2044 tet_infoline( "Allow image time to load" );
2045 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2047 application.SendNotification();
2048 application.Render();
2050 tet_infoline( "Ensure texture generated and renderer created" );
2051 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
2052 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
2054 // Ensure texture is delete when no longer needed
2055 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
2057 application.SendNotification();
2058 application.Render();
2060 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
2061 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
2066 int UtcDaliImageVisualLoadPolicy03(void)
2068 ToolkitTestApplication application;
2069 tet_infoline( "UtcDaliImageVisualLoadPolicy03 Load a visual image and receive ResourceReady Signal when loaded" );
2071 const bool VISUAL_NOT_ENABLED( false ); // Instead of just passing 'false' into an API.
2073 // Set up trace debug
2074 TestGlAbstraction& gl = application.GetGlAbstraction();
2075 TraceCallStack& textureTrace = gl.GetTextureTrace();
2076 textureTrace.Enable(true);
2078 tet_infoline( "Create a control and connect to resource ready signal without adding to stage" );
2079 DummyControl actor = DummyControl::New(true);
2080 actor.ResourceReadySignal().Connect( &ResourceReadySignal);
2081 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2082 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2084 tet_infoline( "Create visual with IMMEDIATE load policy" );
2085 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
2087 tet_infoline( "Registering visual allows control to get a signal once loaded even if visual not enabled( not staged )" );
2088 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED );
2089 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2091 tet_infoline( "Allow image time to load resource" );
2092 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2093 application.SendNotification();
2094 application.Render();
2096 // Ensure texture has been uploaded
2097 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
2098 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2103 int UtcDaliImageVisualLoadPolicy04(void)
2105 ToolkitTestApplication application;
2106 tet_infoline( "UtcDaliImageVisualLoadPolicy04 First part Load a visual image before attaching to stage");
2107 tet_infoline( "Second part, Reuse the same image in aonther control and check resource ready signal fired" );
2109 const bool VISUAL_NOT_ENABLED( false ); // Instead of just passing false into an API.
2111 // Set up trace debug
2112 TestGlAbstraction& gl = application.GetGlAbstraction();
2113 TraceCallStack& textureTrace = gl.GetTextureTrace();
2114 textureTrace.Enable(true);
2116 tet_infoline( "Create a control and connect to resource ready signal" );
2117 DummyControl actor = DummyControl::New(true);
2118 actor.ResourceReadySignal().Connect( &ResourceReadySignal);
2119 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2120 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2122 tet_infoline( "Create visual with IMMEDIATE load policy" );
2123 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
2125 tet_infoline( "Registering visual allows control to get a signal once loaded even if visual not enabled( staged )" );
2126 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual, VISUAL_NOT_ENABLED );
2127 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2129 tet_infoline( "Allow image time to load" );
2130 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2131 application.SendNotification();
2132 application.Render();
2134 tet_infoline( "Testing texture is loaded and resource ready signal fired" );
2135 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
2136 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2138 tet_infoline( "Original control correctly signalled, now testing for signal with new Control reusing the image" );
2140 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
2141 Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
2142 DummyControl actor2 = DummyControl::New(true);
2143 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2144 actor2.ResourceReadySignal().Connect( &ResourceReadySignal);
2146 tet_infoline( "Registering visual this should trigger the loading signal as is already image loaded for previous control" );
2147 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual2 );
2148 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
2149 actor2.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2150 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 0 ), true, TEST_LOCATION ); // Not expecting any further loading as texture is being reused.
2151 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2156 int UtcDaliImageVisualLoadPolicy05(void)
2158 ToolkitTestApplication application;
2159 tet_infoline( "UtcDaliImageVisualLoadPolicy05 LoadPolicy::ATTACHED (default) First part Load a visual image before attaching to stage");
2160 tet_infoline( "Second part, Reuse the same image in aonther control and check resource ready signal fired" );
2161 // Set up trace debug
2162 TestGlAbstraction& gl = application.GetGlAbstraction();
2163 TraceCallStack& textureTrace = gl.GetTextureTrace();
2164 textureTrace.Enable(true);
2166 tet_infoline( "Create a control and connect to resource ready signal" );
2167 DummyControl actor = DummyControl::New(true);
2168 actor.ResourceReadySignal().Connect( &ResourceReadySignal);
2169 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2170 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2171 application.GetScene().Add( actor );
2173 tet_infoline( "Create visual with ATTACHED load policy" );
2174 Visual::Base imageVisual = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
2176 tet_infoline( "Registering visual allows control to get a signal once loaded" );
2177 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
2178 imageVisual.Reset(); // reduce ref count so only the control keeps the visual alive.
2180 tet_infoline( "Allow image time to load" );
2181 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2182 application.SendNotification();
2183 application.Render();
2185 tet_infoline( "Testing texture is loaded and resource ready signal fired" );
2186 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
2187 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2189 tet_infoline( "Original control correctly signalled, now testing for signal with new Control reusing the image" );
2191 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
2192 Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::ATTACHED );
2193 DummyControl actor2 = DummyControl::New(true);
2194 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2195 actor2.ResourceReadySignal().Connect( &ResourceReadySignal);
2197 tet_infoline( "Registering visual this should trigger the loading signal as is already image loaded for previous control" );
2198 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual2 );
2199 imageVisual2.Reset(); // reduce ref count so only the control keeps the visual alive.
2200 actor2.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2201 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 0 ), true, TEST_LOCATION ); // Not expecting any further loading as texture is being reused.
2202 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2208 int UtcDaliImageVisualOrientationCorrection(void)
2210 ToolkitTestApplication application;
2211 tet_infoline( "UtcDaliImageVisualOrientationCorrection Enabling OrientationCorrection should rotate an image with exif (90deg) orientation data with requested" );
2213 VisualFactory factory = VisualFactory::Get();
2214 tet_infoline( "Create visual with Orientation correction set OFF" );
2215 Property::Map propertyMap;
2216 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
2217 propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
2218 propertyMap.Insert( "orientationCorrection", false );
2219 Visual::Base imageVisual = factory.CreateVisual( propertyMap );
2221 tet_infoline( "Create control for visual, need to loaded it" );
2222 DummyControl actor = DummyControl::New(true);
2223 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2224 application.GetScene().Add( actor );
2226 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
2227 // Wait for image to load
2228 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2230 Vector2 originalImageSize;
2231 tet_infoline( "Get size of original visual to compare later with rotated image" );
2232 imageVisual.GetNaturalSize( originalImageSize );
2233 DALI_TEST_GREATER( originalImageSize.width, originalImageSize.height, TEST_LOCATION ); // Width and Height must be different for this test.
2234 imageVisual.Reset(); // remove handle so can unregister it and remove from cache
2235 dummyImpl.UnregisterVisual( DummyControl::Property::TEST_VISUAL );
2236 application.SendNotification();
2237 application.Render();
2239 tet_infoline( "Create visual with Orientation correction set ON " );
2240 propertyMap.Clear();
2241 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
2242 propertyMap.Insert( ImageVisual::Property::URL, TEST_ROTATED_IMAGE );
2243 propertyMap.Insert( ImageVisual::Property::ORIENTATION_CORRECTION, true );
2244 imageVisual = factory.CreateVisual( propertyMap );
2246 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual );
2247 // Wait for image to load
2248 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2250 Vector2 rotatedImageSize;
2251 imageVisual.GetNaturalSize( rotatedImageSize );
2252 tet_infoline( "Confirm that visual has rotated" );
2253 DALI_TEST_EQUALS( originalImageSize.width, rotatedImageSize.height , TEST_LOCATION );
2254 DALI_TEST_EQUALS( originalImageSize.height, rotatedImageSize.width , TEST_LOCATION );
2256 Property::Map resultMap;
2257 imageVisual.CreatePropertyMap( resultMap );
2259 // check the Property::ORIENTATION_CORRECTION value from the returned map
2260 Property::Value* typeValue = resultMap.Find( ImageVisual::Property::ORIENTATION_CORRECTION, Property::BOOLEAN );
2261 DALI_TEST_EQUALS( typeValue->Get<bool>(), true, TEST_LOCATION );
2266 int UtcDaliImageVisualCustomShader(void)
2268 ToolkitTestApplication application;
2269 tet_infoline( "UtcDaliImageVisualCustomShader Test custom shader" );
2271 VisualFactory factory = VisualFactory::Get();
2272 Property::Map properties;
2273 Property::Map shader;
2274 const std::string vertexShader = "Foobar";
2275 const std::string fragmentShader = "Foobar";
2276 shader[Visual::Shader::Property::FRAGMENT_SHADER] = fragmentShader;
2277 shader[Visual::Shader::Property::VERTEX_SHADER] = vertexShader;
2279 properties[Visual::Property::TYPE] = Visual::IMAGE;
2280 properties[Visual::Property::SHADER] = shader;
2281 properties[ImageVisual::Property::URL] = TEST_IMAGE_FILE_NAME;
2283 Visual::Base visual = factory.CreateVisual( properties );
2285 // trigger creation through setting on stage
2286 DummyControl dummy = DummyControl::New( true );
2287 Impl::DummyControl& dummyImpl = static_cast< Impl::DummyControl& >( dummy.GetImplementation() );
2288 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
2290 dummy.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2291 dummy.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2292 application.GetScene().Add( dummy );
2294 application.SendNotification();
2295 application.Render();
2297 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2299 Renderer renderer = dummy.GetRendererAt( 0 );
2300 Shader shader2 = renderer.GetShader();
2301 Property::Value value = shader2.GetProperty( Shader::Property::PROGRAM );
2302 Property::Map* map = value.GetMap();
2303 DALI_TEST_CHECK( map );
2305 Property::Value* fragment = map->Find( "fragment" ); // fragment key name from shader-impl.cpp
2306 DALI_TEST_EQUALS( fragmentShader, fragment->Get< std::string >(), TEST_LOCATION );
2308 Property::Value* vertex = map->Find( "vertex" ); // vertex key name from shader-impl.cpp
2309 DALI_TEST_EQUALS( vertexShader, vertex->Get< std::string >(), TEST_LOCATION );
2313 shader[Visual::Shader::Property::HINTS] = Shader::Hint::OUTPUT_IS_TRANSPARENT;
2314 properties[Visual::Property::SHADER] = shader;
2316 Visual::Base visual1 = factory.CreateVisual( properties );
2318 // trigger creation through setting on stage
2319 DummyControl dummy1 = DummyControl::New( true );
2320 Impl::DummyControl& dummyImpl1 = static_cast< Impl::DummyControl& >( dummy1.GetImplementation() );
2321 dummyImpl1.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual1 );
2322 dummy1.SetProperty( Actor::Property::SIZE, Vector2( 200, 200 ) );
2323 dummy1.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
2324 application.GetScene().Add( dummy1 );
2326 TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
2327 glAbstraction.EnableEnableDisableCallTrace( true );
2329 application.SendNotification();
2330 application.Render();
2332 TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
2333 std::ostringstream blendStr;
2334 blendStr << GL_BLEND;
2335 DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
2341 void ResourceReadyLoadNext( Control control )
2343 static int callNumber = 0;
2345 gResourceReadySignalFired = true;
2346 gReadyIds.push_back(control.GetProperty< int >( Actor::Property::ID ));
2348 if( callNumber == 0 )
2350 DALI_TEST_EQUALS( control.GetVisualResourceStatus(DummyControl::Property::TEST_VISUAL), Toolkit::Visual::ResourceStatus::FAILED, TEST_LOCATION );
2352 tet_infoline( "Create visual with loaded image from within the signal handler" );
2353 VisualFactory factory = VisualFactory::Get();
2354 Visual::Base imageVisual = factory.CreateVisual( TEST_IMAGE_FILE_NAME, ImageDimensions{20,30} );
2356 Impl::DummyControl& controlImpl = static_cast<Impl::DummyControl&>(control.GetImplementation());
2357 controlImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual ); // This should trigger another signal.
2362 tet_infoline( "3rd signal called" );
2363 DALI_TEST_CHECK(true);
2367 int UtcDaliImageVisualLoadReady01(void)
2369 ToolkitTestApplication application;
2370 tet_infoline( "UtcDaliImageVisualLoadReady01");
2371 tet_infoline( "First part: Load an image visual for one resource, then another image visual for a second resource.");
2372 tet_infoline( "Second part, In the ready signal for the second image visual, add a 3rd visual with the first URL" );
2373 tet_infoline( "Should get a ready signal for all three visuals");
2377 tet_infoline( "Create a control and connect to resource ready signal" );
2378 DummyControl actor = DummyControl::New(true);
2379 int actor1Id = actor.GetProperty< int >( Actor::Property::ID );
2380 actor.ResourceReadySignal().Connect( &ResourceReadySignal);
2381 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
2382 actor.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2383 application.GetScene().Add(actor);
2385 tet_infoline( "Create visual with IMMEDIATE load policy" );
2386 Visual::Base imageVisual1 = CreateVisualWithPolicy( TEST_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
2388 tet_infoline( "Registering visual allows control to get a signal once loaded even if visual not enabled( staged )" );
2389 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual1 );
2392 tet_infoline( "Allow image time to load" );
2393 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2394 application.SendNotification();
2395 application.Render();
2397 tet_infoline( "Testing texture is loaded and resource ready signal fired" );
2398 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2399 DALI_TEST_EQUALS( gReadyIds[0], actor1Id, TEST_LOCATION );
2402 tet_infoline( "Original control correctly signalled, now testing failing image" );
2404 gResourceReadySignalFired = false; // Reset signal check ready for testing next Control
2407 Visual::Base imageVisual2 = CreateVisualWithPolicy( TEST_BROKEN_IMAGE_FILE_NAME, ImageVisual::Property::LOAD_POLICY, ImageVisual::LoadPolicy::IMMEDIATE );
2409 DummyControl actor2 = DummyControl::New(true);
2410 int actor2Id = actor2.GetProperty< int >( Actor::Property::ID );
2411 Impl::DummyControl& dummyImpl2 = static_cast<Impl::DummyControl&>(actor2.GetImplementation());
2412 actor2.ResourceReadySignal().Connect( &ResourceReadyLoadNext);
2414 tet_infoline( "Registering visual this should trigger the ready signal when the image fails to load" );
2415 dummyImpl2.RegisterVisual( DummyControl::Property::TEST_VISUAL, imageVisual2 );
2417 actor2.SetProperty( Actor::Property::SIZE, Vector2(200.f, 200.f) );
2418 application.GetScene().Add(actor2);
2420 tet_infoline( "Wait for loading thread to finish");
2421 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
2422 DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION );
2424 DALI_TEST_EQUALS( gReadyIds[0], actor2Id, TEST_LOCATION);
2426 tet_infoline( "Check for 3rd signal");
2427 application.SendNotification();
2428 DALI_TEST_EQUALS( gReadyIds.size(), 2, TEST_LOCATION );
2429 DALI_TEST_EQUALS( gReadyIds[1], actor2Id, TEST_LOCATION);