2 * Copyright (c) 2017 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.
19 #include <dali-toolkit-test-suite-utils.h>
20 #include <toolkit-timer.h>
21 #include <toolkit-bitmap-loader.h>
22 #include <toolkit-event-thread-callback.h>
23 #include <dali/public-api/rendering/renderer.h>
24 #include <dali/public-api/rendering/texture-set.h>
25 #include <dali/public-api/rendering/shader.h>
26 #include <dali/devel-api/images/nine-patch-image.h>
27 #include <dali/devel-api/object/handle-devel.h>
28 #include <dali-toolkit/devel-api/align-enums.h>
29 #include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
30 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
31 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
32 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
33 #include <dali-toolkit/devel-api/controls/control-devel.h>
34 #include <dali-toolkit/dali-toolkit.h>
35 #include "dummy-control.h"
38 using namespace Dali::Toolkit;
40 void dali_image_visual_startup(void)
42 test_return_value = TET_UNDEF;
45 void dali_image_visual_cleanup(void)
47 test_return_value = TET_PASS;
52 const char* TEST_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/gallery-small-1.jpg";
53 const char* TEST_LARGE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/tbcol.png";
54 const char* TEST_SMALL_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/icon-edit.png";
55 const char* TEST_REMOTE_IMAGE_FILE_NAME = "https://www.tizen.org/sites/all/themes/tizen_theme/logo.png";
56 const char* TEST_INVALID_FILE_NAME = TEST_RESOURCE_DIR "/invalid.jpg";
57 const char* TEST_REMOTE_INVALID_FILE_NAME = "https://www.tizen.org/invalid.png";
58 const char* TEST_MASK_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/mask.png";
62 Actor CreateActorWithImageVisual(const Property::Map& map)
64 VisualFactory factory = VisualFactory::Get();
65 DummyControl actor = DummyControl::New();
66 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
67 Visual::Base visual = factory.CreateVisual( map );
68 DALI_TEST_CHECK( visual );
69 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
70 actor.SetSize( 200.f, 200.f );
71 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
75 void TestVisualRender( ToolkitTestApplication& application,
78 std::size_t expectedSamplers = 0,
79 ImageDimensions imageDimensions = ImageDimensions(),
80 Integration::ResourcePointer resourcePtr = Integration::ResourcePointer())
82 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
83 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
87 // set the image size, for test case, this needs to be set before loading started
88 application.GetPlatform().SetClosestImageSize( Vector2(imageDimensions.GetWidth(), imageDimensions.GetHeight()) );
91 actor.SetSize( 200.f, 200.f );
92 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
94 Stage::GetCurrent().Add( actor );
96 application.SendNotification(); // Send messages to update
97 application.Render(); // process update and render
98 application.SendNotification(); // process any signals to event
102 DALI_TEST_EQUALS( application.GetPlatform().WasCalled(TestPlatformAbstraction::LoadResourceSynchronouslyFunc ), true, TEST_LOCATION);
105 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
108 static void TestMixColor( Visual::Base visual, Property::Index mixColorIndex, const Vector4& testColor )
111 visual.CreatePropertyMap(map);
112 Property::Value* value = map.Find( mixColorIndex );
113 DALI_TEST_CHECK( value );
115 DALI_TEST_CHECK( value->Get( mixColor1 ) );
116 DALI_TEST_EQUALS( mixColor1, Vector3(testColor), 0.001, TEST_LOCATION );
118 value = map.Find( DevelVisual::Property::MIX_COLOR );
119 DALI_TEST_CHECK( value );
121 DALI_TEST_CHECK( value->Get( mixColor2 ) );
122 DALI_TEST_EQUALS( mixColor2, testColor, 0.001, TEST_LOCATION );
124 value = map.Find( DevelVisual::Property::OPACITY );
125 DALI_TEST_CHECK( value );
127 DALI_TEST_CHECK( value->Get( opacity ) );
128 DALI_TEST_EQUALS( opacity, testColor.a, 0.001, TEST_LOCATION );
133 int UtcDaliImageVisualPropertyMap(void)
135 ToolkitTestApplication application;
136 tet_infoline( "Request image visual with a Property::Map" );
138 VisualFactory factory = VisualFactory::Get();
139 DALI_TEST_CHECK( factory );
141 Property::Map propertyMap;
142 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
143 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
145 Visual::Base visual = factory.CreateVisual( propertyMap );
146 DALI_TEST_CHECK( visual );
148 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
149 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
151 TestGlAbstraction& gl = application.GetGlAbstraction();
152 TraceCallStack& textureTrace = gl.GetTextureTrace();
153 textureTrace.Enable(true);
155 DummyControl actor = DummyControl::New();
156 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
157 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
159 actor.SetSize( 200.f, 200.f );
160 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
162 Stage::GetCurrent().Add( actor );
163 application.SendNotification();
164 application.Render();
166 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
168 application.SendNotification();
169 application.Render();
171 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
173 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
175 Stage::GetCurrent().Remove( actor );
176 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
182 int UtcDaliImageVisualRemoteImageLoad(void)
184 ToolkitTestApplication application;
185 tet_infoline( "Request remote image visual with a Property::Map" );
187 VisualFactory factory = VisualFactory::Get();
188 DALI_TEST_CHECK( factory );
190 Property::Map propertyMap;
191 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
192 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
194 Visual::Base visual = factory.CreateVisual( propertyMap );
195 DALI_TEST_CHECK( visual );
197 TestGlAbstraction& gl = application.GetGlAbstraction();
198 TraceCallStack& textureTrace = gl.GetTextureTrace();
199 textureTrace.Enable(true);
201 DummyControl actor = DummyControl::New();
202 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
203 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
205 actor.SetSize( 200.f, 200.f );
206 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
208 Stage::GetCurrent().Add( actor );
209 application.SendNotification();
211 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
213 application.SendNotification();
214 application.Render();
216 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
217 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
219 Stage::GetCurrent().Remove( actor );
220 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
225 int UtcDaliImageVisualTextureReuse1(void)
227 ToolkitTestApplication application;
228 tet_infoline( "Request remote image visual with a Property::Map; request a second visual with the same property map - should reuse texture" );
230 Property::Map propertyMap;
231 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
232 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
234 TestGlAbstraction& gl = application.GetGlAbstraction();
235 TraceCallStack& textureTrace = gl.GetTextureTrace();
236 textureTrace.Enable(true);
237 TraceCallStack& drawTrace = gl.GetDrawTrace();
238 drawTrace.Enable(true);
240 Actor actor = CreateActorWithImageVisual( propertyMap );
241 Stage::GetCurrent().Add( actor );
242 application.SendNotification();
244 // Wait for image to load
245 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
247 application.SendNotification();
248 application.Render();
250 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
251 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
252 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
253 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
254 textureTrace.Reset();
257 Actor actor2 = CreateActorWithImageVisual( propertyMap );
258 Stage::GetCurrent().Add(actor2);
260 application.SendNotification(); // Send messages to update
261 application.Render(); // process update and render
262 application.SendNotification(); // process any signals to event
264 DALI_TEST_EQUALS( actor2.GetRendererCount(), 1u, TEST_LOCATION );
266 tet_infoline("Test that 2 draw calls occur with no new texture gens/binds, i.e. both\n"
267 "draw calls use the same texture as the previous draw call\n" );
269 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
270 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
271 DALI_TEST_EQUALS( textureTrace.CountMethod("BindTexture"), 0, TEST_LOCATION );
273 tet_infoline("Test that removing 1 actor doesn't delete the texture\n");
275 Stage::GetCurrent().Remove( actor );
276 application.SendNotification();
277 application.Render();
279 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
280 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 0, TEST_LOCATION );
282 tet_infoline("Test that removing last actor does delete the texture\n");
284 Stage::GetCurrent().Remove( actor2 );
285 application.SendNotification();
286 application.Render();
288 DALI_TEST_CHECK( actor2.GetRendererCount() == 0u );
289 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
295 int UtcDaliImageVisualTextureReuse2(void)
297 ToolkitTestApplication application;
298 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" );
300 Property::Map propertyMap;
301 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
302 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
304 TestGlAbstraction& gl = application.GetGlAbstraction();
305 TraceCallStack& textureTrace = gl.GetTextureTrace();
306 textureTrace.Enable(true);
307 TraceCallStack& drawTrace = gl.GetDrawTrace();
308 drawTrace.Enable(true);
310 Actor actor = CreateActorWithImageVisual( propertyMap );
311 Stage::GetCurrent().Add( actor );
312 application.SendNotification();
314 // Wait for image to load
315 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
317 application.SendNotification();
318 application.Render();
320 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
321 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
322 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
323 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION );
324 textureTrace.Reset();
327 propertyMap.Insert( ImageVisual::Property::SAMPLING_MODE, Dali::SamplingMode::NEAREST );
328 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, 100 );
329 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, 100 );
330 Actor actor2 = CreateActorWithImageVisual( propertyMap );
331 Stage::GetCurrent().Add(actor2);
333 application.SendNotification();
335 // Wait for image to load
336 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
338 application.SendNotification();
339 application.Render();
341 DALI_TEST_EQUALS( actor2.GetRendererCount(), 1u, TEST_LOCATION );
343 tet_infoline("Test that 2 draw calls occur with 1 new texture gen/bind, i.e. both "
344 "renderers are using different textures\n" );
346 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), true, TEST_LOCATION );
347 DALI_TEST_EQUALS( drawTrace.CountMethod("DrawArrays"), 2, TEST_LOCATION );
348 TraceCallStack::NamedParams tex1;
349 tex1["texture"] = "1";
350 TraceCallStack::NamedParams tex2;
351 tex1["texture"] = "2";
352 DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex1), true, TEST_LOCATION );
353 DALI_TEST_EQUALS( textureTrace.FindMethodAndParams("BindTexture", tex2), true, TEST_LOCATION );
355 tet_infoline("Test that removing 1 actor deletes it's texture\n");
357 Stage::GetCurrent().Remove( actor );
358 application.SendNotification();
359 application.Render();
361 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
362 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 1, TEST_LOCATION );
364 tet_infoline("Test that removing last actor deletes it's texture\n");
366 Stage::GetCurrent().Remove( actor2 );
367 application.SendNotification();
368 application.Render();
370 DALI_TEST_CHECK( actor2.GetRendererCount() == 0u );
371 DALI_TEST_EQUALS( textureTrace.CountMethod("DeleteTextures"), 2, TEST_LOCATION );
377 int UtcDaliImageVisualImageHandle(void)
379 ToolkitTestApplication application;
380 tet_infoline( "Request image visual with an image handle" );
382 VisualFactory factory = VisualFactory::Get();
383 DALI_TEST_CHECK( factory );
385 Image image = ResourceImage::New(TEST_IMAGE_FILE_NAME);
386 Visual::Base visual = factory.CreateVisual( image );
388 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
389 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
392 const int height=513;
394 Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
395 bitmap->GetPackedPixelsProfile()->ReserveBuffer( Pixel::RGBA8888, width, height,width, height );
397 TestGlAbstraction& gl = application.GetGlAbstraction();
398 TraceCallStack& textureTrace = gl.GetTextureTrace();
399 textureTrace.Enable(true);
401 DummyControl actor = DummyControl::New();
402 TestVisualRender( application, actor, visual, 1u,
403 ImageDimensions(width, height),
404 Integration::ResourcePointer(bitmap) );
406 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
410 int UtcDaliImageVisualCustomWrapModePixelArea(void)
412 ToolkitTestApplication application;
413 tet_infoline( "Request image visual with a Property::Map, test custom wrap mode and pixel area with atlasing" );
415 VisualFactory factory = VisualFactory::Get();
416 DALI_TEST_CHECK( factory );
418 // Test wrap mode with atlasing. Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
421 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
423 Property::Map propertyMap;
424 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
425 propertyMap.Insert( ImageVisual::Property::URL, TEST_SMALL_IMAGE_FILE_NAME );
426 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
427 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
428 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
429 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
430 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
431 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
432 propertyMap.Insert( DevelImageVisual::Property::ATLASING, true );
434 Visual::Base visual = factory.CreateVisual( propertyMap );
435 DALI_TEST_CHECK( visual );
437 TestGlAbstraction& gl = application.GetGlAbstraction();
438 TraceCallStack& textureTrace = gl.GetTextureTrace();
439 textureTrace.Enable(true);
440 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
441 texParameterTrace.Enable( true );
443 DummyControl actor = DummyControl::New();
444 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
445 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
446 actor.SetSize(2000, 2000);
447 actor.SetParentOrigin(ParentOrigin::CENTER);
448 Stage::GetCurrent().Add( actor );
451 application.SendNotification();
452 application.Render();
454 BitmapLoader loader = BitmapLoader::GetLatestCreated();
455 DALI_TEST_CHECK( loader );
456 loader.WaitForLoading();// waiting until the image to be loaded
457 DALI_TEST_CHECK( loader.IsLoaded() );
459 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
461 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
463 // WITH atlasing, the wrapping is handled manually in shader, so the following gl function should not be called
464 std::stringstream out;
465 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
466 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
468 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
469 DALI_TEST_CHECK( !texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
471 // test the uniforms which used to handle the wrap mode
472 Renderer renderer = actor.GetRendererAt( 0u );
473 DALI_TEST_CHECK( renderer );
475 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
476 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
477 Vector4 pixelAreaUniform;
478 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
479 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
481 Property::Value wrapModeValue = renderer.GetProperty( renderer.GetPropertyIndex( "wrapMode" ) );
482 Vector2 wrapMode( WrapMode::MIRRORED_REPEAT-1, WrapMode::REPEAT-1 );
483 DALI_TEST_EQUALS( wrapModeValue.Get<Vector2>(), wrapMode, TEST_LOCATION );
484 Vector2 wrapModeUniform;
485 DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "wrapMode", wrapModeUniform ) );
486 DALI_TEST_EQUALS( wrapMode, wrapModeUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
489 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
494 int UtcDaliImageVisualCustomWrapModeNoAtlas(void)
496 ToolkitTestApplication application;
497 tet_infoline( "Request image visual with a Property::Map, test custom wrap mode and pixel area without atlasing" );
499 VisualFactory factory = VisualFactory::Get();
500 DALI_TEST_CHECK( factory );
502 // Test wrap mode without atlasing. Image with a size bigger than 512*512 will NOT be uploaded as a part of the atlas.
504 const int height=600;
505 const Vector4 pixelArea(-0.5f, -0.5f, 2.f, 2.f);
507 Property::Map propertyMap;
508 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
509 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
510 propertyMap.Insert( ImageVisual::Property::DESIRED_WIDTH, width );
511 propertyMap.Insert( ImageVisual::Property::DESIRED_HEIGHT, height );
512 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
513 propertyMap.Insert( ImageVisual::Property::PIXEL_AREA, pixelArea );
514 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_U, WrapMode::MIRRORED_REPEAT );
515 propertyMap.Insert( ImageVisual::Property::WRAP_MODE_V, WrapMode::REPEAT );
517 Visual::Base visual = factory.CreateVisual( propertyMap );
518 DALI_TEST_CHECK( visual );
520 TestGlAbstraction& gl = application.GetGlAbstraction();
521 TraceCallStack& textureTrace = gl.GetTextureTrace();
522 textureTrace.Enable(true);
523 TraceCallStack& texParameterTrace = gl.GetTexParameterTrace();
524 texParameterTrace.Enable( true );
526 DummyControl actor = DummyControl::New();
527 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
528 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
529 actor.SetSize(2000, 2000);
530 actor.SetParentOrigin(ParentOrigin::CENTER);
531 Stage::GetCurrent().Add( actor );
534 application.SendNotification();
535 application.Render();
537 BitmapLoader loader = BitmapLoader::GetLatestCreated();
538 DALI_TEST_CHECK( loader );
539 loader.WaitForLoading();// waiting until the image to be loaded
540 DALI_TEST_CHECK( loader.IsLoaded() );
542 DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
544 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
546 // WITHOUT atlasing, the wrapping is handled by setting gl texture parameters
547 std::stringstream out;
548 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_S << ", " << GL_MIRRORED_REPEAT;
549 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
551 out << GL_TEXTURE_2D << ", " << GL_TEXTURE_WRAP_T << ", " << GL_REPEAT;
552 DALI_TEST_CHECK( texParameterTrace.FindMethodAndParams("TexParameteri", out.str()) );
554 // test the uniforms which used to handle the wrap mode
555 Renderer renderer = actor.GetRendererAt( 0u );
556 DALI_TEST_CHECK( renderer );
558 Property::Value pixelAreaValue = renderer.GetProperty( renderer.GetPropertyIndex( "pixelArea" ) );
559 DALI_TEST_EQUALS( pixelAreaValue.Get<Vector4>(), pixelArea, TEST_LOCATION );
560 Vector4 pixelAreaUniform;
561 DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "pixelArea", pixelAreaUniform ) );
562 DALI_TEST_EQUALS( pixelArea, pixelAreaUniform, Math::MACHINE_EPSILON_100, TEST_LOCATION );
564 Property::Index wrapModeIndex = renderer.GetPropertyIndex( "wrapMode" );
565 DALI_TEST_CHECK(wrapModeIndex == Property::INVALID_INDEX);
568 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
573 int UtcDaliImageVisualAnimateMixColor(void)
575 ToolkitTestApplication application;
576 tet_infoline( "Animate mix color" );
578 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
580 VisualFactory factory = VisualFactory::Get();
581 Property::Map propertyMap;
582 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
583 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
584 propertyMap.Insert("mixColor", Color::BLUE);
585 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
586 Visual::Base visual = factory.CreateVisual( propertyMap );
588 DummyControl actor = DummyControl::New(true);
589 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
590 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
592 actor.SetSize(2000, 2000);
593 actor.SetParentOrigin(ParentOrigin::CENTER);
594 actor.SetColor(Color::BLACK);
595 Stage::GetCurrent().Add(actor);
597 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
599 Renderer renderer = actor.GetRendererAt(0);
600 Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::MIX_COLOR );
601 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
602 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
604 tet_infoline("Test that the renderer has the mixColor property");
605 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
607 const Vector4 TARGET_MIX_COLOR( 1.0f, 0.0f, 0.0f, 0.5f );
610 map["target"] = "testVisual";
611 map["property"] = "mixColor";
612 map["initialValue"] = Color::MAGENTA;
613 map["targetValue"] = TARGET_MIX_COLOR;
614 map["animator"] = Property::Map()
615 .Add("alphaFunction", "LINEAR")
616 .Add("timePeriod", Property::Map()
618 .Add("duration", 4.0f));
620 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
622 Animation animation = dummyImpl.CreateTransition( transition );
624 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
625 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
627 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
630 application.SendNotification();
631 application.Render(0); // Ensure animation starts
632 application.Render(2000u); // Halfway point
633 Vector4 testColor(1.0f, 0.0f, 0.5f, 0.75f );
635 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Vector4(0.5f, 0.5f, 0.5f, 1.0f )), true, TEST_LOCATION );
636 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(testColor)), true, TEST_LOCATION );
637 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", testColor.a), true, TEST_LOCATION );
639 application.Render(2000u); // Halfway point between blue and white
641 DALI_TEST_EQUALS( actor.GetCurrentColor(), Color::WHITE, TEST_LOCATION );
642 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("uColor", Color::WHITE ), true, TEST_LOCATION );
643 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector3>("mixColor", Vector3(TARGET_MIX_COLOR)), true, TEST_LOCATION );
644 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", TARGET_MIX_COLOR.a), true, TEST_LOCATION );
646 TestMixColor( visual, DevelVisual::Property::MIX_COLOR, TARGET_MIX_COLOR );
648 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
649 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
654 int UtcDaliImageVisualAnimateOpacity(void)
656 ToolkitTestApplication application;
657 tet_infoline( "Animate image visual opacity" );
659 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
661 VisualFactory factory = VisualFactory::Get();
662 Property::Map propertyMap;
663 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
664 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
665 propertyMap.Insert("opacity", 0.5f);
666 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
667 Visual::Base visual = factory.CreateVisual( propertyMap );
669 DummyControl actor = DummyControl::New(true);
670 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
671 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
673 actor.SetSize(2000, 2000);
674 actor.SetParentOrigin(ParentOrigin::CENTER);
675 actor.SetColor(Color::BLACK);
676 Stage::GetCurrent().Add(actor);
678 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
680 Renderer renderer = actor.GetRendererAt(0);
681 tet_infoline("Test that the renderer has the opacity property");
682 Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::OPACITY );
683 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
686 Property::Value blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
687 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
690 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." );
693 map["target"] = "testVisual";
694 map["property"] = "opacity";
695 map["targetValue"] = 1.0f;
696 map["animator"] = Property::Map()
697 .Add("alphaFunction", "LINEAR")
698 .Add("timePeriod", Property::Map()
700 .Add("duration", 4.0f));
702 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
703 Animation animation = dummyImpl.CreateTransition( transition );
706 application.SendNotification();
707 application.Render(0); // Ensure animation starts
708 application.Render(2000u); // Halfway point through animation
709 application.SendNotification(); // Handle any signals
711 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", 0.75f), true, TEST_LOCATION );
713 application.Render(2001u); // end
714 application.SendNotification(); // ensure animation finished signal is sent
716 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", 1.0f), true, TEST_LOCATION );
718 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
719 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::AUTO, TEST_LOCATION );
724 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." );
727 map["target"] = "testVisual";
728 map["property"] = DevelVisual::Property::OPACITY;
729 map["targetValue"] = 0.1f;
730 map["animator"] = Property::Map()
731 .Add("alphaFunction", "LINEAR")
732 .Add("timePeriod", Property::Map()
734 .Add("duration", 4.0f));
736 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
737 Animation animation = dummyImpl.CreateTransition( transition );
740 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
741 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
743 application.SendNotification();
744 application.Render(0); // Ensure animation starts
745 application.Render(2000u); // Halfway point
746 application.SendNotification();
748 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", 0.55f), true, TEST_LOCATION );
750 application.Render(2016u); // end
751 application.SendNotification();
753 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<float>("opacity", 0.1f), true, TEST_LOCATION );
755 blendModeValue = renderer.GetProperty( Renderer::Property::BLEND_MODE );
756 DALI_TEST_EQUALS( blendModeValue.Get<int>(), (int)BlendMode::ON, TEST_LOCATION );
763 int UtcDaliImageVisualAnimatePixelArea(void)
765 ToolkitTestApplication application;
766 tet_infoline( "ImageVisual animate pixel area" );
768 application.GetPlatform().SetClosestImageSize( Vector2(100, 100) );
770 VisualFactory factory = VisualFactory::Get();
771 Property::Map propertyMap;
772 propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
773 propertyMap.Insert(ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
774 propertyMap.Insert("mixColor", Color::BLUE);
775 propertyMap.Insert(ImageVisual::Property::SYNCHRONOUS_LOADING, true);
776 Visual::Base visual = factory.CreateVisual( propertyMap );
778 DummyControl actor = DummyControl::New(true);
779 Impl::DummyControl& dummyImpl = static_cast<Impl::DummyControl&>(actor.GetImplementation());
780 dummyImpl.RegisterVisual( DummyControl::Property::TEST_VISUAL, visual );
782 actor.SetSize(2000, 2000);
783 actor.SetParentOrigin(ParentOrigin::CENTER);
784 actor.SetColor(Color::BLACK);
785 Stage::GetCurrent().Add(actor);
787 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION);
789 Renderer renderer = actor.GetRendererAt(0);
790 Property::Index index = DevelHandle::GetPropertyIndex( renderer, DevelVisual::Property::MIX_COLOR );
792 tet_infoline("Test that the renderer has the mixColor property");
793 DALI_TEST_CHECK( index != Property::INVALID_INDEX );
795 // TransitionData only takes string keys
797 map["target"] = "testVisual";
798 map["property"] = "pixelArea";
799 map["initialValue"] = Vector4( 0,0,0,1 );
800 map["targetValue"] = Vector4( 0,0,1,1 ); // Animate width from zero to full
801 map["animator"] = Property::Map()
802 .Add("alphaFunction", "LINEAR")
803 .Add("timePeriod", Property::Map()
805 .Add("duration", 4.0f));
807 Dali::Toolkit::TransitionData transition = TransitionData::New( map );
809 Animation animation = dummyImpl.CreateTransition( transition );
810 animation.AnimateTo( Property(actor, Actor::Property::COLOR), Color::WHITE );
813 application.SendNotification();
814 application.Render(0); // Ensure animation starts
815 application.Render(2000u); // Halfway point
817 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4(0.0f, 0.0f, 0.5f, 1.0f )), true, TEST_LOCATION );
819 application.Render(2000u); // End of animation
821 DALI_TEST_EQUALS( application.GetGlAbstraction().CheckUniformValue<Vector4>("pixelArea", Vector4( 0.0f, 0.0f, 1.0f, 1.0f )), true, TEST_LOCATION );
826 int UtcDaliImageVisualTextureCancelRemoteLoad(void)
828 ToolkitTestApplication application;
829 tet_infoline( "Request remote image visual, then destroy visual to cancel load" );
831 Property::Map propertyMap;
832 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
833 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_IMAGE_FILE_NAME );
835 TestGlAbstraction& gl = application.GetGlAbstraction();
836 TraceCallStack& textureTrace = gl.GetTextureTrace();
837 textureTrace.Enable(true);
838 TraceCallStack& drawTrace = gl.GetDrawTrace();
839 drawTrace.Enable(true);
841 Actor actor = CreateActorWithImageVisual( propertyMap );
842 Stage::GetCurrent().Add( actor );
843 application.SendNotification();
845 Stage::GetCurrent().Remove( actor );
846 application.SendNotification();
848 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
849 DALI_TEST_EQUALS( textureTrace.FindMethod("GenTextures"), false, TEST_LOCATION );
850 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), false, TEST_LOCATION );
851 DALI_TEST_EQUALS( drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION );
856 int UtcDaliImageVisualSetInvalidAsyncImage(void)
858 ToolkitTestApplication application;
859 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
861 VisualFactory factory = VisualFactory::Get();
862 DALI_TEST_CHECK( factory );
864 Property::Map propertyMap;
865 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
866 propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
868 Visual::Base visual = factory.CreateVisual( propertyMap );
869 DALI_TEST_CHECK( visual );
871 TestGlAbstraction& gl = application.GetGlAbstraction();
872 TraceCallStack& textureTrace = gl.GetTextureTrace();
873 textureTrace.Enable(true);
875 DummyControl actor = DummyControl::New();
876 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
877 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
879 actor.SetSize( 200.f, 200.f );
880 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
882 Stage::GetCurrent().Add( actor );
884 application.SendNotification();
885 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
887 application.SendNotification();
888 application.Render();
890 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
891 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
893 Stage::GetCurrent().Remove( actor );
894 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
899 int UtcDaliImageVisualSetInvalidSyncImage(void)
901 ToolkitTestApplication application;
902 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
904 VisualFactory factory = VisualFactory::Get();
905 DALI_TEST_CHECK( factory );
907 Property::Map propertyMap;
908 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
909 propertyMap.Insert( ImageVisual::Property::URL, TEST_INVALID_FILE_NAME );
910 propertyMap.Insert( ImageVisual::Property::SYNCHRONOUS_LOADING, true );
912 Visual::Base visual = factory.CreateVisual( propertyMap );
913 DALI_TEST_CHECK( visual );
915 TestGlAbstraction& gl = application.GetGlAbstraction();
916 TraceCallStack& textureTrace = gl.GetTextureTrace();
917 textureTrace.Enable(true);
919 DummyControl actor = DummyControl::New();
920 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
921 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
923 actor.SetSize( 200.f, 200.f );
924 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
926 Stage::GetCurrent().Add( actor );
928 application.SendNotification();
929 application.Render();
931 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
932 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
934 Stage::GetCurrent().Remove( actor );
935 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
940 int UtcDaliImageVisualSetInvalidRemoteImage(void)
942 ToolkitTestApplication application;
943 tet_infoline( "Request image visual with invalid images - should draw broken.png" );
945 VisualFactory factory = VisualFactory::Get();
946 DALI_TEST_CHECK( factory );
948 // Local invalid file, asynchronous loading
949 Property::Map propertyMap;
950 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
951 propertyMap.Insert( ImageVisual::Property::URL, TEST_REMOTE_INVALID_FILE_NAME );
953 Visual::Base visual = factory.CreateVisual( propertyMap );
954 DALI_TEST_CHECK( visual );
956 TestGlAbstraction& gl = application.GetGlAbstraction();
957 TraceCallStack& textureTrace = gl.GetTextureTrace();
958 textureTrace.Enable(true);
960 DummyControl actor = DummyControl::New();
961 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
962 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
964 actor.SetSize( 200.f, 200.f );
965 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
967 Stage::GetCurrent().Add( actor );
969 application.SendNotification();
970 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION );
972 application.SendNotification();
973 application.Render();
975 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
976 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
978 Stage::GetCurrent().Remove( actor );
979 DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
984 int UtcDaliImageVisualAlphaMask(void)
986 ToolkitTestApplication application;
987 tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" );
989 VisualFactory factory = VisualFactory::Get();
990 DALI_TEST_CHECK( factory );
992 Property::Map propertyMap;
993 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
994 propertyMap.Insert( ImageVisual::Property::URL, TEST_LARGE_IMAGE_FILE_NAME );
995 propertyMap.Insert( DevelImageVisual::Property::ALPHA_MASK_URL, TEST_MASK_IMAGE_FILE_NAME );
997 Visual::Base visual = factory.CreateVisual( propertyMap );
998 DALI_TEST_CHECK( visual );
1000 Property::Map testMap;
1001 visual.CreatePropertyMap(testMap);
1002 DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::ALPHA_MASK_URL),Property::Value(TEST_MASK_IMAGE_FILE_NAME), TEST_LOCATION );
1004 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1005 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1007 TestGlAbstraction& gl = application.GetGlAbstraction();
1008 TraceCallStack& textureTrace = gl.GetTextureTrace();
1009 textureTrace.Enable(true);
1011 DummyControl actor = DummyControl::New();
1012 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1013 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1015 actor.SetSize( 200.f, 200.f );
1016 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1017 DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION );
1019 Stage::GetCurrent().Add( actor );
1020 application.SendNotification();
1021 application.Render();
1023 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1025 application.SendNotification();
1026 application.Render();
1028 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1029 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1030 DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION );
1035 int UtcDaliImageVisualRemoteAlphaMask(void)
1037 ToolkitTestApplication application;
1038 tet_infoline( "Request image visual with a Property::Map containing an Alpha mask" );
1040 VisualFactory factory = VisualFactory::Get();
1041 DALI_TEST_CHECK( factory );
1043 const std::string MASK_IMAGE = TEST_REMOTE_IMAGE_FILE_NAME;
1045 Property::Map propertyMap;
1046 propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
1047 propertyMap.Insert( ImageVisual::Property::URL, TEST_IMAGE_FILE_NAME );
1048 propertyMap.Insert( "alphaMaskUrl", MASK_IMAGE );
1050 Visual::Base visual = factory.CreateVisual( propertyMap );
1051 DALI_TEST_CHECK( visual );
1053 Property::Map testMap;
1054 visual.CreatePropertyMap(testMap);
1055 DALI_TEST_EQUALS(*testMap.Find(DevelImageVisual::Property::ALPHA_MASK_URL),Property::Value(MASK_IMAGE), TEST_LOCATION );
1057 // For tesing the LoadResourceFunc is called, a big image size should be set, so the atlasing is not applied.
1058 // Image with a size smaller than 512*512 will be uploaded as a part of the atlas.
1060 TestGlAbstraction& gl = application.GetGlAbstraction();
1061 TraceCallStack& textureTrace = gl.GetTextureTrace();
1062 textureTrace.Enable(true);
1064 DummyControl actor = DummyControl::New();
1065 DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
1066 dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
1067 DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), false, TEST_LOCATION );
1069 actor.SetSize( 200.f, 200.f );
1070 DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
1072 Stage::GetCurrent().Add( actor );
1073 application.SendNotification();
1074 application.Render();
1076 DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 2 ), true, TEST_LOCATION );
1078 application.SendNotification();
1079 application.Render();
1081 DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
1082 DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
1083 DALI_TEST_EQUALS( DevelControl::IsResourceReady( actor ), true, TEST_LOCATION );